Skip to content

Commit db76cd5

Browse files
committed
Give accessibility focus to title of bottom sheet, which can be updated asynchronously.
1 parent 6c942a7 commit db76cd5

9 files changed

+24
-0
lines changed

vector/src/main/java/im/vector/app/core/platform/VectorBaseFragment.kt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import im.vector.app.R
4545
import im.vector.app.core.di.ActivityEntryPoint
4646
import im.vector.app.core.dialogs.UnrecognizedCertificateDialog
4747
import im.vector.app.core.error.ErrorFormatter
48+
import im.vector.app.core.extensions.giveAccessibilityFocus
4849
import im.vector.app.core.extensions.singletonEntryPoint
4950
import im.vector.app.core.extensions.toMvRxBundle
5051
import im.vector.app.core.utils.ToolbarConfig
@@ -318,4 +319,19 @@ abstract class VectorBaseFragment<VB : ViewBinding> : Fragment(), MavericksView
318319
.setPositiveButton(R.string.ok, null)
319320
.show()
320321
}
322+
323+
/* ==========================================================================================
324+
* Accessibility - a11y
325+
* ========================================================================================== */
326+
327+
private var hasBeenAccessibilityFocused = false
328+
329+
/**
330+
* Ensure the View get the accessibility focus. This method has effect only once per fragment instance.
331+
*/
332+
protected fun View.giveAccessibilityFocusOnce() {
333+
if (hasBeenAccessibilityFocused) return
334+
hasBeenAccessibilityFocused = true
335+
giveAccessibilityFocus()
336+
}
321337
}

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConclusionFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,5 +60,6 @@ class BootstrapConclusionFragment :
6060
.toSpannable()
6161
.colorizeMatchingText(getString(R.string.recovery_passphrase), colorProvider.getColorFromAttribute(android.R.attr.textColorLink))
6262
.colorizeMatchingText(getString(R.string.message_key), colorProvider.getColorFromAttribute(android.R.attr.textColorLink))
63+
views.bootstrapConclusionText.giveAccessibilityFocusOnce()
6364
}
6465
}

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapConfirmPassphraseFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ class BootstrapConfirmPassphraseFragment :
5252
views.ssssPassphraseSecurityProgress.isGone = true
5353

5454
views.bootstrapDescriptionText.text = getString(R.string.set_a_security_phrase_again_notice)
55+
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
5556
views.ssssPassphraseEnterEdittext.hint = getString(R.string.set_a_security_phrase_hint)
5657

5758
withState(sharedViewModel) {

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapEnterPassphraseFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,5 +118,6 @@ class BootstrapEnterPassphraseFragment :
118118
}
119119
}
120120
}
121+
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
121122
}
122123
}

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapMigrateBackupFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,6 +141,7 @@ class BootstrapMigrateBackupFragment :
141141

142142
views.bootstrapMigrateUseFile.isVisible = false
143143
}
144+
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
144145
}
145146

146147
private val importFileStartForActivityResult = registerStartForActivityResult { activityResult ->

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapReAuthFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,5 +78,6 @@ class BootstrapReAuthFragment :
7878
views.bootstrapCancelButton.isVisible = true
7979
views.bootstrapRetryButton.isVisible = true
8080
}
81+
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
8182
}
8283
}

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSaveRecoveryKeyFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,5 +117,6 @@ class BootstrapSaveRecoveryKeyFragment :
117117

118118
views.recoveryContinue.isVisible = step.isSaved
119119
views.bootstrapRecoveryKeyText.text = state.recoveryKeyCreationInfo?.recoveryKey?.formatRecoveryKey()
120+
views.bootstrapSaveText.giveAccessibilityFocusOnce()
120121
}
121122
}

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapSetupRecoveryKeyFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ class BootstrapSetupRecoveryKeyFragment :
6868
// Choose between create a passphrase or use a recovery key
6969
renderBackupMethodActions(firstFormStep.methods)
7070
}
71+
views.bootstrapSetupSecureText.giveAccessibilityFocusOnce()
7172
}
7273

7374
private fun renderStateWithExistingKeyBackup() = with(views) {

vector/src/main/java/im/vector/app/features/crypto/recover/BootstrapWaitingFragment.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,5 +52,6 @@ class BootstrapWaitingFragment :
5252
views.bootstrapDescriptionText.isVisible = false
5353
}
5454
}
55+
views.bootstrapDescriptionText.giveAccessibilityFocusOnce()
5556
}
5657
}

0 commit comments

Comments
 (0)