summaryrefslogtreecommitdiffstats
path: root/src/com/android/launcher3/touch
diff options
context:
space:
mode:
authorSiarhei Vishniakou <svv@google.com>2019-03-14 01:16:28 +0000
committerSiarhei Vishniakou <svv@google.com>2019-03-14 01:16:28 +0000
commite7a1e25906709133e51aacea330af3ae0dd497d9 (patch)
treeebaea6dffc3de07947f7fa537a43494654b1b7a0 /src/com/android/launcher3/touch
parent7c8fb786fa529c76fc88b8b24dec2d39e225546b (diff)
downloadandroid_packages_apps_Trebuchet-e7a1e25906709133e51aacea330af3ae0dd497d9.tar.gz
android_packages_apps_Trebuchet-e7a1e25906709133e51aacea330af3ae0dd497d9.tar.bz2
android_packages_apps_Trebuchet-e7a1e25906709133e51aacea330af3ae0dd497d9.zip
Revert "Use GestureDetector in WorkspaceTouchListener"
This reverts commit 7c8fb786fa529c76fc88b8b24dec2d39e225546b. Reason for revert: Chatted with Sunny, the concern was brought up that this is risky and will create potential for dogfood confusion with the new gesture navigation that is getting rolled out soon. So we can try to reland this in a few weeks. Change-Id: I4f09cc9982164195dc42cd6e4714ede767cce786
Diffstat (limited to 'src/com/android/launcher3/touch')
-rw-r--r--src/com/android/launcher3/touch/WorkspaceTouchListener.java12
1 files changed, 4 insertions, 8 deletions
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index 78017569e..4de082e90 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -29,7 +29,6 @@ import android.graphics.Rect;
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
-import android.view.GestureDetector;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
@@ -46,7 +45,7 @@ import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
/**
* Helper class to handle touch on empty space in workspace and show options popup on long press
*/
-public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListener implements OnTouchListener {
+public class WorkspaceTouchListener implements OnTouchListener, Runnable {
/**
* STATE_PENDING_PARENT_INFORM is the state between longPress performed & the next motionEvent.
@@ -67,21 +66,16 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe
private int mLongPressState = STATE_CANCELLED;
- private final GestureDetector mGestureDetector;
-
public WorkspaceTouchListener(Launcher launcher, Workspace workspace) {
mLauncher = launcher;
mWorkspace = workspace;
// Use twice the touch slop as we are looking for long press which is more
// likely to cause movement.
mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop();
- mGestureDetector = new GestureDetector(workspace.getContext(), this);
}
@Override
public boolean onTouch(View view, MotionEvent ev) {
- mGestureDetector.onTouchEvent(ev);
-
int action = ev.getActionMasked();
if (action == ACTION_DOWN) {
// Check if we can handle long press.
@@ -103,6 +97,7 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe
if (handleLongPress) {
mLongPressState = STATE_REQUESTED;
mTouchDownPoint.set(ev.getX(), ev.getY());
+ mWorkspace.postDelayed(this, getLongPressTimeout());
}
mWorkspace.onTouchEvent(ev);
@@ -160,11 +155,12 @@ public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListe
}
private void cancelLongPress() {
+ mWorkspace.removeCallbacks(this);
mLongPressState = STATE_CANCELLED;
}
@Override
- public void onLongPress(MotionEvent event) {
+ public void run() {
if (mLongPressState == STATE_REQUESTED) {
if (canHandleLongPress()) {
mLongPressState = STATE_PENDING_PARENT_INFORM;