diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt index a82cef54e5..b57f288c09 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt @@ -45,6 +45,7 @@ import im.vector.app.R import im.vector.app.core.di.ActivityEntryPoint import im.vector.app.core.dialogs.UnrecognizedCertificateDialog import im.vector.app.core.error.ErrorFormatter +import im.vector.app.core.extensions.giveAccessibilityFocus import im.vector.app.core.extensions.singletonEntryPoint import im.vector.app.core.extensions.toMvRxBundle import im.vector.app.core.utils.ToolbarConfig @@ -318,4 +319,19 @@ abstract class VectorBaseFragment : Fragment(), MavericksView .setPositiveButton(R.string.ok, null) .show() } + + /* ========================================================================================== + * Accessibility - a11y + * ========================================================================================== */ + + private var hasBeenAccessibilityFocused = false + + /** + * Ensure the View get the accessibility focus. This method has effect only once per fragment instance. + */ + protected fun View.giveAccessibilityFocusOnce() { + if (hasBeenAccessibilityFocused) return + hasBeenAccessibilityFocused = true + giveAccessibilityFocus() + } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConclusionFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConclusionFragment.kt index 22ecd3dafd..fd1eb821db 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConclusionFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConclusionFragment.kt @@ -60,5 +60,6 @@ class BootstrapConclusionFragment : .toSpannable() .colorizeMatchingText(getString(R.string.recovery_passphrase), colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) .colorizeMatchingText(getString(R.string.message_key), colorProvider.getColorFromAttribute(android.R.attr.textColorLink)) + views.bootstrapConclusionText.giveAccessibilityFocusOnce() } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt index 285721ee75..3942fc6528 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt @@ -52,6 +52,7 @@ class BootstrapConfirmPassphraseFragment : views.ssssPassphraseSecurityProgress.isGone = true views.bootstrapDescriptionText.text = getString(R.string.set_a_security_phrase_again_notice) + views.bootstrapDescriptionText.giveAccessibilityFocusOnce() views.ssssPassphraseEnterEdittext.hint = getString(R.string.set_a_security_phrase_hint) withState(sharedViewModel) { diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapEnterPassphraseFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapEnterPassphraseFragment.kt index 78f0bc6284..262abd306d 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapEnterPassphraseFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapEnterPassphraseFragment.kt @@ -118,5 +118,6 @@ class BootstrapEnterPassphraseFragment : } } } + views.bootstrapDescriptionText.giveAccessibilityFocusOnce() } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapMigrateBackupFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapMigrateBackupFragment.kt index 2802c872ee..8df5ce7ad3 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapMigrateBackupFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapMigrateBackupFragment.kt @@ -141,6 +141,7 @@ class BootstrapMigrateBackupFragment : views.bootstrapMigrateUseFile.isVisible = false } + views.bootstrapDescriptionText.giveAccessibilityFocusOnce() } private val importFileStartForActivityResult = registerStartForActivityResult { activityResult -> diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt index d5e60631a5..f32ba735a1 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt @@ -78,5 +78,6 @@ class BootstrapReAuthFragment : views.bootstrapCancelButton.isVisible = true views.bootstrapRetryButton.isVisible = true } + views.bootstrapDescriptionText.giveAccessibilityFocusOnce() } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt index 21d68dfe99..88db55a291 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt @@ -117,5 +117,6 @@ class BootstrapSaveRecoveryKeyFragment : views.recoveryContinue.isVisible = step.isSaved views.bootstrapRecoveryKeyText.text = state.recoveryKeyCreationInfo?.recoveryKey?.formatRecoveryKey() + views.bootstrapSaveText.giveAccessibilityFocusOnce() } } diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSetupRecoveryKeyFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSetupRecoveryKeyFragment.kt index b03cbe87a8..a28a7c8f56 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSetupRecoveryKeyFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSetupRecoveryKeyFragment.kt @@ -68,6 +68,7 @@ class BootstrapSetupRecoveryKeyFragment : // Choose between create a passphrase or use a recovery key renderBackupMethodActions(firstFormStep.methods) } + views.bootstrapSetupSecureText.giveAccessibilityFocusOnce() } private fun renderStateWithExistingKeyBackup() = with(views) { diff --git a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt index 310bb5ac37..9d9cf6cdd2 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt @@ -52,5 +52,6 @@ class BootstrapWaitingFragment : views.bootstrapDescriptionText.isVisible = false } } + views.bootstrapDescriptionText.giveAccessibilityFocusOnce() } }