Loading src/com/android/settings/Display.java +15 −22 Original line number Diff line number Diff line Loading @@ -17,12 +17,11 @@ package com.android.settings; import android.app.Activity; import android.app.ActivityManagerNative; import android.content.res.Configuration; import android.content.ContentResolver; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Bundle; import android.os.RemoteException; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; Loading Loading @@ -80,14 +79,12 @@ public class Display extends Activity implements View.OnClickListener { @Override public void onResume() { super.onResume(); try { mCurConfig.updateFrom( ActivityManagerNative.getDefault().getConfiguration()); } catch (RemoteException e) { } if (mCurConfig.fontScale < 1) { final ContentResolver resolver = getContentResolver(); mFontScale = Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, 1.0f); if (mFontScale < 1) { mFontSize.setSelection(0); } else if (mCurConfig.fontScale > 1) { } else if (mFontScale > 1) { mFontSize.setSelection(2); } else { mFontSize.setSelection(1); Loading @@ -96,18 +93,14 @@ public class Display extends Activity implements View.OnClickListener { } private void updateFontScale() { mDisplayMetrics.scaledDensity = mDisplayMetrics.density * mCurConfig.fontScale; mDisplayMetrics.scaledDensity = mDisplayMetrics.density * mFontScale; float size = mTextSizeTyped.getDimension(mDisplayMetrics); mPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); } public void onClick(View v) { try { ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig); } catch (RemoteException e) { } final ContentResolver resolver = getContentResolver(); Settings.System.putFloat(resolver, Settings.System.FONT_SCALE, mFontScale); finish(); } Loading @@ -116,11 +109,11 @@ public class Display extends Activity implements View.OnClickListener { public void onItemSelected(android.widget.AdapterView av, View v, int position, long id) { if (position == 0) { mCurConfig.fontScale = .75f; mFontScale = .75f; } else if (position == 2) { mCurConfig.fontScale = 1.25f; mFontScale = 1.25f; } else { mCurConfig.fontScale = 1.0f; mFontScale = 1.0f; } updateFontScale(); Loading @@ -134,5 +127,5 @@ public class Display extends Activity implements View.OnClickListener { private TextView mPreview; private TypedValue mTextSizeTyped; private DisplayMetrics mDisplayMetrics; private Configuration mCurConfig = new Configuration(); private float mFontScale = 1.0f; } src/com/android/settings/DisplaySettings.java +6 −5 Original line number Diff line number Diff line Loading @@ -88,8 +88,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private Preference mFontSizePref; private final Configuration mCurConfig = new Configuration(); private RestrictedListPreference mScreenTimeoutPreference; private ListPreference mNightModePreference; private Preference mScreenSaverPreference; Loading Loading @@ -411,11 +409,14 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } private void updateFontSizeSummary() { final Resources res = mFontSizePref.getContext().getResources(); final Context context = mFontSizePref.getContext(); final float currentScale = Settings.System.getFloat(context.getContentResolver(), Settings.System.FONT_SCALE, 1.0f); final Resources res = context.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); final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(currentScale, strEntryValues); mFontSizePref.setSummary(entries[index]); } Loading src/com/android/settings/accessibility/AccessibilitySettings.java +4 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,11 @@ package com.android.settings.accessibility; import android.accessibilityservice.AccessibilityServiceInfo; import android.app.ActivityManagerNative; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; Loading Loading @@ -624,11 +622,13 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements } private void updateFontSizeSummary(Preference pref) { final float currentScale = Settings.System.getFloat(getContext().getContentResolver(), Settings.System.FONT_SCALE, 1.0f); final Resources res = 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); final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(currentScale, strEntryValues); pref.setSummary(entries[index]); } Loading src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java +10 −14 Original line number Diff line number Diff line Loading @@ -21,12 +21,11 @@ import com.android.settings.R; import com.android.settings.PreviewSeekBarPreferenceFragment; import android.annotation.Nullable; import android.app.ActivityManagerNative; import android.content.ContentResolver; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; import android.util.Log; import android.provider.Settings; /** * Preference fragment used to control font size. Loading @@ -44,11 +43,13 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr mPreviewSampleResIds = new int[]{R.layout.font_size_preview}; Resources res = getContext().getResources(); final ContentResolver resolver = getContext().getContentResolver(); // Mark the appropriate item in the preferences list. final Configuration origConfig = res.getConfiguration(); mEntries = res.getStringArray(R.array.entries_font_size); final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size); mInitialIndex = fontSizeValueToIndex(origConfig.fontScale, strEntryValues); final float currentScale = Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, 1.0f); mInitialIndex = fontSizeValueToIndex(currentScale, strEntryValues); mValues = new float[strEntryValues.length]; for (int i = 0; i < strEntryValues.length; ++i) { mValues[i] = Float.parseFloat(strEntryValues[i]); Loading @@ -64,17 +65,12 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr } /** * Persists the selected font size and sends a configuration change. * Persists the selected font size. */ @Override protected void commit() { Configuration config = getContext().getResources().getConfiguration(); config.fontScale = mValues[mCurrentIndex]; try { ActivityManagerNative.getDefault().updatePersistentConfiguration(config); } catch (RemoteException e) { Log.w(LOG_TAG, "Unable to save font size setting"); } final ContentResolver resolver = getContext().getContentResolver(); Settings.System.putFloat(resolver, Settings.System.FONT_SCALE, mValues[mCurrentIndex]); } @Override Loading Loading
src/com/android/settings/Display.java +15 −22 Original line number Diff line number Diff line Loading @@ -17,12 +17,11 @@ package com.android.settings; import android.app.Activity; import android.app.ActivityManagerNative; import android.content.res.Configuration; import android.content.ContentResolver; import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Bundle; import android.os.RemoteException; import android.provider.Settings; import android.util.DisplayMetrics; import android.util.TypedValue; import android.view.View; Loading Loading @@ -80,14 +79,12 @@ public class Display extends Activity implements View.OnClickListener { @Override public void onResume() { super.onResume(); try { mCurConfig.updateFrom( ActivityManagerNative.getDefault().getConfiguration()); } catch (RemoteException e) { } if (mCurConfig.fontScale < 1) { final ContentResolver resolver = getContentResolver(); mFontScale = Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, 1.0f); if (mFontScale < 1) { mFontSize.setSelection(0); } else if (mCurConfig.fontScale > 1) { } else if (mFontScale > 1) { mFontSize.setSelection(2); } else { mFontSize.setSelection(1); Loading @@ -96,18 +93,14 @@ public class Display extends Activity implements View.OnClickListener { } private void updateFontScale() { mDisplayMetrics.scaledDensity = mDisplayMetrics.density * mCurConfig.fontScale; mDisplayMetrics.scaledDensity = mDisplayMetrics.density * mFontScale; float size = mTextSizeTyped.getDimension(mDisplayMetrics); mPreview.setTextSize(TypedValue.COMPLEX_UNIT_PX, size); } public void onClick(View v) { try { ActivityManagerNative.getDefault().updatePersistentConfiguration(mCurConfig); } catch (RemoteException e) { } final ContentResolver resolver = getContentResolver(); Settings.System.putFloat(resolver, Settings.System.FONT_SCALE, mFontScale); finish(); } Loading @@ -116,11 +109,11 @@ public class Display extends Activity implements View.OnClickListener { public void onItemSelected(android.widget.AdapterView av, View v, int position, long id) { if (position == 0) { mCurConfig.fontScale = .75f; mFontScale = .75f; } else if (position == 2) { mCurConfig.fontScale = 1.25f; mFontScale = 1.25f; } else { mCurConfig.fontScale = 1.0f; mFontScale = 1.0f; } updateFontScale(); Loading @@ -134,5 +127,5 @@ public class Display extends Activity implements View.OnClickListener { private TextView mPreview; private TypedValue mTextSizeTyped; private DisplayMetrics mDisplayMetrics; private Configuration mCurConfig = new Configuration(); private float mFontScale = 1.0f; }
src/com/android/settings/DisplaySettings.java +6 −5 Original line number Diff line number Diff line Loading @@ -88,8 +88,6 @@ public class DisplaySettings extends SettingsPreferenceFragment implements private Preference mFontSizePref; private final Configuration mCurConfig = new Configuration(); private RestrictedListPreference mScreenTimeoutPreference; private ListPreference mNightModePreference; private Preference mScreenSaverPreference; Loading Loading @@ -411,11 +409,14 @@ public class DisplaySettings extends SettingsPreferenceFragment implements } private void updateFontSizeSummary() { final Resources res = mFontSizePref.getContext().getResources(); final Context context = mFontSizePref.getContext(); final float currentScale = Settings.System.getFloat(context.getContentResolver(), Settings.System.FONT_SCALE, 1.0f); final Resources res = context.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); final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(currentScale, strEntryValues); mFontSizePref.setSummary(entries[index]); } Loading
src/com/android/settings/accessibility/AccessibilitySettings.java +4 −4 Original line number Diff line number Diff line Loading @@ -17,13 +17,11 @@ package com.android.settings.accessibility; import android.accessibilityservice.AccessibilityServiceInfo; import android.app.ActivityManagerNative; import android.app.admin.DevicePolicyManager; import android.content.ComponentName; import android.content.Context; import android.content.pm.PackageManager; import android.content.pm.ServiceInfo; import android.content.res.Configuration; import android.content.res.Resources; import android.net.Uri; import android.os.Bundle; Loading Loading @@ -624,11 +622,13 @@ public class AccessibilitySettings extends SettingsPreferenceFragment implements } private void updateFontSizeSummary(Preference pref) { final float currentScale = Settings.System.getFloat(getContext().getContentResolver(), Settings.System.FONT_SCALE, 1.0f); final Resources res = 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); final int index = ToggleFontSizePreferenceFragment.fontSizeValueToIndex(currentScale, strEntryValues); pref.setSummary(entries[index]); } Loading
src/com/android/settings/accessibility/ToggleFontSizePreferenceFragment.java +10 −14 Original line number Diff line number Diff line Loading @@ -21,12 +21,11 @@ import com.android.settings.R; import com.android.settings.PreviewSeekBarPreferenceFragment; import android.annotation.Nullable; import android.app.ActivityManagerNative; import android.content.ContentResolver; import android.content.res.Configuration; import android.content.res.Resources; import android.os.Bundle; import android.os.RemoteException; import android.util.Log; import android.provider.Settings; /** * Preference fragment used to control font size. Loading @@ -44,11 +43,13 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr mPreviewSampleResIds = new int[]{R.layout.font_size_preview}; Resources res = getContext().getResources(); final ContentResolver resolver = getContext().getContentResolver(); // Mark the appropriate item in the preferences list. final Configuration origConfig = res.getConfiguration(); mEntries = res.getStringArray(R.array.entries_font_size); final String[] strEntryValues = res.getStringArray(R.array.entryvalues_font_size); mInitialIndex = fontSizeValueToIndex(origConfig.fontScale, strEntryValues); final float currentScale = Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, 1.0f); mInitialIndex = fontSizeValueToIndex(currentScale, strEntryValues); mValues = new float[strEntryValues.length]; for (int i = 0; i < strEntryValues.length; ++i) { mValues[i] = Float.parseFloat(strEntryValues[i]); Loading @@ -64,17 +65,12 @@ public class ToggleFontSizePreferenceFragment extends PreviewSeekBarPreferenceFr } /** * Persists the selected font size and sends a configuration change. * Persists the selected font size. */ @Override protected void commit() { Configuration config = getContext().getResources().getConfiguration(); config.fontScale = mValues[mCurrentIndex]; try { ActivityManagerNative.getDefault().updatePersistentConfiguration(config); } catch (RemoteException e) { Log.w(LOG_TAG, "Unable to save font size setting"); } final ContentResolver resolver = getContext().getContentResolver(); Settings.System.putFloat(resolver, Settings.System.FONT_SCALE, mValues[mCurrentIndex]); } @Override Loading