Call assumeLayout for accessibility
When some accessbility actions are performed, if the text is not of type SPANNABLE, TextView will set the type to SPANNABLE. This may null the layout. In this case, when TextView performs the accessibility action MOVEMENT_BY_GRANULARITY the following sequence happens: 1) TextView is requested to perform the MOVEMENT_BY_GRANULARITY action by TalkBack 2) TextView ensures that its text is iterable to accessibility 3) The text is not spannable. TextView sets the text to spannable, which nulls the layout. 4) TextView checks that it can perform the action. Since it has a null layout, it can't perform the action 5) TextView returns false to performing of the action Moving by granularity always fails, at least on the first attempt, for these texts. To solve this, we call assumeLayout to set the layout of the TextView in between 3 and 4. assumeLayout javadocs say "Make a new Layout based on the already-measured size of the view, on the assumption that it was measured correctly at some point." We assume the current measurements are appropriate. If there are edge cases we can handle them as they appear. Bug: 257396548 Test: manual, add test in TextViewTest Change-Id: I9c6f1f7b4b61e05892d04dfd59062d1fdcc1c390
Loading
Please register or sign in to comment