summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorWinson Chung <winsonc@google.com>2012-04-12 14:04:41 -0700
committerWinson Chung <winsonc@google.com>2012-04-12 16:21:17 -0700
commita5c9636f563a2fa5bd3c97266894e002453b13dc (patch)
tree7a4a719f462036435cf656894331825d6e434f9d
parent2c2b28ae557f83b3d114afeedb61c546a503eb99 (diff)
downloadandroid_packages_apps_Trebuchet-a5c9636f563a2fa5bd3c97266894e002453b13dc.tar.gz
android_packages_apps_Trebuchet-a5c9636f563a2fa5bd3c97266894e002453b13dc.tar.bz2
android_packages_apps_Trebuchet-a5c9636f563a2fa5bd3c97266894e002453b13dc.zip
Preventing widgets that don't fit from showing in tray. (Bug 6331357)
Change-Id: I9cbe85bed5c633f2be9b420eecbbee9a1b171e51
-rw-r--r--src/com/android/launcher2/AppWidgetResizeFrame.java2
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java16
-rw-r--r--src/com/android/launcher2/Launcher.java26
3 files changed, 24 insertions, 20 deletions
diff --git a/src/com/android/launcher2/AppWidgetResizeFrame.java b/src/com/android/launcher2/AppWidgetResizeFrame.java
index c01a882cb..4518f9025 100644
--- a/src/com/android/launcher2/AppWidgetResizeFrame.java
+++ b/src/com/android/launcher2/AppWidgetResizeFrame.java
@@ -80,7 +80,7 @@ public class AppWidgetResizeFrame extends FrameLayout {
mWorkspace = (Workspace) dragLayer.findViewById(R.id.workspace);
final AppWidgetProviderInfo info = widgetView.getAppWidgetInfo();
- int[] result = mLauncher.getMinSpanForWidget(info, null);
+ int[] result = mLauncher.getMinSpanForWidget(info);
mMinHSpan = result[0];
mMinVSpan = result[1];
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 67ae1f112..3d5d06a11 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -480,7 +480,15 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
List<ResolveInfo> shortcuts = mPackageManager.queryIntentActivities(shortcutsIntent, 0);
for (AppWidgetProviderInfo widget : widgets) {
if (widget.minWidth > 0 && widget.minHeight > 0) {
- mWidgets.add(widget);
+ // Ensure that all widgets we show can be added on a workspace of this size
+ int[] spanXY = mLauncher.getSpanForWidget(widget);
+ int[] minSpanXY = mLauncher.getMinSpanForWidget(widget);
+ int minSpanX = Math.min(spanXY[0], minSpanXY[0]);
+ int minSpanY = Math.min(spanXY[1], minSpanXY[1]);
+ if (minSpanX < LauncherModel.getCellCountX() &&
+ minSpanY < LauncherModel.getCellCountY()) {
+ mWidgets.add(widget);
+ }
} else {
Log.e(LOG_TAG, "Widget " + widget.provider + " has invalid dimensions (" +
widget.minWidth + ", " + widget.minHeight + ")");
@@ -1205,12 +1213,12 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
createItemInfo = new PendingAddWidgetInfo(info, null, null);
// Determine the widget spans and min resize spans.
- int[] spanXY = mLauncher.getSpanForWidget(info, null);
+ int[] spanXY = mLauncher.getSpanForWidget(info);
int[] size = mLauncher.getWorkspace().estimateItemSize(spanXY[0],
spanXY[1], createItemInfo, true);
createItemInfo.spanX = spanXY[0];
createItemInfo.spanY = spanXY[1];
- int[] minSpanXY = mLauncher.getMinSpanForWidget(info, null);
+ int[] minSpanXY = mLauncher.getMinSpanForWidget(info);
createItemInfo.minSpanX = minSpanXY[0];
createItemInfo.minSpanY = minSpanXY[1];
@@ -1297,7 +1305,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Object rawInfo = items.get(i);
if (rawInfo instanceof AppWidgetProviderInfo) {
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
- int[] cellSpans = mLauncher.getSpanForWidget(info, null);
+ int[] cellSpans = mLauncher.getSpanForWidget(info);
int maxWidth = Math.min(data.maxImageWidth,
mWidgetSpacingLayout.estimateCellWidth(cellSpans[0]));
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index f768a3965..03c5c08a6 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -979,11 +979,7 @@ public final class Launcher extends Activity
}
}
- int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight, int[] spanXY) {
- if (spanXY == null) {
- spanXY = new int[2];
- }
-
+ int[] getSpanForWidget(ComponentName component, int minWidth, int minHeight) {
Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(this, component, null);
// We want to account for the extra amount of padding that we are adding to the widget
// to ensure that it gets the full amount of space that it has requested
@@ -992,21 +988,21 @@ public final class Launcher extends Activity
return CellLayout.rectToCell(getResources(), requiredWidth, requiredHeight, null);
}
- int[] getSpanForWidget(AppWidgetProviderInfo info, int[] spanXY) {
- return getSpanForWidget(info.provider, info.minWidth, info.minHeight, spanXY);
+ int[] getSpanForWidget(AppWidgetProviderInfo info) {
+ return getSpanForWidget(info.provider, info.minWidth, info.minHeight);
}
- int[] getMinSpanForWidget(AppWidgetProviderInfo info, int[] spanXY) {
- return getSpanForWidget(info.provider, info.minResizeWidth, info.minResizeHeight, spanXY);
+ int[] getMinSpanForWidget(AppWidgetProviderInfo info) {
+ return getSpanForWidget(info.provider, info.minResizeWidth, info.minResizeHeight);
}
- int[] getSpanForWidget(PendingAddWidgetInfo info, int[] spanXY) {
- return getSpanForWidget(info.componentName, info.minWidth, info.minHeight, spanXY);
+ int[] getSpanForWidget(PendingAddWidgetInfo info) {
+ return getSpanForWidget(info.componentName, info.minWidth, info.minHeight);
}
- int[] getMinSpanForWidget(PendingAddWidgetInfo info, int[] spanXY) {
+ int[] getMinSpanForWidget(PendingAddWidgetInfo info) {
return getSpanForWidget(info.componentName, info.minResizeWidth,
- info.minResizeHeight, spanXY);
+ info.minResizeHeight);
}
/**
@@ -1024,8 +1020,8 @@ public final class Launcher extends Activity
// Calculate the grid spans needed to fit this widget
CellLayout layout = getCellLayout(container, screen);
- int[] minSpanXY = getMinSpanForWidget(appWidgetInfo, null);
- int[] spanXY = getSpanForWidget(appWidgetInfo, null);
+ int[] minSpanXY = getMinSpanForWidget(appWidgetInfo);
+ int[] spanXY = getSpanForWidget(appWidgetInfo);
// Try finding open space on Launcher screen
// We have saved the position to which the widget was dragged-- this really only matters