summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAdam Cohen <adamcohen@google.com>2012-02-13 19:51:31 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2012-02-13 19:51:31 -0800
commit55952e2f531d7c1ce0a3b2d3131f7ac3d7c1a603 (patch)
tree4830ededc1d1f4a308062782290b525fa926a967 /src
parentd83f5f4db328fbd152491bbf9fa13abc94bd6f25 (diff)
parent1b36dc3f2bb643e3b9600755f1a98522e4efc2ed (diff)
downloadandroid_packages_apps_Trebuchet-55952e2f531d7c1ce0a3b2d3131f7ac3d7c1a603.tar.gz
android_packages_apps_Trebuchet-55952e2f531d7c1ce0a3b2d3131f7ac3d7c1a603.tar.bz2
android_packages_apps_Trebuchet-55952e2f531d7c1ce0a3b2d3131f7ac3d7c1a603.zip
Merge "Fixing bugs with new widget adding"
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AppsCustomizePagedView.java29
-rw-r--r--src/com/android/launcher2/Launcher.java1
-rw-r--r--src/com/android/launcher2/PendingAddItemInfo.java16
-rw-r--r--src/com/android/launcher2/Workspace.java2
4 files changed, 35 insertions, 13 deletions
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index de96edade..91205d06e 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -239,6 +239,7 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
static final int WIDGET_INFLATED = 1;
int mWidgetCleanupState = WIDGET_NO_CLEANUP_REQUIRED;
int mWidgetLoadingId = -1;
+ PendingAddWidgetInfo mCreateWidgetInfo = null;
public AppsCustomizePagedView(Context context, AttributeSet attrs) {
super(context, attrs);
@@ -580,13 +581,14 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
public void onShortPress(View v) {
// We are anticipating a long press, and we use this time to load bind and instantiate
// the widget. This will need to be cleaned up if it turns out no long press occurs.
- PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) v.getTag();
- loadWidgetInBackground(createWidgetInfo);
+ mCreateWidgetInfo = new PendingAddWidgetInfo((PendingAddWidgetInfo) v.getTag());
+ loadWidgetInBackground(mCreateWidgetInfo);
}
@Override
public void cleanUpShortPress(View v) {
- PendingAddWidgetInfo info = (PendingAddWidgetInfo) v.getTag();
+ PendingAddWidgetInfo info = mCreateWidgetInfo;
+ mCreateWidgetInfo = null;
if (mWidgetCleanupState >= 0 && mWidgetLoadingId != -1) {
mLauncher.getAppWidgetHost().deleteAppWidgetId(mWidgetLoadingId);
}
@@ -613,7 +615,9 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
Bitmap preview;
Bitmap outline;
if (createItemInfo instanceof PendingAddWidgetInfo) {
- PendingAddWidgetInfo createWidgetInfo = (PendingAddWidgetInfo) createItemInfo;
+ PendingAddWidgetInfo createWidgetInfo = mCreateWidgetInfo;
+ createItemInfo = createWidgetInfo;
+ mCreateWidgetInfo = null;
int[] spanXY = mLauncher.getSpanForWidget(createWidgetInfo, null);
int[] size = mLauncher.getWorkspace().estimateItemSize(spanXY[0],
spanXY[1], createWidgetInfo, true);
@@ -677,19 +681,23 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
postDelayed(new Runnable() {
@Override
public void run() {
- // Dismiss the cling
- mLauncher.dismissAllAppsCling(null);
+ // We don't enter spring-loaded mode if the drag has been cancelled
+ if (mLauncher.getDragController().isDragging()) {
+ // Dismiss the cling
+ mLauncher.dismissAllAppsCling(null);
- // Reset the alpha on the dragged icon before we drag
- resetDrawableState();
+ // Reset the alpha on the dragged icon before we drag
+ resetDrawableState();
- // Go into spring loaded mode (must happen before we startDrag())
- mLauncher.enterSpringLoadedDragMode();
+ // Go into spring loaded mode (must happen before we startDrag())
+ mLauncher.enterSpringLoadedDragMode();
+ }
}
},150);
return true;
}
+
private void endDragging(View target, boolean success) {
mLauncher.getWorkspace().onDragStopped(success);
if (!success || (target != mLauncher.getWorkspace() &&
@@ -699,7 +707,6 @@ public class AppsCustomizePagedView extends PagedViewWithDraggableItems implemen
mLauncher.exitSpringLoadedDragMode();
}
mLauncher.unlockScreenOrientationOnLargeUI();
-
}
@Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 708d5d631..40621454a 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -582,6 +582,7 @@ public final class Launcher extends Activity
mWorkspace.animateExternalDrop(mWidgetBeingConfigured, cellLayout,
(DragView) mDragLayer.getAnimatedView(), onCompleteRunnable,
animationType);
+ mWidgetBeingConfigured = null;
}
@Override
diff --git a/src/com/android/launcher2/PendingAddItemInfo.java b/src/com/android/launcher2/PendingAddItemInfo.java
index 851dddb15..09a8a9ebc 100644
--- a/src/com/android/launcher2/PendingAddItemInfo.java
+++ b/src/com/android/launcher2/PendingAddItemInfo.java
@@ -57,4 +57,18 @@ class PendingAddWidgetInfo extends PendingAddItemInfo {
configurationData = data;
}
}
-} \ No newline at end of file
+
+ // Copy constructor
+ public PendingAddWidgetInfo(PendingAddWidgetInfo copy) {
+ minWidth = copy.minWidth;
+ minHeight = copy.minHeight;
+ previewImage = copy.previewImage;
+ icon = copy.icon;
+ info = copy.info;
+ boundWidget = copy.boundWidget;
+ mimeType = copy.mimeType;
+ configurationData = copy.configurationData;
+ componentName = copy.componentName;
+ itemType = copy.itemType;
+ }
+}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index c8cab163c..309fda891 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -1950,7 +1950,7 @@ public class Workspace extends SmoothPagedView
}
public boolean transitionStateShouldAllowDrop() {
- return (!isSwitchingState() || mTransitionProgress > 0.5f);
+ return ((!isSwitchingState() || mTransitionProgress > 0.5f) && mState != State.SMALL);
}
/**