From 374ba8b64f7de1008a273122dc265033247969e2 Mon Sep 17 00:00:00 2001 From: Torsten Grote Date: Fri, 14 Oct 2022 16:33:04 -0300 Subject: [PATCH] Remove permission requirement in a better way for debug builds and reformat some SettingsFragment details --- app/src/debug/AndroidManifest.xml | 6 ++---- .../seedvault/settings/SettingsFragment.kt | 12 ++++++------ .../seedvault/settings/SettingsViewModel.kt | 4 ++-- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/app/src/debug/AndroidManifest.xml b/app/src/debug/AndroidManifest.xml index 09836263..0888d2f4 100644 --- a/app/src/debug/AndroidManifest.xml +++ b/app/src/debug/AndroidManifest.xml @@ -7,13 +7,11 @@ + tools:remove="android:permission" /> + tools:remove="android:permission" /> 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 ff26c3a8..e2a817bc 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsFragment.kt @@ -130,14 +130,14 @@ class SettingsFragment : PreferenceFragmentCompat() { override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) - viewModel.lastBackupTime.observe(viewLifecycleOwner, { time -> + viewModel.lastBackupTime.observe(viewLifecycleOwner) { time -> setAppBackupStatusSummary(time) - }) + } val backupFiles: Preference = findPreference("backup_files")!! - viewModel.filesSummary.observe(viewLifecycleOwner, { summary -> + viewModel.filesSummary.observe(viewLifecycleOwner) { summary -> backupFiles.summary = summary - }) + } } override fun onStart() { @@ -160,10 +160,10 @@ class SettingsFragment : PreferenceFragmentCompat() { if (resources.getBoolean(R.bool.show_restore_in_settings)) { menuRestore?.isVisible = true } - viewModel.backupPossible.observe(viewLifecycleOwner, { possible -> + viewModel.backupPossible.observe(viewLifecycleOwner) { possible -> menuBackupNow?.isEnabled = possible menuRestore?.isEnabled = possible - }) + } } override fun onOptionsItemSelected(item: MenuItem): Boolean = when (item.itemId) { diff --git a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt index 8da4f9fc..eb7505b5 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/settings/SettingsViewModel.kt @@ -193,9 +193,9 @@ internal class SettingsViewModel( @UiThread fun loadFilesSummary() = viewModelScope.launch { val uriSummary = storageBackup.getUriSummaryString() - _filesSummary.value = if (uriSummary.isEmpty()) { + _filesSummary.value = uriSummary.ifEmpty { app.getString(R.string.settings_backup_files_summary) - } else uriSummary + } } /**