diff options
Diffstat (limited to 'src/com/android/launcher3/LauncherAppWidgetHostView.java')
-rw-r--r-- | src/com/android/launcher3/LauncherAppWidgetHostView.java | 26 |
1 files changed, 24 insertions, 2 deletions
diff --git a/src/com/android/launcher3/LauncherAppWidgetHostView.java b/src/com/android/launcher3/LauncherAppWidgetHostView.java index 51a649a07..e39727b17 100644 --- a/src/com/android/launcher3/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher3/LauncherAppWidgetHostView.java @@ -21,6 +21,7 @@ import android.content.Context; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.View; +import android.view.ViewConfiguration; import android.view.ViewGroup; import android.widget.RemoteViews; @@ -30,12 +31,16 @@ import com.android.launcher3.DragLayer.TouchCompleteListener; * {@inheritDoc} */ public class LauncherAppWidgetHostView extends AppWidgetHostView implements TouchCompleteListener { + + LayoutInflater mInflater; + private CheckLongPressHelper mLongPressHelper; - private LayoutInflater mInflater; private Context mContext; private int mPreviousOrientation; private DragLayer mDragLayer; + private float mSlop; + public LauncherAppWidgetHostView(Context context) { super(context); mContext = context; @@ -56,7 +61,8 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc super.updateAppWidget(remoteViews); } - public boolean orientationChangedSincedInflation() { + public boolean isReinflateRequired() { + // Re-inflate is required if the orientation has changed since last inflated. int orientation = mContext.getResources().getConfiguration().orientation; if (mPreviousOrientation != orientation) { return true; @@ -90,6 +96,11 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); break; + case MotionEvent.ACTION_MOVE: + if (!Utilities.pointInView(this, ev.getX(), ev.getY(), mSlop)) { + mLongPressHelper.cancelLongPress(); + } + break; } // Otherwise continue letting touch events fall through to children @@ -104,11 +115,22 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView implements Touc case MotionEvent.ACTION_CANCEL: mLongPressHelper.cancelLongPress(); break; + case MotionEvent.ACTION_MOVE: + if (!Utilities.pointInView(this, ev.getX(), ev.getY(), mSlop)) { + mLongPressHelper.cancelLongPress(); + } + break; } return false; } @Override + protected void onAttachedToWindow() { + super.onAttachedToWindow(); + mSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); + } + + @Override public void cancelLongPress() { super.cancelLongPress(); mLongPressHelper.cancelLongPress(); |