From 4ae96ce92df7aad3c767c68b8795b80734e01829 Mon Sep 17 00:00:00 2001 From: Adam Cohen Date: Fri, 29 Aug 2014 15:05:48 -0700 Subject: 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 --- src/com/android/launcher3/DeviceProfile.java | 56 ++++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 7 deletions(-) (limited to 'src/com/android/launcher3/DeviceProfile.java') 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 mCallbacks = new ArrayList(); 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 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,12 +247,42 @@ 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); computeAllAppsButtonSize(context); } + /** + * 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, -- cgit v1.2.3