From db4683e0d60a31d87c41050445c00b0e48b77ae1 Mon Sep 17 00:00:00 2001 From: Harsh Shandilya Date: Sun, 21 Mar 2021 14:03:51 +0530 Subject: Inform users that GPG key selection is mandatory (#1355) * Inform users that GPG key selection is mandatory Fixes #1342 Signed-off-by: Harsh Shandilya * changelog: sync for 1.13.4 release Signed-off-by: Harsh Shandilya * changelog: add GPG key selection improvements Signed-off-by: Harsh Shandilya --- .../java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt | 3 +++ .../msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt | 7 +++++-- app/src/main/res/values/strings.xml | 1 + 3 files changed, 9 insertions(+), 2 deletions(-) (limited to 'app/src/main') diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt index 1e9066b0..ea950a5e 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/crypto/PasswordCreationActivity.kt @@ -24,6 +24,7 @@ import com.github.michaelbull.result.onFailure import com.github.michaelbull.result.onSuccess import com.github.michaelbull.result.runCatching import com.google.android.material.dialog.MaterialAlertDialogBuilder +import com.google.android.material.snackbar.Snackbar import com.google.zxing.integration.android.IntentIntegrator import com.google.zxing.integration.android.IntentIntegrator.QR_CODE import dev.msfjarvis.aps.R @@ -117,6 +118,8 @@ class PasswordCreationActivity : BasePgpActivity(), OpenPgpServiceConnection.OnB .onSuccess { encrypt(encryptionIntent) } } } + } else { + snackbar(message = getString(R.string.gpg_key_select_mandatory), length = Snackbar.LENGTH_LONG) } } diff --git a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt index 44a6d6c5..3d7a66b3 100644 --- a/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt +++ b/app/src/main/java/dev/msfjarvis/aps/ui/onboarding/fragments/KeySelectionFragment.kt @@ -13,6 +13,7 @@ import androidx.appcompat.app.AppCompatActivity import androidx.core.content.edit import androidx.fragment.app.Fragment import androidx.lifecycle.lifecycleScope +import com.google.android.material.snackbar.Snackbar import dev.msfjarvis.aps.R import dev.msfjarvis.aps.data.repo.PasswordRepository import dev.msfjarvis.aps.databinding.FragmentKeySelectionBinding @@ -20,6 +21,7 @@ import dev.msfjarvis.aps.ui.crypto.GetKeyIdsActivity import dev.msfjarvis.aps.util.extensions.commitChange import dev.msfjarvis.aps.util.extensions.finish import dev.msfjarvis.aps.util.extensions.sharedPrefs +import dev.msfjarvis.aps.util.extensions.snackbar import dev.msfjarvis.aps.util.extensions.viewBinding import dev.msfjarvis.aps.util.settings.PreferenceKeys import java.io.File @@ -46,10 +48,11 @@ class KeySelectionFragment : Fragment(R.layout.fragment_key_selection) { requireActivity().commitChange(getString(R.string.git_commit_gpg_id, getString(R.string.app_name))) } } + finish() } else { - throw IllegalStateException("Failed to initialize repository state.") + requireActivity() + .snackbar(message = getString(R.string.gpg_key_select_mandatory), length = Snackbar.LENGTH_LONG) } - finish() } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index f71ddb75..b9a371d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -402,5 +402,6 @@ Enter manually Secret Account + Selecting a GPG key is necessary to proceed -- cgit v1.2.3