diff --git a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java index 1727c7af2..ab805fad6 100644 --- a/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java +++ b/src/androidTest/java/de/dennisguse/opentracks/services/announcement/VoiceAnnouncementUtilsTest.java @@ -312,7 +312,7 @@ public void getAnnouncement_heart_rate_and_sensor_statistics() { lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1); } - SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null); + SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null); // when String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString(); @@ -342,7 +342,7 @@ public void getAnnouncement_only_lap_heart_rate() { lastInterval = intervalStatistics.getIntervalList().get(intervalStatistics.getIntervalList().size() - 1); } - SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null); + SensorStatistics sensorStatistics = new SensorStatistics(HeartRate.of(180f), HeartRate.of(180f), null, null, null, null); // when String announcement = VoiceAnnouncementUtils.getAnnouncement(context, stats, UnitSystem.METRIC, true, lastInterval, sensorStatistics).toString(); diff --git a/src/main/java/de/dennisguse/opentracks/share/DescriptionGenerator.java b/src/main/java/de/dennisguse/opentracks/share/DescriptionGenerator.java index 2058a0fe5..a803ad4ef 100644 --- a/src/main/java/de/dennisguse/opentracks/share/DescriptionGenerator.java +++ b/src/main/java/de/dennisguse/opentracks/share/DescriptionGenerator.java @@ -221,16 +221,16 @@ void writePace(Speed speed, StringBuilder builder, int resId, String lineBreak) } /** - * @param altitude_m altitude_m in meters + * @param altitudeM altitude_m in meters * @param builder StringBuilder to append * @param resId resource id of altitude string * @param lineBreak line break string */ @VisibleForTesting - void writeAltitude(double altitude_m, StringBuilder builder, int resId, String lineBreak) { - long altitudeInM = Math.round(altitude_m); - long altitudeInFt = Math.round(Distance.of(altitude_m).toFT()); + void writeAltitude(double altitudeM, StringBuilder builder, int resId, String lineBreak) { + long altitudeInM = Math.round(altitudeM); + long altitudeInFt = Math.round(Distance.of(altitudeM).toFT()); builder.append(context.getString(resId, altitudeInM, altitudeInFt)); builder.append(lineBreak); } -} +} \ No newline at end of file diff --git a/src/main/java/de/dennisguse/opentracks/share/ShareUtils.java b/src/main/java/de/dennisguse/opentracks/share/ShareUtils.java index 7a87241aa..197a497f5 100644 --- a/src/main/java/de/dennisguse/opentracks/share/ShareUtils.java +++ b/src/main/java/de/dennisguse/opentracks/share/ShareUtils.java @@ -18,6 +18,23 @@ import de.dennisguse.opentracks.io.file.TrackFileFormat; import de.dennisguse.opentracks.settings.PreferencesUtils; +class NoTracksToShareException extends RuntimeException{ + public NoTracksToShareException() + { + super("Did not find any tracks to share."); + } + public NoTracksToShareException(String message) + { + super(message); + } +} + + class NoMarkersToShareException extends RuntimeException { + public NoMarkersToShareException() { + super("Need to share at least one marker."); + } +} + public class ShareUtils { private static final String TAG = ShareUtils.class.getSimpleName(); @@ -34,7 +51,7 @@ private ShareUtils() { */ public static Intent newShareFileIntent(Context context, Track.Id... trackIds) { if (trackIds.length == 0) { - throw new RuntimeException("Need to share at least one track."); + throw new NoTracksToShareException("Need to share at least one track."); } ContentProviderUtils contentProviderUtils = new ContentProviderUtils(context); @@ -80,7 +97,7 @@ public static Intent newShareFileIntent(Context context, Track.Id... trackIds) { @Nullable public static Intent newShareFileIntent(Context context, Marker.Id... markerIds) { if (markerIds.length == 0) { - throw new RuntimeException("Need to share at least one marker."); + throw new NoMarkersToShareException(); } String mime = null; @@ -95,7 +112,7 @@ public static Intent newShareFileIntent(Context context, Marker.Id... markerIds) } if (marker.getPhotoURI() == null) { Log.e(TAG, "MarkerId " + markerId.id() + " has no picture."); - continue; + } mime = context.getContentResolver().getType(marker.getPhotoURI()); diff --git a/src/main/java/de/dennisguse/opentracks/util/PermissionRequester.java b/src/main/java/de/dennisguse/opentracks/util/PermissionRequester.java index 7a72b59ad..f4d8b43cc 100644 --- a/src/main/java/de/dennisguse/opentracks/util/PermissionRequester.java +++ b/src/main/java/de/dennisguse/opentracks/util/PermissionRequester.java @@ -61,11 +61,7 @@ private void requestPermission(ActivityResultCaller context, @Nullable Runnable static { //TODO ACCESS_BACKGROUND_LOCATION is required for API, but the permission is not properly granted. See #1653. -// if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { -// GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION, Manifest.permission.ACCESS_BACKGROUND_LOCATION); -// } else { - GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION); -// } + GPS_PERMISSION = List.of(Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION); } private static final List BLUETOOTH_PERMISSIONS;