@@ -8,6 +8,7 @@ import android.app.PendingIntent
8
8
import android.content.Context
9
9
import android.content.Intent
10
10
import android.content.pm.ServiceInfo
11
+ import androidx.annotation.StringRes
11
12
import androidx.core.app.NotificationCompat
12
13
import androidx.work.ForegroundInfo
13
14
import dagger.hilt.android.qualifiers.ApplicationContext
@@ -19,6 +20,10 @@ import eu.darken.capod.common.debug.logging.logTag
19
20
import eu.darken.capod.common.hasApiLevel
20
21
import eu.darken.capod.common.notifications.PendingIntentCompat
21
22
import eu.darken.capod.main.ui.MainActivity
23
+ import eu.darken.capod.pods.core.HasCase
24
+ import eu.darken.capod.pods.core.HasChargeDetection
25
+ import eu.darken.capod.pods.core.HasDualMicrophone
26
+ import eu.darken.capod.pods.core.HasEarDetection
22
27
import eu.darken.capod.pods.core.PodDevice
23
28
import kotlinx.coroutines.sync.Mutex
24
29
import kotlinx.coroutines.sync.withLock
@@ -71,9 +76,37 @@ class MonitorNotifications @Inject constructor(
71
76
}
72
77
73
78
return builder.apply {
79
+ @StringRes var contentTitleRes = eu.darken.capod.common.R .string.pods_case_unknown_state
80
+ // Options here should be mutually exclusive, and are prioritized by their order of importance
81
+ // Some options are omitted here, as they will conflict with other options
82
+ // TODO: Implement a settings pane to allow user to customize this
83
+ device.apply {
84
+ // Pods charging state
85
+ // This goes first as pods should not be worn if it is still charging
86
+ if (this is HasChargeDetection && isHeadsetBeingCharged) {
87
+ contentTitleRes = eu.darken.capod.common.R .string.pods_charging_label
88
+ return @apply
89
+ }
90
+
91
+ // Pods wear state
92
+ if (this is HasEarDetection ) {
93
+ contentTitleRes = if (isBeingWorn) eu.darken.capod.common.R .string.headset_being_worn_label
94
+ else eu.darken.capod.common.R .string.headset_not_being_worn_label
95
+ return @apply
96
+ }
97
+
98
+ // Case charge state
99
+ // This is under pods wear state as we don't want it conflicting with it
100
+ if (this is HasCase && isCaseCharging) {
101
+ contentTitleRes = eu.darken.capod.common.R .string.pods_charging_label
102
+ return @apply
103
+ }
104
+ }
105
+
74
106
setStyle(NotificationCompat .DecoratedCustomViewStyle ())
75
107
setCustomContentView(notificationViewFactory.createContentView(device))
76
108
setSmallIcon(device.iconRes)
109
+ setContentTitle(context.getString(contentTitleRes))
77
110
setSubText(null )
78
111
log(TAG , VERBOSE ) { " updatingNotification(): $device " }
79
112
}
0 commit comments