summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSunny Goyal <sunnygoyal@google.com>2017-01-27 17:58:34 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-01-27 17:58:34 +0000
commit5cfd1158ec1e4a19689217e9fbddd0fd795b2611 (patch)
treecfa01f78fca2554532e0ae40c2bd660ca68df84b
parent8a0dc38aebdc7624db3de2cdfecb9d11e2baee04 (diff)
parent2bcb3fb1f3ac6234ead13d27817b7a32b7c79b1d (diff)
downloadandroid_packages_apps_Trebuchet-5cfd1158ec1e4a19689217e9fbddd0fd795b2611.tar.gz
android_packages_apps_Trebuchet-5cfd1158ec1e4a19689217e9fbddd0fd795b2611.tar.bz2
android_packages_apps_Trebuchet-5cfd1158ec1e4a19689217e9fbddd0fd795b2611.zip
Merge "Handing pin item drag when workspce is not loaded" into ub-launcher3-master
-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
-rw-r--r--src/com/android/launcher3/popup/PopupContainerWithArrow.java4
4 files changed, 37 insertions, 13 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 73ad1c86a..9770d40e9 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;
@@ -57,7 +58,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";
@@ -136,11 +138,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;
final View view = new View(mLauncher);
@@ -203,6 +200,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;
@@ -213,6 +211,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;
}
diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
index c69cf6d7f..af1bd9b34 100644
--- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java
+++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java
@@ -498,12 +498,12 @@ public class PopupContainerWithArrow extends AbstractFloatingView
}
@Override
- public void onPreDragStart() {
+ public void onPreDragStart(DropTarget.DragObject dragObject) {
mOriginalIcon.setVisibility(INVISIBLE);
}
@Override
- public void onPreDragEnd(boolean dragStarted) {
+ public void onPreDragEnd(DropTarget.DragObject dragObject, boolean dragStarted) {
if (!dragStarted) {
mOriginalIcon.setVisibility(VISIBLE);
mLauncher.getUserEventDispatcher().logDeepShortcutsOpen(mOriginalIcon);