Day73 of #100DaysOfCode
1 min readApr 20, 2022
Hii folks 🙌
Today I will be continuing the same pathway in which we’ll test the unscramble app with TalkBack enabled
Unit 3: Navigation
Pathway 2: Architecture componentsSource
https://developer.android.com/courses/android-basics-kotlin/course
TalkBack is the Google screen reader included on Android devices. TalkBack gives us spoken feedback so that we can use our device without looking at the screen.
With Talkback enabled, we will ensure that a player can play the game.
- In
GameViewModel,
we will use the following code to modify how thecurrentScrambledWord
variable is declared:
val currentScrambledWord: LiveData<Spannable> = Transformations.map(_currentScrambledWord) {
if (it == null) {
SpannableString("")
} else {
val scrambledWord = it.toString()
val spannable: Spannable = SpannableString(scrambledWord)
spannable.setSpan(
TtsSpan.VerbatimBuilder(scrambledWord).build(),
0,
scrambledWord.length,
Spannable.SPAN_INCLUSIVE_INCLUSIVE
)
spannable
}
}
That is all for Day73 ✅
Thanks for reading, See you tomorrow!
If you are reading my #100Days Journey, feel free to drop by ;)