corrected version number

This commit is contained in:
pi
2025-11-11 01:39:35 +01:00
parent 62f44a1654
commit 453e265963
3 changed files with 34 additions and 6 deletions

View File

@@ -9,7 +9,7 @@ android {
minSdkVersion 21 minSdkVersion 21
targetSdkVersion 34 targetSdkVersion 34
versionCode 14 versionCode 14
versionName "1.4" versionName "1.5"
} }
buildTypes { buildTypes {

View File

@@ -95,9 +95,9 @@ class ListenService : Service() {
get() = this@ListenService 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 // 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( val contentIntent = PendingIntent.getActivity(
this, 0, this, 0,
Intent(this, ListenActivity::class.java), Intent(this, ListenActivity::class.java),
@@ -151,6 +151,7 @@ class ListenService : Service() {
if (!connected) { if (!connected) {
Log.e(TAG, "Failed to connect after 3 attempts.") Log.e(TAG, "Failed to connect after 3 attempts.")
playAlert() playAlert()
updateNotification(getString(R.string.disconnected))
onError?.invoke() onError?.invoke()
} else { } else {
Log.i(TAG, "Connection established successfully.") Log.i(TAG, "Connection established successfully.")
@@ -205,6 +206,9 @@ class ListenService : Service() {
true true
} catch (e: Exception) { } catch (e: Exception) {
Log.e(TAG, "Connection lost during streaming", e) Log.e(TAG, "Connection lost during streaming", e)
updateNotification(getString(R.string.disconnected))
playAlert()
onError?.invoke()
false false
} finally { } finally {
try { 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() { private fun playAlert() {
val mp = MediaPlayer.create(this, R.raw.upward_beep_chromatic_fifths) val mp = MediaPlayer.create(this, R.raw.upward_beep_chromatic_fifths)
if (mp != null) { if (mp != null) {

View File

@@ -8,7 +8,7 @@
android:paddingLeft="@dimen/activity_horizontal_margin" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin" android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin" android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.childmonitor_multiple.MonitorActivity" > tools:context="com.example.childmonitor_multiple.MonitorActivity">
<TextView <TextView
android:id="@+id/parentDeviceTitle" android:id="@+id/parentDeviceTitle"
@@ -67,7 +67,26 @@
android:inputType="number" android:inputType="number"
android:maxLength="5" android:maxLength="5"
android:hint="@string/examplePort" android:hint="@string/examplePort"
android:nextFocusForward="@+id/connectViaAddressButton"/> android:nextFocusForward="@+id/retryField" />
<TextView
android:id="@+id/retryTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="Retry attempts" />
<EditText
android:id="@+id/retryField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:ems="10"
android:inputType="number"
android:maxLength="2"
android:text="3"
android:hint="Default: 3"
android:nextFocusForward="@+id/connectViaAddressButton" />
<Space <Space
android:layout_width="match_parent" android:layout_width="match_parent"