From abedd9fd4e692cd390f5c23d850206c9156e387a Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Tue, 24 Sep 2013 15:41:09 -0700 Subject: [PATCH] Extending the hit rect when testing for dragging over the hotseat. Change-Id: I57cf863c663b1e57fa422db880b6003ead1199c8 --- src/com/android/launcher3/DynamicGrid.java | 21 +++++++++++++++++---- src/com/android/launcher3/Workspace.java | 5 ++++- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java index bbf0e03fd..495e930f9 100644 --- a/src/com/android/launcher3/DynamicGrid.java +++ b/src/com/android/launcher3/DynamicGrid.java @@ -290,8 +290,7 @@ class DeviceProfile { Rect getWorkspacePadding(int orientation) { Rect padding = new Rect(); - if (orientation == CellLayout.LANDSCAPE && - transposeLayoutWithOrientation) { + if (isVerticalBarLayout()) { // Pad the left and right of the workspace with search/hotseat bar sizes padding.set(searchBarSpaceHeightPx, edgeMarginPx, hotseatBarHeightPx, edgeMarginPx); @@ -321,6 +320,17 @@ class DeviceProfile { return padding; } + // The rect returned will be extended to below the system ui that covers the workspace + Rect getHotseatRect() { + if (isVerticalBarLayout()) { + return new Rect(availableWidthPx - hotseatBarHeightPx, 0, + Integer.MAX_VALUE, availableHeightPx); + } else { + return new Rect(0, availableHeightPx - hotseatBarHeightPx, + availableWidthPx, Integer.MAX_VALUE); + } + } + int calculateCellWidth(int width, int countX) { return width / countX; } @@ -338,11 +348,14 @@ class DeviceProfile { return isLargeTablet; } + boolean isVerticalBarLayout() { + return isLandscape && transposeLayoutWithOrientation; + } + public void layout(Launcher launcher) { FrameLayout.LayoutParams lp; Resources res = launcher.getResources(); - boolean hasVerticalBarLayout = isLandscape && - res.getBoolean(R.bool.hotseat_transpose_layout_with_orientation); + boolean hasVerticalBarLayout = isVerticalBarLayout(); // Layout the search bar space View searchBarSpace = launcher.findViewById(R.id.qsb_bar); diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index 284c57f70..6be793641 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -2909,7 +2909,10 @@ public class Workspace extends SmoothPagedView mTempPt[0] = x; mTempPt[1] = y; mLauncher.getDragLayer().getDescendantCoordRelativeToSelf(this, mTempPt, true); - mLauncher.getHotseat().getHitRect(r); + + LauncherAppState app = LauncherAppState.getInstance(); + DeviceProfile grid = app.getDynamicGrid().getDeviceProfile(); + r = grid.getHotseatRect(); if (r.contains(mTempPt[0], mTempPt[1])) { return true; } -- 2.11.0