summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-10-07 12:38:55 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-10-07 12:38:56 -0700
commit8b4d91455a0fc8a632ae09138787f4c5c54c4568 (patch)
tree029f3cb8fc23e329ef3d6657a28cd920f328eec2 /src
parent68255cbabe1cb7fbfc0706a8a2e1b1927eae1b55 (diff)
parentaaa5c21ee2e03def644fb6ba8eadbb59873ddd45 (diff)
downloadandroid_packages_apps_Trebuchet-8b4d91455a0fc8a632ae09138787f4c5c54c4568.tar.gz
android_packages_apps_Trebuchet-8b4d91455a0fc8a632ae09138787f4c5c54c4568.tar.bz2
android_packages_apps_Trebuchet-8b4d91455a0fc8a632ae09138787f4c5c54c4568.zip
Merge "Fix to ensure default widgets get size callbacks (issue 7287744)" into jb-mr1-dev
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java19
-rw-r--r--src/com/android/launcher2/Launcher.java5
-rw-r--r--src/com/android/launcher2/LauncherAppWidgetInfo.java3
-rw-r--r--src/com/android/launcher2/Workspace.java8
4 files changed, 21 insertions, 14 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 609bb6d09..b71726165 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -617,11 +617,22 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Bundle options = null;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
AppWidgetResizeFrame.getWidgetSizeRanges(mLauncher, info.spanX, info.spanY, mTmpRect);
+ Rect padding = AppWidgetHostView.getDefaultPaddingForWidget(mLauncher,
+ info.componentName, null);
+
+ float density = getResources().getDisplayMetrics().density;
+ int xPaddingDips = (int) ((padding.left + padding.right) / density);
+ int yPaddingDips = (int) ((padding.top + padding.bottom) / density);
+
options = new Bundle();
- options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, mTmpRect.left);
- options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, mTmpRect.top);
- options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, mTmpRect.right);
- options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, mTmpRect.bottom);
+ options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH,
+ mTmpRect.left - xPaddingDips);
+ options.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT,
+ mTmpRect.top - yPaddingDips);
+ options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH,
+ mTmpRect.right - xPaddingDips);
+ options.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT,
+ mTmpRect.bottom - yPaddingDips);
}
return options;
}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index fedf32460..f94194bb0 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1191,9 +1191,8 @@ public final class Launcher extends Activity
launcherInfo.hostView.setTag(launcherInfo);
launcherInfo.hostView.setVisibility(View.VISIBLE);
- if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
- launcherInfo.notifyWidgetSizeChanged(this);
- }
+ launcherInfo.notifyWidgetSizeChanged(this);
+
mWorkspace.addInScreen(launcherInfo.hostView, container, screen, cellXY[0], cellXY[1],
launcherInfo.spanX, launcherInfo.spanY, isWorkspaceLocked());
diff --git a/src/com/android/launcher2/LauncherAppWidgetInfo.java b/src/com/android/launcher2/LauncherAppWidgetInfo.java
index 5c8fb38e3..602695a46 100644
--- a/src/com/android/launcher2/LauncherAppWidgetInfo.java
+++ b/src/com/android/launcher2/LauncherAppWidgetInfo.java
@@ -73,8 +73,7 @@ class LauncherAppWidgetInfo extends ItemInfo {
* done so already (only really for default workspace widgets).
*/
void onBindAppWidget(Launcher launcher) {
- if (!mHasNotifiedInitialWidgetSizeChanged &&
- Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) {
+ if (!mHasNotifiedInitialWidgetSizeChanged) {
notifyWidgetSizeChanged(launcher);
}
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 77cb46732..6350c8480 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -2232,11 +2232,9 @@ public class Workspace extends SmoothPagedView
boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0;
- // if the widget resizes on drop, or the sdk level is less than JBMR1, then we
- // need to update the size.
+ // if the widget resizes on drop
if (foundCell && (cell instanceof AppWidgetHostView) &&
- (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY ||
- Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) {
+ (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY)) {
resizeOnDrop = true;
item.spanX = resultSpan[0];
item.spanY = resultSpan[1];
@@ -3045,7 +3043,7 @@ public class Workspace extends SmoothPagedView
}
final ItemInfo item = (ItemInfo) d.dragInfo;
- boolean updateWidgetSize = Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN;
+ boolean updateWidgetSize = false;
if (findNearestVacantCell) {
int minSpanX = item.spanX;
int minSpanY = item.spanY;