Merge "Make display density min/max scale an overridable resource."
This commit is contained in:
committed by
Android (Google) Code Review
commit
57a6df4724
@@ -110,4 +110,10 @@
|
||||
|
||||
<dimen name="avatar_picker_icon_inset">25dp</dimen>
|
||||
|
||||
<!-- Minimum increment between density scales. -->
|
||||
<fraction name="display_density_min_scale_interval">9%</fraction>
|
||||
<!-- Maximum density scale. The actual scale used depends on the device. -->
|
||||
<fraction name="display_density_max_scale">150%</fraction>
|
||||
<!-- Minimum density scale. This is available on all devices. -->
|
||||
<fraction name="display_density_min_scale">85%</fraction>
|
||||
</resources>
|
||||
|
||||
@@ -38,15 +38,6 @@ import java.util.Arrays;
|
||||
public class DisplayDensityUtils {
|
||||
private static final String LOG_TAG = "DisplayDensityUtils";
|
||||
|
||||
/** Minimum increment between density scales. */
|
||||
private static final float MIN_SCALE_INTERVAL = 0.09f;
|
||||
|
||||
/** Minimum density scale. This is available on all devices. */
|
||||
private static final float MIN_SCALE = 0.85f;
|
||||
|
||||
/** Maximum density scale. The actual scale used depends on the device. */
|
||||
private static final float MAX_SCALE = 1.50f;
|
||||
|
||||
/** Summary used for "default" scale. */
|
||||
public static final int SUMMARY_DEFAULT = R.string.screen_zoom_summary_default;
|
||||
|
||||
@@ -105,11 +96,16 @@ public 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) defaultDensity);
|
||||
final float minScale = MIN_SCALE;
|
||||
final int numLarger = (int) MathUtils.constrain((maxScale - 1) / MIN_SCALE_INTERVAL,
|
||||
final float maxScaleDimen = context.getResources().getFraction(
|
||||
R.fraction.display_density_max_scale, 1, 1);
|
||||
final float maxScale = Math.min(maxScaleDimen, maxDensity / (float) defaultDensity);
|
||||
final float minScale = context.getResources().getFraction(
|
||||
R.fraction.display_density_min_scale, 1, 1);
|
||||
final float minScaleInterval = context.getResources().getFraction(
|
||||
R.fraction.display_density_min_scale_interval, 1, 1);
|
||||
final int numLarger = (int) MathUtils.constrain((maxScale - 1) / minScaleInterval,
|
||||
0, SUMMARIES_LARGER.length);
|
||||
final int numSmaller = (int) MathUtils.constrain((1 - minScale) / MIN_SCALE_INTERVAL,
|
||||
final int numSmaller = (int) MathUtils.constrain((1 - minScale) / minScaleInterval,
|
||||
0, SUMMARIES_SMALLER.length);
|
||||
|
||||
String[] entries = new String[1 + numSmaller + numLarger];
|
||||
|
||||
Reference in New Issue
Block a user