summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/DeviceProfile.java
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2014-08-29 15:05:48 -0700
committerAdam Cohen <adamcohen@google.com>2014-09-04 15:12:55 +0000
commit4ae96ce92df7aad3c767c68b8795b80734e01829 (patch)
tree05dfbd6b6aa3dc14e39986807eca46859e203cc9 /src/com/android/launcher3/DeviceProfile.java
parent6a2c77856f1cfa402363cfbb04b5718b431bbc6e (diff)
downloadandroid_packages_apps_Trebuchet-4ae96ce92df7aad3c767c68b8795b80734e01829.tar.gz
android_packages_apps_Trebuchet-4ae96ce92df7aad3c767c68b8795b80734e01829.tar.bz2
android_packages_apps_Trebuchet-4ae96ce92df7aad3c767c68b8795b80734e01829.zip
Add ability for Partner customization apk to override certain DeviceProfile params
-> Workspace row / col counts -> All apps row / col counts -> Workspace icon size issue 17208277 Change-Id: I25cfafede4da783083593b9bfeff4e5ba7751d36
Diffstat (limited to 'src/com/android/launcher3/DeviceProfile.java')
-rw-r--r--src/com/android/launcher3/DeviceProfile.java56
1 files changed, 49 insertions, 7 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java
index 8af2a7fbb..daf5556d4 100644
--- a/src/com/android/launcher3/DeviceProfile.java
+++ b/src/com/android/launcher3/DeviceProfile.java
@@ -69,7 +69,7 @@ public class DeviceProfile {
float numRows;
float numColumns;
float numHotseatIcons;
- private float iconSize;
+ float iconSize;
private float iconTextSize;
private int iconDrawablePaddingOriginalPx;
private float hotseatIconSize;
@@ -130,6 +130,9 @@ public class DeviceProfile {
float dragViewScale;
+ int allAppsShortEdgeCount = -1;
+ int allAppsLongEdgeCount = -1;
+
private ArrayList<DeviceProfileCallbacks> mCallbacks = new ArrayList<DeviceProfileCallbacks>();
DeviceProfile(String n, float w, float h, float r, float c,
@@ -152,6 +155,9 @@ public class DeviceProfile {
defaultNoAllAppsLayoutId = dnalId;
}
+ DeviceProfile() {
+ }
+
DeviceProfile(Context context,
ArrayList<DeviceProfile> profiles,
float minWidth, float minHeight,
@@ -218,6 +224,7 @@ public class DeviceProfile {
points.add(new DeviceProfileQuery(p, p.iconSize));
}
iconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
+
// AllApps uses the original non-scaled icon size
allAppsIconSizePx = DynamicGrid.pxFromDp(iconSize, dm);
@@ -240,6 +247,9 @@ public class DeviceProfile {
// Hotseat
hotseatIconSize = invDistWeightedInterpolate(minWidth, minHeight, points);
+ // If the partner customization apk contains any grid overrides, apply them
+ applyPartnerDeviceProfileOverrides(context, dm);
+
// Calculate the remaining vars
updateFromConfiguration(context, res, wPx, hPx, awPx, ahPx);
updateAvailableDimensions(context);
@@ -247,6 +257,33 @@ public class DeviceProfile {
}
/**
+ * Apply any Partner customization grid overrides.
+ *
+ * Currently we support: all apps row / column count.
+ */
+ private void applyPartnerDeviceProfileOverrides(Context ctx, DisplayMetrics dm) {
+ Partner p = Partner.get(ctx.getPackageManager());
+ if (p != null) {
+ DeviceProfile partnerDp = p.getDeviceProfileOverride(dm);
+ if (partnerDp != null) {
+ if (partnerDp.numRows > 0 && partnerDp.numColumns > 0) {
+ numRows = partnerDp.numRows;
+ numColumns = partnerDp.numColumns;
+ }
+ if (partnerDp.allAppsShortEdgeCount > 0 && partnerDp.allAppsLongEdgeCount > 0) {
+ allAppsShortEdgeCount = partnerDp.allAppsShortEdgeCount;
+ allAppsLongEdgeCount = partnerDp.allAppsLongEdgeCount;
+ }
+ if (partnerDp.iconSize > 0) {
+ iconSize = partnerDp.iconSize;
+ // AllApps uses the original non-scaled icon size
+ allAppsIconSizePx = DynamicGrid.pxFromDp(iconSize, dm);
+ }
+ }
+ }
+ }
+
+ /**
* Determine the exact visual footprint of the all apps button, taking into account scaling
* and internal padding of the drawable.
*/
@@ -380,12 +417,17 @@ public class DeviceProfile {
int maxRows = (isLandscape ? maxShortEdgeCellCount : maxLongEdgeCellCount);
int maxCols = (isLandscape ? maxLongEdgeCellCount : maxShortEdgeCellCount);
- allAppsNumRows = (availableHeightPx - pageIndicatorHeightPx) /
- (allAppsCellHeightPx + allAppsCellPaddingPx);
- allAppsNumRows = Math.max(minEdgeCellCount, Math.min(maxRows, allAppsNumRows));
- allAppsNumCols = (availableWidthPx) /
- (allAppsCellWidthPx + allAppsCellPaddingPx);
- allAppsNumCols = Math.max(minEdgeCellCount, Math.min(maxCols, allAppsNumCols));
+ if (allAppsShortEdgeCount > 0 && allAppsLongEdgeCount > 0) {
+ allAppsNumRows = isLandscape ? allAppsShortEdgeCount : allAppsLongEdgeCount;
+ allAppsNumCols = isLandscape ? allAppsLongEdgeCount : allAppsShortEdgeCount;
+ } else {
+ allAppsNumRows = (availableHeightPx - pageIndicatorHeightPx) /
+ (allAppsCellHeightPx + allAppsCellPaddingPx);
+ allAppsNumRows = Math.max(minEdgeCellCount, Math.min(maxRows, allAppsNumRows));
+ allAppsNumCols = (availableWidthPx) /
+ (allAppsCellWidthPx + allAppsCellPaddingPx);
+ allAppsNumCols = Math.max(minEdgeCellCount, Math.min(maxCols, allAppsNumCols));
+ }
}
void updateFromConfiguration(Context context, Resources resources, int wPx, int hPx,