summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/dragndrop
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-25 15:24:29 -0800
committerSunny Goyal <sunnygoyal@google.com>2017-01-25 15:31:42 -0800
commit2bcb3fb1f3ac6234ead13d27817b7a32b7c79b1d (patch)
treed3082b44da4d2651d447670052ee12bd386b3601 /src/com/android/launcher3/dragndrop
parentf3d02e4716f89d14d9017851db9ad6141ad26875 (diff)
downloadandroid_packages_apps_Trebuchet-2bcb3fb1f3ac6234ead13d27817b7a32b7c79b1d.tar.gz
android_packages_apps_Trebuchet-2bcb3fb1f3ac6234ead13d27817b7a32b7c79b1d.tar.bz2
android_packages_apps_Trebuchet-2bcb3fb1f3ac6234ead13d27817b7a32b7c79b1d.zip
Handing pin item drag when workspce is not loaded
While the launcher is loading, the drag view is displayed with a gray tint. The drag is started, as soon as the workspace is unlocked Bug: 33584624 Change-Id: I4013ea8b987ec305e73742b194f9e96af761cc35
Diffstat (limited to 'src/com/android/launcher3/dragndrop')
-rw-r--r--src/com/android/launcher3/dragndrop/DragController.java6
-rw-r--r--src/com/android/launcher3/dragndrop/DragOptions.java6
-rw-r--r--src/com/android/launcher3/dragndrop/PinItemDragListener.java34
3 files changed, 35 insertions, 11 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java
index 80c286027..5a5e7d0ab 100644
--- a/src/com/android/launcher3/dragndrop/DragController.java
+++ b/src/com/android/launcher3/dragndrop/DragController.java
@@ -221,7 +221,7 @@ public class DragController implements DragDriver.EventListener, TouchController
if (!mIsInPreDrag) {
callOnDragStart();
} else if (mOptions.preDragCondition != null) {
- mOptions.preDragCondition.onPreDragStart();
+ mOptions.preDragCondition.onPreDragStart(mDragObject);
}
mLastTouch[0] = mMotionDownX;
@@ -236,7 +236,7 @@ public class DragController implements DragDriver.EventListener, TouchController
listener.onDragStart(mDragObject, mOptions);
}
if (mOptions.preDragCondition != null) {
- mOptions.preDragCondition.onPreDragEnd(true /* dragStarted*/);
+ mOptions.preDragCondition.onPreDragEnd(mDragObject, true /* dragStarted*/);
}
mIsInPreDrag = false;
}
@@ -335,7 +335,7 @@ public class DragController implements DragDriver.EventListener, TouchController
private void callOnDragEnd() {
if (mIsInPreDrag && mOptions.preDragCondition != null) {
- mOptions.preDragCondition.onPreDragEnd(false /* dragStarted*/);
+ mOptions.preDragCondition.onPreDragEnd(mDragObject, false /* dragStarted*/);
}
mIsInPreDrag = false;
mOptions = null;
diff --git a/src/com/android/launcher3/dragndrop/DragOptions.java b/src/com/android/launcher3/dragndrop/DragOptions.java
index 906855a7c..230fa2d4a 100644
--- a/src/com/android/launcher3/dragndrop/DragOptions.java
+++ b/src/com/android/launcher3/dragndrop/DragOptions.java
@@ -20,6 +20,8 @@ import android.graphics.Point;
import android.support.annotation.CallSuper;
import android.view.View;
+import com.android.launcher3.DropTarget;
+
/**
* Set of options to control the drag and drop behavior.
*/
@@ -52,7 +54,7 @@ public class DragOptions {
* The pre-drag has started, but onDragStart() is
* deferred until shouldStartDrag() returns true.
*/
- void onPreDragStart();
+ void onPreDragStart(DropTarget.DragObject dragObject);
/**
* The pre-drag has ended. This gets called at the same time as onDragStart()
@@ -60,6 +62,6 @@ public class DragOptions {
* @param dragStarted Whether the pre-drag ended because the actual drag started.
* This will be true if the condition was met, otherwise false.
*/
- void onPreDragEnd(boolean dragStarted);
+ void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted);
}
}
diff --git a/src/com/android/launcher3/dragndrop/PinItemDragListener.java b/src/com/android/launcher3/dragndrop/PinItemDragListener.java
index 1a99cc886..4fc08bdaa 100644
--- a/src/com/android/launcher3/dragndrop/PinItemDragListener.java
+++ b/src/com/android/launcher3/dragndrop/PinItemDragListener.java
@@ -40,6 +40,7 @@ import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherAppWidgetProviderInfo;
import com.android.launcher3.PendingAddItemInfo;
+import com.android.launcher3.R;
import com.android.launcher3.compat.PinItemRequestCompat;
import com.android.launcher3.folder.Folder;
import com.android.launcher3.graphics.LauncherIcons;
@@ -55,7 +56,8 @@ import java.util.UUID;
* {@link DragSource} for handling drop from from a different window. This object is initialized
* in the source window and is passed on to the Launcher activity as an Intent extra.
*/
-public class PinItemDragListener implements Parcelable, View.OnDragListener, DragSource {
+public class PinItemDragListener
+ implements Parcelable, View.OnDragListener, DragSource, DragOptions.PreDragCondition {
private static final String TAG = "PinItemDragListener";
@@ -134,11 +136,6 @@ public class PinItemDragListener implements Parcelable, View.OnDragListener, Dra
return false;
}
- if (mLauncher.isWorkspaceLocked()) {
- // TODO: implement wait
- return false;
- }
-
final PendingAddItemInfo item;
final Bitmap preview;
@@ -188,6 +185,7 @@ public class PinItemDragListener implements Parcelable, View.OnDragListener, Dra
Point downPos = new Point((int) event.getX(), (int) event.getY());
DragOptions options = new DragOptions();
options.systemDndStartPoint = downPos;
+ options.preDragCondition = this;
int x = downPos.x + dragShift.x;
int y = downPos.y + dragShift.y;
@@ -198,6 +196,30 @@ public class PinItemDragListener implements Parcelable, View.OnDragListener, Dra
}
@Override
+ public boolean shouldStartDrag(double distanceDragged) {
+ // Stay in pre-drag mode, if workspace is locked.
+ return !mLauncher.isWorkspaceLocked();
+ }
+
+ @Override
+ public void onPreDragStart(DropTarget.DragObject dragObject) {
+ // The predrag starts when the workspace is not yet loaded. In some cases we set
+ // the dragLayer alpha to 0 to have a nice fade-in animation. But that will prevent the
+ // dragView from being visible. Instead just skip the fade-in animation here.
+ mLauncher.getDragLayer().setAlpha(1);
+
+ dragObject.dragView.setColor(
+ mLauncher.getResources().getColor(R.color.delete_target_hover_tint));
+ }
+
+ @Override
+ public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
+ if (dragStarted) {
+ dragObject.dragView.setColor(0);
+ }
+ }
+
+ @Override
public boolean supportsAppInfoDropTarget() {
return false;
}