From 59a488ac03aa122b75e9a358db74acf7bb4d2508 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 10 Dec 2013 12:32:14 -0800 Subject: [PATCH] Adjusting grid for tablets and fixing incorrect resources for large tablets. Change-Id: I4c2a058da934bef14f5be3c53ebda940aeb990ca --- res/drawable-sw720dp-hdpi/workspace_bg.9.png | Bin 0 -> 226 bytes res/drawable-sw720dp-mdpi/workspace_bg.9.png | Bin 0 -> 213 bytes res/drawable-sw720dp-xhdpi/workspace_bg.9.png | Bin 0 -> 255 bytes .../workspace_bg.9.png | Bin 0 -> 1126 bytes res/values-land/config.xml | 2 - res/values-sw340dp-port/config.xml | 3 -- res/values-sw720dp/config.xml | 2 - res/values/config.xml | 2 - src/com/android/launcher3/CellLayout.java | 7 ++- src/com/android/launcher3/DeviceProfile.java | 44 +++++++++--------- src/com/android/launcher3/DynamicGrid.java | 4 +- src/com/android/launcher3/Workspace.java | 11 +---- 12 files changed, 32 insertions(+), 43 deletions(-) create mode 100644 res/drawable-sw720dp-hdpi/workspace_bg.9.png create mode 100644 res/drawable-sw720dp-mdpi/workspace_bg.9.png create mode 100644 res/drawable-sw720dp-xhdpi/workspace_bg.9.png create mode 100644 res/drawable-sw720dp-xxhdpi/workspace_bg.9.png diff --git a/res/drawable-sw720dp-hdpi/workspace_bg.9.png b/res/drawable-sw720dp-hdpi/workspace_bg.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5bbfa4fff6bb6a864d6b897417d5a6fd66b8b86f GIT binary patch literal 226 zcmeAS@N?(olHy`uVBq!ia0vp^%nS^SdK_#(mUr%o$3Tju*vT`50|;t3QaXTq&H|6f zVg?58P7r1^KY4mBP_V_*#WBRA^X_y*z5@z8%v54wa^XPtFnGH9xvXaoQ~N)r@T}9yljc4iUOxY zN-2X^zrca*2ihu+Sgv%Gm40y~Sv&oadhRhcE5-FklwZusEb9tt)D%C)bKqOui}O7f zKPG%s@;x+bZpE5;H+PpAr#Y$d-gLVE``JM;;qs^Rk8zu^r~RLuc<>s~2@IaDelF{r G5}E)~15T*` literal 0 HcmV?d00001 diff --git a/res/drawable-sw720dp-xhdpi/workspace_bg.9.png b/res/drawable-sw720dp-xhdpi/workspace_bg.9.png new file mode 100644 index 0000000000000000000000000000000000000000..72269f207a5af6e545efb099fa67ddc343be1ff5 GIT binary patch literal 255 zcmeAS@N?(olHy`uVBq!ia0vp^%nS^SlQ`IbEVb0?w?K-e*vT`50|;t3QaXTq&H|6f zVg?58P7r1^KY4mBP;jBAi(^Pc>(d#h`Hm>?FfXt9Sy#Dvx~;-j#ciHhvx>TN`WY{J z8yYh#j+Q@gE8n2u+UebgH|h#11b%sOW8S5iM`YI&U%Yp@_&WE+`6d&^eph{sU#z0M zaA)q)sS&po4$SRj&1tW@S$T|4)V#`Ar~XSto3?GIFVdQ&MBb@0IkMi AF8}}l literal 0 HcmV?d00001 diff --git a/res/drawable-sw720dp-xxhdpi/workspace_bg.9.png b/res/drawable-sw720dp-xxhdpi/workspace_bg.9.png new file mode 100644 index 0000000000000000000000000000000000000000..efc9b0465881383de73faf2cc77fab87eaa9c00f GIT binary patch literal 1126 zcmbVLPiPcZ7@tIFW5o92K~qbH3Fg$@d2eQSW@p%K*qzyl3vP^?#l|$0OlIC@hh*lB zGjF?-&_j$MRgw18(t~&q6hTBqPaZtwpb)4hOG-&86hu=>BT)?X}PCK&iaV2pb$3#i@ry# zuMMWXd$&*=NV8E72M&D{b4JHj!$lq`={b)6N!pIB8dA|Pw2Y?90+2EgW@Kn&iUqlt zkpxLe=i40HVMS_JWYm=hvThbX$AdhZLKv!e!pWmO; zwfdo?=d023>QBFQ&x0=Gw*2H}@BLR7&n`SL%DFpTSFHOFi+atbBXZT}s~|{XL88&Yz3>ztMgj zT$OHp+}Zf|ueyC?{g1JZ|91F&%f~)CFzmtV)5Un&mi*9sF0ZvZedaV-D< literal 0 HcmV?d00001 diff --git a/res/values-land/config.xml b/res/values-land/config.xml index 121bb0c146..31115c9cb6 100644 --- a/res/values-land/config.xml +++ b/res/values-land/config.xml @@ -18,6 +18,4 @@ false - - false diff --git a/res/values-sw340dp-port/config.xml b/res/values-sw340dp-port/config.xml index d31ee59690..5f71077c72 100644 --- a/res/values-sw340dp-port/config.xml +++ b/res/values-sw340dp-port/config.xml @@ -15,7 +15,4 @@ --> - - - false diff --git a/res/values-sw720dp/config.xml b/res/values-sw720dp/config.xml index 4f537a9f40..c00b5943f1 100644 --- a/res/values-sw720dp/config.xml +++ b/res/values-sw720dp/config.xml @@ -9,8 +9,6 @@ false - - true 18000 diff --git a/res/values/config.xml b/res/values/config.xml index 1538d9fab4..2a08216624 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -52,8 +52,6 @@ false - - false 0 diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index df16d41947..c5ad30a51e 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -100,6 +100,7 @@ public class CellLayout extends ViewGroup { private int mForegroundAlpha = 0; private float mBackgroundAlpha; private float mBackgroundAlphaMultiplier = 1.0f; + private boolean mDrawBackground = true; private Drawable mNormalBackground; private Drawable mActiveGlowBackground; @@ -387,6 +388,10 @@ public class CellLayout extends ViewGroup { mUseActiveGlowBackground = use; } + void disableBackground() { + mDrawBackground = false; + } + boolean getIsDragOverlapping() { return mIsDragOverlapping; } @@ -415,7 +420,7 @@ public class CellLayout extends ViewGroup { // When we're small, we are either drawn normally or in the "accepts drops" state (during // a drag). However, we also drag the mini hover background *over* one of those two // backgrounds - if (mBackgroundAlpha > 0.0f) { + if (mDrawBackground && mBackgroundAlpha > 0.0f) { Drawable bg; if (mUseActiveGlowBackground) { diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index 511b7182f3..67b0933c9a 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -119,6 +119,8 @@ public class DeviceProfile { int searchBarHeightPx; int pageIndicatorHeightPx; + float dragViewScale; + private ArrayList mCallbacks = new ArrayList(); DeviceProfile(String n, float w, float h, float r, float c, @@ -282,11 +284,12 @@ public class DeviceProfile { // Check to see if the icons fit in the new available height. If not, then we need to // shrink the icon size. - Rect workspacePadding = getWorkspacePadding(); float scale = 1f; int drawablePadding = iconDrawablePaddingOriginalPx; updateIconSize(1f, drawablePadding, resources, dm); float usedHeight = (cellHeightPx * numRows); + + Rect workspacePadding = getWorkspacePadding(); int maxHeight = (availableHeightPx - workspacePadding.top - workspacePadding.bottom); if (usedHeight > maxHeight) { scale = maxHeight / usedHeight; @@ -319,6 +322,8 @@ public class DeviceProfile { FontMetrics fm = textPaint.getFontMetrics(); cellWidthPx = iconSizePx; cellHeightPx = iconSizePx + iconDrawablePaddingPx + (int) Math.ceil(fm.bottom - fm.top); + final float scaleDps = resources.getDimensionPixelSize(R.dimen.dragViewScale); + dragViewScale = (iconSizePx + scaleDps) / iconSizePx; // Hotseat hotseatBarHeightPx = iconSizePx + 4 * edgeMarginPx; @@ -491,17 +496,21 @@ public class DeviceProfile { if (isTablet()) { // Pad the left and right of the workspace to ensure consistent spacing // between all icons + float gapScale = 1f + (dragViewScale - 1f) / 2f; int width = (orientation == CellLayout.LANDSCAPE) ? Math.max(widthPx, heightPx) : Math.min(widthPx, heightPx); - // XXX: If the icon size changes across orientations, we will have to take - // that into account here too. - int gap = (int) ((width - 2 * edgeMarginPx - - (numColumns * cellWidthPx)) / (2 * (numColumns + 1))); - padding.set(edgeMarginPx + gap, - searchBarBounds.bottom, - edgeMarginPx + gap, - hotseatBarHeightPx + pageIndicatorHeightPx); + int height = (orientation != CellLayout.LANDSCAPE) + ? Math.max(widthPx, heightPx) + : Math.min(widthPx, heightPx); + int paddingTop = searchBarBounds.bottom; + int paddingBottom = hotseatBarHeightPx + pageIndicatorHeightPx; + int availableWidth = Math.max(0, width - (int) ((numColumns * cellWidthPx) + + (numColumns * gapScale * cellWidthPx))); + int availableHeight = Math.max(0, height - paddingTop - paddingBottom + - (int) (2 * numRows * cellHeightPx)); + padding.set(availableWidth / 2, paddingTop + availableHeight / 2, + availableWidth / 2, paddingBottom + availableHeight / 2); } else { // Pad the top and bottom of the workspace with search/hotseat bar sizes padding.set(desiredWorkspaceLeftRightMarginPx - defaultWidgetPadding.left, @@ -514,8 +523,8 @@ public class DeviceProfile { } int getWorkspacePageSpacing(int orientation) { - if (orientation == CellLayout.LANDSCAPE && - transposeLayoutWithOrientation) { + if ((orientation == CellLayout.LANDSCAPE && + transposeLayoutWithOrientation) || isLargeTablet()) { // In landscape mode the page spacing is set to the default. return defaultPageSpacingPx; } else { @@ -645,19 +654,12 @@ public class DeviceProfile { lp.height = LayoutParams.MATCH_PARENT; hotseat.findViewById(R.id.layout).setPadding(0, 2 * edgeMarginPx, 0, 2 * edgeMarginPx); } else if (isTablet()) { - // Pad the hotseat with the grid gap calculated above - int gridGap = (int) ((widthPx - 2 * edgeMarginPx - - (numColumns * cellWidthPx)) / (2 * (numColumns + 1))); - int gridWidth = (int) ((numColumns * cellWidthPx) + - ((numColumns - 1) * gridGap)); - int hotseatGap = (int) Math.max(0, - (gridWidth - (numHotseatIcons * hotseatCellWidthPx)) - / (numHotseatIcons - 1)); + // Pad the hotseat with the workspace padding calculated above lp.gravity = Gravity.BOTTOM; lp.width = LayoutParams.MATCH_PARENT; lp.height = hotseatBarHeightPx; - hotseat.setPadding(2 * edgeMarginPx + gridGap + hotseatGap, 0, - 2 * edgeMarginPx + gridGap + hotseatGap, + hotseat.setPadding(edgeMarginPx + padding.left, 0, + edgeMarginPx + padding.right, 2 * edgeMarginPx); } else { // For phones, layout the hotseat without any bottom margin diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index dc01c69331..22928ccf3a 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -74,10 +74,10 @@ public class DynamicGrid { // The tablet profile is odd in that the landscape orientation // also includes the nav bar on the side deviceProfiles.add(new DeviceProfile("Nexus 7", - 575, 904, 5, 5, 72, 14.4f, 7, 60)); + 575, 904, 5, 6, 72, 14.4f, 7, 60)); // Larger tablet profiles always have system bars on the top & bottom deviceProfiles.add(new DeviceProfile("Nexus 10", - 727, 1207, 5, 5, 80, 14.4f, 7, 64)); + 727, 1207, 5, 6, 76, 14.4f, 7, 64)); /* deviceProfiles.add(new DeviceProfile("Nexus 7", 600, 960, 5, 5, 72, 14.4f, 5, 60)); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index bf4f561e0a..3d1564a7a2 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -565,6 +565,7 @@ public class Workspace extends SmoothPagedView public void createCustomContentPage() { CellLayout customScreen = (CellLayout) mLauncher.getLayoutInflater().inflate(R.layout.workspace_screen, null); + customScreen.disableBackground(); mWorkspaceScreens.put(CUSTOM_CONTENT_SCREEN_ID, customScreen); mScreenOrder.add(0, CUSTOM_CONTENT_SCREEN_ID); @@ -1155,11 +1156,6 @@ public class Workspace extends SmoothPagedView } } - // Only show page outlines as we pan if we are on large screen - if (LauncherAppState.getInstance().isScreenLarge()) { - showOutlines(); - } - // If we are not fading in adjacent screens, we still need to restore the alpha in case the // user scrolls while we are transitioning (should not affect dispatchDraw optimizations) if (!mWorkspaceFadeInAdjacentScreens) { @@ -1184,11 +1180,6 @@ public class Workspace extends SmoothPagedView // is under a new page (to scroll to) mDragController.forceTouchMove(); } - } else { - // If we are not mid-dragging, hide the page outlines if we are on a large screen - if (LauncherAppState.getInstance().isScreenLarge()) { - hideOutlines(); - } } if (mDelayedResizeRunnable != null) {