Add accessibility display adjustments to Settings
This will be redesigned soon, but for now it allows access to quick setting tiles for testing display adjustments. BUG: 9057596 Change-Id: I4b760487b2fe0a336b188930306000e5dfc01951
This commit is contained in:
@@ -59,6 +59,7 @@ import android.view.Gravity;
|
||||
import android.view.HardwareRenderer;
|
||||
import android.view.IWindowManager;
|
||||
import android.view.View;
|
||||
import android.view.accessibility.AccessibilityManager;
|
||||
import android.webkit.WebViewFactory;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.Switch;
|
||||
@@ -114,6 +115,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
private static final String SHOW_TOUCHES_KEY = "show_touches";
|
||||
private static final String SHOW_SCREEN_UPDATES_KEY = "show_screen_updates";
|
||||
private static final String DISABLE_OVERLAYS_KEY = "disable_overlays";
|
||||
private static final String SIMULATE_COLOR_SPACE = "simulate_color_space";
|
||||
private static final String SHOW_CPU_USAGE_KEY = "show_cpu_usage";
|
||||
private static final String FORCE_HARDWARE_UI_KEY = "force_hw_ui";
|
||||
private static final String FORCE_MSAA_KEY = "force_msaa";
|
||||
@@ -195,6 +197,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
private ListPreference mAnimatorDurationScale;
|
||||
private ListPreference mOverlayDisplayDevices;
|
||||
private ListPreference mOpenGLTraces;
|
||||
private ListPreference mSimulateColorSpace;
|
||||
|
||||
private CheckBoxPreference mImmediatelyDestroyActivities;
|
||||
private ListPreference mAppProcessLimit;
|
||||
@@ -300,6 +303,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
mAnimatorDurationScale = addListPreference(ANIMATOR_DURATION_SCALE_KEY);
|
||||
mOverlayDisplayDevices = addListPreference(OVERLAY_DISPLAY_DEVICES_KEY);
|
||||
mOpenGLTraces = addListPreference(OPENGL_TRACES_KEY);
|
||||
mSimulateColorSpace = addListPreference(SIMULATE_COLOR_SPACE);
|
||||
|
||||
mImmediatelyDestroyActivities = (CheckBoxPreference) findPreference(
|
||||
IMMEDIATELY_DESTROY_ACTIVITIES_KEY);
|
||||
@@ -513,6 +517,7 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
updateBugreportOptions();
|
||||
updateForceRtlOptions();
|
||||
updateWifiDisplayCertificationOptions();
|
||||
updateSimulateColorSpace();
|
||||
}
|
||||
|
||||
private void resetDangerousOptions() {
|
||||
@@ -949,6 +954,40 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
pokeSystemProperties();
|
||||
}
|
||||
|
||||
private void updateSimulateColorSpace() {
|
||||
final ContentResolver cr = getContentResolver();
|
||||
final boolean enabled = Settings.Secure.getInt(
|
||||
cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0) != 0;
|
||||
if (enabled) {
|
||||
final String mode = Integer.toString(Settings.Secure.getInt(
|
||||
cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER,
|
||||
AccessibilityManager.DALTONIZER_DISABLED));
|
||||
mSimulateColorSpace.setValue(mode);
|
||||
final int index = mSimulateColorSpace.findIndexOfValue(mode);
|
||||
if (index < 0) {
|
||||
// We're using a mode controlled by accessibility preferences.
|
||||
mSimulateColorSpace.setSummary(getString(R.string.daltonizer_type_overridden,
|
||||
getString(R.string.accessibility_display_daltonizer_preference_title)));
|
||||
} else {
|
||||
mSimulateColorSpace.setSummary("%s");
|
||||
}
|
||||
} else {
|
||||
mSimulateColorSpace.setValue(
|
||||
Integer.toString(AccessibilityManager.DALTONIZER_DISABLED));
|
||||
}
|
||||
}
|
||||
|
||||
private void writeSimulateColorSpace(Object value) {
|
||||
final ContentResolver cr = getContentResolver();
|
||||
final int newMode = Integer.parseInt(value.toString());
|
||||
if (newMode < 0) {
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 0);
|
||||
} else {
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER_ENABLED, 1);
|
||||
Settings.Secure.putInt(cr, Settings.Secure.ACCESSIBILITY_DISPLAY_DALTONIZER, newMode);
|
||||
}
|
||||
}
|
||||
|
||||
private void updateForceRtlOptions() {
|
||||
updateCheckBox(mForceRtlLayout, Settings.Global.getInt(getActivity().getContentResolver(),
|
||||
Settings.Global.DEVELOPMENT_FORCE_RTL, 0) != 0);
|
||||
@@ -1350,6 +1389,9 @@ public class DevelopmentSettings extends RestrictedSettingsFragment
|
||||
} else if (preference == mAppProcessLimit) {
|
||||
writeAppProcessLimitOptions(newValue);
|
||||
return true;
|
||||
} else if (preference == mSimulateColorSpace) {
|
||||
writeSimulateColorSpace(newValue);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user