Add entry point of screen zoom to accessibility and font size to display.
Also removing large text preference. Change-Id: I076664edf1d1afd69385e34f9300bf5c0788b3e7
This commit is contained in:
@@ -3759,8 +3759,6 @@
|
|||||||
<string name="accessibility_global_gesture_preference_summary_off">Off</string>
|
<string name="accessibility_global_gesture_preference_summary_off">Off</string>
|
||||||
<!-- Description for the preference screen to enable the global geture taht turns on accessibility. [CHAR LIMIT=none] -->
|
<!-- Description for the preference screen to enable the global geture taht turns on accessibility. [CHAR LIMIT=none] -->
|
||||||
<string name="accessibility_global_gesture_preference_description">When this feature is turned on, you can quickly enable accessibility features in two steps:\n\nStep 1: Press and hold the power button until you hear a sound or feel a vibration.\n\nStep 2: Touch and hold two fingers until you hear audio confirmation.\n\nIf the device has multiple users, using this shortcut on the lock screen temporarily enables accessibility until the device is unlocked.</string>
|
<string name="accessibility_global_gesture_preference_description">When this feature is turned on, you can quickly enable accessibility features in two steps:\n\nStep 1: Press and hold the power button until you hear a sound or feel a vibration.\n\nStep 2: Touch and hold two fingers until you hear audio confirmation.\n\nIf the device has multiple users, using this shortcut on the lock screen temporarily enables accessibility until the device is unlocked.</string>
|
||||||
<!-- Title for the accessibility preference to enable large text. [CHAR LIMIT=35] -->
|
|
||||||
<string name="accessibility_toggle_large_text_preference_title">Large text</string>
|
|
||||||
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to high contrast text. [CHAR LIMIT=35] -->
|
||||||
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
|
<string name="accessibility_toggle_high_text_contrast_preference_title">High contrast text</string>
|
||||||
<!-- Title for the accessibility preference to enable screen magnification. [CHAR LIMIT=35] -->
|
<!-- Title for the accessibility preference to enable screen magnification. [CHAR LIMIT=35] -->
|
||||||
|
@@ -43,16 +43,15 @@
|
|||||||
android:key="font_size_preference_screen"
|
android:key="font_size_preference_screen"
|
||||||
android:title="@string/title_font_size"/>
|
android:title="@string/title_font_size"/>
|
||||||
|
|
||||||
|
<com.android.settings.display.ScreenZoomPreference
|
||||||
|
android:key="screen_zoom"
|
||||||
|
android:title="@string/screen_zoom_title"/>
|
||||||
|
|
||||||
<PreferenceScreen
|
<PreferenceScreen
|
||||||
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
|
android:fragment="com.android.settings.accessibility.ToggleAutoclickPreferenceFragment"
|
||||||
android:key="autoclick_preference_screen"
|
android:key="autoclick_preference_screen"
|
||||||
android:title="@string/accessibility_autoclick_preference_title"/>
|
android:title="@string/accessibility_autoclick_preference_title"/>
|
||||||
|
|
||||||
<SwitchPreference
|
|
||||||
android:key="toggle_large_text_preference"
|
|
||||||
android:title="@string/accessibility_toggle_large_text_preference_title"
|
|
||||||
android:persistent="false"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="toggle_high_text_contrast_preference"
|
android:key="toggle_high_text_contrast_preference"
|
||||||
android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
|
android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
|
||||||
|
@@ -91,14 +91,11 @@
|
|||||||
android:summary="@string/tap_to_wake_summary"
|
android:summary="@string/tap_to_wake_summary"
|
||||||
android:persistent="false" />
|
android:persistent="false" />
|
||||||
|
|
||||||
<DropDownPreference
|
<PreferenceScreen
|
||||||
android:key="font_size"
|
android:key="font_size"
|
||||||
android:title="@string/title_font_size"
|
android:title="@string/title_font_size"
|
||||||
settings:keywords="@string/keywords_display_font_size"
|
android:fragment="com.android.settings.accessibility.ToggleFontSizePreferenceFragment"
|
||||||
android:persistent="false"
|
settings:keywords="@string/keywords_display_font_size" />
|
||||||
android:summary="%s"
|
|
||||||
android:entries="@array/entries_font_size"
|
|
||||||
android:entryValues="@array/entryvalues_font_size" />
|
|
||||||
|
|
||||||
<com.android.settings.display.ScreenZoomPreference
|
<com.android.settings.display.ScreenZoomPreference
|
||||||
android:key="screen_zoom"
|
android:key="screen_zoom"
|
||||||
|
@@ -17,7 +17,6 @@
|
|||||||
package com.android.settings;
|
package com.android.settings;
|
||||||
|
|
||||||
import android.app.Activity;
|
import android.app.Activity;
|
||||||
import android.app.ActivityManagerNative;
|
|
||||||
import android.app.UiModeManager;
|
import android.app.UiModeManager;
|
||||||
import android.app.admin.DevicePolicyManager;
|
import android.app.admin.DevicePolicyManager;
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
@@ -29,7 +28,6 @@ import android.hardware.Sensor;
|
|||||||
import android.hardware.SensorManager;
|
import android.hardware.SensorManager;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.RemoteException;
|
|
||||||
import android.os.SystemProperties;
|
import android.os.SystemProperties;
|
||||||
import android.provider.SearchIndexableResource;
|
import android.provider.SearchIndexableResource;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -44,6 +42,7 @@ import android.util.Log;
|
|||||||
import com.android.internal.logging.MetricsLogger;
|
import com.android.internal.logging.MetricsLogger;
|
||||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||||
import com.android.internal.view.RotationPolicy;
|
import com.android.internal.view.RotationPolicy;
|
||||||
|
import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
|
||||||
import com.android.settings.dashboard.SummaryLoader;
|
import com.android.settings.dashboard.SummaryLoader;
|
||||||
import com.android.settings.search.BaseSearchIndexProvider;
|
import com.android.settings.search.BaseSearchIndexProvider;
|
||||||
import com.android.settings.search.Indexable;
|
import com.android.settings.search.Indexable;
|
||||||
@@ -85,7 +84,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
|
private static final String KEY_CAMERA_DOUBLE_TAP_POWER_GESTURE
|
||||||
= "camera_double_tap_power_gesture";
|
= "camera_double_tap_power_gesture";
|
||||||
|
|
||||||
private DropDownPreference mFontSizePref;
|
private Preference mFontSizePref;
|
||||||
|
|
||||||
private final Configuration mCurConfig = new Configuration();
|
private final Configuration mCurConfig = new Configuration();
|
||||||
|
|
||||||
@@ -121,8 +120,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
mScreenTimeoutPreference = (RestrictedListPreference) findPreference(KEY_SCREEN_TIMEOUT);
|
mScreenTimeoutPreference = (RestrictedListPreference) findPreference(KEY_SCREEN_TIMEOUT);
|
||||||
|
|
||||||
mFontSizePref = (DropDownPreference) findPreference(KEY_FONT_SIZE);
|
mFontSizePref = findPreference(KEY_FONT_SIZE);
|
||||||
mFontSizePref.setOnPreferenceChangeListener(this);
|
|
||||||
|
|
||||||
if (isAutomaticBrightnessAvailable(getResources())) {
|
if (isAutomaticBrightnessAvailable(getResources())) {
|
||||||
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
|
mAutoBrightnessPreference = (SwitchPreference) findPreference(KEY_AUTO_BRIGHTNESS);
|
||||||
@@ -339,37 +337,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int floatToIndex(float val) {
|
|
||||||
String[] indices = getResources().getStringArray(R.array.entryvalues_font_size);
|
|
||||||
float lastVal = Float.parseFloat(indices[0]);
|
|
||||||
for (int i=1; i<indices.length; i++) {
|
|
||||||
float thisVal = Float.parseFloat(indices[i]);
|
|
||||||
if (val < (lastVal + (thisVal-lastVal)*.5f)) {
|
|
||||||
return i-1;
|
|
||||||
}
|
|
||||||
lastVal = thisVal;
|
|
||||||
}
|
|
||||||
return indices.length-1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void readFontSizePreference(ListPreference pref) {
|
|
||||||
try {
|
|
||||||
mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
|
|
||||||
} catch (RemoteException e) {
|
|
||||||
Log.w(TAG, "Unable to retrieve font size");
|
|
||||||
}
|
|
||||||
|
|
||||||
// mark the appropriate item in the preferences list
|
|
||||||
int index = floatToIndex(mCurConfig.fontScale);
|
|
||||||
pref.setValueIndex(index);
|
|
||||||
|
|
||||||
// report the current size in the summary text
|
|
||||||
final Resources res = getResources();
|
|
||||||
String[] fontSizeNames = res.getStringArray(R.array.entries_font_size);
|
|
||||||
pref.setSummary(String.format(res.getString(R.string.summary_font_size),
|
|
||||||
fontSizeNames[index]));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onResume() {
|
public void onResume() {
|
||||||
super.onResume();
|
super.onResume();
|
||||||
@@ -384,7 +351,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateState() {
|
private void updateState() {
|
||||||
readFontSizePreference(mFontSizePref);
|
updateFontSizeSummary();
|
||||||
updateScreenSaverSummary();
|
updateScreenSaverSummary();
|
||||||
|
|
||||||
// Update auto brightness if it is available.
|
// Update auto brightness if it is available.
|
||||||
@@ -433,13 +400,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void writeFontSizePreference(Object objValue) {
|
private void updateFontSizeSummary() {
|
||||||
try {
|
final Resources res = mFontSizePref.getContext().getResources();
|
||||||
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
|
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||||
ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
|
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||||
} catch (RemoteException e) {
|
final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
|
||||||
Log.w(TAG, "Unable to save font size");
|
res.getConfiguration().fontScale, strEntryValues);
|
||||||
}
|
mFontSizePref.setSummary(entries[index]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -454,9 +421,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
|||||||
Log.e(TAG, "could not persist screen timeout setting", e);
|
Log.e(TAG, "could not persist screen timeout setting", e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (KEY_FONT_SIZE.equals(key)) {
|
|
||||||
writeFontSizePreference(objValue);
|
|
||||||
}
|
|
||||||
if (preference == mAutoBrightnessPreference) {
|
if (preference == mAutoBrightnessPreference) {
|
||||||
boolean auto = (Boolean) objValue;
|
boolean auto = (Boolean) objValue;
|
||||||
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
|
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
|
||||||
|
@@ -71,15 +71,11 @@ import java.util.Set;
|
|||||||
public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
|
public class AccessibilitySettings extends SettingsPreferenceFragment implements DialogCreatable,
|
||||||
Preference.OnPreferenceChangeListener, Indexable {
|
Preference.OnPreferenceChangeListener, Indexable {
|
||||||
|
|
||||||
private static final float LARGE_FONT_SCALE = 1.3f;
|
|
||||||
|
|
||||||
// Preference categories
|
// Preference categories
|
||||||
private static final String SERVICES_CATEGORY = "services_category";
|
private static final String SERVICES_CATEGORY = "services_category";
|
||||||
private static final String SYSTEM_CATEGORY = "system_category";
|
private static final String SYSTEM_CATEGORY = "system_category";
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
private static final String TOGGLE_LARGE_TEXT_PREFERENCE =
|
|
||||||
"toggle_large_text_preference";
|
|
||||||
private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
|
private static final String TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE =
|
||||||
"toggle_high_text_contrast_preference";
|
"toggle_high_text_contrast_preference";
|
||||||
private static final String TOGGLE_INVERSION_PREFERENCE =
|
private static final String TOGGLE_INVERSION_PREFERENCE =
|
||||||
@@ -127,8 +123,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
|
private final Map<String, String> mLongPressTimeoutValuetoTitleMap = new HashMap<>();
|
||||||
|
|
||||||
private final Configuration mCurConfig = new Configuration();
|
|
||||||
|
|
||||||
private final Handler mHandler = new Handler();
|
private final Handler mHandler = new Handler();
|
||||||
|
|
||||||
private final Runnable mUpdateRunnable = new Runnable() {
|
private final Runnable mUpdateRunnable = new Runnable() {
|
||||||
@@ -185,7 +179,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
private PreferenceCategory mServicesCategory;
|
private PreferenceCategory mServicesCategory;
|
||||||
private PreferenceCategory mSystemsCategory;
|
private PreferenceCategory mSystemsCategory;
|
||||||
|
|
||||||
private SwitchPreference mToggleLargeTextPreference;
|
|
||||||
private SwitchPreference mToggleHighTextContrastPreference;
|
private SwitchPreference mToggleHighTextContrastPreference;
|
||||||
private SwitchPreference mTogglePowerButtonEndsCallPreference;
|
private SwitchPreference mTogglePowerButtonEndsCallPreference;
|
||||||
private SwitchPreference mToggleLockScreenRotationPreference;
|
private SwitchPreference mToggleLockScreenRotationPreference;
|
||||||
@@ -274,10 +267,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onPreferenceTreeClick(Preference preference) {
|
public boolean onPreferenceTreeClick(Preference preference) {
|
||||||
if (mToggleLargeTextPreference == preference) {
|
if (mToggleHighTextContrastPreference == preference) {
|
||||||
handleToggleLargeTextPreferenceClick();
|
|
||||||
return true;
|
|
||||||
} else if (mToggleHighTextContrastPreference == preference) {
|
|
||||||
handleToggleTextContrastPreferenceClick();
|
handleToggleTextContrastPreferenceClick();
|
||||||
return true;
|
return true;
|
||||||
} else if (mTogglePowerButtonEndsCallPreference == preference) {
|
} else if (mTogglePowerButtonEndsCallPreference == preference) {
|
||||||
@@ -302,15 +292,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
return super.onPreferenceTreeClick(preference);
|
return super.onPreferenceTreeClick(preference);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleToggleLargeTextPreferenceClick() {
|
|
||||||
try {
|
|
||||||
mCurConfig.fontScale = mToggleLargeTextPreference.isChecked() ? LARGE_FONT_SCALE : 1;
|
|
||||||
ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
|
|
||||||
} catch (RemoteException re) {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void handleToggleTextContrastPreferenceClick() {
|
private void handleToggleTextContrastPreferenceClick() {
|
||||||
Settings.Secure.putInt(getContentResolver(),
|
Settings.Secure.putInt(getContentResolver(),
|
||||||
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
|
Settings.Secure.ACCESSIBILITY_HIGH_TEXT_CONTRAST_ENABLED,
|
||||||
@@ -368,10 +349,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
|
mServicesCategory = (PreferenceCategory) findPreference(SERVICES_CATEGORY);
|
||||||
mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
|
mSystemsCategory = (PreferenceCategory) findPreference(SYSTEM_CATEGORY);
|
||||||
|
|
||||||
// Large text.
|
|
||||||
mToggleLargeTextPreference =
|
|
||||||
(SwitchPreference) findPreference(TOGGLE_LARGE_TEXT_PREFERENCE);
|
|
||||||
|
|
||||||
// Text contrast.
|
// Text contrast.
|
||||||
mToggleHighTextContrastPreference =
|
mToggleHighTextContrastPreference =
|
||||||
(SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
|
(SwitchPreference) findPreference(TOGGLE_HIGH_TEXT_CONTRAST_PREFERENCE);
|
||||||
@@ -564,14 +541,6 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void updateSystemPreferences() {
|
private void updateSystemPreferences() {
|
||||||
// Large text.
|
|
||||||
try {
|
|
||||||
mCurConfig.updateFrom(ActivityManagerNative.getDefault().getConfiguration());
|
|
||||||
} catch (RemoteException re) {
|
|
||||||
/* ignore */
|
|
||||||
}
|
|
||||||
mToggleLargeTextPreference.setChecked(mCurConfig.fontScale == LARGE_FONT_SCALE);
|
|
||||||
|
|
||||||
// Text contrast.
|
// Text contrast.
|
||||||
mToggleHighTextContrastPreference.setChecked(
|
mToggleHighTextContrastPreference.setChecked(
|
||||||
Settings.Secure.getInt(getContentResolver(),
|
Settings.Secure.getInt(getContentResolver(),
|
||||||
@@ -658,7 +627,7 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements
|
|||||||
final Resources res = getContext().getResources();
|
final Resources res = getContext().getResources();
|
||||||
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||||
final int index = ToggleFontSizePreferenceFragment.floatToIndex(
|
final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
|
||||||
res.getConfiguration().fontScale, strEntryValues);
|
res.getConfiguration().fontScale, strEntryValues);
|
||||||
pref.setSummary(entries[index]);
|
pref.setSummary(entries[index]);
|
||||||
}
|
}
|
||||||
|
@@ -188,7 +188,7 @@ public class AccessibilitySettingsForSetupWizard extends SettingsPreferenceFragm
|
|||||||
final Resources res = getContext().getResources();
|
final Resources res = getContext().getResources();
|
||||||
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||||
final int index = ToggleFontSizePreferenceFragment.floatToIndex(
|
final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
|
||||||
res.getConfiguration().fontScale, strEntryValues);
|
res.getConfiguration().fontScale, strEntryValues);
|
||||||
pref.setSummary(entries[index]);
|
pref.setSummary(entries[index]);
|
||||||
}
|
}
|
||||||
|
@@ -48,7 +48,7 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr
|
|||||||
final Configuration origConfig = res.getConfiguration();
|
final Configuration origConfig = res.getConfiguration();
|
||||||
mEntries = res.getStringArray(R.array.entries_font_size);
|
mEntries = res.getStringArray(R.array.entries_font_size);
|
||||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||||
mInitialIndex = floatToIndex(origConfig.fontScale, strEntryValues);
|
mInitialIndex = fontSizeValueToIndex(origConfig.fontScale, strEntryValues);
|
||||||
mValues = new float[strEntryValues.length];
|
mValues = new float[strEntryValues.length];
|
||||||
for (int i = 0; i < strEntryValues.length; ++i) {
|
for (int i = 0; i < strEntryValues.length; ++i) {
|
||||||
mValues[i] = Float.parseFloat(strEntryValues[i]);
|
mValues[i] = Float.parseFloat(strEntryValues[i]);
|
||||||
@@ -86,7 +86,7 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr
|
|||||||
* Utility function that returns the index in a string array with which the represented value is
|
* Utility function that returns the index in a string array with which the represented value is
|
||||||
* the closest to a given float value.
|
* the closest to a given float value.
|
||||||
*/
|
*/
|
||||||
static int floatToIndex(float val, String[] indices) {
|
public static int fontSizeValueToIndex(float val, String[] indices) {
|
||||||
float lastVal = Float.parseFloat(indices[0]);
|
float lastVal = Float.parseFloat(indices[0]);
|
||||||
for (int i=1; i<indices.length; i++) {
|
for (int i=1; i<indices.length; i++) {
|
||||||
float thisVal = Float.parseFloat(indices[i]);
|
float thisVal = Float.parseFloat(indices[i]);
|
||||||
|
Reference in New Issue
Block a user