Making launcher use new widget binding APIs

Change-Id: I9cd6716e1dc0c53b5c846371ea109ced4cd3d40a
This commit is contained in:
Adam Cohen
2012-09-10 15:53:09 -07:00
parent 671a3a227c
commit 9e05a5ea95
5 changed files with 71 additions and 8 deletions
+19 -1
View File
@@ -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) {