From 08610e133227bdfa31824c08a514c2711b09846b Mon Sep 17 00:00:00 2001 From: Michael Bestas Date: Tue, 24 Aug 2021 04:32:04 +0300 Subject: [PATCH] Don't hide navigation bar in setup wizard Also: Remove back button from recovery code input page Convert root back button to skip button Change-Id: I0bca13b53ac3898f2ab3b8503aaf7d2bc51a983a --- .../seedvault/restore/RestoreActivity.kt | 2 -- .../stevesoltys/seedvault/ui/BackupActivity.kt | 5 ----- .../seedvault/ui/RequireProvisioningActivity.kt | 2 ++ .../ui/recoverycode/RecoveryCodeActivity.kt | 6 ------ .../recoverycode/RecoveryCodeInputFragment.kt | 4 ---- .../seedvault/ui/storage/StorageActivity.kt | 2 -- .../ui/storage/StorageRootsFragment.kt | 14 ++++++++++---- .../res/layout/fragment_recovery_code_input.xml | 17 ----------------- .../main/res/layout/fragment_restore_set.xml | 2 +- .../main/res/layout/fragment_storage_root.xml | 8 ++++---- app/src/main/res/values-cs/strings.xml | 2 +- app/src/main/res/values-de/strings.xml | 4 ++-- app/src/main/res/values-el/strings.xml | 2 +- app/src/main/res/values-es-rUS/strings.xml | 2 +- app/src/main/res/values-es/strings.xml | 4 ++-- app/src/main/res/values-fi/strings.xml | 4 ++-- app/src/main/res/values-fr/strings.xml | 4 ++-- app/src/main/res/values-he/strings.xml | 4 ++-- app/src/main/res/values-hr/strings.xml | 4 ++-- app/src/main/res/values-id/strings.xml | 2 +- app/src/main/res/values-is/strings.xml | 2 +- app/src/main/res/values-it/strings.xml | 2 +- app/src/main/res/values-ja/strings.xml | 4 ++-- app/src/main/res/values-ko/strings.xml | 2 +- app/src/main/res/values-lt/strings.xml | 4 ++-- app/src/main/res/values-nb-rNO/strings.xml | 2 +- app/src/main/res/values-pl/strings.xml | 2 +- app/src/main/res/values-pt-rBR/strings.xml | 4 ++-- app/src/main/res/values-pt-rPT/strings.xml | 2 +- app/src/main/res/values-pt/strings.xml | 4 ++-- app/src/main/res/values-ru/strings.xml | 4 ++-- app/src/main/res/values-sk/strings.xml | 2 +- app/src/main/res/values-ta/strings.xml | 2 +- app/src/main/res/values-te/strings.xml | 2 +- app/src/main/res/values-tr/strings.xml | 4 ++-- app/src/main/res/values-uk/strings.xml | 2 +- app/src/main/res/values-vi/strings.xml | 4 ++-- app/src/main/res/values-zh-rCN/strings.xml | 4 ++-- app/src/main/res/values/strings.xml | 4 ++-- 39 files changed, 61 insertions(+), 89 deletions(-) diff --git a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreActivity.kt index a9548d43..e0afb7b0 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/restore/RestoreActivity.kt @@ -21,8 +21,6 @@ class RestoreActivity : RequireProvisioningActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (isSetupWizard) hideSystemUiNavigation() - setContentView(R.layout.activity_fragment_container) viewModel.displayFragment.observeEvent(this, { fragment -> diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/BackupActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/BackupActivity.kt index acb56a0b..40d35fba 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/BackupActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/BackupActivity.kt @@ -1,7 +1,6 @@ package com.stevesoltys.seedvault.ui import android.view.MenuItem -import android.view.View.SYSTEM_UI_FLAG_HIDE_NAVIGATION import androidx.annotation.CallSuper import androidx.appcompat.app.AppCompatActivity import androidx.fragment.app.Fragment @@ -25,8 +24,4 @@ abstract class BackupActivity : AppCompatActivity() { fragmentTransaction.commit() } - protected fun hideSystemUiNavigation() { - window.decorView.systemUiVisibility = SYSTEM_UI_FLAG_HIDE_NAVIGATION - } - } diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/RequireProvisioningActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/RequireProvisioningActivity.kt index 2e362ce6..393eb2ef 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/RequireProvisioningActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/RequireProvisioningActivity.kt @@ -23,6 +23,7 @@ abstract class RequireProvisioningActivity : BackupActivity() { private val recoveryCodeRequest = registerForActivityResult(StartActivityForResult()) { result -> + setResult(result.resultCode) if (result.resultCode != RESULT_OK) { Log.w(TAG, "Error in activity result for requesting recovery code") if (!getViewModel().recoveryCodeIsSet()) { @@ -32,6 +33,7 @@ abstract class RequireProvisioningActivity : BackupActivity() { } private val requestLocation = registerForActivityResult(StartActivityForResult()) { result -> + setResult(result.resultCode) if (result.resultCode != RESULT_OK) { Log.w(TAG, "Error in activity result for requesting location") if (!getViewModel().validLocationIsSet()) { diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeActivity.kt index d851b688..a6b3d3ed 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeActivity.kt @@ -6,7 +6,6 @@ import android.view.WindowManager.LayoutParams.FLAG_SECURE import com.stevesoltys.seedvault.R import com.stevesoltys.seedvault.ui.BackupActivity import com.stevesoltys.seedvault.ui.INTENT_EXTRA_IS_RESTORE -import com.stevesoltys.seedvault.ui.INTENT_EXTRA_IS_SETUP_WIZARD import org.koin.androidx.viewmodel.ext.android.viewModel class RecoveryCodeActivity : BackupActivity() { @@ -16,7 +15,6 @@ class RecoveryCodeActivity : BackupActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (isSetupWizard()) hideSystemUiNavigation() window.addFlags(FLAG_SECURE) setContentView(R.layout.activity_recovery_code) @@ -66,8 +64,4 @@ class RecoveryCodeActivity : BackupActivity() { return intent?.getBooleanExtra(INTENT_EXTRA_IS_RESTORE, false) ?: false } - private fun isSetupWizard(): Boolean { - return intent?.getBooleanExtra(INTENT_EXTRA_IS_SETUP_WIZARD, false) ?: false - } - } diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeInputFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeInputFragment.kt index f6b15105..f0bc993a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeInputFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/recoverycode/RecoveryCodeInputFragment.kt @@ -46,7 +46,6 @@ class RecoveryCodeInputFragment : Fragment() { private lateinit var introText: TextView private lateinit var doneButton: Button private lateinit var newCodeButton: Button - private lateinit var backView: TextView private lateinit var wordLayout1: TextInputLayout private lateinit var wordLayout2: TextInputLayout private lateinit var wordLayout3: TextInputLayout @@ -76,7 +75,6 @@ class RecoveryCodeInputFragment : Fragment() { introText = v.findViewById(R.id.introText) doneButton = v.findViewById(R.id.doneButton) newCodeButton = v.findViewById(R.id.newCodeButton) - backView = v.findViewById(R.id.backView) wordLayout1 = v.findViewById(R.id.wordLayout1) wordLayout2 = v.findViewById(R.id.wordLayout2) wordLayout3 = v.findViewById(R.id.wordLayout3) @@ -105,8 +103,6 @@ class RecoveryCodeInputFragment : Fragment() { if (viewModel.isRestore) { introText.setText(R.string.recovery_code_input_intro) - backView.visibility = VISIBLE - backView.setOnClickListener { requireActivity().finishAfterTransition() } } val adapterLayout = android.R.layout.simple_list_item_1 diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt index 08472ea8..7c49f1b6 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageActivity.kt @@ -47,8 +47,6 @@ class StorageActivity : BackupActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) - if (isSetupWizard()) hideSystemUiNavigation() - setContentView(R.layout.activity_fragment_container) viewModel = if (isRestore()) { diff --git a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootsFragment.kt b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootsFragment.kt index f2e852ea..6262c34a 100644 --- a/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootsFragment.kt +++ b/app/src/main/java/com/stevesoltys/seedvault/ui/storage/StorageRootsFragment.kt @@ -1,6 +1,7 @@ package com.stevesoltys.seedvault.ui.storage import android.Manifest.permission.MANAGE_DOCUMENTS +import android.app.Activity.RESULT_FIRST_USER import android.annotation.SuppressLint import android.content.Context import android.content.Intent @@ -45,7 +46,7 @@ internal class StorageRootsFragment : Fragment(), StorageRootClickedListener { private lateinit var divider: View private lateinit var listView: RecyclerView private lateinit var progressBar: ProgressBar - private lateinit var backView: TextView + private lateinit var skipView: TextView private val adapter by lazy { StorageRootAdapter(viewModel.isRestoreOperation, this) } @@ -62,7 +63,7 @@ internal class StorageRootsFragment : Fragment(), StorageRootClickedListener { divider = v.findViewById(R.id.divider) listView = v.findViewById(R.id.listView) progressBar = v.findViewById(R.id.progressBar) - backView = v.findViewById(R.id.backView) + skipView = v.findViewById(R.id.skipView) return v } @@ -78,8 +79,13 @@ internal class StorageRootsFragment : Fragment(), StorageRootClickedListener { if (viewModel.isRestoreOperation) { titleView.text = getString(R.string.storage_fragment_restore_title) - backView.visibility = VISIBLE - backView.setOnClickListener { requireActivity().finishAfterTransition() } + skipView.visibility = VISIBLE + skipView.setOnClickListener { + // Equivalent to com.google.android.setupcompat.util.ResultCodes.RESULT_SKIP + // SetupWizard handles this + requireActivity().setResult(RESULT_FIRST_USER) + requireActivity().finishAfterTransition() + } } else { warningIcon.visibility = VISIBLE if (viewModel.hasStorageSet) { diff --git a/app/src/main/res/layout/fragment_recovery_code_input.xml b/app/src/main/res/layout/fragment_recovery_code_input.xml index 52d4ce97..10f51f55 100644 --- a/app/src/main/res/layout/fragment_recovery_code_input.xml +++ b/app/src/main/res/layout/fragment_recovery_code_input.xml @@ -71,23 +71,6 @@ app:layout_constraintEnd_toStartOf="@+id/newCodeButton" app:layout_constraintStart_toStartOf="parent" /> - -