Accessibility settings display category restructure, add text and display fragment for related accessibility services.

Bug: 174829936
Test: atest TextAndDisplayFragmentTest, atest AccessibilitySettingsTest
Change-Id: Ie2cf147de53385ae0c626c8472306f1b85317686
This commit is contained in:
Ben Chung
2020-12-23 18:44:36 +08:00
parent d41cb031c9
commit 3e2e4407cf
6 changed files with 306 additions and 144 deletions

View File

@@ -4952,6 +4952,8 @@
<string name="audio_and_captions_category_title">Audio &amp; on-screen text</string> <string name="audio_and_captions_category_title">Audio &amp; on-screen text</string>
<!-- Title for the accessibility preference category of display services and settings. [CHAR LIMIT=50] --> <!-- Title for the accessibility preference category of display services and settings. [CHAR LIMIT=50] -->
<string name="display_category_title">Display</string> <string name="display_category_title">Display</string>
<!-- Title for the accessibility text options page. [CHAR LIMIT=50] -->
<string name="accessibility_text_and_display_title">Text and display</string>
<!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] --> <!-- Title for the accessibility preference category of interaction control services and settings. [CHAR LIMIT=50] -->
<string name="interaction_control_category_title">Interaction controls</string> <string name="interaction_control_category_title">Interaction controls</string>
<!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] --> <!-- Title for the accessibility preference category of services downloaded by the user. [CHAR LIMIT=50] -->

View File

@@ -45,52 +45,19 @@
android:title="@string/display_category_title"> android:title="@string/display_category_title">
<Preference <Preference
android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment" android:fragment="com.android.settings.accessibility.TextAndDisplayFragment"
android:key="font_size_preference_screen" android:key="text_and_display_preference_screen"
android:persistent="false" android:persistent="false"
android:title="@string/title_font_size" android:title="@string/accessibility_text_and_display_title"
settings:controller="com.android.settings.display.FontSizePreferenceController" settings:searchable="true"/>
settings:searchable="false"/>
<com.android.settings.display.ScreenZoomPreference <Preference
android:fragment="com.android.settings.display.ScreenZoomSettings"
android:key="accessibility_settings_screen_zoom"
android:persistent="false"
android:title="@string/screen_zoom_title"
settings:searchable="false"/>
<SwitchPreference
android:key="dark_ui_mode_accessibility"
android:persistent="false"
android:title="@string/dark_ui_mode"
settings:controller="com.android.settings.display.DarkUIPreferenceController"
settings:searchable="false"/>
<Preference
android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment" android:fragment="com.android.settings.accessibility.MagnificationPreferenceFragment"
android:icon="@drawable/ic_accessibility_magnification" android:icon="@drawable/ic_accessibility_magnification"
android:key="magnification_preference_screen" android:key="magnification_preference_screen"
android:persistent="false" android:persistent="false"
android:title="@string/accessibility_screen_magnification_title" android:title="@string/accessibility_screen_magnification_title"
settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"/> settings:controller="com.android.settings.accessibility.MagnificationPreferenceController"/>
<SwitchPreference
android:key="toggle_large_pointer_icon"
android:persistent="false"
android:title="@string/accessibility_toggle_large_pointer_icon_title"
settings:controller="com.android.settings.accessibility.LargePointerIconPreferenceController"/>
<SwitchPreference
android:key="toggle_disable_animations"
android:persistent="false"
android:title="@string/accessibility_disable_animations"
settings:controller="com.android.settings.accessibility.DisableAnimationsPreferenceController"/>
<SwitchPreference
android:key="toggle_force_bold_text"
android:persistent="false"
android:title="@string/force_bold_text"
settings:controller="com.android.settings.accessibility.FontWeightAdjustmentPreferenceController"/>
</PreferenceCategory> </PreferenceCategory>
<PreferenceCategory <PreferenceCategory
@@ -202,28 +169,6 @@
android:title="@string/experimental_category_title" android:title="@string/experimental_category_title"
settings:initialExpandedChildrenCount="1"> settings:initialExpandedChildrenCount="1">
<SwitchPreference
android:key="toggle_high_text_contrast_preference"
android:persistent="false"
android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
settings:controller="com.android.settings.accessibility.HighTextContrastPreferenceController"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
android:icon="@drawable/ic_daltonizer"
android:key="daltonizer_preference"
android:persistent="false"
android:title="@string/accessibility_display_daltonizer_preference_title"
settings:controller="com.android.settings.accessibility.DaltonizerPreferenceController"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleColorInversionPreferenceFragment"
android:icon="@drawable/ic_color_inversion"
android:key="toggle_inversion_preference"
android:persistent="false"
android:title="@string/accessibility_display_inversion_preference_title"
settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
<SwitchPreference <SwitchPreference
android:key="accessibility_shortcut_preference" android:key="accessibility_shortcut_preference"
android:persistent="false" android:persistent="false"
@@ -231,14 +176,6 @@
android:summary="@string/accessibility_shortcut_description" android:summary="@string/accessibility_shortcut_description"
settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/> settings:controller="com.android.settings.accessibility.AccessibilityShortcutPreferenceController"/>
<!--TODO(b/170973645): Get icon-->
<Preference
android:fragment="com.android.settings.accessibility.ToggleReduceBrightColorsPreferenceFragment"
android:key="reduce_bright_colors_preference"
android:persistent="false"
android:title="@string/reduce_bright_colors_preference_title"
settings:controller="com.android.settings.accessibility.ReduceBrightColorsPreferenceController"/>
</PreferenceCategory> </PreferenceCategory>
</PreferenceScreen> </PreferenceScreen>

