From 233ee964a9ecf419a3e8330a67456d422879132d Mon Sep 17 00:00:00 2001 From: Sunny Goyal Date: Mon, 3 Aug 2015 13:05:01 -0700 Subject: Calculating widget minSpans and spans statically/independent of orientation > Filtering the widget list and excluding widgets which dont fit the grid > setting minSpans for the widget item when binding. Bug: 22541314 Bug: 22559137 Change-Id: Ieda48b56c95bee0c7ec71dd691af7e23e2d43db6 --- src/com/android/launcher3/CellLayout.java | 60 ------------------------------- 1 file changed, 60 deletions(-) (limited to 'src/com/android/launcher3/CellLayout.java') diff --git a/src/com/android/launcher3/CellLayout.java b/src/com/android/launcher3/CellLayout.java index b875d22e6..84e2d49c2 100644 --- a/src/com/android/launcher3/CellLayout.java +++ b/src/com/android/launcher3/CellLayout.java @@ -54,7 +54,6 @@ import com.android.launcher3.accessibility.DragAndDropAccessibilityDelegate; import com.android.launcher3.accessibility.FolderAccessibilityHelper; import com.android.launcher3.accessibility.WorkspaceAccessibilityHelper; import com.android.launcher3.util.Thunk; -import com.android.launcher3.widget.PendingAddWidgetInfo; import java.util.ArrayList; import java.util.Arrays; @@ -2686,65 +2685,6 @@ public class CellLayout extends ViewGroup implements BubbleTextShadowHandler { resultRect.set(x, y, x + width, y + height); } - /** - * Computes the required horizontal and vertical cell spans to always - * fit the given rectangle. - * - * @param width Width in pixels - * @param height Height in pixels - * @param result An array of length 2 in which to store the result (may be null). - */ - public static int[] rectToCell(Launcher launcher, int width, int height, int[] result) { - return rectToCell(launcher.getDeviceProfile(), launcher, width, height, result); - } - - public static int[] rectToCell(DeviceProfile grid, Context context, int width, int height, - int[] result) { - Rect padding = grid.getWorkspacePadding(Utilities.isRtl(context.getResources())); - - // Always assume we're working with the smallest span to make sure we - // reserve enough space in both orientations. - int parentWidth = DeviceProfile.calculateCellWidth(grid.widthPx - - padding.left - padding.right, (int) grid.inv.numColumns); - int parentHeight = DeviceProfile.calculateCellHeight(grid.heightPx - - padding.top - padding.bottom, (int) grid.inv.numRows); - int smallerSize = Math.min(parentWidth, parentHeight); - - // Always round up to next largest cell - int spanX = (int) Math.ceil(width / (float) smallerSize); - int spanY = (int) Math.ceil(height / (float) smallerSize); - - if (result == null) { - return new int[] { spanX, spanY }; - } - result[0] = spanX; - result[1] = spanY; - return result; - } - - /** - * Calculate the grid spans needed to fit given item - */ - public void calculateSpans(ItemInfo info) { - final int minWidth; - final int minHeight; - - if (info instanceof LauncherAppWidgetInfo) { - minWidth = ((LauncherAppWidgetInfo) info).minWidth; - minHeight = ((LauncherAppWidgetInfo) info).minHeight; - } else if (info instanceof PendingAddWidgetInfo) { - minWidth = ((PendingAddWidgetInfo) info).minWidth; - minHeight = ((PendingAddWidgetInfo) info).minHeight; - } else { - // It's not a widget, so it must be 1x1 - info.spanX = info.spanY = 1; - return; - } - int[] spans = rectToCell(mLauncher, minWidth, minHeight, null); - info.spanX = spans[0]; - info.spanY = spans[1]; - } - private void clearOccupiedCells() { for (int x = 0; x < mCountX; x++) { for (int y = 0; y < mCountY; y++) { -- cgit v1.2.3