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:
@@ -17,7 +17,6 @@
|
||||
package com.android.settings;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ActivityManagerNative;
|
||||
import android.app.UiModeManager;
|
||||
import android.app.admin.DevicePolicyManager;
|
||||
import android.content.ContentResolver;
|
||||
@@ -29,7 +28,6 @@ import android.hardware.Sensor;
|
||||
import android.hardware.SensorManager;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.RemoteException;
|
||||
import android.os.SystemProperties;
|
||||
import android.provider.SearchIndexableResource;
|
||||
import android.provider.Settings;
|
||||
@@ -44,6 +42,7 @@ import android.util.Log;
|
||||
import com.android.internal.logging.MetricsLogger;
|
||||
import com.android.internal.logging.MetricsProto.MetricsEvent;
|
||||
import com.android.internal.view.RotationPolicy;
|
||||
import com.android.settings.accessibility.ToggleFontSizePreferenceFragment;
|
||||
import com.android.settings.dashboard.SummaryLoader;
|
||||
import com.android.settings.search.BaseSearchIndexProvider;
|
||||
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
|
||||
= "camera_double_tap_power_gesture";
|
||||
|
||||
private DropDownPreference mFontSizePref;
|
||||
private Preference mFontSizePref;
|
||||
|
||||
private final Configuration mCurConfig = new Configuration();
|
||||
|
||||
@@ -121,8 +120,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
|
||||
mScreenTimeoutPreference = (RestrictedListPreference) findPreference(KEY_SCREEN_TIMEOUT);
|
||||
|
||||
mFontSizePref = (DropDownPreference) findPreference(KEY_FONT_SIZE);
|
||||
mFontSizePref.setOnPreferenceChangeListener(this);
|
||||
mFontSizePref = findPreference(KEY_FONT_SIZE);
|
||||
|
||||
if (isAutomaticBrightnessAvailable(getResources())) {
|
||||
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
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
@@ -384,7 +351,7 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
|
||||
private void updateState() {
|
||||
readFontSizePreference(mFontSizePref);
|
||||
updateFontSizeSummary();
|
||||
updateScreenSaverSummary();
|
||||
|
||||
// Update auto brightness if it is available.
|
||||
@@ -433,13 +400,13 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
}
|
||||
}
|
||||
|
||||
public void writeFontSizePreference(Object objValue) {
|
||||
try {
|
||||
mCurConfig.fontScale = Float.parseFloat(objValue.toString());
|
||||
ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig);
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Unable to save font size");
|
||||
}
|
||||
private void updateFontSizeSummary() {
|
||||
final Resources res = mFontSizePref.getContext().getResources();
|
||||
final String[] entries = res.getStringArray(R.array.entries_font_size);
|
||||
final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size);
|
||||
final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(
|
||||
res.getConfiguration().fontScale, strEntryValues);
|
||||
mFontSizePref.setSummary(entries[index]);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -454,9 +421,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements
|
||||
Log.e(TAG, "could not persist screen timeout setting", e);
|
||||
}
|
||||
}
|
||||
if (KEY_FONT_SIZE.equals(key)) {
|
||||
writeFontSizePreference(objValue);
|
||||
}
|
||||
if (preference == mAutoBrightnessPreference) {
|
||||
boolean auto = (Boolean) objValue;
|
||||
Settings.System.putInt(getContentResolver(), SCREEN_BRIGHTNESS_MODE,
|
||||
|
Reference in New Issue
Block a user