OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package org.chromium.chrome.browser.compositor.layouts.eventfilter; | 5 package org.chromium.chrome.browser.compositor.layouts.eventfilter; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.os.Handler; | 8 import android.os.Handler; |
9 import android.view.GestureDetector; | 9 import android.view.GestureDetector; |
10 import android.view.MotionEvent; | 10 import android.view.MotionEvent; |
11 import android.view.ViewConfiguration; | 11 import android.view.ViewConfiguration; |
12 | 12 |
13 /** | 13 /** |
14 * Filters events that would trigger gestures like scroll and fling. | 14 * Filters events that would trigger gestures like scroll and fling. |
15 */ | 15 */ |
16 public class GestureEventFilter extends EventFilter { | 16 public class GestureEventFilter extends EventFilter { |
17 private final int mLongPressTimeoutMs; | 17 private final int mLongPressTimeoutMs; |
18 private final GestureDetector mDetector; | 18 private final GestureDetector mDetector; |
19 private final GestureHandler mHandler; | 19 private final GestureHandler mHandler; |
20 private final boolean mUseDefaultLongPress; | 20 private final boolean mUseDefaultLongPress; |
21 private final int mScaledTouchSlop; | 21 private final int mScaledTouchSlop; |
22 private boolean mSingleInput = true; | 22 private boolean mSingleInput = true; |
23 private boolean mInLongPress; | 23 private boolean mInLongPress; |
24 private boolean mSeenFirstScrollEvent; | 24 private boolean mSeenFirstScrollEvent; |
25 private int mButtons = 0; | 25 private int mButtons; |
26 private LongPressRunnable mLongPressRunnable = new LongPressRunnable(); | 26 private LongPressRunnable mLongPressRunnable = new LongPressRunnable(); |
27 private Handler mLongPressHandler = new Handler(); | 27 private Handler mLongPressHandler = new Handler(); |
28 | 28 |
29 /** | 29 /** |
30 * A runnable to send a delayed long press. | 30 * A runnable to send a delayed long press. |
31 */ | 31 */ |
32 private class LongPressRunnable implements Runnable { | 32 private class LongPressRunnable implements Runnable { |
33 private MotionEvent mInitialEvent; | 33 private MotionEvent mInitialEvent; |
34 private boolean mIsPending; | 34 private boolean mIsPending; |
35 | 35 |
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 } | 239 } |
240 mDetector.onTouchEvent(e); | 240 mDetector.onTouchEvent(e); |
241 | 241 |
242 // Propagate the up event after any gesture events. | 242 // Propagate the up event after any gesture events. |
243 if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANC
EL) { | 243 if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANC
EL) { |
244 mHandler.onUpOrCancel(); | 244 mHandler.onUpOrCancel(); |
245 } | 245 } |
246 return true; | 246 return true; |
247 } | 247 } |
248 } | 248 } |
OLD | NEW |