View File

@@ -0,0 +1,100 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2021 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:settings="http://schemas.android.com/apk/res-auto"
android:key="accessibility_text_and_display"
android:persistent="false"
android:title="@string/accessibility_text_and_display_title">
<SwitchPreference
android:key="toggle_high_text_contrast_preference"
android:persistent="false"
android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
settings:controller="com.android.settings.accessibility.HighTextContrastPreferenceController"/>
<SwitchPreference
android:key="dark_ui_mode_accessibility"
android:persistent="false"
android:title="@string/dark_ui_mode"
settings:controller="com.android.settings.display.DarkUIPreferenceController"
settings:searchable="false"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleDaltonizerPreferenceFragment"
android:icon="@drawable/ic_daltonizer"
android:key="daltonizer_preference"
android:persistent="false"
android:title="@string/accessibility_display_daltonizer_preference_title"
settings:controller="com.android.settings.accessibility.DaltonizerPreferenceController"/>
<Preference
android:fragment="com.android.settings.accessibility.ToggleColorInversionPreferenceFragment"
android:icon="@drawable/ic_color_inversion"
android:key="toggle_inversion_preference"
android:persistent="false"
android:title="@string/accessibility_display_inversion_preference_title"
settings:controller="com.android.settings.accessibility.ColorInversionPreferenceController"/>
<!--TODO(b/170973645): Get icon-->
<Preference
android:fragment="com.android.settings.accessibility.ToggleReduceBrightColorsPreferenceFragment"
android:key="reduce_bright_colors_preference"
android:persistent="false"
android:title="@string/reduce_bright_colors_preference_title"
settings:controller="com.android.settings.accessibility.ReduceBrightColorsPreferenceController"/>
<SwitchPreference
android:key="toggle_disable_animations"
android:persistent="false"
android:title="@string/accessibility_disable_animations"
settings:controller="com.android.settings.accessibility.DisableAnimationsPreferenceController"/>
<com.android.settings.display.ScreenZoomPreference
android:fragment="com.android.settings.display.ScreenZoomSettings"
android:key="accessibility_settings_screen_zoom"
android:persistent="false"
android:title="@string/screen_zoom_title"
settings:searchable="false"/>
<Preference
android:fragment="com.android.settings.display.ToggleFontSizePreferenceFragment"
android:key="font_size_preference_screen"
android:persistent="false"
android:title="@string/title_font_size"
settings:controller="com.android.settings.display.FontSizePreferenceController"
settings:searchable="false"/>
<SwitchPreference
android:key="toggle_force_bold_text"
android:persistent="false"
android:title="@string/force_bold_text"
settings:controller="com.android.settings.accessibility.FontWeightAdjustmentPreferenceController"/>
<SwitchPreference
android:key="toggle_large_pointer_icon"
android:persistent="false"
android:title="@string/accessibility_toggle_large_pointer_icon_title"
settings:controller="com.android.settings.accessibility.LargePointerIconPreferenceController"/>
<PreferenceCategory
android:key="experimental_category"
android:persistent="false"
android:title="@string/experimental_category_title"
settings:initialExpandedChildrenCount="1">
</PreferenceCategory>
</PreferenceScreen>

