blob: 00aff53595fff5af0844a603735ef1c278787ec2 [file] [log] [blame]
Matthew Nga8f24262017-12-19 11:54:24 -08001/*
2 * Copyright (C) 2018 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
17package com.android.systemui.statusbar.phone;
18
19import android.animation.Animator;
20import android.animation.AnimatorListenerAdapter;
21import android.animation.AnimatorSet;
Matthew Ng7090a802018-01-19 13:36:22 -080022import android.animation.ArgbEvaluator;
Matthew Nga8f24262017-12-19 11:54:24 -080023import android.animation.ObjectAnimator;
24import android.animation.ValueAnimator;
25import android.animation.ValueAnimator.AnimatorUpdateListener;
26import android.content.Context;
27import android.graphics.Canvas;
28import android.graphics.Paint;
29import android.graphics.Rect;
30import android.os.Handler;
31import android.os.RemoteException;
32import android.util.Log;
33import android.util.Slog;
Matthew Nga8f24262017-12-19 11:54:24 -080034import android.view.GestureDetector;
35import android.view.MotionEvent;
36import android.view.View;
37import android.view.ViewConfiguration;
Matthew Nga8f24262017-12-19 11:54:24 -080038import android.view.WindowManagerGlobal;
39import android.view.animation.DecelerateInterpolator;
40import android.view.animation.Interpolator;
41import android.support.annotation.DimenRes;
42import com.android.systemui.Dependency;
43import com.android.systemui.OverviewProxyService;
44import com.android.systemui.R;
45import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper;
46import com.android.systemui.shared.recents.IOverviewProxy;
47import com.android.systemui.shared.recents.utilities.Utilities;
48
49import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT;
50import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM;
Matthew Ngbd824572018-01-17 16:25:56 -080051import static com.android.systemui.OverviewProxyService.DEBUG_OVERVIEW_PROXY;
52import static com.android.systemui.OverviewProxyService.TAG_OPS;
Winson Chungc4e06202018-02-13 10:37:35 -080053import static com.android.systemui.shared.system.NavigationBarCompat.HIT_TARGET_HOME;
Matthew Nga8f24262017-12-19 11:54:24 -080054
55/**
56 * Class to detect gestures on the navigation bar and implement quick scrub and switch.
57 */
Winson Chung0e490d922018-03-14 16:08:43 +000058public class QuickScrubController extends GestureDetector.SimpleOnGestureListener implements
Matthew Nga8f24262017-12-19 11:54:24 -080059 GestureHelper {
60
Winson Chung0e490d922018-03-14 16:08:43 +000061 private static final String TAG = "QuickScrubController";
Matthew Nga8f24262017-12-19 11:54:24 -080062 private static final int QUICK_SWITCH_FLING_VELOCITY = 0;
63 private static final int ANIM_DURATION_MS = 200;
Winson Chungde2a1242018-02-07 15:59:43 -080064 private static final long LONG_PRESS_DELAY_MS = 225;
Matthew Nga8f24262017-12-19 11:54:24 -080065
66 /**
67 * For quick step, set a damping value to allow the button to stick closer its origin position
68 * when dragging before quick scrub is active.
69 */
70 private static final int SWITCH_STICKINESS = 4;
71
72 private NavigationBarView mNavigationBarView;
73 private GestureDetector mGestureDetector;
74
75 private boolean mDraggingActive;
76 private boolean mQuickScrubActive;
Winson Chung49658842018-02-08 12:52:21 -080077 private boolean mAllowQuickSwitch;
Winson Chung0e490d922018-03-14 16:08:43 +000078 private boolean mRecentsAnimationStarted;
Matthew Nga8f24262017-12-19 11:54:24 -080079 private float mDownOffset;
80 private float mTranslation;
81 private int mTouchDownX;
82 private int mTouchDownY;
83 private boolean mDragPositive;
84 private boolean mIsVertical;
85 private boolean mIsRTL;
Matthew Ng7090a802018-01-19 13:36:22 -080086 private float mTrackAlpha;
87 private int mLightTrackColor;
88 private int mDarkTrackColor;
89 private float mDarkIntensity;
Winson Chungd10ca302018-02-14 10:13:41 -080090 private View mHomeButtonView;
Matthew Nga8f24262017-12-19 11:54:24 -080091
92 private final Handler mHandler = new Handler();
93 private final Interpolator mQuickScrubEndInterpolator = new DecelerateInterpolator();
94 private final Rect mTrackRect = new Rect();
Matthew Nga8f24262017-12-19 11:54:24 -080095 private final Paint mTrackPaint = new Paint();
96 private final int mScrollTouchSlop;
97 private final OverviewProxyService mOverviewEventSender;
Matthew Nga8f24262017-12-19 11:54:24 -080098 private final int mTrackThickness;
99 private final int mTrackPadding;
100 private final ValueAnimator mTrackAnimator;
101 private final ValueAnimator mButtonAnimator;
102 private final AnimatorSet mQuickScrubEndAnimator;
103 private final Context mContext;
Matthew Ng7090a802018-01-19 13:36:22 -0800104 private final ArgbEvaluator mTrackColorEvaluator = new ArgbEvaluator();
Matthew Nga8f24262017-12-19 11:54:24 -0800105
106 private final AnimatorUpdateListener mTrackAnimatorListener = valueAnimator -> {
Matthew Ng7090a802018-01-19 13:36:22 -0800107 mTrackAlpha = (float) valueAnimator.getAnimatedValue();
Matthew Nga8f24262017-12-19 11:54:24 -0800108 mNavigationBarView.invalidate();
109 };
110
111 private final AnimatorUpdateListener mButtonTranslationListener = animator -> {
112 int pos = (int) animator.getAnimatedValue();
113 if (!mQuickScrubActive) {
114 pos = mDragPositive ? Math.min((int) mTranslation, pos) : Math.max((int) mTranslation, pos);
115 }
Matthew Nga8f24262017-12-19 11:54:24 -0800116 if (mIsVertical) {
Winson Chungd10ca302018-02-14 10:13:41 -0800117 mHomeButtonView.setTranslationY(pos);
Matthew Nga8f24262017-12-19 11:54:24 -0800118 } else {
Winson Chungd10ca302018-02-14 10:13:41 -0800119 mHomeButtonView.setTranslationX(pos);
Matthew Nga8f24262017-12-19 11:54:24 -0800120 }
121 };
122
123 private AnimatorListenerAdapter mQuickScrubEndListener = new AnimatorListenerAdapter() {
124 @Override
125 public void onAnimationEnd(Animator animation) {
Winson Chung0e490d922018-03-14 16:08:43 +0000126 mNavigationBarView.getHomeButton().setClickable(true);
Matthew Nga8f24262017-12-19 11:54:24 -0800127 mQuickScrubActive = false;
128 mTranslation = 0;
Matthew Nged166f92018-02-20 16:22:09 -0800129 mQuickScrubEndAnimator.setCurrentPlayTime(mQuickScrubEndAnimator.getDuration());
130 mHomeButtonView = null;
Matthew Nga8f24262017-12-19 11:54:24 -0800131 }
132 };
133
134 private Runnable mLongPressRunnable = this::startQuickScrub;
135
136 private final GestureDetector.SimpleOnGestureListener mGestureListener =
137 new GestureDetector.SimpleOnGestureListener() {
138 @Override
139 public boolean onFling(MotionEvent e1, MotionEvent e2, float velX, float velY) {
Matthew Ng8f25fb962018-01-16 17:17:24 -0800140 if (!mNavigationBarView.isQuickScrubEnabled() || mQuickScrubActive
141 || !mAllowQuickSwitch
142 || mNavigationBarView.getDownHitTarget() != HIT_TARGET_HOME) {
Matthew Nga8f24262017-12-19 11:54:24 -0800143 return false;
144 }
145 float velocityX = mIsRTL ? -velX : velX;
146 float absVelY = Math.abs(velY);
147 final boolean isValidFling = velocityX > QUICK_SWITCH_FLING_VELOCITY &&
148 mIsVertical ? (absVelY > velocityX) : (velocityX > absVelY);
149 if (isValidFling) {
150 mDraggingActive = false;
Matthew Nged166f92018-02-20 16:22:09 -0800151 animateEnd();
Matthew Nga8f24262017-12-19 11:54:24 -0800152 mHandler.removeCallbacks(mLongPressRunnable);
153 try {
154 final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
155 overviewProxy.onQuickSwitch();
Matthew Ngbd824572018-01-17 16:25:56 -0800156 if (DEBUG_OVERVIEW_PROXY) {
157 Log.d(TAG_OPS, "Quick Switch");
158 }
Matthew Nga8f24262017-12-19 11:54:24 -0800159 } catch (RemoteException e) {
160 Log.e(TAG, "Failed to send start of quick switch.", e);
161 }
Winson Chung4faf38a2018-02-06 08:53:37 -0800162 return true;
Matthew Nga8f24262017-12-19 11:54:24 -0800163 }
Winson Chung4faf38a2018-02-06 08:53:37 -0800164 return false;
Matthew Nga8f24262017-12-19 11:54:24 -0800165 }
166 };
167
Winson Chung0e490d922018-03-14 16:08:43 +0000168 public QuickScrubController(Context context) {
Matthew Nga8f24262017-12-19 11:54:24 -0800169 mContext = context;
170 mScrollTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
Matthew Nga8f24262017-12-19 11:54:24 -0800171 mOverviewEventSender = Dependency.get(OverviewProxyService.class);
172 mGestureDetector = new GestureDetector(mContext, mGestureListener);
173 mTrackThickness = getDimensionPixelSize(mContext, R.dimen.nav_quick_scrub_track_thickness);
174 mTrackPadding = getDimensionPixelSize(mContext, R.dimen.nav_quick_scrub_track_edge_padding);
Matthew Ng7090a802018-01-19 13:36:22 -0800175 mTrackPaint.setAlpha(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800176
177 mTrackAnimator = ObjectAnimator.ofFloat();
178 mTrackAnimator.addUpdateListener(mTrackAnimatorListener);
Matthew Ng55437a92018-02-23 15:02:07 -0800179 mTrackAnimator.setFloatValues(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800180 mButtonAnimator = ObjectAnimator.ofInt();
181 mButtonAnimator.addUpdateListener(mButtonTranslationListener);
Matthew Ng55437a92018-02-23 15:02:07 -0800182 mButtonAnimator.setIntValues(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800183 mQuickScrubEndAnimator = new AnimatorSet();
184 mQuickScrubEndAnimator.playTogether(mTrackAnimator, mButtonAnimator);
185 mQuickScrubEndAnimator.setDuration(ANIM_DURATION_MS);
186 mQuickScrubEndAnimator.addListener(mQuickScrubEndListener);
187 mQuickScrubEndAnimator.setInterpolator(mQuickScrubEndInterpolator);
188 }
189
190 public void setComponents(NavigationBarView navigationBarView) {
191 mNavigationBarView = navigationBarView;
192 }
193
Winson Chung4faf38a2018-02-06 08:53:37 -0800194 /**
195 * @return true if we want to intercept touch events for quick scrub/switch and prevent proxying
196 * the event to the overview service.
197 */
Matthew Nga8f24262017-12-19 11:54:24 -0800198 @Override
199 public boolean onInterceptTouchEvent(MotionEvent event) {
Winson Chung0e490d922018-03-14 16:08:43 +0000200 final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
201 if (!mNavigationBarView.isQuickScrubEnabled()) {
202 homeButton.setDelayTouchFeedback(false);
Matthew Nga8f24262017-12-19 11:54:24 -0800203 return false;
204 }
Winson Chung0e490d922018-03-14 16:08:43 +0000205
Winson Chungde2a1242018-02-07 15:59:43 -0800206 return handleTouchEvent(event);
207 }
208
209 /**
Winson Chung0e490d922018-03-14 16:08:43 +0000210 * @return true if we want to handle touch events for quick scrub/switch and prevent proxying
211 * the event to the overview service.
Winson Chungde2a1242018-02-07 15:59:43 -0800212 */
213 @Override
214 public boolean onTouchEvent(MotionEvent event) {
Winson Chung0e490d922018-03-14 16:08:43 +0000215 return handleTouchEvent(event);
Winson Chungde2a1242018-02-07 15:59:43 -0800216 }
217
218 private boolean handleTouchEvent(MotionEvent event) {
Winson Chung0e490d922018-03-14 16:08:43 +0000219 final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
Winson Chungde2a1242018-02-07 15:59:43 -0800220 final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
Winson Chung4faf38a2018-02-06 08:53:37 -0800221 if (mGestureDetector.onTouchEvent(event)) {
Winson Chungde2a1242018-02-07 15:59:43 -0800222 // If the fling has been handled on UP, then skip proxying the UP
Winson Chung4faf38a2018-02-06 08:53:37 -0800223 return true;
224 }
Matthew Nga8f24262017-12-19 11:54:24 -0800225 int action = event.getAction();
226 switch (action & MotionEvent.ACTION_MASK) {
227 case MotionEvent.ACTION_DOWN: {
228 int x = (int) event.getX();
229 int y = (int) event.getY();
Winson Chung0be8f082018-02-15 15:52:49 -0800230 // End any existing quickscrub animations before starting the new transition
Matthew Nged166f92018-02-20 16:22:09 -0800231 if (mHomeButtonView != null) {
Winson Chung0be8f082018-02-15 15:52:49 -0800232 mQuickScrubEndAnimator.end();
233 }
Winson Chungd10ca302018-02-14 10:13:41 -0800234 mHomeButtonView = homeButton.getCurrentView();
Winson Chung0e490d922018-03-14 16:08:43 +0000235 if (mNavigationBarView.isQuickScrubEnabled()
236 && mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME) {
237 mTouchDownX = x;
238 mTouchDownY = y;
239 homeButton.setDelayTouchFeedback(true);
Matthew Nga8f24262017-12-19 11:54:24 -0800240 mHandler.postDelayed(mLongPressRunnable, LONG_PRESS_DELAY_MS);
Winson Chung0e490d922018-03-14 16:08:43 +0000241 } else {
242 homeButton.setDelayTouchFeedback(false);
243 mTouchDownX = mTouchDownY = -1;
Matthew Nga8f24262017-12-19 11:54:24 -0800244 }
Winson Chung49658842018-02-08 12:52:21 -0800245 mAllowQuickSwitch = true;
Matthew Nga8f24262017-12-19 11:54:24 -0800246 break;
247 }
248 case MotionEvent.ACTION_MOVE: {
Winson Chung0e490d922018-03-14 16:08:43 +0000249 if (mTouchDownX != -1) {
250 int x = (int) event.getX();
251 int y = (int) event.getY();
252 int xDiff = Math.abs(x - mTouchDownX);
253 int yDiff = Math.abs(y - mTouchDownY);
254 boolean exceededTouchSlopX = xDiff > mScrollTouchSlop && xDiff > yDiff;
255 boolean exceededTouchSlopY = yDiff > mScrollTouchSlop && yDiff > xDiff;
256 boolean exceededTouchSlop, exceededPerpendicularTouchSlop;
257 int pos, touchDown, offset, trackSize;
Matthew Nge0903c92018-01-17 15:32:41 -0800258
Matthew Ngb06ae3b2018-03-07 14:23:04 -0800259 if (mIsVertical) {
Winson Chung0e490d922018-03-14 16:08:43 +0000260 exceededTouchSlop = exceededTouchSlopY;
261 exceededPerpendicularTouchSlop = exceededTouchSlopX;
262 pos = y;
263 touchDown = mTouchDownY;
264 offset = pos - mTrackRect.top;
265 trackSize = mTrackRect.height();
Matthew Ngb06ae3b2018-03-07 14:23:04 -0800266 } else {
Winson Chung0e490d922018-03-14 16:08:43 +0000267 exceededTouchSlop = exceededTouchSlopX;
268 exceededPerpendicularTouchSlop = exceededTouchSlopY;
269 pos = x;
270 touchDown = mTouchDownX;
271 offset = pos - mTrackRect.left;
272 trackSize = mTrackRect.width();
273 }
274 // Do not start scrubbing when dragging in the perpendicular direction if we
275 // haven't already started quickscrub
276 if (!mDraggingActive && !mQuickScrubActive && exceededPerpendicularTouchSlop) {
277 mHandler.removeCallbacksAndMessages(null);
278 return false;
279 }
280 if (!mDragPositive) {
281 offset -= mIsVertical ? mTrackRect.height() : mTrackRect.width();
282 }
283
284 // Control the button movement
285 if (!mDraggingActive && exceededTouchSlop && !mRecentsAnimationStarted) {
286 boolean allowDrag = !mDragPositive
287 ? offset < 0 && pos < touchDown : offset >= 0 && pos > touchDown;
288 if (allowDrag) {
289 mDownOffset = offset;
290 homeButton.setClickable(false);
291 mDraggingActive = true;
292 }
293 }
294 if (mDraggingActive && (mDragPositive && offset >= 0
295 || !mDragPositive && offset <= 0)) {
296 float scrubFraction =
297 Utilities.clamp(Math.abs(offset) * 1f / trackSize, 0, 1);
298 mTranslation = !mDragPositive
299 ? Utilities.clamp(offset - mDownOffset, -trackSize, 0)
300 : Utilities.clamp(offset - mDownOffset, 0, trackSize);
301 if (mQuickScrubActive) {
302 try {
303 mOverviewEventSender.getProxy().onQuickScrubProgress(scrubFraction);
304 if (DEBUG_OVERVIEW_PROXY) {
305 Log.d(TAG_OPS, "Quick Scrub Progress:" + scrubFraction);
306 }
307 } catch (RemoteException e) {
308 Log.e(TAG, "Failed to send progress of quick scrub.", e);
309 }
310 } else {
311 mTranslation /= SWITCH_STICKINESS;
312 }
313 if (mIsVertical) {
314 mHomeButtonView.setTranslationY(mTranslation);
315 } else {
316 mHomeButtonView.setTranslationX(mTranslation);
317 }
Matthew Nga8f24262017-12-19 11:54:24 -0800318 }
319 }
320 break;
321 }
322 case MotionEvent.ACTION_CANCEL:
323 case MotionEvent.ACTION_UP:
Winson Chungd10ca302018-02-14 10:13:41 -0800324 endQuickScrub(true /* animate */);
Matthew Nga8f24262017-12-19 11:54:24 -0800325 break;
326 }
Winson Chung0e490d922018-03-14 16:08:43 +0000327 return mDraggingActive || mQuickScrubActive;
Matthew Nga8f24262017-12-19 11:54:24 -0800328 }
329
330 @Override
331 public void onDraw(Canvas canvas) {
Matthew Ng7090a802018-01-19 13:36:22 -0800332 int color = (int) mTrackColorEvaluator.evaluate(mDarkIntensity, mLightTrackColor,
333 mDarkTrackColor);
334 mTrackPaint.setColor(color);
335 mTrackPaint.setAlpha((int) (mTrackPaint.getAlpha() * mTrackAlpha));
Matthew Nga8f24262017-12-19 11:54:24 -0800336 canvas.drawRect(mTrackRect, mTrackPaint);
337 }
338
339 @Override
340 public void onLayout(boolean changed, int left, int top, int right, int bottom) {
341 final int width = right - left;
342 final int height = bottom - top;
343 final int x1, x2, y1, y2;
344 if (mIsVertical) {
345 x1 = (width - mTrackThickness) / 2;
346 x2 = x1 + mTrackThickness;
347 y1 = mDragPositive ? height / 2 : mTrackPadding;
348 y2 = y1 + height / 2 - mTrackPadding;
349 } else {
350 y1 = (height - mTrackThickness) / 2;
351 y2 = y1 + mTrackThickness;
352 x1 = mDragPositive ? width / 2 : mTrackPadding;
353 x2 = x1 + width / 2 - mTrackPadding;
354 }
355 mTrackRect.set(x1, y1, x2, y2);
Matthew Nga8f24262017-12-19 11:54:24 -0800356 }
357
358 @Override
359 public void onDarkIntensityChange(float intensity) {
Matthew Ng7090a802018-01-19 13:36:22 -0800360 mDarkIntensity = intensity;
361 mNavigationBarView.invalidate();
Matthew Nga8f24262017-12-19 11:54:24 -0800362 }
363
364 @Override
Matthew Nga8f24262017-12-19 11:54:24 -0800365 public void setBarState(boolean isVertical, boolean isRTL) {
Winson Chungd10ca302018-02-14 10:13:41 -0800366 final boolean changed = (mIsVertical != isVertical) || (mIsRTL != isRTL);
367 if (changed) {
368 // End quickscrub if the state changes mid-transition
369 endQuickScrub(false /* animate */);
370 }
Matthew Nga8f24262017-12-19 11:54:24 -0800371 mIsVertical = isVertical;
372 mIsRTL = isRTL;
373 try {
374 int navbarPos = WindowManagerGlobal.getWindowManagerService().getNavBarPosition();
375 mDragPositive = navbarPos == NAV_BAR_LEFT || navbarPos == NAV_BAR_BOTTOM;
376 if (isRTL) {
377 mDragPositive = !mDragPositive;
378 }
379 } catch (RemoteException e) {
380 Slog.e(TAG, "Failed to get nav bar position.", e);
381 }
382 }
383
384 private void startQuickScrub() {
Matthew Ngfee0b5b2018-02-21 15:38:21 -0800385 if (!mQuickScrubActive && mDraggingActive) {
Matthew Nga8f24262017-12-19 11:54:24 -0800386 mQuickScrubActive = true;
Matthew Ng7090a802018-01-19 13:36:22 -0800387 mLightTrackColor = mContext.getColor(R.color.quick_step_track_background_light);
388 mDarkTrackColor = mContext.getColor(R.color.quick_step_track_background_dark);
389 mTrackAnimator.setFloatValues(0, 1);
Matthew Nga8f24262017-12-19 11:54:24 -0800390 mTrackAnimator.start();
391 try {
392 mOverviewEventSender.getProxy().onQuickScrubStart();
Matthew Ngbd824572018-01-17 16:25:56 -0800393 if (DEBUG_OVERVIEW_PROXY) {
394 Log.d(TAG_OPS, "Quick Scrub Start");
395 }
Matthew Nga8f24262017-12-19 11:54:24 -0800396 } catch (RemoteException e) {
397 Log.e(TAG, "Failed to send start of quick scrub.", e);
398 }
Winson Chung0e490d922018-03-14 16:08:43 +0000399 } else {
400 // After long press do not allow quick scrub/switch
401 mTouchDownX = -1;
Matthew Nga8f24262017-12-19 11:54:24 -0800402 }
403 }
404
Winson Chungd10ca302018-02-14 10:13:41 -0800405 private void endQuickScrub(boolean animate) {
Matthew Nga8f24262017-12-19 11:54:24 -0800406 mHandler.removeCallbacks(mLongPressRunnable);
407 if (mDraggingActive || mQuickScrubActive) {
Matthew Nged166f92018-02-20 16:22:09 -0800408 animateEnd();
Matthew Nga8f24262017-12-19 11:54:24 -0800409 try {
410 mOverviewEventSender.getProxy().onQuickScrubEnd();
Matthew Ngbd824572018-01-17 16:25:56 -0800411 if (DEBUG_OVERVIEW_PROXY) {
412 Log.d(TAG_OPS, "Quick Scrub End");
413 }
Matthew Nga8f24262017-12-19 11:54:24 -0800414 } catch (RemoteException e) {
415 Log.e(TAG, "Failed to send end of quick scrub.", e);
416 }
Matthew Nged166f92018-02-20 16:22:09 -0800417 }
418 if (mHomeButtonView != null && !animate) {
419 mQuickScrubEndAnimator.end();
Matthew Nga8f24262017-12-19 11:54:24 -0800420 }
421 mDraggingActive = false;
422 }
423
Winson Chung0e490d922018-03-14 16:08:43 +0000424 public void setRecentsAnimationStarted(boolean started) {
425 mRecentsAnimationStarted = started;
426 if (started) {
427 cancelQuickSwitch();
Matthew Ngdb2734c2018-02-16 16:02:20 -0800428 }
429 }
430
Winson Chung49658842018-02-08 12:52:21 -0800431 public void cancelQuickSwitch() {
432 mAllowQuickSwitch = false;
433 mHandler.removeCallbacks(mLongPressRunnable);
434 }
435
Matthew Nged166f92018-02-20 16:22:09 -0800436 private void animateEnd() {
437 mButtonAnimator.setIntValues((int) mTranslation, 0);
438 mTrackAnimator.setFloatValues(mTrackAlpha, 0);
Matthew Ng55437a92018-02-23 15:02:07 -0800439 mQuickScrubEndAnimator.setCurrentPlayTime(0);
Matthew Nged166f92018-02-20 16:22:09 -0800440 mQuickScrubEndAnimator.start();
441 }
442
Matthew Nga8f24262017-12-19 11:54:24 -0800443 private int getDimensionPixelSize(Context context, @DimenRes int resId) {
444 return context.getResources().getDimensionPixelSize(resId);
445 }
446}