Fix no response after Talkback users double-tap on Learn more in Accessibility pages

Root cause: The ag/16569955 to fix unknown items issue when using Switch Access by grouping of related content. The design change impacts AccessibilityFooterPreference#setLinkEnabled that call TextView#setMovementMethod to change components can be focusable to break the grouping relation.

Solution: Reset summary view to nonFocusable after applied TextView#setMovementMethod.

Bug: 221342261
Bug: 221339524
Bug: 223526982
Bug: 215792117
Bug: 215792876
Test: make RunSettingsRoboTests ROBOTEST_FILTER=AccessibilityFooterPreferenceControllerTest AccessibilityFooterPreferenceTest ToggleFeaturePreferenceFragmentTest
Change-Id: I4a051ea036ded264ee7bf615375177db796f74c7
This commit is contained in:
menghanli
2022-03-11 06:30:34 +08:00
parent cc28c27eaa
commit 466ee402bf
5 changed files with 35 additions and 7 deletions

View File

@@ -25,9 +25,7 @@ import androidx.preference.PreferenceViewHolder;
import com.android.settingslib.widget.FooterPreference;
/**
* A custom preference acting as footer of a page. Disables the movement method by default.
*/
/** A custom preference acting as footer of a page. Disables the movement method by default. */
public final class AccessibilityFooterPreference extends FooterPreference {
private boolean mLinkEnabled;
@@ -46,12 +44,16 @@ public final class AccessibilityFooterPreference extends FooterPreference {
final TextView title = holder.itemView.findViewById(android.R.id.title);
if (mLinkEnabled) {
// When a TextView has a movement method, it will set the view to clickable. This makes
// View.onTouchEvent always return true and consumes the touch event, essentially
// nullifying any return values of MovementMethod.onTouchEvent.
// When a TextView has a movement method, it will set the view to focusable and
// clickable. This makes View.onTouchEvent always return true and consumes the touch
// event, essentially nullifying any return values of MovementMethod.onTouchEvent.
// To still allow propagating touch events to the parent when this view doesn't have
// links, we only set the movement method here if the text contains links.
title.setMovementMethod(LinkMovementMethod.getInstance());
// Groups of related title and link content by making the container focusable,
// then make all the children inside not focusable.
title.setFocusable(false);
} else {
title.setMovementMethod(/* movement= */ null);
}