Change Display size option "normal" to "default"
Bug: 27274227 Change-Id: I83b949cabaf333aa45cfef1beaa986d66067fa53
This commit is contained in:
@@ -6900,7 +6900,7 @@
|
||||
<!-- Description for the screen zoom level that makes interface elements small. [CHAR LIMIT=24] -->
|
||||
<string name="screen_zoom_summary_small">Small</string>
|
||||
<!-- Description for the device's default screen zoom level. [CHAR LIMIT=24] -->
|
||||
<string name="screen_zoom_summary_normal">Normal</string>
|
||||
<string name="screen_zoom_summary_default">Default</string>
|
||||
<!-- Description for the screen zoom level that makes interface elements large. [CHAR LIMIT=24] -->
|
||||
<string name="screen_zoom_summary_large">Large</string>
|
||||
<!-- Description for the screen zoom level that makes interface elements larger. [CHAR LIMIT=24] -->
|
||||
|
@@ -46,14 +46,14 @@ class DisplayDensityUtils {
|
||||
/** Maximum density scale. The actual scale used depends on the device. */
|
||||
private static final float MAX_SCALE = 1.50f;
|
||||
|
||||
/** Summary used for "normal" scale. */
|
||||
private static final int SUMMARY_NORMAL = R.string.screen_zoom_summary_normal;
|
||||
/** Summary used for "default" scale. */
|
||||
private static final int SUMMARY_DEFAULT = R.string.screen_zoom_summary_default;
|
||||
|
||||
/** Summary used for "custom" scale. */
|
||||
private static final int SUMMARY_CUSTOM = R.string.screen_zoom_summary_custom;
|
||||
|
||||
/**
|
||||
* Summaries for scales smaller than "normal" in order of smallest to
|
||||
* Summaries for scales smaller than "default" in order of smallest to
|
||||
* largest.
|
||||
*/
|
||||
private static final int[] SUMMARIES_SMALLER = new int[] {
|
||||
@@ -61,7 +61,7 @@ class DisplayDensityUtils {
|
||||
};
|
||||
|
||||
/**
|
||||
* Summaries for scales larger than "normal" in order of smallest to
|
||||
* Summaries for scales larger than "default" in order of smallest to
|
||||
* largest.
|
||||
*/
|
||||
private static final int[] SUMMARIES_LARGER = new int[] {
|
||||
@@ -80,16 +80,16 @@ class DisplayDensityUtils {
|
||||
private final String[] mEntries;
|
||||
private final int[] mValues;
|
||||
|
||||
private final int mNormalDensity;
|
||||
private final int mDefaultDensity;
|
||||
private final int mCurrentIndex;
|
||||
|
||||
public DisplayDensityUtils(Context context) {
|
||||
final int normalDensity = DisplayDensityUtils.getNormalDisplayDensity(
|
||||
final int defaultDensity = DisplayDensityUtils.getDefaultDisplayDensity(
|
||||
Display.DEFAULT_DISPLAY);
|
||||
if (normalDensity <= 0) {
|
||||
if (defaultDensity <= 0) {
|
||||
mEntries = null;
|
||||
mValues = null;
|
||||
mNormalDensity = 0;
|
||||
mDefaultDensity = 0;
|
||||
mCurrentIndex = -1;
|
||||
return;
|
||||
}
|
||||
@@ -102,7 +102,7 @@ class DisplayDensityUtils {
|
||||
// Compute number of "larger" and "smaller" scales for this display.
|
||||
final int minDimensionPx = Math.min(metrics.widthPixels, metrics.heightPixels);
|
||||
final int maxDensity = DisplayMetrics.DENSITY_MEDIUM * minDimensionPx / MIN_DIMENSION_DP;
|
||||
final float maxScale = Math.min(MAX_SCALE, maxDensity / (float) normalDensity);
|
||||
final float maxScale = Math.min(MAX_SCALE, maxDensity / (float) defaultDensity);
|
||||
final float minScale = MIN_SCALE;
|
||||
final int numLarger = (int) MathUtils.constrain((maxScale - 1) / MIN_SCALE_INTERVAL,
|
||||
0, SUMMARIES_LARGER.length);
|
||||
@@ -117,7 +117,7 @@ class DisplayDensityUtils {
|
||||
final float interval = (1 - minScale) / numSmaller;
|
||||
for (int i = numSmaller - 1; i >= 0; i--) {
|
||||
// Round down to a multiple of 2 by truncating the low bit.
|
||||
final int density = ((int) (normalDensity * (1 - (i + 1) * interval))) & ~1;
|
||||
final int density = ((int) (defaultDensity * (1 - (i + 1) * interval))) & ~1;
|
||||
if (currentDensity == density) {
|
||||
currentDensityIndex = curIndex;
|
||||
}
|
||||
@@ -127,18 +127,18 @@ class DisplayDensityUtils {
|
||||
}
|
||||
}
|
||||
|
||||
if (currentDensity == normalDensity) {
|
||||
if (currentDensity == defaultDensity) {
|
||||
currentDensityIndex = curIndex;
|
||||
}
|
||||
values[curIndex] = normalDensity;
|
||||
entries[curIndex] = res.getString(SUMMARY_NORMAL);
|
||||
values[curIndex] = defaultDensity;
|
||||
entries[curIndex] = res.getString(SUMMARY_DEFAULT);
|
||||
curIndex++;
|
||||
|
||||
if (numLarger > 0) {
|
||||
final float interval = (maxScale - 1) / numLarger;
|
||||
for (int i = 0; i < numLarger; i++) {
|
||||
// Round down to a multiple of 2 by truncating the low bit.
|
||||
final int density = ((int) (normalDensity * (1 + (i + 1) * interval))) & ~1;
|
||||
final int density = ((int) (defaultDensity * (1 + (i + 1) * interval))) & ~1;
|
||||
if (currentDensity == density) {
|
||||
currentDensityIndex = curIndex;
|
||||
}
|
||||
@@ -163,7 +163,7 @@ class DisplayDensityUtils {
|
||||
displayIndex = curIndex;
|
||||
}
|
||||
|
||||
mNormalDensity = normalDensity;
|
||||
mDefaultDensity = defaultDensity;
|
||||
mCurrentIndex = displayIndex;
|
||||
mEntries = entries;
|
||||
mValues = values;
|
||||
@@ -181,18 +181,18 @@ class DisplayDensityUtils {
|
||||
return mCurrentIndex;
|
||||
}
|
||||
|
||||
public int getNormalDensity() {
|
||||
return mNormalDensity;
|
||||
public int getDefaultDensity() {
|
||||
return mDefaultDensity;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the normal (default) density for the specified display.
|
||||
* Returns the default density for the specified display.
|
||||
*
|
||||
* @param displayId the identifier of the display
|
||||
* @return the normal density of the specified display, or {@code -1} if
|
||||
* @return the default density of the specified display, or {@code -1} if
|
||||
* the display does not exist or the density could not be obtained
|
||||
*/
|
||||
private static int getNormalDisplayDensity(int displayId) {
|
||||
private static int getDefaultDisplayDensity(int displayId) {
|
||||
try {
|
||||
final IWindowManager wm = WindowManagerGlobal.getWindowManagerService();
|
||||
return wm.getInitialDisplayDensity(displayId);
|
||||
|
@@ -38,7 +38,7 @@ import java.util.List;
|
||||
*/
|
||||
public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment implements Indexable {
|
||||
|
||||
private int mNormalDensity;
|
||||
private int mDefaultDensity;
|
||||
private int[] mValues;
|
||||
|
||||
@Override
|
||||
@@ -56,19 +56,19 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
|
||||
final int initialIndex = density.getCurrentIndex();
|
||||
if (initialIndex < 0) {
|
||||
// Failed to obtain normal density, which means we failed to
|
||||
// Failed to obtain default density, which means we failed to
|
||||
// connect to the window manager service. Just use the current
|
||||
// density and don't let the user change anything.
|
||||
final int densityDpi = getResources().getDisplayMetrics().densityDpi;
|
||||
mValues = new int[] { densityDpi };
|
||||
mEntries = new String[] { getString(R.string.screen_zoom_summary_normal) };
|
||||
mEntries = new String[] { getString(R.string.screen_zoom_summary_default) };
|
||||
mInitialIndex = 0;
|
||||
mNormalDensity = densityDpi;
|
||||
mDefaultDensity = densityDpi;
|
||||
} else {
|
||||
mValues = density.getValues();
|
||||
mEntries = density.getEntries();
|
||||
mInitialIndex = initialIndex;
|
||||
mNormalDensity = density.getNormalDensity();
|
||||
mDefaultDensity = density.getDefaultDensity();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ public class ScreenZoomSettings extends PreviewSeekBarPreferenceFragment impleme
|
||||
@Override
|
||||
protected void commit() {
|
||||
final int densityDpi = mValues[mCurrentIndex];
|
||||
if (densityDpi == mNormalDensity) {
|
||||
if (densityDpi == mDefaultDensity) {
|
||||
DisplayDensityUtils.clearForcedDisplayDensity(Display.DEFAULT_DISPLAY);
|
||||
} else {
|
||||
DisplayDensityUtils.setForcedDisplayDensity(Display.DEFAULT_DISPLAY, densityDpi);
|
||||
|
Reference in New Issue
Block a user