forked from upstream-mirrors/OpenTracks
Merge pull request 'Cleanup' (#2173) from cleanup into main
Reviewed-on: https://codeberg.org/OpenTracksApp/OpenTracks/pulls/2173
This commit is contained in:
+1
-1
@@ -152,7 +152,7 @@ dependencies {
|
||||
implementation 'androidx.core:core-splashscreen:1.0.1'
|
||||
implementation 'androidx.mediarouter:mediarouter:1.8.1'
|
||||
implementation 'androidx.core:core-location-altitude:1.0.0-alpha03'
|
||||
implementation 'androidx.work:work-runtime:2.10.2'
|
||||
implementation 'androidx.work:work-runtime:2.10.5'
|
||||
|
||||
androidTestImplementation 'androidx.test:core:1.7.0'
|
||||
androidTestImplementation 'androidx.test.ext:junit:1.3.0'
|
||||
|
||||
+4
-5
@@ -47,7 +47,6 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.TestDataUtil;
|
||||
import de.dennisguse.opentracks.content.data.TestSensorDataUtil;
|
||||
@@ -451,7 +450,7 @@ public class CustomContentProviderUtilsTest {
|
||||
contentProviderUtils.insertMarker(marker1);
|
||||
|
||||
// Check insert was done.
|
||||
assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
|
||||
assertEquals(1, contentProviderUtils.getMarkers(trackId).size());
|
||||
|
||||
// Get marker id that needs to delete.
|
||||
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
||||
@@ -478,7 +477,7 @@ public class CustomContentProviderUtilsTest {
|
||||
contentProviderUtils.insertMarker(marker1);
|
||||
|
||||
// Check insert was done.
|
||||
assertEquals(contentProviderUtils.getMarkers(trackId).size(), 1);
|
||||
assertEquals(1, contentProviderUtils.getMarkers(trackId).size());
|
||||
|
||||
// Get marker id that needs to delete.
|
||||
Marker.Id marker1Id = contentProviderUtils.insertMarker(marker1);
|
||||
@@ -832,7 +831,7 @@ public class CustomContentProviderUtilsTest {
|
||||
|
||||
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
||||
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.getId())))
|
||||
.map(TrackPoint.Id::new).collect(Collectors.toList());
|
||||
.map(TrackPoint.Id::new).toList();
|
||||
|
||||
// when
|
||||
try (Cursor cursor = contentProviderUtils.getTrackPointCursor(trackId, trackpointIds.get(8))) {
|
||||
@@ -850,7 +849,7 @@ public class CustomContentProviderUtilsTest {
|
||||
|
||||
List<TrackPoint.Id> trackpointIds = track.second.stream()
|
||||
.map(it -> ContentUris.parseId(contentProviderUtils.insertTrackPoint(it, track.first.getId())))
|
||||
.map(TrackPoint.Id::new).collect(Collectors.toList());
|
||||
.map(TrackPoint.Id::new).toList();
|
||||
|
||||
TrackPoint.Id startTrackPointId = trackpointIds.get(0);
|
||||
|
||||
|
||||
@@ -48,10 +48,8 @@ public class CustomSQLiteOpenHelperTest {
|
||||
public static Map<String, String> getSQL(SQLiteDatabase db, String type) {
|
||||
HashMap<String, String> sqlMap = new HashMap<>();
|
||||
try (Cursor cursor = db.query("sqlite_master", new String[]{"name", "SQL"}, "type=?", new String[]{type}, null, null, "name")) {
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
sqlMap.put(cursor.getString(0), cursor.getString(1));
|
||||
}
|
||||
while (cursor.moveToNext()) {
|
||||
sqlMap.put(cursor.getString(0), cursor.getString(1));
|
||||
}
|
||||
}
|
||||
return sqlMap;
|
||||
@@ -64,12 +62,10 @@ public class CustomSQLiteOpenHelperTest {
|
||||
*/
|
||||
private static boolean hasSqlCreate(SQLiteDatabase db, String sqlCreate) {
|
||||
try (Cursor cursor = db.rawQuery("SELECT SQL FROM sqlite_master", null)) {
|
||||
if (cursor != null) {
|
||||
while (cursor.moveToNext()) {
|
||||
String sql = cursor.getString(0);
|
||||
if (sqlCreate.equals(sql)) {
|
||||
return true;
|
||||
}
|
||||
while (cursor.moveToNext()) {
|
||||
String sql = cursor.getString(0);
|
||||
if (sqlCreate.equals(sql)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -37,9 +37,9 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "_id IN (?)");
|
||||
assertEquals(selection.selectionArgs().length, 1);
|
||||
assertEquals(selection.selectionArgs()[0], "1");
|
||||
assertEquals("_id IN (?)", selection.selection());
|
||||
assertEquals(1, selection.selectionArgs().length);
|
||||
assertEquals("1", selection.selectionArgs()[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -57,11 +57,11 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "_id IN (?,?,?)");
|
||||
assertEquals(selection.selectionArgs().length, 3);
|
||||
assertEquals(selection.selectionArgs()[0], "1");
|
||||
assertEquals(selection.selectionArgs()[1], "2");
|
||||
assertEquals(selection.selectionArgs()[2], "3");
|
||||
assertEquals("_id IN (?,?,?)", selection.selection());
|
||||
assertEquals(3, selection.selectionArgs().length);
|
||||
assertEquals("1", selection.selectionArgs()[0]);
|
||||
assertEquals("2", selection.selectionArgs()[1]);
|
||||
assertEquals("3", selection.selectionArgs()[2]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -73,9 +73,9 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "category IN (?)");
|
||||
assertEquals(selection.selectionArgs().length, 1);
|
||||
assertEquals(selection.selectionArgs()[0], "running");
|
||||
assertEquals("category IN (?)", selection.selection());
|
||||
assertEquals(1, selection.selectionArgs().length);
|
||||
assertEquals("running", selection.selectionArgs()[0]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -91,12 +91,12 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "category IN (?,?,?,?)");
|
||||
assertEquals(selection.selectionArgs().length, 4);
|
||||
assertEquals(selection.selectionArgs()[0], "running");
|
||||
assertEquals(selection.selectionArgs()[1], "road biking");
|
||||
assertEquals(selection.selectionArgs()[2], "mountain biking");
|
||||
assertEquals(selection.selectionArgs()[3], "trail walking");
|
||||
assertEquals("category IN (?,?,?,?)", selection.selection());
|
||||
assertEquals(4, selection.selectionArgs().length);
|
||||
assertEquals("running", selection.selectionArgs()[0]);
|
||||
assertEquals("road biking", selection.selectionArgs()[1]);
|
||||
assertEquals("mountain biking", selection.selectionArgs()[2]);
|
||||
assertEquals("trail walking", selection.selectionArgs()[3]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -120,8 +120,8 @@ public class TrackSelectionTest extends TestCase {
|
||||
assertNull(selectionWrong2.selection());
|
||||
assertNull(selectionWrong2.selectionArgs());
|
||||
|
||||
assertEquals(selectionOk.selection(), "starttime BETWEEN ? AND ?");
|
||||
assertEquals(selectionOk.selectionArgs().length, 2);
|
||||
assertEquals("starttime BETWEEN ? AND ?", selectionOk.selection());
|
||||
assertEquals(2, selectionOk.selectionArgs().length);
|
||||
assertEquals(selectionOk.selectionArgs()[0], Long.toString(instant.toEpochMilli()));
|
||||
assertEquals(selectionOk.selectionArgs()[1], Long.toString(instant.toEpochMilli() + oneDay));
|
||||
}
|
||||
@@ -143,13 +143,13 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "_id IN (?,?,?) AND category IN (?,?)");
|
||||
assertEquals(selection.selectionArgs().length, 5);
|
||||
assertEquals(selection.selectionArgs()[0], "1");
|
||||
assertEquals(selection.selectionArgs()[1], "2");
|
||||
assertEquals(selection.selectionArgs()[2], "3");
|
||||
assertEquals(selection.selectionArgs()[3], "running");
|
||||
assertEquals(selection.selectionArgs()[4], "road biking");
|
||||
assertEquals("_id IN (?,?,?) AND category IN (?,?)", selection.selection());
|
||||
assertEquals(5, selection.selectionArgs().length);
|
||||
assertEquals("1", selection.selectionArgs()[0]);
|
||||
assertEquals("2", selection.selectionArgs()[1]);
|
||||
assertEquals("3", selection.selectionArgs()[2]);
|
||||
assertEquals("running", selection.selectionArgs()[3]);
|
||||
assertEquals("road biking", selection.selectionArgs()[4]);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -172,11 +172,11 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "_id IN (?,?,?) AND starttime BETWEEN ? AND ?");
|
||||
assertEquals(selection.selectionArgs().length, 5);
|
||||
assertEquals(selection.selectionArgs()[0], "1");
|
||||
assertEquals(selection.selectionArgs()[1], "2");
|
||||
assertEquals(selection.selectionArgs()[2], "3");
|
||||
assertEquals("_id IN (?,?,?) AND starttime BETWEEN ? AND ?", selection.selection());
|
||||
assertEquals(5, selection.selectionArgs().length);
|
||||
assertEquals("1", selection.selectionArgs()[0]);
|
||||
assertEquals("2", selection.selectionArgs()[1]);
|
||||
assertEquals("3", selection.selectionArgs()[2]);
|
||||
assertEquals(selection.selectionArgs()[3], Long.toString(instant.toEpochMilli()));
|
||||
assertEquals(selection.selectionArgs()[4], Long.toString(instant.toEpochMilli() + oneDay));
|
||||
}
|
||||
@@ -196,10 +196,10 @@ public class TrackSelectionTest extends TestCase {
|
||||
SelectionData selection = filter.buildSelection();
|
||||
|
||||
// Then
|
||||
assertEquals(selection.selection(), "category IN (?,?) AND starttime BETWEEN ? AND ?");
|
||||
assertEquals(selection.selectionArgs().length, 4);
|
||||
assertEquals(selection.selectionArgs()[0], "running");
|
||||
assertEquals(selection.selectionArgs()[1], "road biking");
|
||||
assertEquals("category IN (?,?) AND starttime BETWEEN ? AND ?", selection.selection());
|
||||
assertEquals(4, selection.selectionArgs().length);
|
||||
assertEquals("running", selection.selectionArgs()[0]);
|
||||
assertEquals("road biking", selection.selectionArgs()[1]);
|
||||
assertEquals(selection.selectionArgs()[2], Long.toString(instant.toEpochMilli()));
|
||||
assertEquals(selection.selectionArgs()[3], Long.toString(instant.toEpochMilli() + oneDay));
|
||||
}
|
||||
|
||||
+3
-3
@@ -21,7 +21,7 @@ public class DistanceFormatterTest {
|
||||
@Test
|
||||
public void testFormatDistance_metric() {
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setDecimalPlaces(2)
|
||||
.setUnit(UnitSystem.METRIC)
|
||||
.build(context);
|
||||
|
||||
@@ -34,7 +34,7 @@ public class DistanceFormatterTest {
|
||||
@Test
|
||||
public void testFormatDistance_imperial() {
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setDecimalPlaces(2)
|
||||
.setUnit(UnitSystem.IMPERIAL_FEET)
|
||||
.build(context);
|
||||
|
||||
@@ -47,7 +47,7 @@ public class DistanceFormatterTest {
|
||||
@Test
|
||||
public void testFormatDistance_nautical() {
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setDecimalPlaces(2)
|
||||
.setUnit(UnitSystem.NAUTICAL_IMPERIAL)
|
||||
.build(context);
|
||||
|
||||
|
||||
@@ -21,7 +21,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_pace_metric() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.METRIC)
|
||||
.setReportSpeedOrPace(false)
|
||||
.build(context);
|
||||
@@ -35,7 +34,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_pace_imperial() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.IMPERIAL_FEET)
|
||||
.setReportSpeedOrPace(false)
|
||||
.build(context);
|
||||
@@ -47,7 +45,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_pace_nautical() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.NAUTICAL_IMPERIAL)
|
||||
.setReportSpeedOrPace(false)
|
||||
.build(context);
|
||||
@@ -59,7 +56,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_speed_metric() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.METRIC)
|
||||
.setReportSpeedOrPace(true)
|
||||
.build(context);
|
||||
@@ -71,7 +67,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_speed_imperial() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.IMPERIAL_FEET)
|
||||
.setReportSpeedOrPace(true)
|
||||
.build(context);
|
||||
@@ -83,7 +78,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testGetSpeedParts_speed_nautical() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.NAUTICAL_IMPERIAL)
|
||||
.setReportSpeedOrPace(true)
|
||||
.build(context);
|
||||
@@ -95,7 +89,6 @@ public class SpeedFormatterTest {
|
||||
@Test
|
||||
public void testFormatSpeed() {
|
||||
SpeedFormatter formatter = SpeedFormatter.Builder()
|
||||
.setDecimalCount(2)
|
||||
.setUnit(UnitSystem.METRIC)
|
||||
.setReportSpeedOrPace(false)
|
||||
.build(context);
|
||||
|
||||
@@ -1,50 +1,54 @@
|
||||
package de.dennisguse.opentracks.sensors;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThrows;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
public class UintUtilsTest {
|
||||
|
||||
@Test
|
||||
public void diff() {
|
||||
public void diff_uint16_valid() {
|
||||
assertEquals(0, UintUtils.diff(1, 1, UintUtils.UINT16_MAX));
|
||||
assertEquals(1, UintUtils.diff(2, 1, UintUtils.UINT16_MAX));
|
||||
assertEquals(3, UintUtils.diff(5, 2, UintUtils.UINT16_MAX));
|
||||
assertEquals(65535, UintUtils.diff(1, 2, UintUtils.UINT16_MAX)); /* unsigned 16 arithmetic is modulo UINT16_MAX + 1, not modulo UINT16_MAX */
|
||||
assertEquals(65530, UintUtils.diff(UintUtils.UINT16_MAX, 5, UintUtils.UINT16_MAX));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void diff_uint16_invalid() {
|
||||
/* Test modulo arithmetic for arguments that are out of range */
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(65537, 1, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(1, 65537, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(65537, 65537, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-65535, 1, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(1, -65535, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-65535, -65535, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-65535, 65537, UintUtils.UINT16_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(65537, -65535, UintUtils.UINT16_MAX));
|
||||
}
|
||||
|
||||
if (false) { /* false means UintUtils.diff() throws if arguments out of range */
|
||||
assertEquals(0, UintUtils.diff(65537, 1, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(1, 65537, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(65537, 65537, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(-65535, 1, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(1, -65535, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(-65535, -65535, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(-65535, 65537, UintUtils.UINT16_MAX));
|
||||
assertEquals(0, UintUtils.diff(65537, -65535, UintUtils.UINT16_MAX));
|
||||
}
|
||||
|
||||
/* The following tests are the above, but for 32-bit unsigned. */
|
||||
|
||||
@Test
|
||||
public void diff_uint32() {
|
||||
assertEquals(0, UintUtils.diff(1, 1, UintUtils.UINT32_MAX));
|
||||
assertEquals(1, UintUtils.diff(2, 1, UintUtils.UINT32_MAX));
|
||||
assertEquals(3, UintUtils.diff(5, 2, UintUtils.UINT32_MAX));
|
||||
assertEquals(4294967295L, UintUtils.diff(1, 2, UintUtils.UINT32_MAX));
|
||||
assertEquals(4294967290L, UintUtils.diff(UintUtils.UINT32_MAX, 5, UintUtils.UINT32_MAX));
|
||||
}
|
||||
|
||||
if (false) { /* false means UintUtils.diff() throws if arguments out of range */
|
||||
assertEquals(0, UintUtils.diff(4294967297L, 1, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(1, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(4294967297L, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(-4294967295L, 1, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(1, -4294967295L, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(-4294967295L, -4294967295L, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(-4294967295L, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertEquals(0, UintUtils.diff(65537, -4294967297L, UintUtils.UINT32_MAX));
|
||||
}
|
||||
@Test
|
||||
public void diff_unint32_invalid() {
|
||||
/* Test modulo arithmetic for arguments that are out of range */
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(4294967297L, 1, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(1, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(4294967297L, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-4294967295L, 1, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(1, -4294967295L, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-4294967295L, -4294967295L, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(-4294967295L, 4294967297L, UintUtils.UINT32_MAX));
|
||||
assertThrows(RuntimeException.class, () -> UintUtils.diff(65537, -4294967297L, UintUtils.UINT32_MAX));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
+6
-6
@@ -165,7 +165,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
@@ -216,7 +216,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
@@ -330,7 +330,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
@@ -381,7 +381,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
@@ -411,7 +411,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
@@ -449,7 +449,7 @@ public class VoiceAnnouncementUtilsTest {
|
||||
TrackStatistics stats = trackWithStats.second;
|
||||
IntervalStatistics.Interval lastInterval;
|
||||
try (TrackPointIterator trackPointIterator = contentProviderUtils.getTrackPointLocationIterator(trackId, null)) {
|
||||
assertEquals(trackPointIterator.getCount(), numberOfPoints);
|
||||
assertEquals(numberOfPoints, trackPointIterator.getCount());
|
||||
IntervalStatistics intervalStatistics = new IntervalStatistics(Distance.of(1000));
|
||||
intervalStatistics.addTrackPoints(trackPointIterator);
|
||||
lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1);
|
||||
|
||||
+5
-5
@@ -41,7 +41,7 @@ public class PreferencesOpenHelperTest {
|
||||
// then there should be one layout with old custom layout that has the new CSV value.
|
||||
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
||||
assertNotNull(recordingLayouts);
|
||||
assertEquals(recordingLayouts.size(), 1);
|
||||
assertEquals(1, recordingLayouts.size());
|
||||
assertEquals(recordingLayouts.get(0).toCsv(), PreferencesUtils.getCustomLayout().toCsv());
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public class PreferencesOpenHelperTest {
|
||||
// then there should be one layout with old custom layout that has the new CSV value.
|
||||
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
||||
assertNotNull(recordingLayouts);
|
||||
assertEquals(recordingLayouts.size(), 1);
|
||||
assertEquals(1, recordingLayouts.size());
|
||||
assertEquals(recordingLayouts.get(0).toCsv(), updatedOldCustomLayoutCsv);
|
||||
}
|
||||
|
||||
@@ -90,8 +90,8 @@ public class PreferencesOpenHelperTest {
|
||||
// then there should be one layout with old custom layout that has the new CSV value.
|
||||
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
||||
assertNotNull(recordingLayouts);
|
||||
assertEquals(recordingLayouts.size(), 1);
|
||||
assertEquals(recordingLayouts.get(0).toCsv(), updatedOldCustomLayoutCsv);
|
||||
assertEquals(1, recordingLayouts.size());
|
||||
assertEquals(updatedOldCustomLayoutCsv, recordingLayouts.get(0).toCsv());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -113,7 +113,7 @@ public class PreferencesOpenHelperTest {
|
||||
RecordingLayout defaultRecordingLayout = RecordingLayoutIO.fromCsv(PreferencesUtils.buildDefaultLayout(), resources);
|
||||
List<RecordingLayout> customRecordingLayout = PreferencesUtils.getAllCustomLayouts();
|
||||
|
||||
assertEquals(customRecordingLayout.size(), 1);
|
||||
assertEquals(1, customRecordingLayout.size());
|
||||
assertEquals(defaultRecordingLayout.toCsv(), customRecordingLayout.get(0).toCsv());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -89,8 +89,8 @@ public class PreferencesUtilsTest {
|
||||
List<RecordingLayout> recordingLayouts = PreferencesUtils.getAllCustomLayouts();
|
||||
|
||||
// then
|
||||
assertEquals(recordingLayouts.size(), 1);
|
||||
assertTrue(recordingLayouts.get(0).getFields().size() > 0);
|
||||
assertEquals(1, recordingLayouts.size());
|
||||
assertFalse(recordingLayouts.get(0).getFields().isEmpty());
|
||||
assertEquals(recordingLayouts.get(0).getName(), context.getString(R.string.stats_custom_layout_default_layout));
|
||||
assertTrue(recordingLayouts.get(0).getFields().stream().anyMatch(DataField::isVisible));
|
||||
}
|
||||
@@ -107,7 +107,7 @@ public class PreferencesUtilsTest {
|
||||
RecordingLayout recordingLayout = PreferencesUtils.getCustomLayout();
|
||||
|
||||
// then
|
||||
assertTrue(recordingLayout.getFields().size() > 0);
|
||||
assertFalse(recordingLayout.getFields().isEmpty());
|
||||
assertEquals(recordingLayout.getName(), context.getString(R.string.stats_custom_layout_default_layout));
|
||||
assertTrue(recordingLayout.getFields().stream().anyMatch(DataField::isVisible));
|
||||
}
|
||||
@@ -130,9 +130,9 @@ public class PreferencesUtilsTest {
|
||||
RecordingLayout recordingLayout = PreferencesUtils.getCustomLayout();
|
||||
|
||||
// then
|
||||
assertEquals(recordingLayout.getFields().size(), 4);
|
||||
assertEquals(recordingLayout.getName(), "run");
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), 2);
|
||||
assertEquals(4, recordingLayout.getFields().size());
|
||||
assertEquals("run", recordingLayout.getName());
|
||||
assertEquals(2, recordingLayout.getColumnsPerRow());
|
||||
|
||||
assertEquals(recordingLayout.getFields().get(0).getKey(), context.getString(R.string.stats_custom_layout_moving_time_key));
|
||||
assertTrue(recordingLayout.getFields().get(0).isVisible());
|
||||
@@ -169,9 +169,9 @@ public class PreferencesUtilsTest {
|
||||
RecordingLayout recordingLayout = PreferencesUtils.getCustomLayout();
|
||||
|
||||
// then
|
||||
assertEquals(recordingLayout.getFields().size(), 4);
|
||||
assertEquals(recordingLayout.getName(), "walking");
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), 2);
|
||||
assertEquals(4, recordingLayout.getFields().size());
|
||||
assertEquals("walking", recordingLayout.getName());
|
||||
assertEquals(2, recordingLayout.getColumnsPerRow());
|
||||
|
||||
assertEquals(recordingLayout.getFields().get(0).getKey(), context.getString(R.string.stats_custom_layout_moving_time_key));
|
||||
assertTrue(recordingLayout.getFields().get(0).isVisible());
|
||||
@@ -266,11 +266,11 @@ public class PreferencesUtilsTest {
|
||||
// then only updated profile is modified in the custom layouts
|
||||
List<RecordingLayout> layoutsAfter = PreferencesUtils.getAllCustomLayouts();
|
||||
|
||||
assertEquals(layoutsBefore.size(), 2);
|
||||
assertEquals(layoutsAfter.size(), 2);
|
||||
assertEquals(2, layoutsBefore.size());
|
||||
assertEquals(2, layoutsAfter.size());
|
||||
|
||||
assertEquals(layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count(), 4);
|
||||
assertEquals(layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count(), 1);
|
||||
assertEquals(4, layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count());
|
||||
assertEquals(1, layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -309,11 +309,11 @@ public class PreferencesUtilsTest {
|
||||
// then only updated profile is modified in the custom layouts
|
||||
List<RecordingLayout> layoutsAfter = PreferencesUtils.getAllCustomLayouts();
|
||||
|
||||
assertEquals(layoutsBefore.size(), 2);
|
||||
assertEquals(layoutsAfter.size(), 2);
|
||||
assertEquals(2, layoutsBefore.size());
|
||||
assertEquals(2, layoutsAfter.size());
|
||||
|
||||
assertEquals(layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count(), 4);
|
||||
assertEquals(layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count(), 1);
|
||||
assertEquals(4, layoutsBefore.get(0).getFields().stream().filter(DataField::isVisible).count());
|
||||
assertEquals(1, layoutsAfter.get(0).getFields().stream().filter(DataField::isVisible).count());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -341,6 +341,6 @@ public class PreferencesUtilsTest {
|
||||
RecordingLayout recordingLayout = PreferencesUtils.getCustomLayout();
|
||||
|
||||
// then the first one was returned
|
||||
assertEquals(recordingLayout.getName(), "cycling");
|
||||
assertEquals("cycling", recordingLayout.getName());
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -26,11 +26,11 @@ public class CsvRecordingLayoutUtilsTest extends TestCase {
|
||||
|
||||
// then
|
||||
assertNotNull(partsOk);
|
||||
assertEquals(partsOk.size(), 4);
|
||||
assertEquals(partsOk.get(0), "Layout Name");
|
||||
assertEquals(partsOk.get(1), "2");
|
||||
assertEquals(partsOk.get(2), "distance,1,1");
|
||||
assertEquals(partsOk.get(3), "speed,1,1");
|
||||
assertEquals(4, partsOk.size());
|
||||
assertEquals("Layout Name", partsOk.get(0));
|
||||
assertEquals("2", partsOk.get(1));
|
||||
assertEquals("distance,1,1", partsOk.get(2));
|
||||
assertEquals("speed,1,1", partsOk.get(3));
|
||||
assertNull(partsWrong1);
|
||||
assertNull(partsWrong2);
|
||||
}
|
||||
|
||||
+12
-12
@@ -32,9 +32,9 @@ public class RecordingLayoutTest extends TestCase {
|
||||
List<DataField> dataFieldList = recordingLayout.getFields();
|
||||
|
||||
// then layout and data fields are built correctly
|
||||
assertEquals(recordingLayout.getName(), "running");
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), 2);
|
||||
assertEquals(dataFieldList.size(), 4);
|
||||
assertEquals("running", recordingLayout.getName());
|
||||
assertEquals(2, recordingLayout.getColumnsPerRow());
|
||||
assertEquals(4, dataFieldList.size());
|
||||
assertEquals(dataFieldList.get(0).getKey(), context.getString(R.string.stats_custom_layout_speed_key));
|
||||
assertEquals(dataFieldList.get(1).getKey(), context.getString(R.string.stats_custom_layout_distance_key));
|
||||
assertEquals(dataFieldList.get(2).getKey(), context.getString(R.string.stats_custom_layout_altitude_key));
|
||||
@@ -66,7 +66,7 @@ public class RecordingLayoutTest extends TestCase {
|
||||
// then layout and data fields are built correctly
|
||||
assertEquals(recordingLayout.getName(), PreferencesUtils.getDefaultLayoutName());
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), PreferencesUtils.getLayoutColumnsByDefault());
|
||||
assertEquals(recordingLayout.getFields().size(), 0);
|
||||
assertEquals(0, recordingLayout.getFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -81,7 +81,7 @@ public class RecordingLayoutTest extends TestCase {
|
||||
// then layout and data fields are built correctly
|
||||
assertEquals(recordingLayout.getName(), PreferencesUtils.getDefaultLayoutName());
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), PreferencesUtils.getLayoutColumnsByDefault());
|
||||
assertEquals(recordingLayout.getFields().size(), 0);
|
||||
assertEquals(0, recordingLayout.getFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -94,9 +94,9 @@ public class RecordingLayoutTest extends TestCase {
|
||||
List<DataField> dataFieldList = recordingLayout.getFields();
|
||||
|
||||
// then layout and data fields are built correctly
|
||||
assertEquals(recordingLayout.getName(), "Layout Name");
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), 2);
|
||||
assertEquals(recordingLayout.getFields().size(), 0);
|
||||
assertEquals("Layout Name", recordingLayout.getName());
|
||||
assertEquals(2, recordingLayout.getColumnsPerRow());
|
||||
assertEquals(0, recordingLayout.getFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -109,9 +109,9 @@ public class RecordingLayoutTest extends TestCase {
|
||||
List<DataField> dataFieldList = recordingLayout.getFields();
|
||||
|
||||
// then layout and data fields are built correctly
|
||||
assertEquals(recordingLayout.getName(), "Layout Name");
|
||||
assertEquals(recordingLayout.getColumnsPerRow(), 2);
|
||||
assertEquals(recordingLayout.getFields().size(), 1);
|
||||
assertEquals("Layout Name", recordingLayout.getName());
|
||||
assertEquals(2, recordingLayout.getColumnsPerRow());
|
||||
assertEquals(1, recordingLayout.getFields().size());
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -128,7 +128,7 @@ public class RecordingLayoutTest extends TestCase {
|
||||
String csv = recordingLayout.toCsv();
|
||||
|
||||
// then csv is well built
|
||||
assertEquals(csv, "Test Layout;2;key1,0,0,0;key2,0,1,0;key3,1,0,0;key4,1,1,0;key5,1,1,1;");
|
||||
assertEquals("Test Layout;2;key1,0,0,0;key2,0,1,0;key3,1,0,0;key4,1,1,0;key5,1,1,1;", csv);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -38,11 +38,10 @@ import java.time.OffsetDateTime;
|
||||
import java.time.ZoneId;
|
||||
import java.time.ZoneOffset;
|
||||
import java.time.format.TextStyle;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.TimeZone;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.LocaleRule;
|
||||
import de.dennisguse.opentracks.TimezoneRule;
|
||||
@@ -133,8 +132,10 @@ public class StringUtilsTest {
|
||||
@Test
|
||||
public void testFormatDateTodayRelative() {
|
||||
// given
|
||||
ArrayList<String> shortDays = Arrays.stream(DayOfWeek.values()).map(d -> d.getDisplayName(TextStyle.FULL, Locale.getDefault())).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<String> shortMonths = Arrays.stream(Month.values()).map(m -> m.getDisplayName(TextStyle.SHORT, Locale.getDefault())).collect(Collectors.toCollection(ArrayList::new));
|
||||
List<String> shortDays = Arrays.stream(DayOfWeek.values()).map(d -> d.getDisplayName(TextStyle.FULL, Locale.getDefault()))
|
||||
.toList();
|
||||
List<String> shortMonths = Arrays.stream(Month.values()).map(m -> m.getDisplayName(TextStyle.SHORT, Locale.getDefault()))
|
||||
.toList();
|
||||
|
||||
LocalDate today = LocalDateTime.ofInstant(Instant.now(), ZoneId.systemDefault()).toLocalDate();
|
||||
LocalDate yesterday = today.minusDays(1);
|
||||
|
||||
@@ -23,9 +23,8 @@ import androidx.work.OneTimeWorkRequest;
|
||||
import androidx.work.WorkManager;
|
||||
import androidx.work.WorkRequest;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
import de.dennisguse.opentracks.services.TrackDeletionWorker;
|
||||
@@ -50,8 +49,8 @@ public abstract class AbstractTrackDeleteActivity extends AbstractActivity imple
|
||||
//TODO A callback is better.
|
||||
@Override
|
||||
public void onConfirmDeleteDone(Track.Id... trackIds) {
|
||||
ArrayList<Track.Id> trackIdList = Arrays.stream(trackIds)
|
||||
.filter(trackId -> !trackId.equals(getRecordingTrackId())).collect(Collectors.toCollection(ArrayList::new));
|
||||
List<Track.Id> trackIdList = Arrays.stream(trackIds)
|
||||
.filter(trackId -> !trackId.equals(getRecordingTrackId())).toList();
|
||||
|
||||
onDeleteConfirmed();
|
||||
|
||||
|
||||
@@ -17,7 +17,6 @@
|
||||
package de.dennisguse.opentracks.chart;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Canvas;
|
||||
import android.graphics.DashPathEffect;
|
||||
import android.graphics.Paint;
|
||||
@@ -49,10 +48,8 @@ import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.data.models.Marker;
|
||||
import de.dennisguse.opentracks.settings.UnitSystem;
|
||||
import de.dennisguse.opentracks.stats.ExtremityMonitor;
|
||||
import de.dennisguse.opentracks.ui.markers.MarkerDetailActivity;
|
||||
import de.dennisguse.opentracks.ui.markers.MarkerUtils;
|
||||
import de.dennisguse.opentracks.ui.util.ThemeUtils;
|
||||
import de.dennisguse.opentracks.util.IntentUtils;
|
||||
import de.dennisguse.opentracks.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -857,7 +854,7 @@ public class ChartView extends View {
|
||||
* @param chartValueSeries the chart value series
|
||||
* @param canvas the canvas
|
||||
* @param xPosition the right most x position
|
||||
* @parm yOffset offset to apply to y position
|
||||
* @param yOffset offset to apply to y position
|
||||
* @param yValue the y value
|
||||
* @return the marker width.
|
||||
*/
|
||||
@@ -883,7 +880,7 @@ public class ChartView extends View {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (firstChartValueSeries != null && chartPoints.size() > 0) {
|
||||
if (firstChartValueSeries != null && !chartPoints.isEmpty()) {
|
||||
int dx = getX(maxX) - pointer.getIntrinsicWidth() / 2;
|
||||
double value = firstChartValueSeries.extractDataFromChartPoint(last);
|
||||
int dy = getY(firstChartValueSeries, value) - pointer.getIntrinsicHeight();
|
||||
@@ -897,7 +894,7 @@ public class ChartView extends View {
|
||||
*/
|
||||
private void updateSeries() {
|
||||
synchronized (chartPoints) {
|
||||
seriesList.stream().forEach(this::updateSerie);
|
||||
seriesList.forEach(this::updateSerie);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package de.dennisguse.opentracks.data;
|
||||
|
||||
public record SelectionData(
|
||||
String selection,
|
||||
String[] selectionArgs
|
||||
String[] selectionArgs //TODO Refactor to List<String>
|
||||
) {
|
||||
|
||||
public SelectionData() {
|
||||
|
||||
@@ -386,7 +386,7 @@ public class TrackDataHub {
|
||||
lastSeenTrackPointId = localLastSeenTrackPointIdId;
|
||||
}
|
||||
|
||||
listeners.stream().forEach(Listener::onNewTrackPointsDone);
|
||||
listeners.forEach(Listener::onNewTrackPointsDone);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@ import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
import de.dennisguse.opentracks.data.tables.TracksColumns;
|
||||
@@ -67,10 +66,11 @@ public class TrackSelection implements ContentProviderUtils.ContentProviderSelec
|
||||
}
|
||||
|
||||
// Builds selection arguments.
|
||||
ArrayList<String> args = trackIds.stream().map(id -> Long.toString(id.id())).collect(Collectors.toCollection(ArrayList::new));
|
||||
ArrayList<String> args = new ArrayList<>();
|
||||
args.addAll(trackIds.stream().map(id -> Long.toString(id.id())).toList());
|
||||
args.addAll(categories);
|
||||
args.addAll(fromToArgs);
|
||||
selectionArgs = args.stream().toArray(String[]::new);
|
||||
selectionArgs = args.toArray(String[]::new);
|
||||
|
||||
return new SelectionData(selection, selectionArgs);
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import androidx.annotation.NonNull;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
|
||||
@@ -118,7 +117,7 @@ public enum ActivityType {
|
||||
return Arrays.stream(values())
|
||||
.map(ActivityType::getLocalizedStringId)
|
||||
.map(context::getString)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -14,15 +14,15 @@ public class DistanceFormatter {
|
||||
|
||||
private final Resources resources;
|
||||
|
||||
private final int decimalCount;
|
||||
private final int decimalPlaces;
|
||||
|
||||
private final double threshold;
|
||||
|
||||
private final UnitSystem unitSystem;
|
||||
|
||||
private DistanceFormatter(Resources resources, int decimalCount, double threshold, UnitSystem unitSystem) {
|
||||
private DistanceFormatter(Resources resources, int decimalPlaces, double threshold, UnitSystem unitSystem) {
|
||||
this.resources = resources;
|
||||
this.decimalCount = decimalCount;
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
this.threshold = threshold;
|
||||
this.unitSystem = unitSystem;
|
||||
assert unitSystem != null;
|
||||
@@ -57,30 +57,30 @@ public class DistanceFormatter {
|
||||
switch (unitSystem) {
|
||||
case METRIC -> {
|
||||
if (distance.greaterThan(Distance.ofKilometer(threshold))) {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toKM(), decimalCount), resources.getString(R.string.unit_kilometer));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toKM(), decimalPlaces), resources.getString(R.string.unit_kilometer));
|
||||
} else {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toM(), decimalCount), resources.getString(R.string.unit_meter));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toM(), decimalPlaces), resources.getString(R.string.unit_meter));
|
||||
}
|
||||
}
|
||||
case IMPERIAL_FEET -> {
|
||||
if (distance.greaterThan(Distance.ofMile(threshold))) {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toMI(), decimalCount), resources.getString(R.string.unit_mile));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toMI(), decimalPlaces), resources.getString(R.string.unit_mile));
|
||||
} else {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toFT(), decimalCount), resources.getString(R.string.unit_feet));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toFT(), decimalPlaces), resources.getString(R.string.unit_feet));
|
||||
}
|
||||
}
|
||||
case IMPERIAL_METER -> {
|
||||
if (distance.greaterThan(Distance.ofMile(threshold))) {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toMI(), decimalCount), resources.getString(R.string.unit_mile));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toMI(), decimalPlaces), resources.getString(R.string.unit_mile));
|
||||
} else {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toM(), decimalCount), resources.getString(R.string.unit_meter));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toM(), decimalPlaces), resources.getString(R.string.unit_meter));
|
||||
}
|
||||
}
|
||||
case NAUTICAL_IMPERIAL -> {
|
||||
if (distance.greaterThan(Distance.ofNauticalMile(threshold))) {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toNauticalMiles(), decimalCount), resources.getString(R.string.unit_nautical_mile));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toNauticalMiles(), decimalPlaces), resources.getString(R.string.unit_nautical_mile));
|
||||
} else {
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toFT(), decimalCount), resources.getString(R.string.unit_feet));
|
||||
return new Pair<>(StringUtils.formatDecimal(distance.toFT(), decimalPlaces), resources.getString(R.string.unit_feet));
|
||||
}
|
||||
}
|
||||
default -> throw new RuntimeException("Not implemented");
|
||||
@@ -93,19 +93,19 @@ public class DistanceFormatter {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private int decimalCount;
|
||||
private int decimalPlaces;
|
||||
|
||||
private UnitSystem unitSystem;
|
||||
|
||||
private double threshold;
|
||||
|
||||
public Builder() {
|
||||
decimalCount = 2;
|
||||
decimalPlaces = 2;
|
||||
threshold = 0.5;
|
||||
}
|
||||
|
||||
public Builder setDecimalCount(int decimalCount) {
|
||||
this.decimalCount = decimalCount;
|
||||
public Builder setDecimalPlaces(int decimalPlaces) {
|
||||
this.decimalPlaces = decimalPlaces;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class DistanceFormatter {
|
||||
}
|
||||
|
||||
public DistanceFormatter build(Resources resource) {
|
||||
return new DistanceFormatter(resource, decimalCount, threshold, unitSystem);
|
||||
return new DistanceFormatter(resource, decimalPlaces, threshold, unitSystem);
|
||||
}
|
||||
|
||||
public DistanceFormatter build(Context context) {
|
||||
|
||||
@@ -12,17 +12,16 @@ import de.dennisguse.opentracks.util.StringUtils;
|
||||
|
||||
public class SpeedFormatter {
|
||||
|
||||
private final Resources resources;
|
||||
private final int DECIMAL_PLACES = 1;
|
||||
|
||||
private final int decimalCount;
|
||||
private final Resources resources;
|
||||
|
||||
private final UnitSystem unitSystem;
|
||||
|
||||
private final boolean reportSpeedOrPace;
|
||||
|
||||
private SpeedFormatter(Resources resources, int decimalCount, UnitSystem unitSystem, boolean reportSpeedOrPace) {
|
||||
private SpeedFormatter(Resources resources, UnitSystem unitSystem, boolean reportSpeedOrPace) {
|
||||
this.resources = resources;
|
||||
this.decimalCount = decimalCount;
|
||||
this.unitSystem = unitSystem;
|
||||
this.reportSpeedOrPace = reportSpeedOrPace;
|
||||
}
|
||||
@@ -55,7 +54,7 @@ public class SpeedFormatter {
|
||||
}
|
||||
|
||||
if (reportSpeedOrPace) {
|
||||
return new Pair<>(StringUtils.formatDecimal(speed.to(unitSystem), 1), unitString);
|
||||
return new Pair<>(StringUtils.formatDecimal(speed.to(unitSystem), DECIMAL_PLACES), unitString);
|
||||
}
|
||||
|
||||
int pace = (int) speed.toPace(unitSystem).getSeconds();
|
||||
@@ -71,22 +70,14 @@ public class SpeedFormatter {
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private int decimalCount;
|
||||
|
||||
private UnitSystem unitSystem;
|
||||
|
||||
private boolean reportSpeedOrPace;
|
||||
|
||||
public Builder() {
|
||||
decimalCount = 2;
|
||||
reportSpeedOrPace = true;
|
||||
}
|
||||
|
||||
public Builder setDecimalCount(int decimalCount) {
|
||||
this.decimalCount = decimalCount;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setUnit(@NonNull UnitSystem unitSystem) {
|
||||
this.unitSystem = unitSystem;
|
||||
return this;
|
||||
@@ -98,7 +89,7 @@ public class SpeedFormatter {
|
||||
}
|
||||
|
||||
public SpeedFormatter build(Resources resource) {
|
||||
return new SpeedFormatter(resource, decimalCount, unitSystem, reportSpeedOrPace);
|
||||
return new SpeedFormatter(resource, unitSystem, reportSpeedOrPace);
|
||||
}
|
||||
|
||||
public SpeedFormatter build(Context context) {
|
||||
|
||||
@@ -35,7 +35,7 @@ import java.util.Optional;
|
||||
public class TrackPoint {
|
||||
|
||||
@Nullable
|
||||
private TrackPoint.Id id;
|
||||
private final TrackPoint.Id id;
|
||||
|
||||
//Requires: position.time must be non-null
|
||||
@NonNull
|
||||
|
||||
@@ -23,7 +23,6 @@ public class ChooseActivityTypeDialogFragment extends DialogFragment implements
|
||||
|
||||
private static final String CHOOSE_ACTIVITY_TYPE_DIALOG_TAG = "chooseActivityType";
|
||||
|
||||
@Deprecated
|
||||
public static void showDialog(FragmentManager fragmentManager, Context context, String activityTypeLocalized) {
|
||||
ActivityType activityType = ActivityType.findByLocalizedString(context, activityTypeLocalized);
|
||||
showDialog(fragmentManager, activityType);
|
||||
|
||||
@@ -10,8 +10,6 @@ import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
import de.dennisguse.opentracks.util.FileUtils;
|
||||
@@ -25,8 +23,7 @@ public class TrackFilenameGenerator {
|
||||
public static final String STARTTIME_DATE_KEY = "{date}";
|
||||
|
||||
public static String getAllOptions() {
|
||||
return Stream.of(UUID_KEY, TRACKNAME_KEY, ACTIVITY_TYPE_KEY, STARTTIME_TIME_KEY, STARTTIME_DATE_KEY)
|
||||
.collect(Collectors.joining(", "));
|
||||
return String.join(", ", UUID_KEY, TRACKNAME_KEY, ACTIVITY_TYPE_KEY, STARTTIME_TIME_KEY, STARTTIME_DATE_KEY);
|
||||
}
|
||||
|
||||
public static String format(@NonNull String name, @NonNull TrackFileFormat trackFileFormat) {
|
||||
|
||||
@@ -149,12 +149,12 @@ public class CSVTrackExporter implements TrackExporter {
|
||||
printWriter = null;
|
||||
}
|
||||
|
||||
public void writeHeader(List<Column> columns) {
|
||||
private void writeHeader(List<Column> columns) {
|
||||
String columnNames = columns.stream().map(c -> c.columnName).reduce((s, s2) -> s + "," + s2).orElseThrow(() -> new RuntimeException("No columns defined"));
|
||||
printWriter.println("#" + columnNames);
|
||||
}
|
||||
|
||||
public void writeTrackPoint(List<Column> columns, TrackPoint trackPoint) {
|
||||
private void writeTrackPoint(List<Column> columns, TrackPoint trackPoint) {
|
||||
String columnNames = columns.stream().map(c -> c.extractor.apply(trackPoint)).reduce((s, s2) -> s + "," + s2).orElseThrow(() -> new RuntimeException("No columns defined"));
|
||||
printWriter.println(columnNames);
|
||||
}
|
||||
|
||||
@@ -35,7 +35,6 @@ import androidx.work.WorkRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.AbstractActivity;
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -223,9 +222,9 @@ public class ExportActivity extends AbstractActivity {
|
||||
exportTasks = new ArrayList<>();
|
||||
if (allInOneFile) {
|
||||
String filename = "OpenTracks-Backup";
|
||||
exportTasks.add(new ExportTask(filename, trackFileFormat, tracks.stream().map(Track::getId).collect(Collectors.toList())));
|
||||
exportTasks.add(new ExportTask(filename, trackFileFormat, tracks.stream().map(Track::getId).toList()));
|
||||
} else {
|
||||
exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.getId()))).collect(Collectors.toList()));
|
||||
exportTasks.addAll(tracks.stream().map(it -> new ExportTask(null, trackFileFormat, List.of(it.getId()))).toList());
|
||||
}
|
||||
trackExportTotalCount = exportTasks.size();
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.data.ContentProviderUtils;
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
@@ -105,7 +104,9 @@ public class ExportUtils {
|
||||
@Deprecated
|
||||
public static void exportTrack(Context context, DocumentFile directory, ExportTask exportTask) {
|
||||
ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context);
|
||||
List<Track> tracks = exportTask.getTrackIds().stream().map(contentProviderUtils::getTrack).collect(Collectors.toList());
|
||||
List<Track> tracks = exportTask.getTrackIds().stream()
|
||||
.map(contentProviderUtils::getTrack)
|
||||
.toList();
|
||||
Uri exportDocumentFileUri;
|
||||
if (tracks.size() == 1) {
|
||||
exportDocumentFileUri = getExportDocumentFileUri(context, tracks.get(0), exportTask.getTrackFileFormat(), directory);
|
||||
|
||||
+1
-4
@@ -4,7 +4,6 @@ import android.app.Activity;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.provider.DocumentsContract;
|
||||
import android.widget.Toast;
|
||||
@@ -149,9 +148,7 @@ public abstract class DirectoryChooserActivity extends AppCompatActivity {
|
||||
super.configureDirectoryChooserIntent(intent);
|
||||
intent.addFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION | Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION);
|
||||
if (PreferencesUtils.isDefaultExportDirectoryUri()) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, PreferencesUtils.getDefaultExportDirectoryUri());
|
||||
}
|
||||
intent.putExtra(DocumentsContract.EXTRA_INITIAL_URI, PreferencesUtils.getDefaultExportDirectoryUri());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -28,7 +28,6 @@ import androidx.documentfile.provider.DocumentFile;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.AbstractActivity;
|
||||
import de.dennisguse.opentracks.R;
|
||||
@@ -92,14 +91,14 @@ public class ImportActivity extends AbstractActivity {
|
||||
documentFiles = new ArrayList<>();
|
||||
documentFiles.add(DocumentFile.fromTreeUri(this, documentUris.get(0)));
|
||||
} else {
|
||||
documentFiles = documentUris.stream().map(it -> DocumentFile.fromSingleUri(this, it)).collect(Collectors.toList());
|
||||
documentFiles = documentUris.stream()
|
||||
.map(it -> DocumentFile.fromSingleUri(this, it))
|
||||
.toList();
|
||||
}
|
||||
|
||||
importer = new Importer(this, documentFiles);
|
||||
importer.getLiveData()
|
||||
.observe(this, summary -> {
|
||||
setProgress(summary);
|
||||
});
|
||||
.observe(this, this::setProgress);
|
||||
importer.startImport();
|
||||
|
||||
//Works for a directory, but we might have received multiple files via SEND_MULTIPLE.
|
||||
|
||||
@@ -12,7 +12,6 @@ import androidx.work.WorkRequest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.data.models.Track;
|
||||
@@ -38,7 +37,7 @@ public class Importer {
|
||||
|
||||
List<ArrayList<DocumentFile>> nestedFileList = documentFiles.stream()
|
||||
.map(FileUtils::getFiles)
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
|
||||
List<DocumentFile> fileList = new ArrayList<>();
|
||||
nestedFileList.forEach(fileList::addAll);
|
||||
|
||||
+6
-9
@@ -43,15 +43,13 @@ class TrackRecordingServiceNotificationManager implements SharedPreferences.OnSh
|
||||
|
||||
TrackRecordingServiceNotificationManager(Context context) {
|
||||
notificationManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
notificationChannel.setAllowBubbles(true);
|
||||
}
|
||||
|
||||
notificationManager.createNotificationChannel(notificationChannel);
|
||||
NotificationChannel notificationChannel = new NotificationChannel(CHANNEL_ID, context.getString(R.string.app_name), NotificationManager.IMPORTANCE_HIGH);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
|
||||
notificationChannel.setAllowBubbles(true);
|
||||
}
|
||||
|
||||
notificationManager.createNotificationChannel(notificationChannel);
|
||||
|
||||
notificationBuilder = new NotificationCompat.Builder(context, CHANNEL_ID);
|
||||
notificationBuilder
|
||||
.setPriority(NotificationCompat.PRIORITY_DEFAULT)
|
||||
@@ -105,8 +103,7 @@ class TrackRecordingServiceNotificationManager implements SharedPreferences.OnSh
|
||||
Notification setGPSonlyStarted(Context context) {
|
||||
Intent intent = IntentUtils.newIntent(context, TrackListActivity.class);
|
||||
|
||||
int pendingIntentFlags = 0;
|
||||
pendingIntentFlags = PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
int pendingIntentFlags = PendingIntent.FLAG_IMMUTABLE | PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
PendingIntent pendingIntent = TaskStackBuilder.create(context)
|
||||
.addParentStack(TrackListActivity.class)
|
||||
.addNextIntent(intent)
|
||||
|
||||
@@ -29,7 +29,7 @@ import de.dennisguse.opentracks.R;
|
||||
|
||||
public class LocalePreference extends ListPreference {
|
||||
|
||||
private String TAG = LocalePreference.class.getSimpleName();
|
||||
private final String TAG = LocalePreference.class.getSimpleName();
|
||||
|
||||
public LocalePreference(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) {
|
||||
super(context, attrs, defStyleAttr, defStyleRes);
|
||||
|
||||
@@ -2,7 +2,6 @@ package de.dennisguse.opentracks.settings;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.ui.customRecordingLayout.CsvLayoutUtils;
|
||||
@@ -59,7 +58,7 @@ class PreferencesOpenHelper {
|
||||
if (!parts.get(1).matches("\\d+")) {
|
||||
parts.add(1, String.valueOf(PreferencesUtils.getLayoutColumnsByDefault()));
|
||||
}
|
||||
PreferencesUtils.setString(R.string.stats_custom_layouts_key, parts.stream().collect(Collectors.joining(CsvLayoutUtils.ITEM_SEPARATOR)));
|
||||
PreferencesUtils.setString(R.string.stats_custom_layouts_key, String.join(CsvLayoutUtils.ITEM_SEPARATOR, parts));
|
||||
}
|
||||
|
||||
private void onDowngrade() {
|
||||
|
||||
@@ -396,7 +396,7 @@ public class PreferencesUtils {
|
||||
UnitSystem unitSystem = getUnitSystem();
|
||||
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setUnit(unitSystem)
|
||||
.build(resources);
|
||||
for (int i = 0; i < entryValues.length; i++) {
|
||||
@@ -503,7 +503,7 @@ public class PreferencesUtils {
|
||||
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setUnit(unitSystem)
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setThreshold(Double.MAX_VALUE)
|
||||
.build(resources);
|
||||
for (int i = 0; i < entryValues.length; i++) {
|
||||
@@ -546,7 +546,7 @@ public class PreferencesUtils {
|
||||
UnitSystem unitSystem = getUnitSystem();
|
||||
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setThreshold(Double.MAX_VALUE)
|
||||
.setUnit(unitSystem)
|
||||
.build(resources);
|
||||
@@ -619,7 +619,7 @@ public class PreferencesUtils {
|
||||
UnitSystem unitSystem = getUnitSystem();
|
||||
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setThreshold(Double.MAX_VALUE)
|
||||
.setUnit(unitSystem)
|
||||
.build(resources);
|
||||
@@ -829,7 +829,8 @@ public class PreferencesUtils {
|
||||
R.array.stats_custom_layout_fields_default_value_16,
|
||||
R.array.stats_custom_layout_fields_default_value_17,
|
||||
R.array.stats_custom_layout_fields_default_value_18
|
||||
).map(id -> resources.obtainTypedArray(id)).collect(Collectors.toList());
|
||||
).map(id -> resources.obtainTypedArray(id))
|
||||
.toList();
|
||||
}
|
||||
|
||||
@SuppressLint("ResourceType")
|
||||
@@ -904,7 +905,9 @@ public class PreferencesUtils {
|
||||
}
|
||||
|
||||
public static List<String> getAllCustomLayoutNames() {
|
||||
return getAllCustomLayouts().stream().map(RecordingLayout::getName).collect(Collectors.toList());
|
||||
return getAllCustomLayouts().stream()
|
||||
.map(RecordingLayout::getName)
|
||||
.toList();
|
||||
}
|
||||
|
||||
public static void resetCustomLayoutPreferences() {
|
||||
|
||||
@@ -18,7 +18,7 @@ public class RecordingSettingsFragment extends PreferenceFragmentCompat {
|
||||
UnitSystem unitSystem = PreferencesUtils.getUnitSystem();
|
||||
|
||||
final DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setUnit(unitSystem)
|
||||
.build(getContext());
|
||||
|
||||
|
||||
@@ -31,7 +31,7 @@ public class SensorsSettingsFragment extends PreferenceFragmentCompat {
|
||||
UnitSystem unitSystem = PreferencesUtils.getUnitSystem();
|
||||
|
||||
final DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setUnit(unitSystem)
|
||||
.build(getContext());
|
||||
|
||||
|
||||
+2
-2
@@ -62,8 +62,8 @@ public class SettingsCustomLayoutEditActivity extends AbstractActivity implement
|
||||
ItemTouchHelper.UP | ItemTouchHelper.DOWN | ItemTouchHelper.START | ItemTouchHelper.END, 0) {
|
||||
@Override
|
||||
public boolean onMove(@NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, @NonNull RecyclerView.ViewHolder target) {
|
||||
int fromPosition = viewHolder.getAdapterPosition();
|
||||
int toPosition = target.getAdapterPosition();
|
||||
int fromPosition = viewHolder.getAbsoluteAdapterPosition();
|
||||
int toPosition = target.getAbsoluteAdapterPosition();
|
||||
recordingLayoutFieldsVisible = adapterFieldsVisible.move(fromPosition, toPosition);
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ public class SettingsCustomLayoutListActivity extends AbstractActivity implement
|
||||
|
||||
@Override
|
||||
public void onSwiped(@NonNull RecyclerView.ViewHolder viewHolder, int i) {
|
||||
final int position = viewHolder.getAdapterPosition();
|
||||
final int position = viewHolder.getAbsoluteAdapterPosition();
|
||||
final RecordingLayout item = adapter.getLayouts().get(position);
|
||||
|
||||
adapter.removeLayout(position);
|
||||
|
||||
+3
-4
@@ -24,7 +24,6 @@ import androidx.vectordrawable.graphics.drawable.AnimatedVectorDrawableCompat;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import de.dennisguse.opentracks.R;
|
||||
import de.dennisguse.opentracks.sensors.BluetoothUtils;
|
||||
@@ -126,7 +125,7 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
||||
|
||||
@Override
|
||||
public void onBatchScanResults(List<ScanResult> results) {
|
||||
listAdapter.addAll(results.stream().map(ScanResult::getDevice).collect(Collectors.toList()));
|
||||
listAdapter.addAll(results.stream().map(ScanResult::getDevice).toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -149,7 +148,7 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
||||
b.putParcelableArrayList(ARG_BLE_SERVICE_UUIDS, new ArrayList<>(sensorUUIDs.stream()
|
||||
.map(ServiceMeasurementUUID::serviceUUID)
|
||||
.map(ParcelUuid::new)
|
||||
.collect(Collectors.toList())));
|
||||
.toList()));
|
||||
b.putBoolean(ARG_INCLUDE_INTERNAL, includeInternalSensor);
|
||||
|
||||
fragment.setArguments(b);
|
||||
@@ -224,7 +223,7 @@ public abstract class BluetoothLeSensorPreference extends DialogPreference {
|
||||
if (PreferencesUtils.getBluetoothFilterEnabled()) {
|
||||
scanFilter = serviceUUIDs.stream()
|
||||
.map(it -> new ScanFilter.Builder().setServiceUuid(it).build())
|
||||
.collect(Collectors.toList());
|
||||
.toList();
|
||||
}
|
||||
|
||||
ScanSettings.Builder scanSettingsBuilder = new ScanSettings.Builder();
|
||||
|
||||
@@ -88,7 +88,7 @@ public class DescriptionGenerator {
|
||||
* @param lineBreak the line break
|
||||
*/
|
||||
private void writeString(String text, StringBuilder builder, int resId, String lineBreak) {
|
||||
if (text == null || text.length() == 0) {
|
||||
if (text == null || text.isEmpty()) {
|
||||
text = context.getString(R.string.value_unknown);
|
||||
}
|
||||
builder.append(context.getString(resId, text));
|
||||
|
||||
@@ -80,7 +80,7 @@ public class TrackStatisticsUpdater {
|
||||
}
|
||||
|
||||
public void addTrackPoints(List<TrackPoint> trackPoints) {
|
||||
trackPoints.stream().forEachOrdered(this::addTrackPoint);
|
||||
trackPoints.forEach(this::addTrackPoint);
|
||||
}
|
||||
|
||||
public void addTrackPoint(TrackPoint trackPoint) {
|
||||
|
||||
+2
-2
@@ -45,7 +45,7 @@ public class AggregatedStatisticsActivity extends AbstractActivity implements Fi
|
||||
|
||||
List<Track.Id> trackIds = getIntent().getParcelableArrayListExtra(EXTRA_TRACK_IDS);
|
||||
if (trackIds != null && !trackIds.isEmpty()) {
|
||||
trackIds.stream().forEach(selection::addTrackId);
|
||||
trackIds.forEach(selection::addTrackId);
|
||||
}
|
||||
|
||||
LinearLayoutManager layoutManager = new LinearLayoutManager(this);
|
||||
@@ -103,7 +103,7 @@ public class AggregatedStatisticsActivity extends AbstractActivity implements Fi
|
||||
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
|
||||
if (item.getItemId() == R.id.aggregated_statistics_filter) {
|
||||
ArrayList<FilterDialogFragment.FilterItem> filterItems = new ArrayList<>();
|
||||
adapter.getCategories().stream().forEach(activityType -> filterItems.add(new FilterDialogFragment.FilterItem(activityType, activityType, true)));
|
||||
adapter.getCategories().forEach(activityType -> filterItems.add(new FilterDialogFragment.FilterItem(activityType, activityType, true)));
|
||||
FilterDialogFragment.showDialog(getSupportFragmentManager(), filterItems);
|
||||
return true;
|
||||
}
|
||||
|
||||
+1
-1
@@ -68,7 +68,7 @@ public class RecordingLayout implements Parcelable {
|
||||
|
||||
public RecordingLayout toRecordingLayout(boolean visibility) {
|
||||
RecordingLayout result = new RecordingLayout(this.getName());
|
||||
result.addFields(dataFields.stream().filter(f -> f.isVisible() == visibility).collect(Collectors.toList()));
|
||||
result.addFields(dataFields.stream().filter(f -> f.isVisible() == visibility).toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,7 +21,7 @@ public class IntervalStatisticsAdapter extends RecyclerView.Adapter<RecyclerView
|
||||
private List<IntervalStatistics.Interval> intervalList;
|
||||
private final Context context;
|
||||
private final StackMode stackMode;
|
||||
private UnitSystem unitSystem = UnitSystem.defaultUnitSystem();
|
||||
private UnitSystem unitSystem;
|
||||
private boolean isReportSpeed;
|
||||
|
||||
public IntervalStatisticsAdapter(Context context, StackMode stackMode, UnitSystem unitSystem, boolean isReportSpeed) {
|
||||
|
||||
@@ -114,7 +114,7 @@ public class IntervalsFragment extends Fragment {
|
||||
TextView v = (TextView) super.getView(position, convertView, parent);
|
||||
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setUnit(unitSystem)
|
||||
.build(getContext());
|
||||
|
||||
@@ -200,7 +200,7 @@ public class IntervalsFragment extends Fragment {
|
||||
|
||||
private void setIntervalsDropdownText() {
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setUnit(unitSystem)
|
||||
.build(getContext());
|
||||
|
||||
|
||||
@@ -3,7 +3,6 @@ package de.dennisguse.opentracks.ui.util;
|
||||
import static android.content.Context.VIBRATOR_SERVICE;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.os.VibrationEffect;
|
||||
import android.os.Vibrator;
|
||||
import android.view.Menu;
|
||||
@@ -18,11 +17,7 @@ public class ActivityUtils {
|
||||
|
||||
public static void vibrate(@NonNull Context context, Duration duration) {
|
||||
final Vibrator vibrator = (Vibrator) context.getSystemService(VIBRATOR_SERVICE);
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(duration.toMillis(), VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
} else {
|
||||
vibrator.vibrate(duration.toMillis());
|
||||
}
|
||||
vibrator.vibrate(VibrationEffect.createOneShot(duration.toMillis(), VibrationEffect.DEFAULT_AMPLITUDE));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -49,13 +49,13 @@ public class ListItemUtils {
|
||||
*/
|
||||
private static String getTimeDistance(String totalTime, String totalDistance) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
if (totalTime != null && totalTime.length() != 0) {
|
||||
if (totalTime != null && !totalTime.isEmpty()) {
|
||||
if (builder.length() != 0) {
|
||||
builder.append(" ‧ ");
|
||||
}
|
||||
builder.append(totalTime);
|
||||
}
|
||||
if (totalDistance != null && totalDistance.length() != 0) {
|
||||
if (totalDistance != null && !totalDistance.isEmpty()) {
|
||||
if (builder.length() != 0) {
|
||||
builder.append(" ");
|
||||
}
|
||||
|
||||
@@ -48,8 +48,6 @@ abstract public class RecyclerViewSwipeDeleteCallback extends ItemTouchHelper.Ca
|
||||
|
||||
@Override
|
||||
public void onChildDraw(@NonNull Canvas c, @NonNull RecyclerView recyclerView, @NonNull RecyclerView.ViewHolder viewHolder, float dX, float dY, int actionState, boolean isCurrentlyActive) {
|
||||
super.onChildDraw(c, recyclerView, viewHolder, dX, dY, actionState, isCurrentlyActive);
|
||||
|
||||
View itemView = viewHolder.itemView;
|
||||
int itemHeight = itemView.getHeight();
|
||||
|
||||
|
||||
@@ -95,7 +95,7 @@ public class PermissionRequester {
|
||||
ArrayList<String> recording = new ArrayList<>(GPS_PERMISSION);
|
||||
recording.addAll(BLUETOOTH_PERMISSIONS);
|
||||
|
||||
RECORDING_PERMISSIONS = Collections.unmodifiableList(new ArrayList<>(recording));
|
||||
RECORDING_PERMISSIONS = List.copyOf(recording);
|
||||
|
||||
recording.addAll(NOTIFICATION_PERMISSIONS);
|
||||
|
||||
|
||||
@@ -233,7 +233,7 @@ public class StringUtils {
|
||||
//TODO altitude_m should be double or a value object
|
||||
public static Pair<String, String> getAltitudeParts(Context context, Float altitude_m, UnitSystem unitSystem) {
|
||||
DistanceFormatter formatter = DistanceFormatter.Builder()
|
||||
.setDecimalCount(0)
|
||||
.setDecimalPlaces(0)
|
||||
.setThreshold(Double.MAX_VALUE)
|
||||
.setUnit(unitSystem)
|
||||
.build(context);
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
android:translateY="24">
|
||||
<path
|
||||
android:pathData="M85.133,20.59C85.731,18.546 84.756,17.817 82.965,18.968L23.874,56.967c-1.791,1.152 -1.519,2.224 0.604,2.382L49.019,61.18c2.124,0.159 4.477,1.918 5.229,3.91l8.7,23.021c0.753,1.992 1.857,1.949 2.455,-0.094z"
|
||||
android:fillColor="#FFFFFF"></path>
|
||||
android:fillColor="#FFFFFF" />
|
||||
</group>
|
||||
</vector>
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
android:id="@+id/recycler_view_visible"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical"
|
||||
app:layout_constraintBottom_toTopOf="@id/recycler_view_not_visible"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
|
||||
@@ -18,11 +18,11 @@
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<LinearLayout xmlns:tools="http://schemas.android.com/tools"
|
||||
android:paddingTop="?attr/actionBarSize"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:fitsSystemWindows="true"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:paddingTop="?attr/actionBarSize">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/custom_layout_list_add_linear_layout"
|
||||
@@ -82,7 +82,8 @@
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recycler_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content" />
|
||||
android:layout_height="wrap_content"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
android:id="@+id/aggregated_stats_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical"
|
||||
android:visibility="gone" />
|
||||
|
||||
<TextView
|
||||
@@ -35,8 +36,8 @@
|
||||
style="?attr/textAppearanceHeadline4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="16dp"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:padding="16dp"
|
||||
android:text="@string/aggregated_stats_empty_message" />
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
@@ -3,8 +3,8 @@
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:padding="8dp"
|
||||
android:orientation="vertical">
|
||||
android:orientation="vertical"
|
||||
android:padding="8dp">
|
||||
|
||||
<com.google.android.material.textfield.TextInputLayout
|
||||
android:id="@+id/intervals_input_layout"
|
||||
@@ -29,26 +29,26 @@
|
||||
|
||||
<TextView
|
||||
android:id="@+id/interval_distance"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.OpenTracks.PrimaryHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/stats_distance" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/interval_rate"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.OpenTracks.PrimaryHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
tools:text="Speed" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/interval_altitude"
|
||||
android:layout_width="0dp"
|
||||
android:layout_weight="1"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/TextAppearance.OpenTracks.PrimaryHeader"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_weight="1"
|
||||
android:text="@string/stats_gain_loss" />
|
||||
|
||||
</LinearLayout>
|
||||
@@ -64,13 +64,14 @@
|
||||
android:id="@+id/interval_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_margin="8dp" />
|
||||
android:layout_margin="8dp"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/interval_list_empty_view"
|
||||
style="?attr/textAppearanceHeadline4"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
style="?attr/textAppearanceHeadline4"
|
||||
android:gravity="center_horizontal|center_vertical"
|
||||
android:text="@string/interval_list_empty_message" />
|
||||
|
||||
|
||||
@@ -27,9 +27,9 @@ limitations under the License.
|
||||
android:id="@+id/marker_list_toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:navigationIcon="@drawable/ic_marker_show_24dp"
|
||||
app:layout_behavior="@string/searchbar_scrolling_view_behavior"
|
||||
app:menu="@menu/marker_list" />
|
||||
app:menu="@menu/marker_list"
|
||||
app:navigationIcon="@drawable/ic_marker_show_24dp" />
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
|
||||
<com.google.android.material.search.SearchView
|
||||
@@ -51,7 +51,8 @@ limitations under the License.
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/marker_list"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
android:layout_height="match_parent"
|
||||
android:scrollbars="vertical" />
|
||||
|
||||
<TextView
|
||||
android:id="@+id/marker_list_empty"
|
||||
|
||||
@@ -46,6 +46,7 @@ limitations under the License.
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:paddingBottom="?attr/actionBarSize"
|
||||
android:scrollbars="vertical"
|
||||
app:layout_behavior="@string/appbar_scrolling_view_behavior" />
|
||||
|
||||
<com.google.android.material.bottomappbar.BottomAppBar
|
||||
|
||||
@@ -44,7 +44,7 @@ limitations under the License.
|
||||
<string name="sensor_unit_power" translatable="false">w</string>
|
||||
|
||||
<string name="value_unknown" translatable="false">-</string>
|
||||
<string name="empty" translatable="false"></string>
|
||||
<string name="empty" translatable="false" />
|
||||
<string name="report_issue_link" translatable="false">https://codeberg.org/OpenTracksApp/OpenTracks/issues/new?labels=bug&template=bug_report.md&body=%1$s</string>
|
||||
|
||||
<string-array name="marker_types">
|
||||
|
||||
Reference in New Issue
Block a user