View File

@@ -29,7 +29,6 @@ import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo; import android.content.pm.ResolveInfo;
import android.content.pm.ServiceInfo; import android.content.pm.ServiceInfo;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.hardware.display.ColorDisplayManager;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
@@ -43,7 +42,6 @@ import androidx.annotation.VisibleForTesting;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.preference.Preference; import androidx.preference.Preference;
import androidx.preference.PreferenceCategory; import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
import com.android.internal.accessibility.AccessibilityShortcutController; import com.android.internal.accessibility.AccessibilityShortcutController;
import com.android.internal.content.PackageMonitor; import com.android.internal.content.PackageMonitor;
@@ -51,7 +49,6 @@ import com.android.settings.R;
import com.android.settings.Utils; import com.android.settings.Utils;
import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType; import com.android.settings.accessibility.AccessibilityUtil.AccessibilityServiceFragmentType;
import com.android.settings.dashboard.DashboardFragment; import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.display.DarkUIPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider; import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin; import com.android.settingslib.RestrictedLockUtils.EnforcedAdmin;
import com.android.settingslib.RestrictedLockUtilsInternal; import com.android.settingslib.RestrictedLockUtilsInternal;
@@ -82,23 +79,14 @@ public class AccessibilitySettings extends DashboardFragment {
private static final String CATEGORY_EXPERIMENTAL = "experimental_category"; private static final String CATEGORY_EXPERIMENTAL = "experimental_category";
private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category"; private static final String CATEGORY_DOWNLOADED_SERVICES = "user_installed_services_category";
private static final String[] CATEGORIES = new String[] { private static final String[] CATEGORIES = new String[]{
CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY, CATEGORY_SCREEN_READER, CATEGORY_AUDIO_AND_CAPTIONS, CATEGORY_DISPLAY,
CATEGORY_INTERACTION_CONTROL, CATEGORY_EXPERIMENTAL, CATEGORY_DOWNLOADED_SERVICES CATEGORY_INTERACTION_CONTROL, CATEGORY_EXPERIMENTAL, CATEGORY_DOWNLOADED_SERVICES
}; };
// Preferences // Preferences
private static final String TOGGLE_INVERSION_PREFERENCE =
"toggle_inversion_preference";
private static final String TOGGLE_LARGE_POINTER_ICON =
"toggle_large_pointer_icon";
private static final String TOGGLE_DISABLE_ANIMATIONS = "toggle_disable_animations";
private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN = private static final String DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN =
"magnification_preference_screen"; "magnification_preference_screen";
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN =
"daltonizer_preference";
private static final String DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN =
"reduce_bright_colors_preference";
// Extras passed to sub-fragments. // Extras passed to sub-fragments.
static final String EXTRA_PREFERENCE_KEY = "preference_key"; static final String EXTRA_PREFERENCE_KEY = "preference_key";
@@ -167,13 +155,7 @@ public class AccessibilitySettings extends DashboardFragment {
private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap = private final Map<ComponentName, PreferenceCategory> mPreBundledServiceComponentToCategoryMap =
new ArrayMap<>(); new ArrayMap<>();
private SwitchPreference mToggleLargePointerIconPreference;
private SwitchPreference mToggleDisableAnimationsPreference;
private Preference mDisplayMagnificationPreferenceScreen; private Preference mDisplayMagnificationPreferenceScreen;
private Preference mDisplayDaltonizerPreferenceScreen;
private Preference mToggleInversionPreference;
private Preference mReduceBrightColorsPreference;
/** /**
* Check if the color transforms are color accelerated. Some transforms are experimental only * Check if the color transforms are color accelerated. Some transforms are experimental only
@@ -226,7 +208,6 @@ public class AccessibilitySettings extends DashboardFragment {
@Override @Override
public void onAttach(Context context) { public void onAttach(Context context) {
super.onAttach(context); super.onAttach(context);
use(DarkUIPreferenceController.class).setParentFragment(this);
use(AccessibilityHearingAidPreferenceController.class) use(AccessibilityHearingAidPreferenceController.class)
.setFragmentManager(getFragmentManager()); .setFragmentManager(getFragmentManager());
} }
@@ -259,8 +240,8 @@ public class AccessibilitySettings extends DashboardFragment {
/** /**
* Returns the summary for the current state of this accessibilityService. * Returns the summary for the current state of this accessibilityService.
* *
* @param context A valid context * @param context A valid context
* @param info The accessibilityService's info * @param info The accessibilityService's info
* @param serviceEnabled Whether the accessibility service is enabled. * @param serviceEnabled Whether the accessibility service is enabled.
* @return The service summary * @return The service summary
*/ */
@@ -299,8 +280,8 @@ public class AccessibilitySettings extends DashboardFragment {
/** /**
* Returns the description for the current state of this accessibilityService. * Returns the description for the current state of this accessibilityService.
* *
* @param context A valid context * @param context A valid context
* @param info The accessibilityService's info * @param info The accessibilityService's info
* @param serviceEnabled Whether the accessibility service is enabled. * @param serviceEnabled Whether the accessibility service is enabled.
* @return The service description * @return The service description
*/ */
@@ -325,24 +306,9 @@ public class AccessibilitySettings extends DashboardFragment {
mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory); mCategoryToPrefCategoryMap.put(CATEGORIES[i], prefCategory);
} }
// Display inversion.
mToggleInversionPreference = findPreference(TOGGLE_INVERSION_PREFERENCE);
// Large pointer icon.
mToggleLargePointerIconPreference = findPreference(TOGGLE_LARGE_POINTER_ICON);
mToggleDisableAnimationsPreference = findPreference(TOGGLE_DISABLE_ANIMATIONS);
// Display magnification. // Display magnification.
mDisplayMagnificationPreferenceScreen = findPreference( mDisplayMagnificationPreferenceScreen = findPreference(
DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN); DISPLAY_MAGNIFICATION_PREFERENCE_SCREEN);
// Display color adjustments.
mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
// Reduce brightness.
mReduceBrightColorsPreference =
findPreference(DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN);
} }
private void updateAllPreferences() { private void updateAllPreferences() {
@@ -392,13 +358,13 @@ public class AccessibilitySettings extends DashboardFragment {
// Update the order of all the category according to the order defined in xml file. // Update the order of all the category according to the order defined in xml file.
updateCategoryOrderFromArray(CATEGORY_SCREEN_READER, updateCategoryOrderFromArray(CATEGORY_SCREEN_READER,
R.array.config_order_screen_reader_services); R.array.config_order_screen_reader_services);
updateCategoryOrderFromArray(CATEGORY_AUDIO_AND_CAPTIONS, updateCategoryOrderFromArray(CATEGORY_AUDIO_AND_CAPTIONS,
R.array.config_order_audio_and_caption_services); R.array.config_order_audio_and_caption_services);
updateCategoryOrderFromArray(CATEGORY_INTERACTION_CONTROL, updateCategoryOrderFromArray(CATEGORY_INTERACTION_CONTROL,
R.array.config_order_interaction_control_services); R.array.config_order_interaction_control_services);
updateCategoryOrderFromArray(CATEGORY_DISPLAY, updateCategoryOrderFromArray(CATEGORY_DISPLAY,
R.array.config_order_display_services); R.array.config_order_display_services);
// Need to check each time when updateServicePreferences() called. // Need to check each time when updateServicePreferences() called.
if (downloadedServicesCategory.getPreferenceCount() == 0) { if (downloadedServicesCategory.getPreferenceCount() == 0) {
@@ -468,7 +434,7 @@ public class AccessibilitySettings extends DashboardFragment {
* key with the string array of preference order which is defined in the xml. * key with the string array of preference order which is defined in the xml.
* *
* @param categoryKey The key of the category need to update the order * @param categoryKey The key of the category need to update the order
* @param key The key of the string array which defines the order of category * @param key The key of the string array which defines the order of category
*/ */
private void updateCategoryOrderFromArray(String categoryKey, int key) { private void updateCategoryOrderFromArray(String categoryKey, int key) {
String[] services = getResources().getStringArray(key); String[] services = getResources().getStringArray(key);
@@ -486,39 +452,11 @@ public class AccessibilitySettings extends DashboardFragment {
} }
} }
/**
* Updates preferences related to system configurations.
*/
protected void updateSystemPreferences() { protected void updateSystemPreferences() {
// Move color inversion and color correction preferences to Display category if device // Do nothing.
// supports HWC hardware-accelerated color transform.
if (ColorDisplayManager.isColorTransformAccelerated(getContext())) {
PreferenceCategory experimentalCategory =
mCategoryToPrefCategoryMap.get(CATEGORY_EXPERIMENTAL);
PreferenceCategory displayCategory =
mCategoryToPrefCategoryMap.get(CATEGORY_DISPLAY);
experimentalCategory.removePreference(mToggleInversionPreference);
experimentalCategory.removePreference(mDisplayDaltonizerPreferenceScreen);
experimentalCategory.removePreference(mReduceBrightColorsPreference);
mDisplayMagnificationPreferenceScreen.setSummary(
ToggleScreenMagnificationPreferenceFragment.getServiceSummary(getContext()));
mDisplayDaltonizerPreferenceScreen.setOrder(
mDisplayMagnificationPreferenceScreen.getOrder() + 1);
mDisplayDaltonizerPreferenceScreen.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED));
mToggleInversionPreference.setOrder(
mDisplayDaltonizerPreferenceScreen.getOrder() + 1);
mToggleLargePointerIconPreference.setOrder(
mToggleInversionPreference.getOrder() + 1);
mToggleDisableAnimationsPreference.setOrder(
mToggleLargePointerIconPreference.getOrder() + 1);
mToggleInversionPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED));
mReduceBrightColorsPreference.setOrder(
mToggleDisableAnimationsPreference.getOrder() + 1);
mReduceBrightColorsPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED));
displayCategory.addPreference(mToggleInversionPreference);
displayCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
displayCategory.addPreference(mReduceBrightColorsPreference);
}
} }
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER = public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =

