diff options
Diffstat (limited to 'src/com/android/launcher3/DeviceProfile.java')
-rw-r--r-- | src/com/android/launcher3/DeviceProfile.java | 72 |
1 files changed, 48 insertions, 24 deletions
diff --git a/src/com/android/launcher3/DeviceProfile.java b/src/com/android/launcher3/DeviceProfile.java index c6da5844a..8538a1f4d 100644 --- a/src/com/android/launcher3/DeviceProfile.java +++ b/src/com/android/launcher3/DeviceProfile.java @@ -319,6 +319,18 @@ public class DeviceProfile { return bounds; } + public Point getCellSize() { + Point result = new Point(); + // Since we are only concerned with the overall padding, layout direction does + // not matter. + Rect padding = getWorkspacePadding(false /* isLayoutRtl */ ); + result.x = calculateCellWidth(availableWidthPx - padding.left - padding.right, + inv.numColumns); + result.y = calculateCellHeight(availableHeightPx - padding.top - padding.bottom, + inv.numRows); + return result; + } + /** Returns the workspace padding in the specified orientation */ Rect getWorkspacePadding(boolean isLayoutRtl) { Rect searchBarBounds = getSearchBarBounds(isLayoutRtl); @@ -381,13 +393,13 @@ public class DeviceProfile { } // The rect returned will be extended to below the system ui that covers the workspace - Rect getHotseatRect() { + public boolean isInHotseatRect(int x, int y) { if (isVerticalBarLayout()) { - return new Rect(availableWidthPx - normalHotseatBarHeightPx, 0, - Integer.MAX_VALUE, availableHeightPx); + return (x >= (availableWidthPx - hotseatBarHeightPx)) + && (y >= 0) && (y <= availableHeightPx); } else { - return new Rect(0, availableHeightPx - hotseatBarHeightPx, - availableWidthPx, Integer.MAX_VALUE); + return (x >= 0) && (x <= availableWidthPx) + && (y >= (availableHeightPx - hotseatBarHeightPx)); } } @@ -403,7 +415,7 @@ public class DeviceProfile { * When {@code false}, either device is in portrait mode or the device is in landscape mode and * the hotseat is on the bottom row. */ - boolean isVerticalBarLayout() { + public boolean isVerticalBarLayout() { return isLandscape && transposeLayoutWithOrientation; } @@ -442,26 +454,17 @@ public class DeviceProfile { // Layout the search bar space Rect searchBarBounds = getSearchBarBounds(isLayoutRtl); View searchBar = launcher.getSearchDropTargetBar(); - lp = (FrameLayout.LayoutParams) searchBar.getLayoutParams(); + lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, searchBar, Gravity.TOP); lp.width = searchBarBounds.width(); lp.height = searchBarBounds.height(); - if (hasVerticalBarLayout) { - // Vertical search bar space -- The search bar is fixed in the layout to be on the left - // of the screen regardless of RTL - lp.gravity = Gravity.LEFT; - - LinearLayout targets = (LinearLayout) searchBar.findViewById(R.id.drag_target_bar); - targets.setOrientation(LinearLayout.VERTICAL); - FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams(); - targetsLp.gravity = Gravity.TOP; - targetsLp.height = LayoutParams.WRAP_CONTENT; - - } else { - // Horizontal search bar space - lp.gravity = Gravity.TOP|Gravity.CENTER_HORIZONTAL; - } searchBar.setLayoutParams(lp); + // Layout the app info bar space + View appInfoBar = launcher.getAppInfoDropTargetBar(); + lp = getDropTargetBarLayoutParams(hasVerticalBarLayout, appInfoBar, Gravity.BOTTOM); + lp.bottomMargin = hotseatBarHeightPx; + appInfoBar.setLayoutParams(lp); + // Layout the workspace PagedView workspace = (PagedView) launcher.findViewById(R.id.workspace); lp = (FrameLayout.LayoutParams) workspace.getLayoutParams(); @@ -528,7 +531,6 @@ public class DeviceProfile { // Layout the Overview Mode ViewGroup overviewMode = launcher.getOverviewPanel(); if (overviewMode != null) { - int overviewButtonBarHeight = getOverviewModeButtonBarHeight(); lp = (FrameLayout.LayoutParams) overviewMode.getLayoutParams(); lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM; @@ -537,7 +539,7 @@ public class DeviceProfile { int maxWidth = totalItemWidth + (visibleChildCount-1) * overviewModeBarSpacerWidthPx; lp.width = Math.min(availableWidthPx, maxWidth); - lp.height = overviewButtonBarHeight; + lp.height = getOverviewModeButtonBarHeight(); overviewMode.setLayoutParams(lp); if (lp.width > totalItemWidth && visibleChildCount > 1) { @@ -566,6 +568,28 @@ public class DeviceProfile { } } + private FrameLayout.LayoutParams getDropTargetBarLayoutParams(boolean hasVerticalBarLayout, + View dropTargetBar, int verticalGravity) { + FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) dropTargetBar.getLayoutParams(); + if (hasVerticalBarLayout) { + // Vertical drop target bar space -- The drop target bar is fixed in the layout to be on + // the left of the screen regardless of RTL + lp.gravity = Gravity.LEFT; + lp.width = normalSearchBarSpaceHeightPx; + + LinearLayout targets = (LinearLayout) dropTargetBar.findViewById(R.id.drag_target_bar); + targets.setOrientation(LinearLayout.VERTICAL); + FrameLayout.LayoutParams targetsLp = (FrameLayout.LayoutParams) targets.getLayoutParams(); + targetsLp.gravity = verticalGravity; + targetsLp.height = LayoutParams.WRAP_CONTENT; + } else { + // Horizontal drop target bar space + lp.gravity = verticalGravity | Gravity.CENTER_HORIZONTAL; + lp.height = searchBarSpaceHeightPx; + } + return lp; + } + private int getCurrentWidth() { return isLandscape ? Math.max(widthPx, heightPx) |