From 0966072c91340990d61dfb29d31f7f19d7936f8f Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Wed, 14 Jun 2017 14:20:14 -0700 Subject: [PATCH] Portrait grid changes for Workspace/All Apps. Bug: 37015359 Change-Id: Ifbdd0e71c36e532b189e02283e3eeb562ebe2654 --- res/layout/all_apps_icon.xml | 5 ++-- res/layout/page_indicator.xml | 2 +- res/layout/qsb_default_view.xml | 2 +- res/values/dimens.xml | 11 +++++---- src/com/android/launcher3/BubbleTextView.java | 1 + src/com/android/launcher3/DeviceProfile.java | 24 ++++++++++--------- src/com/android/launcher3/IconCache.java | 2 +- src/com/android/launcher3/Launcher.java | 1 - .../launcher3/ShortcutAndWidgetContainer.java | 2 +- .../launcher3/WidgetPreviewLoader.java | 2 +- 10 files changed, 28 insertions(+), 24 deletions(-) diff --git a/res/layout/all_apps_icon.xml b/res/layout/all_apps_icon.xml index ca0cbcc4df..79fb6126ad 100644 --- a/res/layout/all_apps_icon.xml +++ b/res/layout/all_apps_icon.xml @@ -23,7 +23,6 @@ android:stateListAnimator="@animator/all_apps_fastscroll_icon_anim" launcher:iconDisplay="all_apps" launcher:centerVertically="true" - android:paddingLeft="4dp" - android:paddingRight="4dp" - android:drawablePadding="@dimen/dynamic_grid_icon_drawable_padding" /> + android:paddingLeft="@dimen/dynamic_grid_cell_padding_x" + android:paddingRight="@dimen/dynamic_grid_cell_padding_x" /> diff --git a/res/layout/page_indicator.xml b/res/layout/page_indicator.xml index e29e5b1628..c5ef6e0a8e 100644 --- a/res/layout/page_indicator.xml +++ b/res/layout/page_indicator.xml @@ -23,6 +23,6 @@ android:id="@+id/all_apps_handle" android:layout_width="48dp" android:layout_height="match_parent" - android:layout_gravity="center" + android:layout_gravity="top|center" android:scaleType="centerInside"/> diff --git a/res/layout/qsb_default_view.xml b/res/layout/qsb_default_view.xml index 3075f803f1..04fe236084 100644 --- a/res/layout/qsb_default_view.xml +++ b/res/layout/qsb_default_view.xml @@ -21,7 +21,7 @@ - 8dp - 28dp + 16dp + 32dp 1dp 38dp 48dp @@ -26,14 +26,17 @@ 120dp 80dp 25dp - 12dp + 8dp 8dp 8dp + + 8dp + 8dp - 0dp + 2dp 80dp 24dp diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index b6e73287f4..f8e87c57f1 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -168,6 +168,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { int defaultIconSize = grid.iconSizePx; if (display == DISPLAY_WORKSPACE) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.iconTextSizePx); + setCompoundDrawablePadding(grid.iconDrawablePaddingPx); } else if (display == DISPLAY_ALL_APPS) { setTextSize(TypedValue.COMPLEX_UNIT_PX, grid.allAppsIconTextSizePx); setCompoundDrawablePadding(grid.allAppsIconDrawablePaddingPx); diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 83ea067bc7..0a346a6eac 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -32,6 +32,7 @@ import android.widget.FrameLayout; import com.android.launcher3.CellLayout.ContainerType; import com.android.launcher3.badge.BadgeRenderer; +import com.android.launcher3.config.FeatureFlags; import java.util.ArrayList; @@ -92,6 +93,7 @@ public class DeviceProfile { public int cellWidthPx; public int cellHeightPx; + public int cellPaddingXPx; // Folder public int folderBackgroundOffset; @@ -192,6 +194,8 @@ public class DeviceProfile { workspaceSpringLoadedBottomSpace = res.getDimensionPixelSize(R.dimen.dynamic_grid_min_spring_loaded_space); + cellPaddingXPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_cell_padding_x); + hotseatBarTopPaddingPx = res.getDimensionPixelSize(R.dimen.dynamic_grid_hotseat_top_padding); hotseatBarBottomPaddingPx = @@ -264,36 +268,34 @@ public class DeviceProfile { } private void updateAvailableDimensions(DisplayMetrics dm, Resources res) { - updateIconSize(1f, iconDrawablePaddingOriginalPx, res, dm); + updateIconSize(1f, res, dm); // Check to see if the icons fit within the available height. If not, then scale down. float usedHeight = (cellHeightPx * inv.numRows); int maxHeight = (availableHeightPx - getTotalWorkspacePadding().y); if (usedHeight > maxHeight) { float scale = maxHeight / usedHeight; - updateIconSize(scale, 0, res, dm); + updateIconSize(scale, res, dm); } - updateAvailableFolderCellDimensions(dm, res); } - private void updateIconSize(float scale, int drawablePadding, Resources res, - DisplayMetrics dm) { + private void updateIconSize(float scale, Resources res, DisplayMetrics dm) { iconSizePx = (int) (Utilities.pxFromDp(inv.iconSize, dm) * scale); iconTextSizePx = (int) (Utilities.pxFromSp(inv.iconTextSize, dm) * scale); - iconDrawablePaddingPx = drawablePadding; + iconDrawablePaddingPx = (int) (iconDrawablePaddingOriginalPx * scale); hotseatIconSizePx = (int) (Utilities.pxFromDp(inv.hotseatIconSize, dm) * scale); allAppsIconSizePx = iconSizePx; allAppsIconDrawablePaddingPx = iconDrawablePaddingPx; allAppsIconTextSizePx = iconTextSizePx; - cellWidthPx = iconSizePx; + cellWidthPx = iconSizePx + iconDrawablePaddingPx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + Utilities.calculateTextHeight(iconTextSizePx); // Hotseat - hotseatCellWidthPx = iconSizePx; - hotseatCellHeightPx = iconSizePx; + hotseatCellWidthPx = cellWidthPx; + hotseatCellHeightPx = iconSizePx + iconDrawablePaddingPx; if (!isVerticalBarLayout()) { int expectedWorkspaceHeight = availableHeightPx - hotseatBarHeightPx @@ -308,7 +310,7 @@ public class DeviceProfile { } // Folder icon - folderBackgroundOffset = -edgeMarginPx; + folderBackgroundOffset = -iconDrawablePaddingPx; folderIconSizePx = iconSizePx + 2 * -folderBackgroundOffset; folderIconPreviewPadding = res.getDimensionPixelSize(R.dimen.folder_preview_padding); } @@ -522,7 +524,7 @@ public class DeviceProfile { lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); lp.width = searchBarBounds.x; lp.height = searchBarBounds.y; - lp.topMargin = mInsets.top + edgeMarginPx; + lp.topMargin = mInsets.top + edgeMarginPx / 2; searchBar.setLayoutParams(lp); // Layout the workspace diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java index ad816afbc7..09ca5c5cdb 100644 --- a/src/com/android/launcher3/IconCache.java +++ b/src/com/android/launcher3/IconCache.java @@ -749,7 +749,7 @@ public class IconCache { } private static final class IconDB extends SQLiteCacheHelper { - private final static int DB_VERSION = 14; + private final static int DB_VERSION = 15; private final static int RELEASE_VERSION = DB_VERSION + (FeatureFlags.LAUNCHER3_DISABLE_ICON_NORMALIZATION ? 0 : 1); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index bd006c7185..bb32a4563b 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -1413,7 +1413,6 @@ public class Launcher extends BaseActivity BubbleTextView favorite = (BubbleTextView) LayoutInflater.from(parent.getContext()) .inflate(R.layout.app_icon, parent, false); favorite.applyFromShortcutInfo(info); - favorite.setCompoundDrawablePadding(mDeviceProfile.iconDrawablePaddingPx); favorite.setOnClickListener(this); favorite.setOnFocusChangeListener(mFocusHandler); return favorite; diff --git a/src/com/android/launcher3/ShortcutAndWidgetContainer.java b/src/com/android/launcher3/ShortcutAndWidgetContainer.java index f8742f8958..3a3e13d22f 100644 --- a/src/com/android/launcher3/ShortcutAndWidgetContainer.java +++ b/src/com/android/launcher3/ShortcutAndWidgetContainer.java @@ -120,7 +120,7 @@ public class ShortcutAndWidgetContainer extends ViewGroup { // Center the icon/folder int cHeight = getCellContentHeight(); int cellPaddingY = (int) Math.max(0, ((lp.height - cHeight) / 2f)); - int cellPaddingX = (int) (profile.edgeMarginPx / 2f); + int cellPaddingX = profile.cellPaddingXPx; child.setPadding(cellPaddingX, cellPaddingY, cellPaddingX, 0); } } else { diff --git a/src/com/android/launcher3/WidgetPreviewLoader.java b/src/com/android/launcher3/WidgetPreviewLoader.java index f66995f701..d421a0e4ce 100644 --- a/src/com/android/launcher3/WidgetPreviewLoader.java +++ b/src/com/android/launcher3/WidgetPreviewLoader.java @@ -111,7 +111,7 @@ public class WidgetPreviewLoader { * sizes (landscape vs portrait). */ private static class CacheDb extends SQLiteCacheHelper { - private static final int DB_VERSION = 6; + private static final int DB_VERSION = 7; private static final String TABLE_NAME = "shortcut_and_widget_previews"; private static final String COLUMN_COMPONENT = "componentName";