From b041c208ac367e75918b1ac3768dfb28dc30ef07 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Mon, 29 Apr 2024 12:00:39 -0300 Subject: [PATCH] Always update next scheduling time in UI Also avoid hard-coded strings and log when no backups are scheduled. --- .../com/stevesoltys/seedvault/settings/SettingsFragment.kt | 6 +++--- app/src/main/res/xml/settings.xml | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt index e76bcf82..83589026 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt @@ -275,13 +275,13 @@ class SettingsFragment : PreferenceFragmentCompat() { backupScheduling.summary = getString(R.string.settings_backup_status_next_backup_usb) return } - if (workInfo == null) return - val nextScheduleTimeMillis = workInfo.nextScheduleTimeMillis - if (workInfo.state == WorkInfo.State.RUNNING) { + val nextScheduleTimeMillis = workInfo?.nextScheduleTimeMillis ?: Long.MAX_VALUE + if (workInfo != null && workInfo.state == WorkInfo.State.RUNNING) { val text = getString(R.string.notification_title) backupScheduling.summary = getString(R.string.settings_backup_status_next_backup, text) } else if (nextScheduleTimeMillis == Long.MAX_VALUE) { + Log.i(TAG, "No backup scheduled! workInfo: $workInfo") val text = getString(R.string.settings_backup_last_backup_never) backupScheduling.summary = getString(R.string.settings_backup_status_next_backup, text) } else { diff --git a/app/src/main/res/xml/settings.xml b/app/src/main/res/xml/settings.xml index 784f0400..d407b1c1 100644 --- a/app/src/main/res/xml/settings.xml +++ b/app/src/main/res/xml/settings.xml @@ -51,7 +51,7 @@ app:icon="@drawable/ic_access_time" app:key="backup_scheduling" app:title="@string/settings_backup_scheduling_title" - app:summary="Next backup: Never" /> + tools:summary="Next backup: Never" />