View File

@@ -0,0 +1,136 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import android.app.settings.SettingsEnums;
import android.content.Context;
import android.hardware.display.ColorDisplayManager;
import android.os.Bundle;
import android.provider.Settings;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import androidx.preference.SwitchPreference;
import com.android.settings.R;
import com.android.settings.dashboard.DashboardFragment;
import com.android.settings.display.DarkUIPreferenceController;
import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.search.SearchIndexable;
/** Accessibility settings for text and display. */
@SearchIndexable(forTarget = SearchIndexable.ALL & ~SearchIndexable.ARC)
public class TextAndDisplayFragment extends DashboardFragment {
private static final String TAG = "TextAndDisplayFragment";
private static final String CATEGORY_EXPERIMENTAL = "experimental_category";
// Preferences
private static final String DISPLAY_DALTONIZER_PREFERENCE_SCREEN = "daltonizer_preference";
private static final String TOGGLE_INVERSION_PREFERENCE = "toggle_inversion_preference";
private static final String DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN =
"reduce_bright_colors_preference";
private static final String TOGGLE_DISABLE_ANIMATIONS = "toggle_disable_animations";
private static final String TOGGLE_LARGE_POINTER_ICON = "toggle_large_pointer_icon";
private Preference mDisplayDaltonizerPreferenceScreen;
private Preference mToggleInversionPreference;
private Preference mReduceBrightColorsPreference;
private SwitchPreference mToggleDisableAnimationsPreference;
private SwitchPreference mToggleLargePointerIconPreference;
@Override
public int getMetricsCategory() {
return SettingsEnums.ACCESSIBILITY_TEXT_AND_DISPLAY;
}
@Override
public void onCreate(Bundle icicle) {
super.onCreate(icicle);
initializeAllPreferences();
updateSystemPreferences();
}
@Override
public void onAttach(Context context) {
super.onAttach(context);
use(DarkUIPreferenceController.class).setParentFragment(this);
}
@Override
protected int getPreferenceScreenResId() {
return R.xml.accessibility_text_and_display;
}
@Override
protected String getLogTag() {
return TAG;
}
private void initializeAllPreferences() {
// Display color adjustments.
mDisplayDaltonizerPreferenceScreen = findPreference(DISPLAY_DALTONIZER_PREFERENCE_SCREEN);
// Display inversion.
mToggleInversionPreference = findPreference(TOGGLE_INVERSION_PREFERENCE);
// Reduce brightness.
mReduceBrightColorsPreference =
findPreference(DISPLAY_REDUCE_BRIGHT_COLORS_PREFERENCE_SCREEN);
// Disable animation.
mToggleDisableAnimationsPreference = findPreference(TOGGLE_DISABLE_ANIMATIONS);
// Large pointer icon.
mToggleLargePointerIconPreference = findPreference(TOGGLE_LARGE_POINTER_ICON);
}
/**
* Updates preferences related to system configurations.
*/
private void updateSystemPreferences() {
final PreferenceCategory experimentalCategory = getPreferenceScreen().findPreference(
CATEGORY_EXPERIMENTAL);
if (ColorDisplayManager.isColorTransformAccelerated(getContext())) {
mDisplayDaltonizerPreferenceScreen.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED));
mToggleInversionPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.ACCESSIBILITY_DISPLAY_INVERSION_ENABLED));
mReduceBrightColorsPreference.setSummary(AccessibilityUtil.getSummary(
getContext(), Settings.Secure.REDUCE_BRIGHT_COLORS_ACTIVATED));
getPreferenceScreen().removePreference(experimentalCategory);
} else {
// Move following preferences to experimental category if device don't supports HWC
// hardware-accelerated color transform.
getPreferenceScreen().removePreference(mDisplayDaltonizerPreferenceScreen);
getPreferenceScreen().removePreference(mToggleInversionPreference);
getPreferenceScreen().removePreference(mReduceBrightColorsPreference);
getPreferenceScreen().removePreference(mToggleDisableAnimationsPreference);
getPreferenceScreen().removePreference(mToggleLargePointerIconPreference);
experimentalCategory.addPreference(mDisplayDaltonizerPreferenceScreen);
experimentalCategory.addPreference(mToggleInversionPreference);
experimentalCategory.addPreference(mReduceBrightColorsPreference);
experimentalCategory.addPreference(mToggleDisableAnimationsPreference);
experimentalCategory.addPreference(mToggleLargePointerIconPreference);
}
}
public static final BaseSearchIndexProvider SEARCH_INDEX_DATA_PROVIDER =
new BaseSearchIndexProvider(R.xml.accessibility_text_and_display);
}

View File

@@ -0,0 +1,49 @@
/*
* Copyright (C) 2021 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.settings.accessibility;
import static com.google.common.truth.Truth.assertThat;
import android.content.Context;
import androidx.test.core.app.ApplicationProvider;
import com.android.settings.R;
import com.android.settings.testutils.XmlTestUtils;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricTestRunner;
import java.util.List;
@RunWith(RobolectricTestRunner.class)
public class TextAndDisplayFragmentTest {
private Context mContext = ApplicationProvider.getApplicationContext();
@Test
public void getNonIndexableKeys_existInXmlLayout() {
final List<String> niks = TextAndDisplayFragment.SEARCH_INDEX_DATA_PROVIDER
.getNonIndexableKeys(mContext);
final List<String> keys =
XmlTestUtils.getKeysFromPreferenceXml(mContext,
R.xml.accessibility_text_and_display);
assertThat(keys).containsAtLeastElementsIn(niks);
}
}