diff --git a/app-common/src/main/java/eu/darken/capod/main/core/GeneralSettings.kt b/app-common/src/main/java/eu/darken/capod/main/core/GeneralSettings.kt
index a3136f1e..f8c25125 100644
--- a/app-common/src/main/java/eu/darken/capod/main/core/GeneralSettings.kt
+++ b/app-common/src/main/java/eu/darken/capod/main/core/GeneralSettings.kt
@@ -30,6 +30,9 @@ class GeneralSettings @Inject constructor(
val useExtraMonitorNotification = preferences.createFlowPreference("core.monitor.notification.connected", false)
+ val keepConnectedNotificationAfterDisconnect =
+ preferences.createFlowPreference("core.monitor.notification.connected.keepafterdisconnected", false)
+
val scannerMode = preferences.createFlowPreference("core.scanner.mode", ScannerMode.BALANCED, moshi)
val showAll = preferences.createFlowPreference("core.showall.enabled", true)
@@ -61,6 +64,7 @@ class GeneralSettings @Inject constructor(
override val preferenceDataStore: PreferenceDataStore = PreferenceStoreMapper(
monitorMode,
useExtraMonitorNotification,
+ keepConnectedNotificationAfterDisconnect,
scannerMode,
showAll,
minimumSignalQuality,
diff --git a/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt b/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt
index 5247f733..d76427d2 100644
--- a/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt
+++ b/app/src/main/java/eu/darken/capod/monitor/core/worker/MonitorWorker.kt
@@ -95,6 +95,13 @@ class MonitorWorker @AssistedInject constructor(
Result.success()
}
} finally {
+ if (generalSettings.useExtraMonitorNotification.value && !generalSettings.keepConnectedNotificationAfterDisconnect.value) {
+ try {
+ notificationManager.cancel(MonitorNotifications.NOTIFICATION_ID_CONNECTED)
+ } catch (e: Exception) {
+ log(TAG, WARN) { "Failed to cancel connected notification: ${e.message}" }
+ }
+ }
this.workerScope.cancel("Worker finished (withError?=$finishedWithError).")
}
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 668fcf6c..66c7123f 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -20,6 +20,8 @@
Under which circumstances this app monitors Bluetooth data.
Extra notification
Shows an extra notification when a device is connected. This lets you hide the permanent \"No devices\" notification by disabling the \"Device status\" channel.
+ Keep notification after disconnect
+ Continue showing the last known battery levels even after your AirPods disconnect
Scanner mode
Should the Bluetooth Low Energy data scanner prioritize performance or conserve energy?
Auto pause
diff --git a/app/src/main/res/xml/preferences_general.xml b/app/src/main/res/xml/preferences_general.xml
index e0a3fdd4..33e30f42 100644
--- a/app/src/main/res/xml/preferences_general.xml
+++ b/app/src/main/res/xml/preferences_general.xml
@@ -90,6 +90,13 @@
android:summary="@string/settings_monitor_connected_notification_description"
android:title="@string/settings_monitor_connected_notification_label" />
+
+