From edd3cf0c2b065ce05039e20705896d2b68e9a973 Mon Sep 17 00:00:00 2001 From: darken Date: Tue, 28 Jul 2026 20:27:55 +0200 Subject: [PATCH] ui(monitor): Give the early service notification a content text --- .../capod/monitor/ui/MonitorNotifications.kt | 1 + app/src/main/res/values/strings.xml | 1 + .../monitor/ui/MonitorNotificationsTest.kt | 28 +++++++++++++++++++ 3 files changed, 30 insertions(+) create mode 100644 app/src/test/java/eu/darken/capod/monitor/ui/MonitorNotificationsTest.kt diff --git a/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt b/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt index c3d1cfb5..0e4f2de5 100644 --- a/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt +++ b/app/src/main/java/eu/darken/capod/monitor/ui/MonitorNotifications.kt @@ -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() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e9cf3b3d..3645b927 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -86,6 +86,7 @@ Device status Connected device You can disable this notification in system settings. + Starting up… Debug log Record everything the app is doing into a text file that you can share. diff --git a/app/src/test/java/eu/darken/capod/monitor/ui/MonitorNotificationsTest.kt b/app/src/test/java/eu/darken/capod/monitor/ui/MonitorNotificationsTest.kt new file mode 100644 index 00000000..9775365c --- /dev/null +++ b/app/src/test/java/eu/darken/capod/monitor/ui/MonitorNotificationsTest.kt @@ -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 + } +}