Loading src/com/android/settings/accessibility/AccessibilityFooterPreference.java +8 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java +3 −0 Original line number Diff line number Diff line Loading @@ -122,5 +122,8 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr } else { footerPreference.setLinkEnabled(false); } // Grouping subcomponents to make more accessible. footerPreference.setSelectable(false); } } tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -121,4 +121,16 @@ public class AccessibilityFooterPreferenceControllerTest { assertThat(learnMoreView.getVisibility()).isEqualTo(View.GONE); assertThat(mPreference.isLinkEnabled()).isFalse(); } @Test public void onBindViewHolder_setHelpResource_expectSummaryViewIsNonFocusable() { mController.setupHelpLink(R.string.help_url_timeout, TEST_CONTENT_DESCRIPTION); mController.displayPreference(mScreen); mPreference.onBindViewHolder(mPreferenceViewHolder); final TextView summaryView = (TextView) mPreferenceViewHolder .findViewById(android.R.id.title); assertThat(summaryView.isFocusable()).isFalse(); } } tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,15 @@ public final class AccessibilityFooterPreferenceTest { android.R.id.title); assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class); } @Test public void onBindViewHolder_setLinkEnabled_expectSummaryViewIsNonFocusable() { mAccessibilityFooterPreference.setLinkEnabled(true); mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder); final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById( android.R.id.title); assertThat(summaryView.isFocusable()).isFalse(); } } tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -322,7 +322,7 @@ public class ToggleFeaturePreferenceFragmentTest { (AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference( mFragment.getPreferenceScreen().getPreferenceCount() - 1); assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY); assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true); assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(false); assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1); } Loading Loading
src/com/android/settings/accessibility/AccessibilityFooterPreference.java +8 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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); } Loading
src/com/android/settings/accessibility/AccessibilityFooterPreferenceController.java +3 −0 Original line number Diff line number Diff line Loading @@ -122,5 +122,8 @@ public class AccessibilityFooterPreferenceController extends BasePreferenceContr } else { footerPreference.setLinkEnabled(false); } // Grouping subcomponents to make more accessible. footerPreference.setSelectable(false); } }
tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceControllerTest.java +12 −0 Original line number Diff line number Diff line Loading @@ -121,4 +121,16 @@ public class AccessibilityFooterPreferenceControllerTest { assertThat(learnMoreView.getVisibility()).isEqualTo(View.GONE); assertThat(mPreference.isLinkEnabled()).isFalse(); } @Test public void onBindViewHolder_setHelpResource_expectSummaryViewIsNonFocusable() { mController.setupHelpLink(R.string.help_url_timeout, TEST_CONTENT_DESCRIPTION); mController.displayPreference(mScreen); mPreference.onBindViewHolder(mPreferenceViewHolder); final TextView summaryView = (TextView) mPreferenceViewHolder .findViewById(android.R.id.title); assertThat(summaryView.isFocusable()).isFalse(); } }
tests/robotests/src/com/android/settings/accessibility/AccessibilityFooterPreferenceTest.java +11 −0 Original line number Diff line number Diff line Loading @@ -71,4 +71,15 @@ public final class AccessibilityFooterPreferenceTest { android.R.id.title); assertThat(summaryView.getMovementMethod()).isInstanceOf(MovementMethod.class); } @Test public void onBindViewHolder_setLinkEnabled_expectSummaryViewIsNonFocusable() { mAccessibilityFooterPreference.setLinkEnabled(true); mAccessibilityFooterPreference.onBindViewHolder(mPreferenceViewHolder); final TextView summaryView = (TextView) mPreferenceViewHolder.findViewById( android.R.id.title); assertThat(summaryView.isFocusable()).isFalse(); } }
tests/robotests/src/com/android/settings/accessibility/ToggleFeaturePreferenceFragmentTest.java +1 −1 Original line number Diff line number Diff line Loading @@ -322,7 +322,7 @@ public class ToggleFeaturePreferenceFragmentTest { (AccessibilityFooterPreference) mFragment.getPreferenceScreen().getPreference( mFragment.getPreferenceScreen().getPreferenceCount() - 1); assertThat(accessibilityFooterPreference.getSummary()).isEqualTo(DEFAULT_SUMMARY); assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(true); assertThat(accessibilityFooterPreference.isSelectable()).isEqualTo(false); assertThat(accessibilityFooterPreference.getOrder()).isEqualTo(Integer.MAX_VALUE - 1); } Loading