OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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.content.browser; | 5 package org.chromium.content.browser; |
6 | 6 |
7 import android.content.Context; | 7 import android.content.Context; |
8 import android.util.Log; | 8 import android.util.Log; |
9 import android.view.MotionEvent; | 9 import android.view.MotionEvent; |
10 import android.view.ScaleGestureDetector; | 10 import android.view.ScaleGestureDetector; |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
116 | 116 |
117 // Passes the touch event to ScaleGestureDetector so that its internal state | 117 // Passes the touch event to ScaleGestureDetector so that its internal state |
118 // won't go wrong. ScaleGestureDetector needs two pointers in a MotionEvent | 118 // won't go wrong. ScaleGestureDetector needs two pointers in a MotionEvent |
119 // to recognize a zoom gesture. | 119 // to recognize a zoom gesture. |
120 boolean processTouchEvent(MotionEvent event) { | 120 boolean processTouchEvent(MotionEvent event) { |
121 // TODO: Need to deal with multi-touch transition | 121 // TODO: Need to deal with multi-touch transition |
122 mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(false); | 122 mMultiTouchListener.setTemporarilyIgnoreDetectorEvents(false); |
123 try { | 123 try { |
124 boolean inGesture = isScaleGestureDetectionInProgress(); | 124 boolean inGesture = isScaleGestureDetectionInProgress(); |
125 boolean retVal = mMultiTouchDetector.onTouchEvent(event); | 125 boolean retVal = mMultiTouchDetector.onTouchEvent(event); |
126 if (event.getActionMasked() == MotionEvent.ACTION_UP && !inGesture)
return false; | 126 if (!inGesture && (event.getActionMasked() == MotionEvent.ACTION_UP |
| 127 || event.getActionMasked() == MotionEvent.ACTION_CANCEL)) { |
| 128 return false; |
| 129 } |
127 return retVal; | 130 return retVal; |
128 } catch (Exception e) { | 131 } catch (Exception e) { |
129 Log.e(TAG, "ScaleGestureDetector got into a bad state!", e); | 132 Log.e(TAG, "ScaleGestureDetector got into a bad state!", e); |
130 assert(false); | 133 assert(false); |
131 } | 134 } |
132 return false; | 135 return false; |
133 } | 136 } |
134 | 137 |
135 void updateMultiTouchSupport(boolean supportsMultiTouchZoom) { | 138 void updateMultiTouchSupport(boolean supportsMultiTouchZoom) { |
136 mMultiTouchListener.setPermanentlyIgnoreDetectorEvents(!supportsMultiTou
chZoom); | 139 mMultiTouchListener.setPermanentlyIgnoreDetectorEvents(!supportsMultiTou
chZoom); |
137 } | 140 } |
138 } | 141 } |
OLD | NEW |