From 453e265963388e21d5231f6b3e989bdb963ec266 Mon Sep 17 00:00:00 2001 From: pi Date: Tue, 11 Nov 2025 01:39:35 +0100 Subject: [PATCH] corrected version number --- app/build.gradle | 2 +- .../childmonitor_multiple/ListenService.kt | 13 ++++++++-- .../res/layout/activity_discover_address.xml | 25 ++++++++++++++++--- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e3b0bc4..2055fc0 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -9,7 +9,7 @@ android { minSdkVersion 21 targetSdkVersion 34 versionCode 14 - versionName "1.4" + versionName "1.5" } buildTypes { diff --git a/app/src/main/kotlin/com/example/childmonitor_multiple/ListenService.kt b/app/src/main/kotlin/com/example/childmonitor_multiple/ListenService.kt index 711b6b9..6b57031 100644 --- a/app/src/main/kotlin/com/example/childmonitor_multiple/ListenService.kt +++ b/app/src/main/kotlin/com/example/childmonitor_multiple/ListenService.kt @@ -95,9 +95,9 @@ class ListenService : Service() { get() = this@ListenService } - private fun buildNotification(name: String?): Notification { + private fun buildNotification(name: String?, status: String = getString(R.string.listening)): Notification { // In this sample, we'll use the same text for the ticker and the expanded notification - val text = getText(R.string.listening) + val text = status val contentIntent = PendingIntent.getActivity( this, 0, Intent(this, ListenActivity::class.java), @@ -151,6 +151,7 @@ class ListenService : Service() { if (!connected) { Log.e(TAG, "Failed to connect after 3 attempts.") playAlert() + updateNotification(getString(R.string.disconnected)) onError?.invoke() } else { Log.i(TAG, "Connection established successfully.") @@ -205,6 +206,9 @@ class ListenService : Service() { true } catch (e: Exception) { Log.e(TAG, "Connection lost during streaming", e) + updateNotification(getString(R.string.disconnected)) + playAlert() + onError?.invoke() false } finally { try { @@ -215,6 +219,11 @@ class ListenService : Service() { } } + private fun updateNotification(status: String) { + val n = buildNotification(childDeviceName, status) + notificationManager.notify(ID, n) + } + private fun playAlert() { val mp = MediaPlayer.create(this, R.raw.upward_beep_chromatic_fifths) if (mp != null) { diff --git a/app/src/main/res/layout/activity_discover_address.xml b/app/src/main/res/layout/activity_discover_address.xml index 956fbbf..df6308f 100644 --- a/app/src/main/res/layout/activity_discover_address.xml +++ b/app/src/main/res/layout/activity_discover_address.xml @@ -8,7 +8,7 @@ android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin" android:paddingTop="@dimen/activity_vertical_margin" - tools:context="com.example.childmonitor_multiple.MonitorActivity" > + tools:context="com.example.childmonitor_multiple.MonitorActivity"> + android:nextFocusForward="@+id/retryField" /> + + + + - \ No newline at end of file +