mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-09-30 16:52:21 +02:00
Always cancel TrackRecordingService's notification.
This commit is contained in:
@@ -80,8 +80,6 @@ public class TrackRecordingService extends Service {
|
||||
// Anything faster than that (in meters per second) will be considered moving.
|
||||
private static final String TAG = TrackRecordingService.class.getSimpleName();
|
||||
|
||||
private static final int NOTIFICATION_ID = 123;
|
||||
|
||||
public static final double MAX_NO_MOVEMENT_SPEED = 0.224;
|
||||
|
||||
// The following variables are set in onCreate:
|
||||
@@ -741,10 +739,12 @@ public class TrackRecordingService extends Service {
|
||||
// Dijkstra If
|
||||
if (isRecording() && isPaused()) {
|
||||
stopForeground(true);
|
||||
notificationManager.cancelNotification();
|
||||
|
||||
}
|
||||
if (!isRecording() && !isGpsStarted) {
|
||||
stopForeground(true);
|
||||
notificationManager.cancelNotification();
|
||||
}
|
||||
if (isRecording() && !isPaused()) {
|
||||
Intent intent = IntentUtils.newIntent(this, TrackDetailActivity.class)
|
||||
@@ -756,7 +756,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
notificationManager.updatePendingIntent(pendingIntent);
|
||||
notificationManager.updateContent(getString(R.string.gps_starting));
|
||||
startForeground(NOTIFICATION_ID, notificationManager.getNotification());
|
||||
startForeground(TrackRecordingServiceNotificationManager.NOTIFICATION_ID, notificationManager.getNotification());
|
||||
}
|
||||
if (!isRecording() && isGpsStarted) {
|
||||
Intent intent = IntentUtils.newIntent(this, TrackListActivity.class);
|
||||
@@ -766,7 +766,7 @@ public class TrackRecordingService extends Service {
|
||||
|
||||
notificationManager.updatePendingIntent(pendingIntent);
|
||||
notificationManager.updateContent(getString(R.string.gps_starting));
|
||||
startForeground(NOTIFICATION_ID, notificationManager.getNotification());
|
||||
startForeground(TrackRecordingServiceNotificationManager.NOTIFICATION_ID, notificationManager.getNotification());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-1
@@ -20,7 +20,7 @@ import de.dennisguse.opentracks.util.StringUtils;
|
||||
*/
|
||||
class TrackRecordingServiceNotificationManager {
|
||||
|
||||
private static final int NOTIFICATION_ID = 123;
|
||||
static final int NOTIFICATION_ID = 123;
|
||||
|
||||
private static final String CHANNEL_ID = TrackRecordingServiceNotificationManager.class.getSimpleName();
|
||||
|
||||
@@ -76,6 +76,7 @@ class TrackRecordingServiceNotificationManager {
|
||||
|
||||
notificationBuilder.setContentText(context.getString(R.string.track_recording_notification_accuracy, formattedAccuracy));
|
||||
updateNotification();
|
||||
|
||||
notificationBuilder.setOnlyAlertOnce(true);
|
||||
}
|
||||
|
||||
@@ -84,6 +85,10 @@ class TrackRecordingServiceNotificationManager {
|
||||
updateNotification();
|
||||
}
|
||||
|
||||
void cancelNotification() {
|
||||
notificationManager.cancel(NOTIFICATION_ID);
|
||||
}
|
||||
|
||||
Notification getNotification() {
|
||||
return notificationBuilder.build();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user