summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/InvariantDeviceProfile.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-05-22 12:25:45 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-06-03 19:07:44 -0700
commit53d7ee4285842732517edcccbdcaa92dccb1e107 (patch)
tree95f5a6520d621ab43c122ed37b7d12f45633b41e /src/com/android/launcher3/InvariantDeviceProfile.java
parentf4fe7fc5449bbfcfa7e95c7f9040c81d833a1fdb (diff)
downloadandroid_packages_apps_Trebuchet-53d7ee4285842732517edcccbdcaa92dccb1e107.tar.gz
android_packages_apps_Trebuchet-53d7ee4285842732517edcccbdcaa92dccb1e107.tar.bz2
android_packages_apps_Trebuchet-53d7ee4285842732517edcccbdcaa92dccb1e107.zip
Fixing different bitmap sizes in different orientations
> Using a single bitmap icon size > Picking up appropriate density for satisfy the required icon size > Fixing some icon size assumptions during icon animations Bug: 19514688 Change-Id: Ia7a1d0d2c03a9d39ccc241fa4ae3eb8a0f374585
Diffstat (limited to 'src/com/android/launcher3/InvariantDeviceProfile.java')
-rw-r--r--src/com/android/launcher3/InvariantDeviceProfile.java29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java
index 7f34593a9..fcaf834a2 100644
--- a/src/com/android/launcher3/InvariantDeviceProfile.java
+++ b/src/com/android/launcher3/InvariantDeviceProfile.java
@@ -35,6 +35,8 @@ public class InvariantDeviceProfile {
// This is a static that we use for the default icon size on a 4/5-inch phone
private static float DEFAULT_ICON_SIZE_DP = 60;
+ private static final float ICON_SIZE_DEFINED_IN_APP_DP = 48;
+
// Constants that affects the interpolation curve between statically defined device profile
// buckets.
private static float KNEARESTNEIGHBOR = 3;
@@ -60,6 +62,8 @@ public class InvariantDeviceProfile {
public int numFolderRows;
public int numFolderColumns;
float iconSize;
+ int iconBitmapSize;
+ int fillResIconDpi;
float iconTextSize;
/**
@@ -135,8 +139,10 @@ public class InvariantDeviceProfile {
numFolderColumns = closestProfile.numFolderColumns;
iconSize = interpolatedDeviceProfileOut.iconSize;
+ iconBitmapSize = Utilities.pxFromDp(iconSize, dm);
iconTextSize = interpolatedDeviceProfileOut.iconTextSize;
hotseatIconSize = interpolatedDeviceProfileOut.hotseatIconSize;
+ fillResIconDpi = getLauncherIconDensity(iconBitmapSize);
// If the partner customization apk contains any grid overrides, apply them
// Supported overrides: numRows, numColumns, iconSize
@@ -187,6 +193,29 @@ public class InvariantDeviceProfile {
return predefinedDeviceProfiles;
}
+ private int getLauncherIconDensity(int requiredSize) {
+ // Densities typically defined by an app.
+ int[] densityBuckets = new int[] {
+ DisplayMetrics.DENSITY_LOW,
+ DisplayMetrics.DENSITY_MEDIUM,
+ DisplayMetrics.DENSITY_TV,
+ DisplayMetrics.DENSITY_HIGH,
+ DisplayMetrics.DENSITY_XHIGH,
+ DisplayMetrics.DENSITY_XXHIGH,
+ DisplayMetrics.DENSITY_XXXHIGH
+ };
+
+ int density = DisplayMetrics.DENSITY_XXXHIGH;
+ for (int i = densityBuckets.length - 1; i >= 0; i--) {
+ float expectedSize = ICON_SIZE_DEFINED_IN_APP_DP * densityBuckets[i]
+ / DisplayMetrics.DENSITY_DEFAULT;
+ if (expectedSize >= requiredSize) {
+ density = densityBuckets[i];
+ }
+ }
+
+ return density;
+ }
/**
* Apply any Partner customization grid overrides.