ui(monitor): Give the early service notification a content text

This commit is contained in:
darken
2026-07-28 23:51:46 +02:00
committed by Matthias Urhahn
parent 9f322f0a3f
commit edd3cf0c2b
3 changed files with 30 additions and 0 deletions
@@ -170,6 +170,7 @@ class MonitorNotifications @Inject constructor(
setContentIntent(openPi)
setSmallIcon(R.drawable.device_earbuds_generic_both)
setContentTitle(context.getString(R.string.app_name))
setContentText(context.getString(R.string.monitor_notification_starting))
setPriority(NotificationCompat.PRIORITY_LOW)
setOngoing(true)
}.build()
+1
View File
@@ -86,6 +86,7 @@
<string name="notification_channel_device_status_label">Device status</string>
<string name="notification_channel_device_status_connected_label">Connected device</string>
<string name="monitor_notification_extra_enabled_hint">You can disable this notification in system settings.</string>
<string name="monitor_notification_starting">Starting up…</string>
<string name="support_debuglog_label">Debug log</string>
<string name="support_debuglog_desc">Record everything the app is doing into a text file that you can share.</string>
@@ -0,0 +1,28 @@
package eu.darken.capod.monitor.ui
import android.app.Application
import android.app.Notification
import io.kotest.matchers.shouldBe
import io.kotest.matchers.shouldNotBe
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(manifest = Config.NONE, sdk = [34], application = Application::class)
class MonitorNotificationsTest {
@Test
fun `early notification is user presentable`() {
// It can be the notification the user sees for the whole lifetime of a service that never
// finishes starting up, so it has to stand on its own.
val notification = MonitorNotifications.createEarlyNotification(RuntimeEnvironment.getApplication())
notification.extras.getString(Notification.EXTRA_TITLE).isNullOrBlank() shouldBe false
notification.extras.getString(Notification.EXTRA_TEXT).isNullOrBlank() shouldBe false
notification.smallIcon shouldNotBe null
notification.contentIntent shouldNotBe null
}
}