summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/dragndrop/DragLayer.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher3/dragndrop/DragLayer.java')
-rw-r--r--src/com/android/launcher3/dragndrop/DragLayer.java61
1 files changed, 57 insertions, 4 deletions
diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java
index 58638288e..016347b17 100644
--- a/src/com/android/launcher3/dragndrop/DragLayer.java
+++ b/src/com/android/launcher3/dragndrop/DragLayer.java
@@ -21,14 +21,22 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.TimeInterpolator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
+import android.annotation.TargetApi;
+import android.content.ClipDescription;
import android.content.Context;
+import android.content.Intent;
import android.content.res.Resources;
+import android.graphics.Bitmap;
+import android.graphics.Bitmap.Config;
import android.graphics.Canvas;
import android.graphics.Color;
+import android.graphics.Point;
import android.graphics.Rect;
import android.graphics.Region;
import android.graphics.drawable.Drawable;
+import android.os.Build;
import android.util.AttributeSet;
+import android.util.Log;
import android.view.DragEvent;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -45,12 +53,14 @@ import com.android.launcher3.AppWidgetResizeFrame;
import com.android.launcher3.CellLayout;
import com.android.launcher3.DropTargetBar;
import com.android.launcher3.InsettableFrameLayout;
+import com.android.launcher3.InstallShortcutReceiver;
import com.android.launcher3.ItemInfo;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherAppWidgetHostView;
import com.android.launcher3.PinchToOverviewListener;
import com.android.launcher3.R;
import com.android.launcher3.ShortcutAndWidgetContainer;
+import com.android.launcher3.ShortcutInfo;
import com.android.launcher3.Utilities;
import com.android.launcher3.Workspace;
import com.android.launcher3.allapps.AllAppsTransitionController;
@@ -62,6 +72,7 @@ import com.android.launcher3.shortcuts.DeepShortcutsContainer;
import com.android.launcher3.util.Thunk;
import com.android.launcher3.util.TouchController;
+import java.net.URISyntaxException;
import java.util.ArrayList;
/**
@@ -431,8 +442,46 @@ public class DragLayer extends InsettableFrameLayout {
return false;
}
+ @TargetApi(Build.VERSION_CODES.N)
+ private void handleSystemDragStart(DragEvent event) {
+ if (!FeatureFlags.LAUNCHER3_USE_SYSTEM_DRAG_DRIVER || !Utilities.isNycOrAbove()) {
+ return;
+ }
+ if (mLauncher.isWorkspaceLocked()) {
+ return;
+ }
+
+ ClipDescription description = event.getClipDescription();
+ if (!description.hasMimeType(ClipDescription.MIMETYPE_TEXT_INTENT)) {
+ return;
+ }
+ ShortcutInfo info = new ShortcutInfo();
+ // Set a dummy intent until we get the final value
+ info.intent = new Intent();
+
+ // Since we are not going through the workspace for starting the drag, set drag related
+ // information on the workspace before starting the drag.
+ ExternalDragPreviewProvider previewProvider =
+ new ExternalDragPreviewProvider(mLauncher, info);
+ mLauncher.getWorkspace().prepareDragWithProvider(previewProvider);
+
+ DragOptions options = new DragOptions();
+ options.systemDndStartPoint = new Point((int) event.getX(), (int) event.getY());
+
+ int halfPadding = previewProvider.previewPadding / 2;
+ mDragController.startDrag(
+ Bitmap.createBitmap(1, 1, Config.ARGB_8888),
+ 0, 0,
+ new AnotherWindowDragSource(mLauncher), info,
+ new Point(- halfPadding, halfPadding),
+ previewProvider.getPreviewBounds(), 1f, options);
+ }
+
@Override
public boolean onDragEvent (DragEvent event) {
+ if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) {
+ handleSystemDragStart(event);
+ }
return mDragController.onDragEvent(event);
}
@@ -758,11 +807,15 @@ public class DragLayer extends InsettableFrameLayout {
// If duration < 0, this is a cue to compute the duration based on the distance
if (duration < 0) {
- duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
- if (dist < maxDist) {
- duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist);
+ if (mDragController != null && mDragController.isExternalDrag()) {
+ duration = 1;
+ } else {
+ duration = res.getInteger(R.integer.config_dropAnimMaxDuration);
+ if (dist < maxDist) {
+ duration *= mCubicEaseOutInterpolator.getInterpolation(dist / maxDist);
+ }
+ duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration));
}
- duration = Math.max(duration, res.getInteger(R.integer.config_dropAnimMinDuration));
}
// Fall back to cubic ease out interpolator for the animation if none is specified