Prevent an activity loop when no OpenPGP Provider is selected (#572)

Signed-off-by: Aditya Wasan <adityawasan55@gmail.com>
This commit is contained in:
Aditya Wasan 2019-11-13 12:31:02 +05:30 committed by Harsh Shandilya
parent 1f158c5ca6
commit 9892799824

View file

@ -29,6 +29,7 @@ import androidx.preference.PreferenceFragmentCompat
import androidx.preference.PreferenceManager import androidx.preference.PreferenceManager
import androidx.preference.SwitchPreferenceCompat import androidx.preference.SwitchPreferenceCompat
import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.autofill.AutofillPreferenceActivity import com.zeapo.pwdstore.autofill.AutofillPreferenceActivity
import com.zeapo.pwdstore.crypto.PgpActivity import com.zeapo.pwdstore.crypto.PgpActivity
import com.zeapo.pwdstore.git.GitActivity import com.zeapo.pwdstore.git.GitActivity
@ -126,10 +127,16 @@ class UserPreference : AppCompatActivity() {
appVersionPreference?.summary = "Version: ${BuildConfig.VERSION_NAME}" appVersionPreference?.summary = "Version: ${BuildConfig.VERSION_NAME}"
keyPreference?.onPreferenceClickListener = ClickListener { keyPreference?.onPreferenceClickListener = ClickListener {
val intent = Intent(callingActivity, PgpActivity::class.java) val providerPackageName = requireNotNull(sharedPreferences.getString("openpgp_provider_list", ""))
intent.putExtra("OPERATION", "GET_KEY_ID") if (providerPackageName.isEmpty()) {
startActivityForResult(intent, IMPORT_PGP_KEY) Snackbar.make(requireView(), resources.getString(R.string.provider_toast_text), Snackbar.LENGTH_LONG).show()
true false
} else {
val intent = Intent(callingActivity, PgpActivity::class.java)
intent.putExtra("OPERATION", "GET_KEY_ID")
startActivityForResult(intent, IMPORT_PGP_KEY)
true
}
} }
sshKeyPreference?.onPreferenceClickListener = ClickListener { sshKeyPreference?.onPreferenceClickListener = ClickListener {