summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/ButtonDropTarget.java
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-03-28 16:56:30 -0700
committerTony Wickham <twickham@google.com>2016-03-29 12:41:14 -0700
commit855b1b5fff5f6f03a641b3b6973780a24fd9641e (patch)
treeb33415fbe8d3fac286c093549cb26f220a6099ab /src/com/android/launcher3/ButtonDropTarget.java
parent1f5d3ccc253ab0e4b2abb911a83e7f4d33b6869f (diff)
downloadandroid_packages_apps_Trebuchet-855b1b5fff5f6f03a641b3b6973780a24fd9641e.tar.gz
android_packages_apps_Trebuchet-855b1b5fff5f6f03a641b3b6973780a24fd9641e.tar.bz2
android_packages_apps_Trebuchet-855b1b5fff5f6f03a641b3b6973780a24fd9641e.zip
Add distance threshold for dragged items before accepted by targets.
With the new spring-loaded workspace, items are often very close to button drop targets (e.g. App Info) at the start of a drag. This threshold makes it less likely to accidentally drop on a target. Bug: 24099531 Change-Id: I4912ceeb0b63958816177c7bde073e825176d987
Diffstat (limited to 'src/com/android/launcher3/ButtonDropTarget.java')
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index af1ebde8f..43afbe59e 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -24,13 +24,13 @@ import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.annotation.TargetApi;
import android.content.Context;
import android.content.res.ColorStateList;
+import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.PointF;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.InsetDrawable;
import android.os.Build;
import android.util.AttributeSet;
import android.view.View;
@@ -62,6 +62,8 @@ public abstract class ButtonDropTarget extends TextView
/** Whether this drop target is active for the current drag */
protected boolean mActive;
+ /** An item must be dragged at least this many pixels before this drop target is enabled. */
+ private final int mDragDistanceThreshold;
/** The paint applied to the drag view on hover */
protected int mHoverColor = 0;
@@ -78,12 +80,14 @@ public abstract class ButtonDropTarget extends TextView
public ButtonDropTarget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mBottomDragPadding = getResources().getDimensionPixelSize(R.dimen.drop_target_drag_padding);
+ Resources resources = getResources();
+ mBottomDragPadding = resources.getDimensionPixelSize(R.dimen.drop_target_drag_padding);
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.ButtonDropTarget, defStyle, 0);
mHideParentOnDisable = a.getBoolean(R.styleable.ButtonDropTarget_hideParentOnDisable, false);
a.recycle();
+ mDragDistanceThreshold = resources.getDimensionPixelSize(R.dimen.drag_distanceThreshold);
}
@Override
@@ -216,7 +220,8 @@ public abstract class ButtonDropTarget extends TextView
@Override
public boolean isDropEnabled() {
- return mActive;
+ return mActive
+ && mLauncher.getDragController().getDistanceDragged() >= mDragDistanceThreshold;
}
@Override