Loading src/com/android/launcher3/dragndrop/DragController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; } Loading Loading @@ -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; Loading src/com/android/launcher3/dragndrop/DragOptions.java +4 −2 Original line number Diff line number Diff line Loading @@ -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. */ Loading Loading @@ -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() Loading @@ -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); } } src/com/android/launcher3/dragndrop/PinItemDragListener.java +28 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"; Loading Loading @@ -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); Loading Loading @@ -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; Loading @@ -212,6 +210,30 @@ public class PinItemDragListener implements Parcelable, View.OnDragListener, Dra return true; } @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; Loading src/com/android/launcher3/popup/PopupContainerWithArrow.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading Loading
src/com/android/launcher3/dragndrop/DragController.java +3 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; } Loading Loading @@ -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; Loading
src/com/android/launcher3/dragndrop/DragOptions.java +4 −2 Original line number Diff line number Diff line Loading @@ -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. */ Loading Loading @@ -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() Loading @@ -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); } }
src/com/android/launcher3/dragndrop/PinItemDragListener.java +28 −6 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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"; Loading Loading @@ -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); Loading Loading @@ -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; Loading @@ -212,6 +210,30 @@ public class PinItemDragListener implements Parcelable, View.OnDragListener, Dra return true; } @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; Loading
src/com/android/launcher3/popup/PopupContainerWithArrow.java +2 −2 Original line number Diff line number Diff line Loading @@ -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); Loading