diff options
Diffstat (limited to 'src/com/android/launcher2/Workspace.java')
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index cae002308..7d1724997 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -39,6 +39,7 @@ import android.graphics.PointF; import android.graphics.Rect; import android.graphics.Region.Op; import android.graphics.drawable.Drawable; +import android.os.Build; import android.os.IBinder; import android.os.Parcelable; import android.util.AttributeSet; @@ -2228,7 +2229,12 @@ public class Workspace extends SmoothPagedView mTargetCell, resultSpan, CellLayout.MODE_ON_DROP); boolean foundCell = mTargetCell[0] >= 0 && mTargetCell[1] >= 0; - if (foundCell && (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY)) { + + // if the widget resizes on drop, or the sdk level is less than JBMR1, then we + // need to update the size. + if (foundCell && (cell instanceof AppWidgetHostView) && + (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY || + Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)) { resizeOnDrop = true; item.spanX = resultSpan[0]; item.spanY = resultSpan[1]; @@ -3037,6 +3043,7 @@ public class Workspace extends SmoothPagedView } final ItemInfo item = (ItemInfo) d.dragInfo; + boolean updateWidgetSize = Build.VERSION.SDK_INT <= Build.VERSION_CODES.JELLY_BEAN; if (findNearestVacantCell) { int minSpanX = item.spanX; int minSpanY = item.spanY; @@ -3048,6 +3055,10 @@ public class Workspace extends SmoothPagedView mTargetCell = cellLayout.createArea((int) mDragViewVisualCenter[0], (int) mDragViewVisualCenter[1], minSpanX, minSpanY, info.spanX, info.spanY, null, mTargetCell, resultSpan, CellLayout.MODE_ON_DROP_EXTERNAL); + + if (resultSpan[0] != item.spanX || resultSpan[1] != item.spanY) { + updateWidgetSize = true; + } item.spanX = resultSpan[0]; item.spanY = resultSpan[1]; } @@ -3077,6 +3088,13 @@ public class Workspace extends SmoothPagedView }; View finalView = pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET ? ((PendingAddWidgetInfo) pendingInfo).boundWidget : null; + + if (finalView instanceof AppWidgetHostView && updateWidgetSize) { + AppWidgetHostView awhv = (AppWidgetHostView) finalView; + AppWidgetResizeFrame.updateWidgetSizeRanges(awhv, mLauncher, item.spanX, + item.spanY); + } + int animationStyle = ANIMATE_INTO_POSITION_AND_DISAPPEAR; if (pendingInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_APPWIDGET && ((PendingAddWidgetInfo) pendingInfo).info.configure != null) { |