Give accessibility focus to title of bottom sheet, which can be updated asynchronously.

This commit is contained in:
Benoit Marty 2023-05-10 17:27:25 +02:00
parent 6c942a7575
commit db76cd5899
9 changed files with 24 additions and 0 deletions

View file

@ -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<VB : ViewBinding> : 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()
}
}

View file

@ -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()
}
}

View file

@ -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) {

View file

@ -118,5 +118,6 @@ class BootstrapEnterPassphraseFragment :
}
}
}
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
}
}

View file

@ -141,6 +141,7 @@ class BootstrapMigrateBackupFragment :
views.bootstrapMigrateUseFile.isVisible = false
}
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
}
private val importFileStartForActivityResult = registerStartForActivityResult { activityResult ->

View file

@ -78,5 +78,6 @@ class BootstrapReAuthFragment :
views.bootstrapCancelButton.isVisible = true
views.bootstrapRetryButton.isVisible = true
}
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
}
}

View file

@ -117,5 +117,6 @@ class BootstrapSaveRecoveryKeyFragment :
views.recoveryContinue.isVisible = step.isSaved
views.bootstrapRecoveryKeyText.text = state.recoveryKeyCreationInfo?.recoveryKey?.formatRecoveryKey()
views.bootstrapSaveText.giveAccessibilityFocusOnce()
}
}

View file

@ -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) {

View file

@ -52,5 +52,6 @@ class BootstrapWaitingFragment :
views.bootstrapDescriptionText.isVisible = false
}
}
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
}
}