aboutsummaryrefslogtreecommitdiff
path: root/app/src
diff options
context:
space:
mode:
authorAditya Wasan <adityawasan55@gmail.com>2019-11-13 12:31:02 +0530
committerHarsh Shandilya <msfjarvis@gmail.com>2019-11-13 12:31:02 +0530
commit98927998244c3cce103f92f6e1a85050e8d0c5ba (patch)
tree4f29ca2aa2244c3e34c32b2ba1fd8b2ad91f3c8b /app/src
parent1f158c5ca6f5b88df0ff0a6234299bf839581c04 (diff)
Prevent an activity loop when no OpenPGP Provider is selected (#572)
Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
Diffstat (limited to 'app/src')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/UserPreference.kt15
1 files changed, 11 insertions, 4 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
index d2b08132..d40c0802 100644
--- a/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/UserPreference.kt
@@ -29,6 +29,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager
import androidx.preference.SwitchPreferenceCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder
+import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.autofill.AutofillPreferenceActivity
import com.zeapo.pwdstore.crypto.PgpActivity
import com.zeapo.pwdstore.git.GitActivity
@@ -126,10 +127,16 @@ class UserPreference : AppCompatActivity() {
appVersionPreference?.summary = "Version: ${BuildConfig.VERSION_NAME}"
keyPreference?.onPreferenceClickListener = ClickListener {
- val intent = Intent(callingActivity, PgpActivity::class.java)
- intent.putExtra("OPERATION", "GET_KEY_ID")
- startActivityForResult(intent, IMPORT_PGP_KEY)
- true
+ val providerPackageName = requireNotNull(sharedPreferences.getString("openpgp_provider_list", ""))
+ if (providerPackageName.isEmpty()) {
+ Snackbar.make(requireView(), resources.getString(R.string.provider_toast_text), Snackbar.LENGTH_LONG).show()
+ false
+ } else {
+ val intent = Intent(callingActivity, PgpActivity::class.java)
+ intent.putExtra("OPERATION", "GET_KEY_ID")
+ startActivityForResult(intent, IMPORT_PGP_KEY)
+ true
+ }
}
sshKeyPreference?.onPreferenceClickListener = ClickListener {