diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2016-09-14 11:26:21 -0700 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2016-09-16 12:05:02 -0700 |
commit | baec6ffae2c260180dbdf2c6b2ca2f38e1df8f1a (patch) | |
tree | 1f7308d88cdb308df0452b241dfe27927d5c767d | |
parent | f595f3de0fb166f5b4d43f885b63dccaaa9efd5b (diff) | |
download | android_packages_apps_Trebuchet-baec6ffae2c260180dbdf2c6b2ca2f38e1df8f1a.tar.gz android_packages_apps_Trebuchet-baec6ffae2c260180dbdf2c6b2ca2f38e1df8f1a.tar.bz2 android_packages_apps_Trebuchet-baec6ffae2c260180dbdf2c6b2ca2f38e1df8f1a.zip |
Updating the paddings in folder cell
> Updating overall padding for the cell and adding drawable padding
> Ensuring that the folder cell is always rendered properly based
on available vertical space
Bug: 30605958
Change-Id: I8ceb9fea5a25052b0d7461f52edca0e6a33fa085
-rw-r--r-- | res/layout/user_folder.xml | 13 | ||||
-rw-r--r-- | res/layout/user_folder_icon_normalized.xml | 16 | ||||
-rw-r--r-- | res/values/attrs.xml | 3 | ||||
-rw-r--r-- | res/values/dimens.xml | 6 | ||||
-rw-r--r-- | res/values/styles.xml | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 34 | ||||
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 4 |
8 files changed, 52 insertions, 32 deletions
diff --git a/res/layout/user_folder.xml b/res/layout/user_folder.xml index d95075058..50bd89699 100644 --- a/res/layout/user_folder.xml +++ b/res/layout/user_folder.xml @@ -28,7 +28,7 @@ android:layout_height="match_parent" android:paddingLeft="4dp" android:paddingRight="4dp" - android:paddingTop="8dp" + android:paddingTop="4dp" launcher:pageIndicator="@+id/folder_page_indicator" /> <LinearLayout @@ -37,8 +37,8 @@ android:layout_height="wrap_content" android:clipChildren="false" android:orientation="horizontal" - android:paddingLeft="8dp" - android:paddingRight="8dp" > + android:paddingLeft="12dp" + android:paddingRight="12dp" > <com.android.launcher3.ExtendedEditText android:id="@+id/folder_name" @@ -51,13 +51,14 @@ android:gravity="center_horizontal" android:hint="@string/folder_hint_text" android:imeOptions="flagNoExtractUi" - android:paddingBottom="8dp" - android:paddingTop="4dp" + android:paddingBottom="@dimen/folder_label_padding" + android:paddingTop="@dimen/folder_label_padding" android:singleLine="true" android:textColor="#ff777777" + android:includeFontPadding="false" android:textColorHighlight="#ffCCCCCC" android:textColorHint="#ff808080" - android:textSize="14sp" /> + android:textSize="@dimen/folder_label_text_size" /> <com.android.launcher3.pageindicators.PageIndicatorDots android:id="@+id/folder_page_indicator" diff --git a/res/layout/user_folder_icon_normalized.xml b/res/layout/user_folder_icon_normalized.xml index bb6bd765b..16e618a80 100644 --- a/res/layout/user_folder_icon_normalized.xml +++ b/res/layout/user_folder_icon_normalized.xml @@ -26,9 +26,9 @@ android:id="@+id/folder_content" android:layout_width="match_parent" android:layout_height="match_parent" - android:paddingLeft="8dp" - android:paddingRight="8dp" - android:paddingTop="8dp" + android:paddingLeft="4dp" + android:paddingRight="4dp" + android:paddingTop="4dp" launcher:pageIndicator="@+id/folder_page_indicator" /> <LinearLayout @@ -37,8 +37,8 @@ android:layout_height="wrap_content" android:clipChildren="false" android:orientation="horizontal" - android:paddingLeft="8dp" - android:paddingRight="8dp" > + android:paddingLeft="12dp" + android:paddingRight="12dp" > <com.android.launcher3.ExtendedEditText android:id="@+id/folder_name" @@ -52,13 +52,13 @@ android:gravity="center_horizontal" android:hint="@string/folder_hint_text" android:imeOptions="flagNoExtractUi" - android:paddingBottom="12dp" - android:paddingTop="4dp" + android:paddingBottom="@dimen/folder_label_padding" + android:paddingTop="@dimen/folder_label_padding" android:singleLine="true" android:textColor="#EE777777" android:textColorHighlight="#ffCCCCCC" android:textColorHint="#ff808080" - android:textSize="14sp" /> + android:textSize="@dimen/folder_label_text_size" /> <com.android.launcher3.pageindicators.PageIndicatorDots android:id="@+id/folder_page_indicator" diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 3cfaf02d0..3423835a9 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -25,7 +25,8 @@ <attr name="iconDisplay" format="integer"> <enum name="workspace" value="0" /> <enum name="all_apps" value="1" /> - <enum name="widget_section" value="2" /> + <enum name="folder" value="2" /> + <enum name="widget_section" value="3" /> </attr> <attr name="deferShadowGeneration" format="boolean" /> <attr name="customShadows" format="boolean" /> diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 1ae468557..33466a813 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -137,6 +137,12 @@ <dimen name="folder_preview_padding">6dp</dimen> <dimen name="page_indicator_dot_size">8dp</dimen> + <dimen name="folder_cell_x_padding">9dp</dimen> + <dimen name="folder_cell_y_padding">8dp</dimen> + <dimen name="folder_child_text_size">13sp</dimen> + <dimen name="folder_label_padding">12dp</dimen> + <dimen name="folder_label_text_size">14sp</dimen> + <!-- Sizes for managed profile badges --> <dimen name="profile_badge_size">24dp</dimen> <dimen name="profile_badge_margin">5dp</dimen> diff --git a/res/values/styles.xml b/res/values/styles.xml index f0297654b..ecc11b0ee 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -74,7 +74,11 @@ <item name="android:background">@null</item> <item name="android:textColor">@color/quantum_panel_text_color</item> <item name="android:shadowRadius">0</item> + <item name="android:textSize">@dimen/folder_child_text_size</item> + <item name="android:gravity">center</item> + <item name="android:includeFontPadding">false</item> <item name="customShadows">false</item> + <item name="iconDisplay">folder</item> </style> <style name="Icon.DeepShortcut"> diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 33b3ad347..a294fa538 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -65,6 +65,7 @@ public class BubbleTextView extends TextView private static final int DISPLAY_WORKSPACE = 0; private static final int DISPLAY_ALL_APPS = 1; + private static final int DISPLAY_FOLDER = 2; private final Launcher mLauncher; private Drawable mIcon; @@ -125,12 +126,13 @@ public class BubbleTextView extends TextView setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx); setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx); defaultIconSize = grid.allAppsIconSizePx; + } else if (display == DISPLAY_FOLDER) { + setCompoundDrawablePadding(grid.folderChildDrawablePaddingPx); } mCenterVertically = a.getBoolean(R.styleable.BubbleTextView_centerVertically, false); mIconSize = a.getDimensionPixelSize(R.styleable.BubbleTextView_iconSizeOverride, defaultIconSize); - a.recycle(); if (mCustomShadowsEnabled) { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index c9fd85a16..c4e6ed119 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -20,8 +20,6 @@ import android.appwidget.AppWidgetHostView; import android.content.ComponentName; import android.content.Context; import android.content.res.Resources; -import android.graphics.Paint; -import android.graphics.Paint.FontMetrics; import android.graphics.Point; import android.graphics.Rect; import android.util.DisplayMetrics; @@ -100,6 +98,7 @@ public class DeviceProfile { public int folderIconPreviewPadding; public int folderCellWidthPx; public int folderCellHeightPx; + public int folderChildDrawablePaddingPx; // Hotseat public int hotseatCellWidthPx; @@ -255,12 +254,9 @@ public class DeviceProfile { allAppsIconDrawablePaddingPx = iconDrawablePaddingPx; allAppsIconTextSizePx = iconTextSizePx; - // Calculate the actual text height - Paint textPaint = new Paint(); - textPaint.setTextSize(iconTextSizePx); - FontMetrics fm = textPaint.getFontMetrics(); cellWidthPx = iconSizePx; - cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); + cellHeightPx = iconSizePx + iconDrawablePaddingPx + + Utilities.calculateTextHeight(iconTextSizePx); final float scaleDps = !FeatureFlags.LAUNCHER3_LEGACY_WORKSPACE_DND ? 0f : res.getDimensionPixelSize(R.dimen.dragViewScale); dragViewScale = (iconSizePx + scaleDps) / iconSizePx; @@ -281,12 +277,25 @@ public class DeviceProfile { res.getInteger(R.integer.config_workspaceSpringLoadShrinkPercentage) / 100.0f; } - // Folder - int folderCellPadding = isTablet || isLandscape ? 6 * edgeMarginPx : 3 * edgeMarginPx; + // Folder cell + int cellPaddingX = res.getDimensionPixelSize(R.dimen.folder_cell_x_padding); + int cellPaddingY = res.getDimensionPixelSize(R.dimen.folder_cell_y_padding); + final int folderChildTextSize = + Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_child_text_size)); + + final int folderBottomPanelSize = + 2 * res.getDimensionPixelSize(R.dimen.folder_label_padding) + + Utilities.calculateTextHeight(res.getDimension(R.dimen.folder_label_text_size)); + // Don't let the folder get too close to the edges of the screen. - folderCellWidthPx = Math.min(cellWidthPx + folderCellPadding, + folderCellWidthPx = Math.min(iconSizePx + 2 * cellPaddingX, (availableWidthPx - 4 * edgeMarginPx) / inv.numFolderColumns); - folderCellHeightPx = cellHeightPx + edgeMarginPx; + folderCellHeightPx = Math.min(iconSizePx + 3 * cellPaddingY + folderChildTextSize, + (availableHeightPx - 4 * edgeMarginPx - folderBottomPanelSize) / inv.numFolderRows); + folderChildDrawablePaddingPx = Math.max(0, + (folderCellHeightPx - iconSizePx - folderChildTextSize) / 3); + + // Folder icon folderBackgroundOffset = -edgeMarginPx; folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset; folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding); @@ -296,9 +305,6 @@ public class DeviceProfile { mInsets.set(insets); } - /** - * @param recyclerViewWidth the available width of the AllAppsRecyclerView - */ public void updateAppsViewNumCols() { allAppsNumCols = allAppsNumPredictiveCols = inv.numColumns; } diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index e34f509da..b0e096a2e 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -686,11 +686,11 @@ public final class Utilities { /** * Calculates the height of a given string at a specific text size. */ - public static float calculateTextHeight(float textSizePx) { + public static int calculateTextHeight(float textSizePx) { Paint p = new Paint(); p.setTextSize(textSizePx); Paint.FontMetrics fm = p.getFontMetrics(); - return -fm.top + fm.bottom; + return (int) Math.ceil(fm.bottom - fm.top); } /** |