diff options
author | Winson Chung <winsonc@google.com> | 2012-02-23 15:23:44 -0800 |
---|---|---|
committer | Winson Chung <winsonc@google.com> | 2012-02-23 15:23:56 -0800 |
commit | 88f334571fe41df620ba903ced9b2c69b0170d5c (patch) | |
tree | 10cab22bd80262aa11dfc12238eb07394a2b0bf6 /src/com/android/launcher2/LauncherAppWidgetHostView.java | |
parent | 72d598400da7cef9c7fc4f99bb1fcd7ff0710011 (diff) | |
download | android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.tar.gz android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.tar.bz2 android_packages_apps_Trebuchet-88f334571fe41df620ba903ced9b2c69b0170d5c.zip |
Lowering long press time for workspace items.
Change-Id: I6a3b0e13681f07d0e50bf2dcec777037c4ef51a5
Diffstat (limited to 'src/com/android/launcher2/LauncherAppWidgetHostView.java')
-rw-r--r-- | src/com/android/launcher2/LauncherAppWidgetHostView.java | 48 |
1 files changed, 7 insertions, 41 deletions
diff --git a/src/com/android/launcher2/LauncherAppWidgetHostView.java b/src/com/android/launcher2/LauncherAppWidgetHostView.java index 0c3bdcaf8..d73dd3008 100644 --- a/src/com/android/launcher2/LauncherAppWidgetHostView.java +++ b/src/com/android/launcher2/LauncherAppWidgetHostView.java @@ -30,12 +30,12 @@ import com.android.launcher.R; * {@inheritDoc} */ public class LauncherAppWidgetHostView extends AppWidgetHostView { - private boolean mHasPerformedLongPress; - private CheckForLongPress mPendingCheckForLongPress; + private CheckLongPressHelper mLongPressHelper; private LayoutInflater mInflater; public LauncherAppWidgetHostView(Context context) { super(context); + mLongPressHelper = new CheckLongPressHelper(this); mInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } @@ -46,8 +46,8 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView { public boolean onInterceptTouchEvent(MotionEvent ev) { // Consume any touch events for ourselves after longpress is triggered - if (mHasPerformedLongPress) { - mHasPerformedLongPress = false; + if (mLongPressHelper.hasPerformedLongPress()) { + mLongPressHelper.cancelLongPress(); return true; } @@ -55,16 +55,13 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView { // users can always pick up this widget switch (ev.getAction()) { case MotionEvent.ACTION_DOWN: { - postCheckForLongClick(); + mLongPressHelper.postCheckForLongPress(); break; } case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: - mHasPerformedLongPress = false; - if (mPendingCheckForLongPress != null) { - removeCallbacks(mPendingCheckForLongPress); - } + mLongPressHelper.cancelLongPress(); break; } @@ -72,42 +69,11 @@ public class LauncherAppWidgetHostView extends AppWidgetHostView { return false; } - class CheckForLongPress implements Runnable { - private int mOriginalWindowAttachCount; - - public void run() { - if ((mParent != null) && hasWindowFocus() - && mOriginalWindowAttachCount == getWindowAttachCount() - && !mHasPerformedLongPress) { - if (performLongClick()) { - mHasPerformedLongPress = true; - } - } - } - - public void rememberWindowAttachCount() { - mOriginalWindowAttachCount = getWindowAttachCount(); - } - } - - private void postCheckForLongClick() { - mHasPerformedLongPress = false; - - if (mPendingCheckForLongPress == null) { - mPendingCheckForLongPress = new CheckForLongPress(); - } - mPendingCheckForLongPress.rememberWindowAttachCount(); - postDelayed(mPendingCheckForLongPress, ViewConfiguration.getLongPressTimeout()); - } - @Override public void cancelLongPress() { super.cancelLongPress(); - mHasPerformedLongPress = false; - if (mPendingCheckForLongPress != null) { - removeCallbacks(mPendingCheckForLongPress); - } + mLongPressHelper.cancelLongPress(); } @Override |