summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/CellLayout.java
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2015-08-03 13:05:01 -0700
committerSunny Goyal <sunnygoyal@google.com>2015-08-03 16:39:49 -0700
commit233ee964a9ecf419a3e8330a67456d422879132d (patch)
tree5ce6c56ee6fa4060fffbbb294b505080008da0f7 /src/com/android/launcher3/CellLayout.java
parent6eeab68fd4a5ba51e32717b18c40e9bea8b38e97 (diff)
downloadandroid_packages_apps_Trebuchet-233ee964a9ecf419a3e8330a67456d422879132d.tar.gz
android_packages_apps_Trebuchet-233ee964a9ecf419a3e8330a67456d422879132d.tar.bz2
android_packages_apps_Trebuchet-233ee964a9ecf419a3e8330a67456d422879132d.zip
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
Diffstat (limited to 'src/com/android/launcher3/CellLayout.java')
-rw-r--r--src/com/android/launcher3/CellLayout.java60
1 files changed, 0 insertions, 60 deletions
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++) {