diff options
author | Yvonne Wong <ywong@cyngn.com> | 2015-12-01 17:04:07 -0800 |
---|---|---|
committer | Yvonne Wong <ywong@cyngn.com> | 2015-12-03 02:05:08 -0800 |
commit | 4cc0018c15a8cf2ab58f00929de6a5bd034ddb86 (patch) | |
tree | e3c93e83b158855fcb86259a7b489916702ed070 /src/com/android/launcher3/InvariantDeviceProfile.java | |
parent | 95dfdf845c3accc749609d8b955d55fc8df5adf1 (diff) | |
download | android_packages_apps_Trebuchet-4cc0018c15a8cf2ab58f00929de6a5bd034ddb86.tar.gz android_packages_apps_Trebuchet-4cc0018c15a8cf2ab58f00929de6a5bd034ddb86.tar.bz2 android_packages_apps_Trebuchet-4cc0018c15a8cf2ab58f00929de6a5bd034ddb86.zip |
Reimplement CM Settings Overview Panel Part 3
- Enable dynamic grid resizing
Change-Id: I95a7f20da48e037a94ce5b6191c5597490d91d9d
Diffstat (limited to 'src/com/android/launcher3/InvariantDeviceProfile.java')
-rw-r--r-- | src/com/android/launcher3/InvariantDeviceProfile.java | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/src/com/android/launcher3/InvariantDeviceProfile.java b/src/com/android/launcher3/InvariantDeviceProfile.java index 6d4d95292..a03cc31f2 100644 --- a/src/com/android/launcher3/InvariantDeviceProfile.java +++ b/src/com/android/launcher3/InvariantDeviceProfile.java @@ -33,6 +33,38 @@ import java.util.Comparator; public class InvariantDeviceProfile { + public enum GridSize { + Comfortable(0), + Cozy(1), + Condensed(2), + Custom(3); + + private final int mValue; + GridSize(int value) { + mValue = value; + } + + public int getValue() { + return mValue; + } + + public static GridSize getModeForValue(int value) { + switch (value) { + case 1: + return Cozy; + case 2: + return Condensed; + case 3: + return Custom; + default : + return Comfortable; + } + } + } + + public final static int GRID_SIZE_MAX = 3; + public final static int GRID_SIZE_MIN = 2; + // 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; @@ -56,6 +88,8 @@ public class InvariantDeviceProfile { */ public int numRows; public int numColumns; + public int numRowsBase; + public int numColumnsBase; /** * The minimum number of predicted apps in all apps. @@ -148,6 +182,29 @@ public class InvariantDeviceProfile { numFolderColumns = closestProfile.numFolderColumns; minAllAppsPredictionColumns = closestProfile.minAllAppsPredictionColumns; + numRowsBase = numRows; + int gridResize = SettingsProvider.getIntCustomDefault(context, + SettingsProvider.SETTINGS_UI_DYNAMIC_GRID_SIZE, 0); + if (GridSize.getModeForValue(gridResize) != GridSize.Custom) { + numRows += gridResize; + } else { + int iTempNumberOfRows = SettingsProvider.getIntCustomDefault(context, + SettingsProvider.SETTINGS_UI_HOMESCREEN_ROWS, numRows); + if (iTempNumberOfRows > 0) { + numRows = iTempNumberOfRows; + } + } + numColumnsBase = numColumns; + if (GridSize.getModeForValue(gridResize) != GridSize.Custom) { + numColumns += gridResize; + } else { + int iTempNumberOfColumns = SettingsProvider.getIntCustomDefault(context, + SettingsProvider.SETTINGS_UI_HOMESCREEN_COLUMNS, numColumns); + if (iTempNumberOfColumns > 0) { + numColumns = iTempNumberOfColumns; + } + } + iconSize = interpolatedDeviceProfileOut.iconSize; iconBitmapSize = Utilities.pxFromDp(iconSize, dm); iconTextSize = interpolatedDeviceProfileOut.iconTextSize; |