summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher2/FolderIcon.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/com/android/launcher2/FolderIcon.java')
-rw-r--r--src/com/android/launcher2/FolderIcon.java34
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();
+ }
}