Skip to content
This repository has been archived by the owner on Jan 12, 2024. It is now read-only.

Commit

Permalink
Merge pull request #107 from VarunAggarwal1998/NishaBhatia
Browse files Browse the repository at this point in the history
Nisha bhatia
  • Loading branch information
nishabhatia98 authored Oct 12, 2023
2 parents d2c7fb5 + 96d0b4c commit 890fa57
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
23 changes: 20 additions & 3 deletions src/main/java/de/dennisguse/opentracks/share/ShareUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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);
Expand Down Expand Up @@ -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;
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> BLUETOOTH_PERMISSIONS;
Expand Down

0 comments on commit 890fa57

Please sign in to comment.