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/FolderIcon.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/FolderIcon.java')
-rw-r--r-- | src/com/android/launcher2/FolderIcon.java | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/src/com/android/launcher2/FolderIcon.java b/src/com/android/launcher2/FolderIcon.java index ff7e10f5f..c005edfcd 100644 --- a/src/com/android/launcher2/FolderIcon.java +++ b/src/com/android/launcher2/FolderIcon.java @@ -30,6 +30,7 @@ import android.graphics.drawable.Drawable; import android.os.Parcelable; import android.util.AttributeSet; import android.view.LayoutInflater; +import android.view.MotionEvent; import android.view.View; import android.view.ViewGroup; import android.view.animation.AccelerateInterpolator; @@ -53,6 +54,8 @@ public class FolderIcon extends LinearLayout implements FolderListener { FolderInfo mInfo; private static boolean sStaticValuesDirty = true; + private CheckLongPressHelper mLongPressHelper; + // The number of icons to display in the private static final int NUM_ITEMS_IN_PREVIEW = 3; private static final int CONSUMPTION_ANIMATION_DURATION = 100; @@ -95,10 +98,16 @@ public class FolderIcon extends LinearLayout implements FolderListener { public FolderIcon(Context context, AttributeSet attrs) { super(context, attrs); + init(); } public FolderIcon(Context context) { super(context); + init(); + } + + private void init() { + mLongPressHelper = new CheckLongPressHelper(this); } public boolean isDropEnabled() { @@ -591,4 +600,29 @@ public class FolderIcon extends LinearLayout implements FolderListener { setContentDescription(String.format(mContext.getString(R.string.folder_name_format), title)); } + + @Override + public boolean onTouchEvent(MotionEvent event) { + // Call the superclass onTouchEvent first, because sometimes it changes the state to + // isPressed() on an ACTION_UP + boolean result = super.onTouchEvent(event); + + switch (event.getAction()) { + case MotionEvent.ACTION_DOWN: + mLongPressHelper.postCheckForLongPress(); + break; + case MotionEvent.ACTION_CANCEL: + case MotionEvent.ACTION_UP: + mLongPressHelper.cancelLongPress(); + break; + } + return result; + } + + @Override + public void cancelLongPress() { + super.cancelLongPress(); + + mLongPressHelper.cancelLongPress(); + } } |