diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java index 46c03594..b1401867 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/AuthenticateActivity.java @@ -89,6 +89,9 @@ public class AuthenticateActivity extends ThemedActivity TextInputLayout passwordLayout = v.findViewById(R.id.passwordLayout); passwordInput = v.findViewById(R.id.passwordEdit); + if (settings.getBlockAccessibility()) + passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + passwordLabel.setText(labelMsg); authMethod = settings.getAuthMethod(); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java index ac9caede..c57613bb 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Activities/BackupActivity.java @@ -458,7 +458,7 @@ public class BackupActivity extends BaseActivity { String password = settings.getBackupPasswordEnc(); if (password.isEmpty()) { - PasswordEntryDialog pwDialog = new PasswordEntryDialog(this, PasswordEntryDialog.Mode.ENTER, new PasswordEntryDialog.PasswordEnteredCallback() { + PasswordEntryDialog pwDialog = new PasswordEntryDialog(this, PasswordEntryDialog.Mode.ENTER, settings.getBlockAccessibility(), new PasswordEntryDialog.PasswordEnteredCallback() { @Override public void onPasswordEntered(String newPassword) { doRestoreCryptWithPassword(uri, newPassword, old_format); @@ -514,7 +514,7 @@ public class BackupActivity extends BaseActivity { String password = settings.getBackupPasswordEnc(); if (password.isEmpty()) { - PasswordEntryDialog pwDialog = new PasswordEntryDialog(this, PasswordEntryDialog.Mode.UPDATE, new PasswordEntryDialog.PasswordEnteredCallback() { + PasswordEntryDialog pwDialog = new PasswordEntryDialog(this, PasswordEntryDialog.Mode.UPDATE, settings.getBlockAccessibility(), new PasswordEntryDialog.PasswordEnteredCallback() { @Override public void onPasswordEntered(String newPassword) { doBackupCryptWithPassword(uri, newPassword); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/ManualEntryDialog.java b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/ManualEntryDialog.java index b166cd84..dfd1ce7c 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/ManualEntryDialog.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/ManualEntryDialog.java @@ -60,6 +60,9 @@ public class ManualEntryDialog { ViewGroup container = callingActivity.findViewById(R.id.main_content); View inputView = callingActivity.getLayoutInflater().inflate(R.layout.dialog_manual_entry, container, false); + if (settings.getBlockAccessibility()) + inputView.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + final Spinner typeInput = inputView.findViewById(R.id.manual_type); final EditText issuerInput = inputView.findViewById(R.id.manual_issuer); final EditText labelInput = inputView.findViewById(R.id.manual_label); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java index b95375eb..9209e368 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Dialogs/PasswordEntryDialog.java @@ -2,6 +2,8 @@ package org.shadowice.flocke.andotp.Dialogs; import android.content.Context; import com.google.android.material.textfield.TextInputEditText; +import com.google.android.material.textfield.TextInputLayout; + import androidx.appcompat.app.AppCompatDialog; import android.text.Editable; import android.text.TextUtils; @@ -29,15 +31,21 @@ public class PasswordEntryDialog extends AppCompatDialog private EditText passwordConfirm; private Button okButton; - public PasswordEntryDialog(Context context, Mode newMode, PasswordEnteredCallback newCallback) { + public PasswordEntryDialog(Context context, Mode newMode, boolean blockAccessibility, PasswordEnteredCallback newCallback) { super(context, Tools.getThemeResource(context, R.attr.dialogTheme)); setTitle(R.string.dialog_title_enter_password); setContentView(R.layout.dialog_password_entry); + TextInputLayout passwordLayout = findViewById(R.id.passwordInputLayout); passwordInput = findViewById(R.id.passwordInput); passwordConfirm = findViewById(R.id.passwordConfirm); + if (blockAccessibility) { + passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + passwordConfirm.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); + } + okButton = findViewById(R.id.buttonOk); Button cancelButton = findViewById(R.id.buttonCancel); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java index 66d2337a..9d1373df 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/CredentialsPreference.java @@ -127,6 +127,11 @@ public class CredentialsPreference extends DialogPreference passwordInput = view.findViewById(R.id.passwordEdit); passwordConfirm = view.findViewById(R.id.passwordConfirm); + if (settings.getBlockAccessibility()) { + passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + passwordConfirm.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); + } + toShortWarning = view.findViewById(R.id.toShortWarning); passwordInput.addTextChangedListener(this); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java index 20345eb9..4fcc709f 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Preferences/PasswordEncryptedPreference.java @@ -42,6 +42,7 @@ import org.shadowice.flocke.andotp.R; import org.shadowice.flocke.andotp.Utilities.Constants; import org.shadowice.flocke.andotp.Utilities.EncryptionHelper; import org.shadowice.flocke.andotp.Utilities.KeyStoreHelper; +import org.shadowice.flocke.andotp.Utilities.Settings; import java.nio.charset.StandardCharsets; import java.security.KeyPair; @@ -92,10 +93,17 @@ public class PasswordEncryptedPreference extends DialogPreference @Override protected void onBindDialogView(View view) { + Settings settings = new Settings(getContext()); + TextInputLayout passwordLayout = view.findViewById(R.id.passwordLayout); passwordInput = view.findViewById(R.id.passwordEdit); passwordConfirm = view.findViewById(R.id.passwordConfirm); + if (settings.getBlockAccessibility()) { + passwordLayout.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS); + passwordConfirm.setImportantForAccessibility(View.IMPORTANT_FOR_ACCESSIBILITY_NO); + } + Button btnCancel = view.findViewById(R.id.btnCancel); btnSave = view.findViewById(R.id.btnSave); btnSave.setEnabled(false); diff --git a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java index 909b4470..bbbfbed1 100644 --- a/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java +++ b/app/src/main/java/org/shadowice/flocke/andotp/Utilities/Settings.java @@ -311,6 +311,10 @@ public class Settings { return getBoolean(R.string.settings_key_relock_screen_off, true); } + public boolean getBlockAccessibility() { + return getBoolean(R.string.settings_key_block_accessibility, false); + } + public void setLocale(String locale) { setString(R.string.settings_key_locale, locale); } diff --git a/app/src/main/res/values/settings.xml b/app/src/main/res/values/settings.xml index 5798d926..edd0fd64 100644 --- a/app/src/main/res/values/settings.xml +++ b/app/src/main/res/values/settings.xml @@ -16,6 +16,7 @@ pref_encryption pref_panic pref_relock_screen_off + pref_block_accessibility pref_lang pref_locale diff --git a/app/src/main/res/values/strings_settings.xml b/app/src/main/res/values/strings_settings.xml index 56c3bf89..e395727c 100644 --- a/app/src/main/res/values/strings_settings.xml +++ b/app/src/main/res/values/strings_settings.xml @@ -16,6 +16,7 @@ Database encryption Panic Trigger Re-lock on screen off + Block accessibility services Language Theme @@ -53,6 +54,8 @@ Decide what happens when a Panic Trigger is received Require authentication after the devices screen has been turned off + Hide sensitive fields from the accessibility + services. DO NOT enable this if you rely on the accessibility services! Scroll overlong labels instead of truncating them Specify which values should be included when searching diff --git a/app/src/main/res/xml/preferences.xml b/app/src/main/res/xml/preferences.xml index 857415cf..1079c37d 100644 --- a/app/src/main/res/xml/preferences.xml +++ b/app/src/main/res/xml/preferences.xml @@ -48,6 +48,12 @@ android:summary="@string/settings_desc_relock_screen_off" android:defaultValue="true" /> + +