Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package android.view; |
| 18 | |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 19 | import android.annotation.UnsupportedAppUsage; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 20 | import android.content.Context; |
Adam Powell | 3307958 | 2012-10-09 11:20:39 -0700 | [diff] [blame] | 21 | import android.content.res.Resources; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 22 | import android.os.Build; |
| 23 | import android.os.Handler; |
Adam Powell | a4ce6ae | 2012-09-24 20:13:23 -0700 | [diff] [blame] | 24 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 25 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 26 | * Detects scaling transformation gestures using the supplied {@link MotionEvent}s. |
| 27 | * The {@link OnScaleGestureListener} callback will notify users when a particular |
| 28 | * gesture event has occurred. |
| 29 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 30 | * This class should only be used with {@link MotionEvent}s reported via touch. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 31 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 32 | * To use this class: |
| 33 | * <ul> |
| 34 | * <li>Create an instance of the {@code ScaleGestureDetector} for your |
| 35 | * {@link View} |
| 36 | * <li>In the {@link View#onTouchEvent(MotionEvent)} method ensure you call |
| 37 | * {@link #onTouchEvent(MotionEvent)}. The methods defined in your |
| 38 | * callback will be executed when the events occur. |
| 39 | * </ul> |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 40 | */ |
| 41 | public class ScaleGestureDetector { |
Adam Powell | 0818020 | 2011-03-07 16:48:29 -0800 | [diff] [blame] | 42 | private static final String TAG = "ScaleGestureDetector"; |
| 43 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 44 | /** |
| 45 | * The listener for receiving notifications when gestures occur. |
| 46 | * If you want to listen for all the different gestures then implement |
| 47 | * this interface. If you only want to listen for a subset it might |
| 48 | * be easier to extend {@link SimpleOnScaleGestureListener}. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 49 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 50 | * An application will receive events in the following order: |
| 51 | * <ul> |
Adam Powell | ab905c87 | 2010-02-03 11:01:58 -0800 | [diff] [blame] | 52 | * <li>One {@link OnScaleGestureListener#onScaleBegin(ScaleGestureDetector)} |
| 53 | * <li>Zero or more {@link OnScaleGestureListener#onScale(ScaleGestureDetector)} |
| 54 | * <li>One {@link OnScaleGestureListener#onScaleEnd(ScaleGestureDetector)} |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 55 | * </ul> |
| 56 | */ |
| 57 | public interface OnScaleGestureListener { |
| 58 | /** |
| 59 | * Responds to scaling events for a gesture in progress. |
| 60 | * Reported by pointer motion. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 61 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 62 | * @param detector The detector reporting the event - use this to |
| 63 | * retrieve extended info about event state. |
| 64 | * @return Whether or not the detector should consider this event |
| 65 | * as handled. If an event was not handled, the detector |
| 66 | * will continue to accumulate movement until an event is |
| 67 | * handled. This can be useful if an application, for example, |
| 68 | * only wants to update scaling factors if the change is |
| 69 | * greater than 0.01. |
| 70 | */ |
| 71 | public boolean onScale(ScaleGestureDetector detector); |
| 72 | |
| 73 | /** |
| 74 | * Responds to the beginning of a scaling gesture. Reported by |
| 75 | * new pointers going down. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 76 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 77 | * @param detector The detector reporting the event - use this to |
| 78 | * retrieve extended info about event state. |
| 79 | * @return Whether or not the detector should continue recognizing |
| 80 | * this gesture. For example, if a gesture is beginning |
| 81 | * with a focal point outside of a region where it makes |
| 82 | * sense, onScaleBegin() may return false to ignore the |
| 83 | * rest of the gesture. |
| 84 | */ |
| 85 | public boolean onScaleBegin(ScaleGestureDetector detector); |
| 86 | |
| 87 | /** |
| 88 | * Responds to the end of a scale gesture. Reported by existing |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 89 | * pointers going up. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 90 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 91 | * Once a scale has ended, {@link ScaleGestureDetector#getFocusX()} |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 92 | * and {@link ScaleGestureDetector#getFocusY()} will return focal point |
| 93 | * of the pointers remaining on the screen. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 94 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 95 | * @param detector The detector reporting the event - use this to |
| 96 | * retrieve extended info about event state. |
| 97 | */ |
| 98 | public void onScaleEnd(ScaleGestureDetector detector); |
| 99 | } |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 100 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 101 | /** |
| 102 | * A convenience class to extend when you only want to listen for a subset |
| 103 | * of scaling-related events. This implements all methods in |
| 104 | * {@link OnScaleGestureListener} but does nothing. |
Adam Powell | 346c8fb | 2010-03-12 10:52:35 -0800 | [diff] [blame] | 105 | * {@link OnScaleGestureListener#onScale(ScaleGestureDetector)} returns |
| 106 | * {@code false} so that a subclass can retrieve the accumulated scale |
| 107 | * factor in an overridden onScaleEnd. |
| 108 | * {@link OnScaleGestureListener#onScaleBegin(ScaleGestureDetector)} returns |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 109 | * {@code true}. |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 110 | */ |
Adam Powell | 216bccf | 2010-02-01 15:03:17 -0800 | [diff] [blame] | 111 | public static class SimpleOnScaleGestureListener implements OnScaleGestureListener { |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 112 | |
| 113 | public boolean onScale(ScaleGestureDetector detector) { |
Adam Powell | 346c8fb | 2010-03-12 10:52:35 -0800 | [diff] [blame] | 114 | return false; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 115 | } |
| 116 | |
| 117 | public boolean onScaleBegin(ScaleGestureDetector detector) { |
| 118 | return true; |
| 119 | } |
| 120 | |
| 121 | public void onScaleEnd(ScaleGestureDetector detector) { |
| 122 | // Intentionally empty |
| 123 | } |
| 124 | } |
| 125 | |
Adam Powell | 346c8fb | 2010-03-12 10:52:35 -0800 | [diff] [blame] | 126 | private final Context mContext; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 127 | @UnsupportedAppUsage |
Adam Powell | 346c8fb | 2010-03-12 10:52:35 -0800 | [diff] [blame] | 128 | private final OnScaleGestureListener mListener; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 129 | |
| 130 | private float mFocusX; |
| 131 | private float mFocusY; |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 132 | |
Mindy Pereira | 9f1221f | 2013-09-16 11:36:12 -0700 | [diff] [blame] | 133 | private boolean mQuickScaleEnabled; |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 134 | private boolean mStylusScaleEnabled; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 135 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 136 | private float mCurrSpan; |
| 137 | private float mPrevSpan; |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 138 | private float mInitialSpan; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 139 | private float mCurrSpanX; |
| 140 | private float mCurrSpanY; |
| 141 | private float mPrevSpanX; |
| 142 | private float mPrevSpanY; |
| 143 | private long mCurrTime; |
| 144 | private long mPrevTime; |
| 145 | private boolean mInProgress; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 146 | @UnsupportedAppUsage |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 147 | private int mSpanSlop; |
Mathew Inwood | a570dee | 2018-08-17 14:56:00 +0100 | [diff] [blame] | 148 | @UnsupportedAppUsage |
Adam Powell | 828e56e | 2012-09-14 18:56:16 -0700 | [diff] [blame] | 149 | private int mMinSpan; |
Adam Powell | e33cef8 | 2011-02-23 16:51:20 -0800 | [diff] [blame] | 150 | |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 151 | private final Handler mHandler; |
Adam Powell | a4ce6ae | 2012-09-24 20:13:23 -0700 | [diff] [blame] | 152 | |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 153 | private float mAnchoredScaleStartX; |
| 154 | private float mAnchoredScaleStartY; |
| 155 | private int mAnchoredScaleMode = ANCHORED_SCALE_MODE_NONE; |
| 156 | |
Adam Powell | d736d20 | 2012-09-25 19:30:44 -0700 | [diff] [blame] | 157 | private static final long TOUCH_STABILIZE_TIME = 128; // ms |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 158 | private static final float SCALE_FACTOR = .5f; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 159 | private static final int ANCHORED_SCALE_MODE_NONE = 0; |
| 160 | private static final int ANCHORED_SCALE_MODE_DOUBLE_TAP = 1; |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 161 | private static final int ANCHORED_SCALE_MODE_STYLUS = 2; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 162 | |
Adam Powell | a4ce6ae | 2012-09-24 20:13:23 -0700 | [diff] [blame] | 163 | |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 164 | /** |
| 165 | * Consistency verifier for debugging purposes. |
| 166 | */ |
| 167 | private final InputEventConsistencyVerifier mInputEventConsistencyVerifier = |
| 168 | InputEventConsistencyVerifier.isInstrumentationEnabled() ? |
| 169 | new InputEventConsistencyVerifier(this, 0) : null; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 170 | private GestureDetector mGestureDetector; |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 171 | |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 172 | private boolean mEventBeforeOrAboveStartingGestureEvent; |
| 173 | |
| 174 | /** |
| 175 | * Creates a ScaleGestureDetector with the supplied listener. |
| 176 | * You may only use this constructor from a {@link android.os.Looper Looper} thread. |
| 177 | * |
| 178 | * @param context the application's context |
| 179 | * @param listener the listener invoked for all the callbacks, this must |
| 180 | * not be null. |
| 181 | * |
| 182 | * @throws NullPointerException if {@code listener} is null. |
| 183 | */ |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 184 | public ScaleGestureDetector(Context context, OnScaleGestureListener listener) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 185 | this(context, listener, null); |
| 186 | } |
| 187 | |
| 188 | /** |
| 189 | * Creates a ScaleGestureDetector with the supplied listener. |
| 190 | * @see android.os.Handler#Handler() |
| 191 | * |
| 192 | * @param context the application's context |
| 193 | * @param listener the listener invoked for all the callbacks, this must |
| 194 | * not be null. |
| 195 | * @param handler the handler to use for running deferred listener events. |
| 196 | * |
| 197 | * @throws NullPointerException if {@code listener} is null. |
| 198 | */ |
| 199 | public ScaleGestureDetector(Context context, OnScaleGestureListener listener, |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 200 | Handler handler) { |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 201 | mContext = context; |
| 202 | mListener = listener; |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 203 | mSpanSlop = ViewConfiguration.get(context).getScaledTouchSlop() * 2; |
Adam Powell | 3307958 | 2012-10-09 11:20:39 -0700 | [diff] [blame] | 204 | |
| 205 | final Resources res = context.getResources(); |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 206 | mMinSpan = res.getDimensionPixelSize(com.android.internal.R.dimen.config_minScalingSpan); |
| 207 | mHandler = handler; |
| 208 | // Quick scale is enabled by default after JB_MR2 |
Mady Mellor | 7c36a68 | 2015-04-22 11:52:31 -0700 | [diff] [blame] | 209 | final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; |
| 210 | if (targetSdkVersion > Build.VERSION_CODES.JELLY_BEAN_MR2) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 211 | setQuickScaleEnabled(true); |
| 212 | } |
Mady Mellor | 7c36a68 | 2015-04-22 11:52:31 -0700 | [diff] [blame] | 213 | // Stylus scale is enabled by default after LOLLIPOP_MR1 |
| 214 | if (targetSdkVersion > Build.VERSION_CODES.LOLLIPOP_MR1) { |
| 215 | setStylusScaleEnabled(true); |
| 216 | } |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 217 | } |
| 218 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 219 | /** |
| 220 | * Accepts MotionEvents and dispatches events to a {@link OnScaleGestureListener} |
| 221 | * when appropriate. |
| 222 | * |
| 223 | * <p>Applications should pass a complete and consistent event stream to this method. |
| 224 | * A complete and consistent event stream involves all MotionEvents from the initial |
| 225 | * ACTION_DOWN to the final ACTION_UP or ACTION_CANCEL.</p> |
| 226 | * |
| 227 | * @param event The event to process |
| 228 | * @return true if the event was processed and the detector wants to receive the |
| 229 | * rest of the MotionEvents in this event stream. |
| 230 | */ |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 231 | public boolean onTouchEvent(MotionEvent event) { |
Jeff Brown | 21bc5c9 | 2011-02-28 18:27:14 -0800 | [diff] [blame] | 232 | if (mInputEventConsistencyVerifier != null) { |
| 233 | mInputEventConsistencyVerifier.onTouchEvent(event, 0); |
| 234 | } |
| 235 | |
Adam Powell | 7232b0a | 2012-11-28 18:29:22 -0800 | [diff] [blame] | 236 | mCurrTime = event.getEventTime(); |
| 237 | |
Adam Powell | e33cef8 | 2011-02-23 16:51:20 -0800 | [diff] [blame] | 238 | final int action = event.getActionMasked(); |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 239 | |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 240 | // Forward the event to check for double tap gesture |
Mindy Pereira | 9f1221f | 2013-09-16 11:36:12 -0700 | [diff] [blame] | 241 | if (mQuickScaleEnabled) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 242 | mGestureDetector.onTouchEvent(event); |
| 243 | } |
| 244 | |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 245 | final int count = event.getPointerCount(); |
Mady Mellor | 772fcb9 | 2015-05-21 17:46:58 -0700 | [diff] [blame] | 246 | final boolean isStylusButtonDown = |
| 247 | (event.getButtonState() & MotionEvent.BUTTON_STYLUS_PRIMARY) != 0; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 248 | |
| 249 | final boolean anchoredScaleCancelled = |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 250 | mAnchoredScaleMode == ANCHORED_SCALE_MODE_STYLUS && !isStylusButtonDown; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 251 | final boolean streamComplete = action == MotionEvent.ACTION_UP || |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 252 | action == MotionEvent.ACTION_CANCEL || anchoredScaleCancelled; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 253 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 254 | if (action == MotionEvent.ACTION_DOWN || streamComplete) { |
| 255 | // Reset any scale in progress with the listener. |
| 256 | // If it's an ACTION_DOWN we're beginning a new event stream. |
| 257 | // This means the app probably didn't give us all the events. Shame on it. |
| 258 | if (mInProgress) { |
Adam Powell | d0197f3 | 2011-03-17 00:09:03 -0700 | [diff] [blame] | 259 | mListener.onScaleEnd(this); |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 260 | mInProgress = false; |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 261 | mInitialSpan = 0; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 262 | mAnchoredScaleMode = ANCHORED_SCALE_MODE_NONE; |
| 263 | } else if (inAnchoredScaleMode() && streamComplete) { |
Mindy Pereira | 5823352 | 2013-11-14 17:01:25 -0800 | [diff] [blame] | 264 | mInProgress = false; |
| 265 | mInitialSpan = 0; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 266 | mAnchoredScaleMode = ANCHORED_SCALE_MODE_NONE; |
Adam Powell | d0197f3 | 2011-03-17 00:09:03 -0700 | [diff] [blame] | 267 | } |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 268 | |
| 269 | if (streamComplete) { |
| 270 | return true; |
| 271 | } |
Adam Powell | d0197f3 | 2011-03-17 00:09:03 -0700 | [diff] [blame] | 272 | } |
| 273 | |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 274 | if (!mInProgress && mStylusScaleEnabled && !inAnchoredScaleMode() |
| 275 | && !streamComplete && isStylusButtonDown) { |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 276 | // Start of a button scale gesture |
| 277 | mAnchoredScaleStartX = event.getX(); |
| 278 | mAnchoredScaleStartY = event.getY(); |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 279 | mAnchoredScaleMode = ANCHORED_SCALE_MODE_STYLUS; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 280 | mInitialSpan = 0; |
| 281 | } |
| 282 | |
Adam Powell | abde042 | 2012-09-26 17:12:50 -0700 | [diff] [blame] | 283 | final boolean configChanged = action == MotionEvent.ACTION_DOWN || |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 284 | action == MotionEvent.ACTION_POINTER_UP || |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 285 | action == MotionEvent.ACTION_POINTER_DOWN || anchoredScaleCancelled; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 286 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 287 | final boolean pointerUp = action == MotionEvent.ACTION_POINTER_UP; |
| 288 | final int skipIndex = pointerUp ? event.getActionIndex() : -1; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 289 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 290 | // Determine focal point |
| 291 | float sumX = 0, sumY = 0; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 292 | final int div = pointerUp ? count - 1 : count; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 293 | final float focusX; |
| 294 | final float focusY; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 295 | if (inAnchoredScaleMode()) { |
| 296 | // In anchored scale mode, the focal pt is always where the double tap |
| 297 | // or button down gesture started |
| 298 | focusX = mAnchoredScaleStartX; |
| 299 | focusY = mAnchoredScaleStartY; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 300 | if (event.getY() < focusY) { |
| 301 | mEventBeforeOrAboveStartingGestureEvent = true; |
| 302 | } else { |
| 303 | mEventBeforeOrAboveStartingGestureEvent = false; |
| 304 | } |
| 305 | } else { |
| 306 | for (int i = 0; i < count; i++) { |
| 307 | if (skipIndex == i) continue; |
| 308 | sumX += event.getX(i); |
| 309 | sumY += event.getY(i); |
| 310 | } |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 311 | |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 312 | focusX = sumX / div; |
| 313 | focusY = sumY / div; |
| 314 | } |
Adam Powell | 5b5c414 | 2012-10-02 16:25:30 -0700 | [diff] [blame] | 315 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 316 | // Determine average deviation from focal point |
| 317 | float devSumX = 0, devSumY = 0; |
| 318 | for (int i = 0; i < count; i++) { |
| 319 | if (skipIndex == i) continue; |
Adam Powell | 828e56e | 2012-09-14 18:56:16 -0700 | [diff] [blame] | 320 | |
Adam Powell | 5b5c414 | 2012-10-02 16:25:30 -0700 | [diff] [blame] | 321 | // Convert the resulting diameter into a radius. |
Adam Powell | c6df18f | 2016-04-04 14:42:24 -0700 | [diff] [blame] | 322 | devSumX += Math.abs(event.getX(i) - focusX); |
| 323 | devSumY += Math.abs(event.getY(i) - focusY); |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 324 | } |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 325 | final float devX = devSumX / div; |
| 326 | final float devY = devSumY / div; |
| 327 | |
| 328 | // Span is the average distance between touch points through the focal point; |
| 329 | // i.e. the diameter of the circle with a radius of the average deviation from |
| 330 | // the focal point. |
| 331 | final float spanX = devX * 2; |
| 332 | final float spanY = devY * 2; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 333 | final float span; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 334 | if (inAnchoredScaleMode()) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 335 | span = spanY; |
| 336 | } else { |
Neil Fuller | 33253a4 | 2014-10-01 11:55:10 +0100 | [diff] [blame] | 337 | span = (float) Math.hypot(spanX, spanY); |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 338 | } |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 339 | |
| 340 | // Dispatch begin/end events as needed. |
| 341 | // If the configuration changes, notify the app to reset its current state by beginning |
| 342 | // a fresh scale event stream. |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 343 | final boolean wasInProgress = mInProgress; |
| 344 | mFocusX = focusX; |
| 345 | mFocusY = focusY; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 346 | if (!inAnchoredScaleMode() && mInProgress && (span < mMinSpan || configChanged)) { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 347 | mListener.onScaleEnd(this); |
| 348 | mInProgress = false; |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 349 | mInitialSpan = span; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 350 | } |
| 351 | if (configChanged) { |
| 352 | mPrevSpanX = mCurrSpanX = spanX; |
| 353 | mPrevSpanY = mCurrSpanY = spanY; |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 354 | mInitialSpan = mPrevSpan = mCurrSpan = span; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 355 | } |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 356 | |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 357 | final int minSpan = inAnchoredScaleMode() ? mSpanSlop : mMinSpan; |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 358 | if (!mInProgress && span >= minSpan && |
Adam Powell | 47ec2fb | 2012-08-31 17:15:32 -0700 | [diff] [blame] | 359 | (wasInProgress || Math.abs(span - mInitialSpan) > mSpanSlop)) { |
| 360 | mPrevSpanX = mCurrSpanX = spanX; |
| 361 | mPrevSpanY = mCurrSpanY = spanY; |
| 362 | mPrevSpan = mCurrSpan = span; |
Adam Powell | 7232b0a | 2012-11-28 18:29:22 -0800 | [diff] [blame] | 363 | mPrevTime = mCurrTime; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 364 | mInProgress = mListener.onScaleBegin(this); |
| 365 | } |
| 366 | |
| 367 | // Handle motion; focal point and span/scale factor are changing. |
| 368 | if (action == MotionEvent.ACTION_MOVE) { |
| 369 | mCurrSpanX = spanX; |
| 370 | mCurrSpanY = spanY; |
| 371 | mCurrSpan = span; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 372 | |
| 373 | boolean updatePrev = true; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 374 | |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 375 | if (mInProgress) { |
| 376 | updatePrev = mListener.onScale(this); |
| 377 | } |
| 378 | |
| 379 | if (updatePrev) { |
| 380 | mPrevSpanX = mCurrSpanX; |
| 381 | mPrevSpanY = mCurrSpanY; |
| 382 | mPrevSpan = mCurrSpan; |
Adam Powell | 7232b0a | 2012-11-28 18:29:22 -0800 | [diff] [blame] | 383 | mPrevTime = mCurrTime; |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 384 | } |
| 385 | } |
| 386 | |
| 387 | return true; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 388 | } |
| 389 | |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 390 | private boolean inAnchoredScaleMode() { |
| 391 | return mAnchoredScaleMode != ANCHORED_SCALE_MODE_NONE; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 392 | } |
| 393 | |
| 394 | /** |
| 395 | * Set whether the associated {@link OnScaleGestureListener} should receive onScale callbacks |
| 396 | * when the user performs a doubleTap followed by a swipe. Note that this is enabled by default |
| 397 | * if the app targets API 19 and newer. |
| 398 | * @param scales true to enable quick scaling, false to disable |
| 399 | */ |
| 400 | public void setQuickScaleEnabled(boolean scales) { |
Mindy Pereira | 9f1221f | 2013-09-16 11:36:12 -0700 | [diff] [blame] | 401 | mQuickScaleEnabled = scales; |
| 402 | if (mQuickScaleEnabled && mGestureDetector == null) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 403 | GestureDetector.SimpleOnGestureListener gestureListener = |
| 404 | new GestureDetector.SimpleOnGestureListener() { |
| 405 | @Override |
| 406 | public boolean onDoubleTap(MotionEvent e) { |
| 407 | // Double tap: start watching for a swipe |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 408 | mAnchoredScaleStartX = e.getX(); |
| 409 | mAnchoredScaleStartY = e.getY(); |
| 410 | mAnchoredScaleMode = ANCHORED_SCALE_MODE_DOUBLE_TAP; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 411 | return true; |
| 412 | } |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 413 | }; |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 414 | mGestureDetector = new GestureDetector(mContext, gestureListener, mHandler); |
| 415 | } |
| 416 | } |
| 417 | |
Mindy Pereira | 9f1221f | 2013-09-16 11:36:12 -0700 | [diff] [blame] | 418 | /** |
| 419 | * Return whether the quick scale gesture, in which the user performs a double tap followed by a |
| 420 | * swipe, should perform scaling. {@see #setQuickScaleEnabled(boolean)}. |
| 421 | */ |
| 422 | public boolean isQuickScaleEnabled() { |
| 423 | return mQuickScaleEnabled; |
| 424 | } |
| 425 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 426 | /** |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 427 | * Sets whether the associates {@link OnScaleGestureListener} should receive |
| 428 | * onScale callbacks when the user uses a stylus and presses the button. |
| 429 | * Note that this is enabled by default if the app targets API 23 and newer. |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 430 | * |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 431 | * @param scales true to enable stylus scaling, false to disable. |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 432 | */ |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 433 | public void setStylusScaleEnabled(boolean scales) { |
| 434 | mStylusScaleEnabled = scales; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 435 | } |
| 436 | |
| 437 | /** |
Mady Mellor | d9ff4df | 2015-06-04 18:03:49 -0700 | [diff] [blame] | 438 | * Return whether the stylus scale gesture, in which the user uses a stylus and presses the |
| 439 | * button, should perform scaling. {@see #setStylusScaleEnabled(boolean)} |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 440 | */ |
Mady Mellor | 6895518 | 2015-04-16 12:50:53 -0700 | [diff] [blame] | 441 | public boolean isStylusScaleEnabled() { |
| 442 | return mStylusScaleEnabled; |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 443 | } |
| 444 | |
| 445 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 446 | * Returns {@code true} if a scale gesture is in progress. |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 447 | */ |
| 448 | public boolean isInProgress() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 449 | return mInProgress; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 450 | } |
| 451 | |
| 452 | /** |
| 453 | * Get the X coordinate of the current gesture's focal point. |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 454 | * If a gesture is in progress, the focal point is between |
| 455 | * each of the pointers forming the gesture. |
| 456 | * |
Adam Powell | ab905c87 | 2010-02-03 11:01:58 -0800 | [diff] [blame] | 457 | * If {@link #isInProgress()} would return false, the result of this |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 458 | * function is undefined. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 459 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 460 | * @return X coordinate of the focal point in pixels. |
| 461 | */ |
| 462 | public float getFocusX() { |
| 463 | return mFocusX; |
| 464 | } |
| 465 | |
| 466 | /** |
| 467 | * Get the Y coordinate of the current gesture's focal point. |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 468 | * If a gesture is in progress, the focal point is between |
| 469 | * each of the pointers forming the gesture. |
| 470 | * |
Adam Powell | ab905c87 | 2010-02-03 11:01:58 -0800 | [diff] [blame] | 471 | * If {@link #isInProgress()} would return false, the result of this |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 472 | * function is undefined. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 473 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 474 | * @return Y coordinate of the focal point in pixels. |
| 475 | */ |
| 476 | public float getFocusY() { |
| 477 | return mFocusY; |
| 478 | } |
| 479 | |
| 480 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 481 | * Return the average distance between each of the pointers forming the |
| 482 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 483 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 484 | * @return Distance between pointers in pixels. |
| 485 | */ |
| 486 | public float getCurrentSpan() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 487 | return mCurrSpan; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 488 | } |
| 489 | |
| 490 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 491 | * Return the average X distance between each of the pointers forming the |
| 492 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 493 | * |
| 494 | * @return Distance between pointers in pixels. |
| 495 | */ |
| 496 | public float getCurrentSpanX() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 497 | return mCurrSpanX; |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 498 | } |
| 499 | |
| 500 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 501 | * Return the average Y distance between each of the pointers forming the |
| 502 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 503 | * |
| 504 | * @return Distance between pointers in pixels. |
| 505 | */ |
| 506 | public float getCurrentSpanY() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 507 | return mCurrSpanY; |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 508 | } |
| 509 | |
| 510 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 511 | * Return the previous average distance between each of the pointers forming the |
| 512 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 513 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 514 | * @return Previous distance between pointers in pixels. |
| 515 | */ |
| 516 | public float getPreviousSpan() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 517 | return mPrevSpan; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 521 | * Return the previous average X distance between each of the pointers forming the |
| 522 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 523 | * |
| 524 | * @return Previous distance between pointers in pixels. |
| 525 | */ |
| 526 | public float getPreviousSpanX() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 527 | return mPrevSpanX; |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 528 | } |
| 529 | |
| 530 | /** |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 531 | * Return the previous average Y distance between each of the pointers forming the |
| 532 | * gesture in progress through the focal point. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 533 | * |
| 534 | * @return Previous distance between pointers in pixels. |
| 535 | */ |
| 536 | public float getPreviousSpanY() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 537 | return mPrevSpanY; |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 538 | } |
| 539 | |
| 540 | /** |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 541 | * Return the scaling factor from the previous scale event to the current |
| 542 | * event. This value is defined as |
Adam Powell | ab905c87 | 2010-02-03 11:01:58 -0800 | [diff] [blame] | 543 | * ({@link #getCurrentSpan()} / {@link #getPreviousSpan()}). |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 544 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 545 | * @return The current scaling factor. |
| 546 | */ |
| 547 | public float getScaleFactor() { |
Mady Mellor | 847d17f | 2015-03-30 09:42:12 -0700 | [diff] [blame] | 548 | if (inAnchoredScaleMode()) { |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 549 | // Drag is moving up; the further away from the gesture |
| 550 | // start, the smaller the span should be, the closer, |
| 551 | // the larger the span, and therefore the larger the scale |
Mindy Pereira | 24870ce | 2013-09-09 15:56:23 -0700 | [diff] [blame] | 552 | final boolean scaleUp = |
| 553 | (mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan < mPrevSpan)) || |
| 554 | (!mEventBeforeOrAboveStartingGestureEvent && (mCurrSpan > mPrevSpan)); |
| 555 | final float spanDiff = (Math.abs(1 - (mCurrSpan / mPrevSpan)) * SCALE_FACTOR); |
| 556 | return mPrevSpan <= 0 ? 1 : scaleUp ? (1 + spanDiff) : (1 - spanDiff); |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 557 | } |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 558 | return mPrevSpan > 0 ? mCurrSpan / mPrevSpan : 1; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 559 | } |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 560 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 561 | /** |
| 562 | * Return the time difference in milliseconds between the previous |
| 563 | * accepted scaling event and the current scaling event. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 564 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 565 | * @return Time difference since the last scaling event in milliseconds. |
| 566 | */ |
| 567 | public long getTimeDelta() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 568 | return mCurrTime - mPrevTime; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 569 | } |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 570 | |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 571 | /** |
| 572 | * Return the event time of the current event being processed. |
Erik | 47c41e8 | 2010-09-01 15:39:08 -0700 | [diff] [blame] | 573 | * |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 574 | * @return Current event time in milliseconds. |
| 575 | */ |
| 576 | public long getEventTime() { |
Adam Powell | 618cbea | 2012-08-27 17:44:59 -0700 | [diff] [blame] | 577 | return mCurrTime; |
Adam Powell | ae542ff | 2010-01-13 16:29:27 -0800 | [diff] [blame] | 578 | } |
Mindy Pereira | e8ce8ba | 2013-08-21 15:59:36 -0700 | [diff] [blame] | 579 | } |