From 9c1cc8690d34d7824e1bb8b7e7766df0a152cd5a Mon Sep 17 00:00:00 2001 From: Fabian Henneke Date: Wed, 22 Apr 2020 11:14:25 +0200 Subject: Mark Autofill onboarding dialog as seen on dismiss (#731) --- app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt index da1e72a1..58e1f39c 100644 --- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt +++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt @@ -128,7 +128,7 @@ class PasswordStore : AppCompatActivity() { // If user is eligible for Oreo autofill, prompt them to switch. if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O && - !settings.getBoolean("seen_autofill_onboarding", false)) { + !settings.getBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, false)) { MaterialAlertDialogBuilder(this).run { @SuppressLint("InflateParams") val layout = @@ -151,13 +151,16 @@ class PasswordStore : AppCompatActivity() { "$appLabel: $supportDescription" } setView(layout) - setTitle(getString(R.string.autofill_onboarding_dialog_title)) + setTitle(R.string.autofill_onboarding_dialog_title) setPositiveButton(R.string.dialog_ok) { _, _ -> - settings.edit { putBoolean("seen_autofill_onboarding", true) } startActivity(Intent(Settings.ACTION_REQUEST_SET_AUTOFILL_SERVICE).apply { data = Uri.parse("package:${BuildConfig.APPLICATION_ID}") }) } + setNegativeButton(R.string.dialog_cancel) { _, _ -> } + setOnDismissListener { + settings.edit { putBoolean(PREFERENCE_SEEN_AUTOFILL_ONBOARDING, true) } + } show() } } @@ -846,6 +849,8 @@ class PasswordStore : AppCompatActivity() { block != null && block !== UnicodeBlock.SPECIALS) } + private const val PREFERENCE_SEEN_AUTOFILL_ONBOARDING = "seen_autofill_onboarding" + fun commitChange(activity: Activity, message: String, finishWithResultOnEnd: Intent? = null) { object : GitOperation(getRepositoryDirectory(activity), activity) { override fun execute() { -- cgit v1.2.3