aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/main')
-rw-r--r--app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt41
-rw-r--r--app/src/main/res/layout/oreo_autofill_instructions.xml1
-rw-r--r--app/src/main/res/values/strings.xml2
3 files changed, 44 insertions, 0 deletions
diff --git a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
index ad8d4a70..17e2464e 100644
--- a/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
+++ b/app/src/main/java/com/zeapo/pwdstore/PasswordStore.kt
@@ -14,8 +14,10 @@ import android.content.pm.ShortcutInfo.Builder
import android.content.pm.ShortcutManager
import android.graphics.Color
import android.graphics.drawable.Icon
+import android.net.Uri
import android.os.Build
import android.os.Bundle
+import android.provider.Settings
import android.text.TextUtils
import android.view.KeyEvent
import android.view.Menu
@@ -43,6 +45,8 @@ import com.github.ajalt.timberkt.w
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.google.android.material.snackbar.Snackbar
import com.zeapo.pwdstore.autofill.oreo.AutofillMatcher
+import com.zeapo.pwdstore.autofill.oreo.BrowserAutofillSupportLevel
+import com.zeapo.pwdstore.autofill.oreo.getInstalledBrowsersWithAutofillSupportLevel
import com.zeapo.pwdstore.crypto.PgpActivity
import com.zeapo.pwdstore.crypto.PgpActivity.Companion.getLongName
import com.zeapo.pwdstore.git.BaseGitActivity
@@ -122,6 +126,43 @@ class PasswordStore : AppCompatActivity() {
super.onCreate(savedInstance)
setContentView(R.layout.activity_pwdstore)
+ // 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)) {
+ MaterialAlertDialogBuilder(this).run {
+ @SuppressLint("InflateParams")
+ val layout =
+ layoutInflater.inflate(R.layout.oreo_autofill_instructions, null)
+ layout.findViewById<AppCompatTextView>(R.id.intro_text).visibility = View.GONE
+ val supportedBrowsersTextView =
+ layout.findViewById<AppCompatTextView>(R.id.supportedBrowsers)
+ supportedBrowsersTextView.text =
+ getInstalledBrowsersWithAutofillSupportLevel(context).joinToString(
+ separator = "\n"
+ ) {
+ val appLabel = it.first
+ val supportDescription = when (it.second) {
+ BrowserAutofillSupportLevel.None -> getString(R.string.oreo_autofill_no_support)
+ BrowserAutofillSupportLevel.FlakyFill -> getString(R.string.oreo_autofill_flaky_fill_support)
+ BrowserAutofillSupportLevel.PasswordFill -> getString(R.string.oreo_autofill_password_fill_support)
+ BrowserAutofillSupportLevel.GeneralFill -> getString(R.string.oreo_autofill_general_fill_support)
+ BrowserAutofillSupportLevel.GeneralFillAndSave -> getString(R.string.oreo_autofill_general_fill_and_save_support)
+ }
+ "$appLabel: $supportDescription"
+ }
+ setView(layout)
+ setTitle(getString(R.string.autofill_onboarding_dialog_title))
+ setMessage(getString(R.string.autofill_onboarding_dialog_message))
+ 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}")
+ })
+ }
+ show()
+ }
+ }
+
model.currentDir.observe(this) { dir ->
val basePath = getRepositoryDirectory(applicationContext).absoluteFile
supportActionBar!!.apply {
diff --git a/app/src/main/res/layout/oreo_autofill_instructions.xml b/app/src/main/res/layout/oreo_autofill_instructions.xml
index e9bb7e55..874d764f 100644
--- a/app/src/main/res/layout/oreo_autofill_instructions.xml
+++ b/app/src/main/res/layout/oreo_autofill_instructions.xml
@@ -14,6 +14,7 @@
android:paddingTop="20dp">
<androidx.appcompat.widget.AppCompatTextView
+ android:id="@+id/intro_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/oreo_autofill_enable_dialog_description"
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 87357f86..1c1f480d 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -362,4 +362,6 @@
<string name="git_operation_wrong_passphrase">Wrong passphrase</string>
<string name="bottom_sheet_create_new_folder">Create new folder</string>
<string name="bottom_sheet_create_new_password">Create new password</string>
+ <string name="autofill_onboarding_dialog_title">New, revamped Autofill!</string>
+ <string name="autofill_onboarding_dialog_message">In this release, Autofill support has been massively improved with advanced features like anti-phishing protection and enhanced reliability. If you have been holding out on using it because of the shortcomings on the previous version, you\'ll likely love the new iteration. Give it a shot!</string>
</resources>