Merge "Settings: Fix the a11y focus issues in App Notifications subpage" into main
This commit is contained in:
@@ -21,7 +21,8 @@
|
|||||||
|
|
||||||
<com.android.settingslib.widget.LayoutPreference
|
<com.android.settingslib.widget.LayoutPreference
|
||||||
android:key="pref_app_header"
|
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
|
<com.android.settings.widget.SettingsMainSwitchPreference
|
||||||
android:key="block" />
|
android:key="block" />
|
||||||
|
@@ -240,6 +240,11 @@ public class SettingsMainSwitchPreference extends TwoStatePreference implements
|
|||||||
if (mMainSwitchBar != null) {
|
if (mMainSwitchBar != null) {
|
||||||
mMainSwitchBar.setTitle(getTitle());
|
mMainSwitchBar.setTitle(getTitle());
|
||||||
mMainSwitchBar.setDisabledByAdmin(mEnforcedAdmin);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -41,6 +41,7 @@ public class SettingsMainSwitchPreferenceTest {
|
|||||||
private EnforcedAdmin mEnforcedAdmin;
|
private EnforcedAdmin mEnforcedAdmin;
|
||||||
private SettingsMainSwitchPreference mPreference;
|
private SettingsMainSwitchPreference mPreference;
|
||||||
private PreferenceViewHolder mHolder;
|
private PreferenceViewHolder mHolder;
|
||||||
|
private View mRootView;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
@@ -50,9 +51,9 @@ public class SettingsMainSwitchPreferenceTest {
|
|||||||
mPreference = new SettingsMainSwitchPreference(context);
|
mPreference = new SettingsMainSwitchPreference(context);
|
||||||
ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
|
ReflectionHelpers.setField(mPreference, "mEnforcedAdmin", mEnforcedAdmin);
|
||||||
ReflectionHelpers.setField(mPreference, "mMainSwitchBar", switchBar);
|
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 */);
|
null /* parent */);
|
||||||
mHolder = PreferenceViewHolder.createInstanceForTests(rootView);
|
mHolder = PreferenceViewHolder.createInstanceForTests(mRootView);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@@ -74,4 +75,22 @@ public class SettingsMainSwitchPreferenceTest {
|
|||||||
assertThat(mPreference.isShowing()).isFalse();
|
assertThat(mPreference.isShowing()).isFalse();
|
||||||
assertThat(mPreference.isVisible()).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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user