Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7313080e authored by Nikki Moteva's avatar Nikki Moteva Committed by Android (Google) Code Review
Browse files

Merge "Settings: Fix the a11y focus issues in App Notifications subpage" into main

parents f92c187b bc1b12db
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -21,7 +21,8 @@

    <com.android.settingslib.widget.LayoutPreference
        android:key="pref_app_header"
        android:layout="@layout/settings_entity_header" />
        android:layout="@layout/settings_entity_header"
        android:selectable="false" />

    <com.android.settings.widget.SettingsMainSwitchPreference
        android:key="block" />
+5 −0
Original line number Diff line number Diff line
@@ -240,6 +240,11 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
        if (mMainSwitchBar != null) {
            mMainSwitchBar.setTitle(getTitle());
            mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);

            // Disable the focusability of the switch bar. The parent FrameLayout
            // will be the only focusable view for the Main Switch Bar to avoid
            // duplicate a11y focus.
            mMainSwitchBar.setFocusable(false);
        }
    }

+21 −2
Original line number Diff line number Diff line
@@ -41,6 +41,7 @@ public class SettingsMainSwitchPreferenceTest {
    private EnforcedAdmin mEnforcedAdmin;
    private SettingsMainSwitchPreference mPreference;
    private PreferenceViewHolder mHolder;
    private View mRootView;

    @Before
    public void setUp() {
@@ -50,9 +51,9 @@ public class SettingsMainSwitchPreferenceTest {
        mPreference = new SettingsMainSwitchPreference(context);
        ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
        ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
        final View rootView = View.inflate(context, com.android.settings.R.layout.preference_widget_main_switch,
        mRootView = View.inflate(context, com.android.settings.R.layout.preference_widget_main_switch,
                null /* parent */);
        mHolder = PreferenceViewHolder.createInstanceForTests(rootView);
        mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
    }

    @Test
@@ -74,4 +75,22 @@ public class SettingsMainSwitchPreferenceTest {
        assertThat(mPreference.isShowing()).isFalse();
        assertThat(mPreference.isVisible()).isFalse();
    }

    @Test
    public void focusability_mainSwitchBarIsNotFocusable() {
        mPreference.show();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mPreference.getSwitchBar().isFocusable()).isFalse();
    }

    @Test
    public void focusability_mainSwitchBarFrameLayoutIsFocusable() {
        mPreference.show();

        mPreference.onBindViewHolder(mHolder);

        assertThat(mRootView.isFocusable()).isTrue();
    }
}