summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTony Wickham <twickham@google.com>2016-08-15 22:52:56 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2016-08-15 22:52:56 +0000
commite8882f7d273eaa6521d57707e344ddd9d70af4bd (patch)
tree69767ec15f57b87f11756d534c66d492959a018f /src
parent650cd2377bd2b9f576108bb921c7317c7c520bce (diff)
parente04a07f6acecc1565d037f62b0b109e0b8a243d4 (diff)
downloadandroid_packages_apps_Trebuchet-e8882f7d273eaa6521d57707e344ddd9d70af4bd.tar.gz
android_packages_apps_Trebuchet-e8882f7d273eaa6521d57707e344ddd9d70af4bd.tar.bz2
android_packages_apps_Trebuchet-e8882f7d273eaa6521d57707e344ddd9d70af4bd.zip
Merge "Ignore clicks on shortcuts' drag handles." into ub-launcher3-calgary
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher3/shortcuts/DeepShortcutTextView.java37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
index 450d36da5..42086fcb5 100644
--- a/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
+++ b/src/com/android/launcher3/shortcuts/DeepShortcutTextView.java
@@ -17,15 +17,23 @@
package com.android.launcher3.shortcuts;
import android.content.Context;
+import android.content.res.Resources;
+import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
+import android.view.MotionEvent;
import com.android.launcher3.BubbleTextView;
+import com.android.launcher3.R;
+import com.android.launcher3.Utilities;
/**
* A {@link BubbleTextView} that has the shortcut icon on the left and drag handle on the right.
*/
public class DeepShortcutTextView extends BubbleTextView {
+ private final Rect mDragHandleBounds = new Rect();
+ private final int mDragHandleWidth;
+ private boolean mShouldPerformClick = true;
public DeepShortcutTextView(Context context) {
this(context, null, 0);
@@ -37,10 +45,39 @@ public class DeepShortcutTextView extends BubbleTextView {
public DeepShortcutTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
+
+ Resources resources = getResources();
+ mDragHandleWidth = resources.getDimensionPixelSize(R.dimen.deep_shortcut_padding_end)
+ + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drag_handle_size)
+ + resources.getDimensionPixelSize(R.dimen.deep_shortcut_drawable_padding) / 2;
+ }
+
+ @Override
+ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+ super.onMeasure(widthMeasureSpec, heightMeasureSpec);
+
+ mDragHandleBounds.set(0, 0, mDragHandleWidth, getMeasuredHeight());
+ if (!Utilities.isRtl(getResources())) {
+ mDragHandleBounds.offset(getMeasuredWidth() - mDragHandleBounds.width(), 0);
+ }
}
@Override
protected void applyCompoundDrawables(Drawable icon) {
// The icon is drawn in a separate view.
}
+
+ @Override
+ public boolean onTouchEvent(MotionEvent ev) {
+ if (ev.getAction() == MotionEvent.ACTION_DOWN) {
+ // Ignore clicks on the drag handle (long clicks still start the drag).
+ mShouldPerformClick = !mDragHandleBounds.contains((int) ev.getX(), (int) ev.getY());
+ }
+ return super.onTouchEvent(ev);
+ }
+
+ @Override
+ public boolean performClick() {
+ return mShouldPerformClick && super.performClick();
+ }
}