blob: d3d4e421a4d8c212cac6c5f307aaf5baca9f42c7 [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;
Matthew Ng2ea93b72018-03-14 19:43:18 +000028import android.graphics.Matrix;
Matthew Nga8f24262017-12-19 11:54:24 -080029import android.graphics.Paint;
30import android.graphics.Rect;
31import android.os.Handler;
32import android.os.RemoteException;
33import android.util.Log;
34import android.util.Slog;
Matthew Nga8f24262017-12-19 11:54:24 -080035import 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/**
Matthew Ngfba39692018-03-13 18:08:34 -070056 * Class to detect gestures on the navigation bar and implement quick scrub.
Matthew Nga8f24262017-12-19 11:54:24 -080057 */
Matthew Ngfba39692018-03-13 18:08:34 -070058public class QuickStepController implements GestureHelper {
Matthew Nga8f24262017-12-19 11:54:24 -080059
Matthew Ng2ea93b72018-03-14 19:43:18 +000060 private static final String TAG = "QuickStepController";
Matthew Nga8f24262017-12-19 11:54:24 -080061 private static final int ANIM_DURATION_MS = 200;
Matthew Nga8f24262017-12-19 11:54:24 -080062
63 private NavigationBarView mNavigationBarView;
Matthew Nga8f24262017-12-19 11:54:24 -080064
Matthew Nga8f24262017-12-19 11:54:24 -080065 private boolean mQuickScrubActive;
Matthew Ng2ea93b72018-03-14 19:43:18 +000066 private boolean mAllowGestureDetection;
67 private boolean mQuickStepStarted;
Matthew Nga8f24262017-12-19 11:54:24 -080068 private float mDownOffset;
69 private float mTranslation;
70 private int mTouchDownX;
71 private int mTouchDownY;
72 private boolean mDragPositive;
73 private boolean mIsVertical;
74 private boolean mIsRTL;
Matthew Ng7090a802018-01-19 13:36:22 -080075 private float mTrackAlpha;
76 private int mLightTrackColor;
77 private int mDarkTrackColor;
78 private float mDarkIntensity;
Winson Chungd10ca302018-02-14 10:13:41 -080079 private View mHomeButtonView;
Matthew Nga8f24262017-12-19 11:54:24 -080080
81 private final Handler mHandler = new Handler();
82 private final Interpolator mQuickScrubEndInterpolator = new DecelerateInterpolator();
83 private final Rect mTrackRect = new Rect();
Matthew Nga8f24262017-12-19 11:54:24 -080084 private final Paint mTrackPaint = new Paint();
85 private final int mScrollTouchSlop;
86 private final OverviewProxyService mOverviewEventSender;
Matthew Nga8f24262017-12-19 11:54:24 -080087 private final int mTrackThickness;
88 private final int mTrackPadding;
89 private final ValueAnimator mTrackAnimator;
90 private final ValueAnimator mButtonAnimator;
91 private final AnimatorSet mQuickScrubEndAnimator;
92 private final Context mContext;
Matthew Ng2ea93b72018-03-14 19:43:18 +000093 private final Matrix mTransformGlobalMatrix = new Matrix();
94 private final Matrix mTransformLocalMatrix = new Matrix();
Matthew Ng7090a802018-01-19 13:36:22 -080095 private final ArgbEvaluator mTrackColorEvaluator = new ArgbEvaluator();
Matthew Nga8f24262017-12-19 11:54:24 -080096
97 private final AnimatorUpdateListener mTrackAnimatorListener = valueAnimator -> {
Matthew Ng7090a802018-01-19 13:36:22 -080098 mTrackAlpha = (float) valueAnimator.getAnimatedValue();
Matthew Nga8f24262017-12-19 11:54:24 -080099 mNavigationBarView.invalidate();
100 };
101
102 private final AnimatorUpdateListener mButtonTranslationListener = animator -> {
103 int pos = (int) animator.getAnimatedValue();
104 if (!mQuickScrubActive) {
105 pos = mDragPositive ? Math.min((int) mTranslation, pos) : Math.max((int) mTranslation, pos);
106 }
Matthew Nga8f24262017-12-19 11:54:24 -0800107 if (mIsVertical) {
Winson Chungd10ca302018-02-14 10:13:41 -0800108 mHomeButtonView.setTranslationY(pos);
Matthew Nga8f24262017-12-19 11:54:24 -0800109 } else {
Winson Chungd10ca302018-02-14 10:13:41 -0800110 mHomeButtonView.setTranslationX(pos);
Matthew Nga8f24262017-12-19 11:54:24 -0800111 }
112 };
113
114 private AnimatorListenerAdapter mQuickScrubEndListener = new AnimatorListenerAdapter() {
115 @Override
116 public void onAnimationEnd(Animator animation) {
Matthew Nga8f24262017-12-19 11:54:24 -0800117 mQuickScrubActive = false;
118 mTranslation = 0;
Matthew Nged166f92018-02-20 16:22:09 -0800119 mQuickScrubEndAnimator.setCurrentPlayTime(mQuickScrubEndAnimator.getDuration());
120 mHomeButtonView = null;
Matthew Nga8f24262017-12-19 11:54:24 -0800121 }
122 };
123
Matthew Ng2ea93b72018-03-14 19:43:18 +0000124 public QuickStepController(Context context) {
Matthew Nga8f24262017-12-19 11:54:24 -0800125 mContext = context;
126 mScrollTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
Matthew Nga8f24262017-12-19 11:54:24 -0800127 mOverviewEventSender = Dependency.get(OverviewProxyService.class);
Matthew Nga8f24262017-12-19 11:54:24 -0800128 mTrackThickness = getDimensionPixelSize(mContext, R.dimen.nav_quick_scrub_track_thickness);
129 mTrackPadding = getDimensionPixelSize(mContext, R.dimen.nav_quick_scrub_track_edge_padding);
Matthew Ng7090a802018-01-19 13:36:22 -0800130 mTrackPaint.setAlpha(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800131
132 mTrackAnimator = ObjectAnimator.ofFloat();
133 mTrackAnimator.addUpdateListener(mTrackAnimatorListener);
Matthew Ng55437a92018-02-23 15:02:07 -0800134 mTrackAnimator.setFloatValues(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800135 mButtonAnimator = ObjectAnimator.ofInt();
136 mButtonAnimator.addUpdateListener(mButtonTranslationListener);
Matthew Ng55437a92018-02-23 15:02:07 -0800137 mButtonAnimator.setIntValues(0);
Matthew Nga8f24262017-12-19 11:54:24 -0800138 mQuickScrubEndAnimator = new AnimatorSet();
139 mQuickScrubEndAnimator.playTogether(mTrackAnimator, mButtonAnimator);
140 mQuickScrubEndAnimator.setDuration(ANIM_DURATION_MS);
141 mQuickScrubEndAnimator.addListener(mQuickScrubEndListener);
142 mQuickScrubEndAnimator.setInterpolator(mQuickScrubEndInterpolator);
143 }
144
145 public void setComponents(NavigationBarView navigationBarView) {
146 mNavigationBarView = navigationBarView;
147 }
148
Winson Chung4faf38a2018-02-06 08:53:37 -0800149 /**
Matthew Ngfba39692018-03-13 18:08:34 -0700150 * @return true if we want to intercept touch events for quick scrub and prevent proxying the
151 * event to the overview service.
Winson Chung4faf38a2018-02-06 08:53:37 -0800152 */
Matthew Nga8f24262017-12-19 11:54:24 -0800153 @Override
154 public boolean onInterceptTouchEvent(MotionEvent event) {
Winson Chungde2a1242018-02-07 15:59:43 -0800155 return handleTouchEvent(event);
156 }
157
158 /**
Matthew Ngfba39692018-03-13 18:08:34 -0700159 * @return true if we want to handle touch events for quick scrub or if down event (that will
160 * get consumed and ignored). No events will be proxied to the overview service.
Winson Chungde2a1242018-02-07 15:59:43 -0800161 */
162 @Override
163 public boolean onTouchEvent(MotionEvent event) {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000164 // The same down event was just sent on intercept and therefore can be ignored here
165 final boolean ignoreProxyDownEvent = event.getAction() == MotionEvent.ACTION_DOWN
166 && mOverviewEventSender.getProxy() != null;
167 return ignoreProxyDownEvent || handleTouchEvent(event);
Winson Chungde2a1242018-02-07 15:59:43 -0800168 }
169
170 private boolean handleTouchEvent(MotionEvent event) {
Matthew Ng22cf5142018-03-14 12:26:14 -0700171 if (!mNavigationBarView.isQuickScrubEnabled()
172 && !mNavigationBarView.isQuickStepSwipeUpEnabled()) {
173 mNavigationBarView.getHomeButton().setDelayTouchFeedback(false /* delay */);
174 return false;
175 }
176 mNavigationBarView.requestUnbufferedDispatch(event);
177
Winson Chungde2a1242018-02-07 15:59:43 -0800178 final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton();
Matthew Ng2ea93b72018-03-14 19:43:18 +0000179 final boolean homePressed = mNavigationBarView.getDownHitTarget() == HIT_TARGET_HOME;
Matthew Nga8f24262017-12-19 11:54:24 -0800180 int action = event.getAction();
181 switch (action & MotionEvent.ACTION_MASK) {
182 case MotionEvent.ACTION_DOWN: {
183 int x = (int) event.getX();
184 int y = (int) event.getY();
Winson Chung0be8f082018-02-15 15:52:49 -0800185 // End any existing quickscrub animations before starting the new transition
Matthew Nged166f92018-02-20 16:22:09 -0800186 if (mHomeButtonView != null) {
Winson Chung0be8f082018-02-15 15:52:49 -0800187 mQuickScrubEndAnimator.end();
188 }
Winson Chungd10ca302018-02-14 10:13:41 -0800189 mHomeButtonView = homeButton.getCurrentView();
Matthew Ng2ea93b72018-03-14 19:43:18 +0000190 homeButton.setDelayTouchFeedback(true /* delay */);
191 mTouchDownX = x;
192 mTouchDownY = y;
Matthew Ng2ea93b72018-03-14 19:43:18 +0000193 mTransformGlobalMatrix.set(Matrix.IDENTITY_MATRIX);
194 mTransformLocalMatrix.set(Matrix.IDENTITY_MATRIX);
195 mNavigationBarView.transformMatrixToGlobal(mTransformGlobalMatrix);
196 mNavigationBarView.transformMatrixToLocal(mTransformLocalMatrix);
197 mQuickStepStarted = false;
Matthew Ng2ea93b72018-03-14 19:43:18 +0000198 mAllowGestureDetection = true;
Matthew Nga8f24262017-12-19 11:54:24 -0800199 break;
200 }
201 case MotionEvent.ACTION_MOVE: {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000202 if (mQuickStepStarted || !mAllowGestureDetection){
203 break;
204 }
205 int x = (int) event.getX();
206 int y = (int) event.getY();
207 int xDiff = Math.abs(x - mTouchDownX);
208 int yDiff = Math.abs(y - mTouchDownY);
209 boolean exceededTouchSlopX = xDiff > mScrollTouchSlop && xDiff > yDiff;
210 boolean exceededTouchSlopY = yDiff > mScrollTouchSlop && yDiff > xDiff;
211 boolean exceededTouchSlop, exceededPerpendicularTouchSlop;
212 int pos, touchDown, offset, trackSize;
Matthew Nge0903c92018-01-17 15:32:41 -0800213
Matthew Ng2ea93b72018-03-14 19:43:18 +0000214 if (mIsVertical) {
215 exceededTouchSlop = exceededTouchSlopY;
216 exceededPerpendicularTouchSlop = exceededTouchSlopX;
217 pos = y;
218 touchDown = mTouchDownY;
219 offset = pos - mTrackRect.top;
220 trackSize = mTrackRect.height();
221 } else {
222 exceededTouchSlop = exceededTouchSlopX;
223 exceededPerpendicularTouchSlop = exceededTouchSlopY;
224 pos = x;
225 touchDown = mTouchDownX;
226 offset = pos - mTrackRect.left;
227 trackSize = mTrackRect.width();
228 }
229 // Decide to start quickstep if dragging away from the navigation bar, otherwise in
230 // the parallel direction, decide to start quickscrub. Only one may run.
Matthew Ngfba39692018-03-13 18:08:34 -0700231 if (!mQuickScrubActive && exceededPerpendicularTouchSlop) {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000232 if (mNavigationBarView.isQuickStepSwipeUpEnabled()) {
233 startQuickStep(event);
Winson Chung0e490d922018-03-14 16:08:43 +0000234 }
Matthew Ng2ea93b72018-03-14 19:43:18 +0000235 break;
236 }
Winson Chung0e490d922018-03-14 16:08:43 +0000237
Matthew Ngfba39692018-03-13 18:08:34 -0700238 // Do not handle quick scrub if disabled or hit target is not home button
Matthew Ng2ea93b72018-03-14 19:43:18 +0000239 if (!homePressed || !mNavigationBarView.isQuickScrubEnabled()) {
240 break;
241 }
242
243 if (!mDragPositive) {
244 offset -= mIsVertical ? mTrackRect.height() : mTrackRect.width();
245 }
246
247 // Control the button movement
Matthew Ngfba39692018-03-13 18:08:34 -0700248 if (!mQuickScrubActive && exceededTouchSlop) {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000249 boolean allowDrag = !mDragPositive
250 ? offset < 0 && pos < touchDown : offset >= 0 && pos > touchDown;
251 if (allowDrag) {
252 mDownOffset = offset;
253 homeButton.abortCurrentGesture();
Matthew Ngfba39692018-03-13 18:08:34 -0700254 startQuickScrub();
Winson Chung0e490d922018-03-14 16:08:43 +0000255 }
Matthew Ng2ea93b72018-03-14 19:43:18 +0000256 }
Matthew Ngfba39692018-03-13 18:08:34 -0700257 if (mQuickScrubActive && (mDragPositive && offset >= 0
Matthew Ng2ea93b72018-03-14 19:43:18 +0000258 || !mDragPositive && offset <= 0)) {
259 float scrubFraction = Utilities.clamp(Math.abs(offset) * 1f / trackSize, 0, 1);
260 mTranslation = !mDragPositive
261 ? Utilities.clamp(offset - mDownOffset, -trackSize, 0)
262 : Utilities.clamp(offset - mDownOffset, 0, trackSize);
Matthew Ngfba39692018-03-13 18:08:34 -0700263 try {
264 mOverviewEventSender.getProxy().onQuickScrubProgress(scrubFraction);
265 if (DEBUG_OVERVIEW_PROXY) {
266 Log.d(TAG_OPS, "Quick Scrub Progress:" + scrubFraction);
Winson Chung0e490d922018-03-14 16:08:43 +0000267 }
Matthew Ngfba39692018-03-13 18:08:34 -0700268 } catch (RemoteException e) {
269 Log.e(TAG, "Failed to send progress of quick scrub.", e);
Matthew Ng2ea93b72018-03-14 19:43:18 +0000270 }
271 if (mIsVertical) {
272 mHomeButtonView.setTranslationY(mTranslation);
273 } else {
274 mHomeButtonView.setTranslationX(mTranslation);
Matthew Nga8f24262017-12-19 11:54:24 -0800275 }
276 }
277 break;
278 }
279 case MotionEvent.ACTION_CANCEL:
280 case MotionEvent.ACTION_UP:
Winson Chungd10ca302018-02-14 10:13:41 -0800281 endQuickScrub(true /* animate */);
Matthew Nga8f24262017-12-19 11:54:24 -0800282 break;
283 }
Matthew Ng2ea93b72018-03-14 19:43:18 +0000284
Matthew Ngfba39692018-03-13 18:08:34 -0700285 // Proxy motion events to launcher if not handled by quick scrub
286 if (!mQuickScrubActive && mAllowGestureDetection) {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000287 proxyMotionEvents(event);
288 }
Matthew Ngfba39692018-03-13 18:08:34 -0700289 return mQuickScrubActive || mQuickStepStarted;
Matthew Nga8f24262017-12-19 11:54:24 -0800290 }
291
292 @Override
293 public void onDraw(Canvas canvas) {
Matthew Ng2ea93b72018-03-14 19:43:18 +0000294 if (mNavigationBarView.isQuickScrubEnabled()) {
295 return;
296 }
Matthew Ng7090a802018-01-19 13:36:22 -0800297 int color = (int) mTrackColorEvaluator.evaluate(mDarkIntensity, mLightTrackColor,
298 mDarkTrackColor);
299 mTrackPaint.setColor(color);
300 mTrackPaint.setAlpha((int) (mTrackPaint.getAlpha() * mTrackAlpha));
Matthew Nga8f24262017-12-19 11:54:24 -0800301 canvas.drawRect(mTrackRect, mTrackPaint);
302 }
303
304 @Override
305 public void onLayout(boolean changed, int left, int top, int right, int bottom) {
306 final int width = right - left;
307 final int height = bottom - top;
308 final int x1, x2, y1, y2;
309 if (mIsVertical) {
310 x1 = (width - mTrackThickness) / 2;
311 x2 = x1 + mTrackThickness;
312 y1 = mDragPositive ? height / 2 : mTrackPadding;
313 y2 = y1 + height / 2 - mTrackPadding;
314 } else {
315 y1 = (height - mTrackThickness) / 2;
316 y2 = y1 + mTrackThickness;
317 x1 = mDragPositive ? width / 2 : mTrackPadding;
318 x2 = x1 + width / 2 - mTrackPadding;
319 }
320 mTrackRect.set(x1, y1, x2, y2);
Matthew Nga8f24262017-12-19 11:54:24 -0800321 }
322
323 @Override
324 public void onDarkIntensityChange(float intensity) {
Matthew Ng7090a802018-01-19 13:36:22 -0800325 mDarkIntensity = intensity;
326 mNavigationBarView.invalidate();
Matthew Nga8f24262017-12-19 11:54:24 -0800327 }
328
329 @Override
Matthew Nga8f24262017-12-19 11:54:24 -0800330 public void setBarState(boolean isVertical, boolean isRTL) {
Winson Chungd10ca302018-02-14 10:13:41 -0800331 final boolean changed = (mIsVertical != isVertical) || (mIsRTL != isRTL);
332 if (changed) {
333 // End quickscrub if the state changes mid-transition
334 endQuickScrub(false /* animate */);
335 }
Matthew Nga8f24262017-12-19 11:54:24 -0800336 mIsVertical = isVertical;
337 mIsRTL = isRTL;
338 try {
339 int navbarPos = WindowManagerGlobal.getWindowManagerService().getNavBarPosition();
340 mDragPositive = navbarPos == NAV_BAR_LEFT || navbarPos == NAV_BAR_BOTTOM;
341 if (isRTL) {
342 mDragPositive = !mDragPositive;
343 }
344 } catch (RemoteException e) {
345 Slog.e(TAG, "Failed to get nav bar position.", e);
346 }
347 }
348
Matthew Ng2ea93b72018-03-14 19:43:18 +0000349 @Override
350 public void onNavigationButtonLongPress(View v) {
351 mAllowGestureDetection = false;
352 mHandler.removeCallbacksAndMessages(null);
353 }
354
355 private void startQuickStep(MotionEvent event) {
356 mQuickStepStarted = true;
357 event.transform(mTransformGlobalMatrix);
358 try {
359 mOverviewEventSender.getProxy().onQuickStep(event);
360 if (DEBUG_OVERVIEW_PROXY) {
361 Log.d(TAG_OPS, "Quick Step Start");
362 }
363 } catch (RemoteException e) {
364 Log.e(TAG, "Failed to send quick step started.", e);
365 } finally {
366 event.transform(mTransformLocalMatrix);
367 }
368 mOverviewEventSender.notifyQuickStepStarted();
369 mNavigationBarView.getHomeButton().abortCurrentGesture();
Matthew Ng2ea93b72018-03-14 19:43:18 +0000370 mHandler.removeCallbacksAndMessages(null);
371 }
372
Matthew Nga8f24262017-12-19 11:54:24 -0800373 private void startQuickScrub() {
Matthew Ngfba39692018-03-13 18:08:34 -0700374 if (!mQuickScrubActive) {
Matthew Nga8f24262017-12-19 11:54:24 -0800375 mQuickScrubActive = true;
Matthew Ng7090a802018-01-19 13:36:22 -0800376 mLightTrackColor = mContext.getColor(R.color.quick_step_track_background_light);
377 mDarkTrackColor = mContext.getColor(R.color.quick_step_track_background_dark);
378 mTrackAnimator.setFloatValues(0, 1);
Matthew Nga8f24262017-12-19 11:54:24 -0800379 mTrackAnimator.start();
380 try {
381 mOverviewEventSender.getProxy().onQuickScrubStart();
Matthew Ngbd824572018-01-17 16:25:56 -0800382 if (DEBUG_OVERVIEW_PROXY) {
383 Log.d(TAG_OPS, "Quick Scrub Start");
384 }
Matthew Nga8f24262017-12-19 11:54:24 -0800385 } catch (RemoteException e) {
386 Log.e(TAG, "Failed to send start of quick scrub.", e);
387 }
388 }
389 }
390
Winson Chungd10ca302018-02-14 10:13:41 -0800391 private void endQuickScrub(boolean animate) {
Matthew Ngfba39692018-03-13 18:08:34 -0700392 if (mQuickScrubActive) {
Matthew Nged166f92018-02-20 16:22:09 -0800393 animateEnd();
Matthew Nga8f24262017-12-19 11:54:24 -0800394 try {
395 mOverviewEventSender.getProxy().onQuickScrubEnd();
Matthew Ngbd824572018-01-17 16:25:56 -0800396 if (DEBUG_OVERVIEW_PROXY) {
397 Log.d(TAG_OPS, "Quick Scrub End");
398 }
Matthew Nga8f24262017-12-19 11:54:24 -0800399 } catch (RemoteException e) {
400 Log.e(TAG, "Failed to send end of quick scrub.", e);
401 }
Matthew Nged166f92018-02-20 16:22:09 -0800402 }
403 if (mHomeButtonView != null && !animate) {
404 mQuickScrubEndAnimator.end();
Matthew Nga8f24262017-12-19 11:54:24 -0800405 }
Matthew Nga8f24262017-12-19 11:54:24 -0800406 }
407
Matthew Ng2ea93b72018-03-14 19:43:18 +0000408 private boolean proxyMotionEvents(MotionEvent event) {
409 final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy();
410 event.transform(mTransformGlobalMatrix);
411 try {
412 if (event.getActionMasked() == MotionEvent.ACTION_DOWN) {
413 overviewProxy.onPreMotionEvent(mNavigationBarView.getDownHitTarget());
414 }
415 overviewProxy.onMotionEvent(event);
416 if (DEBUG_OVERVIEW_PROXY) {
417 Log.d(TAG_OPS, "Send MotionEvent: " + event.toString());
418 }
419 return true;
420 } catch (RemoteException e) {
421 Log.e(TAG, "Callback failed", e);
422 } finally {
423 event.transform(mTransformLocalMatrix);
Matthew Ngdb2734c2018-02-16 16:02:20 -0800424 }
Matthew Ng2ea93b72018-03-14 19:43:18 +0000425 return false;
Matthew Ngdb2734c2018-02-16 16:02:20 -0800426 }
427
Matthew Nged166f92018-02-20 16:22:09 -0800428 private void animateEnd() {
429 mButtonAnimator.setIntValues((int) mTranslation, 0);
430 mTrackAnimator.setFloatValues(mTrackAlpha, 0);
Matthew Ng55437a92018-02-23 15:02:07 -0800431 mQuickScrubEndAnimator.setCurrentPlayTime(0);
Matthew Nged166f92018-02-20 16:22:09 -0800432 mQuickScrubEndAnimator.start();
433 }
434
Matthew Nga8f24262017-12-19 11:54:24 -0800435 private int getDimensionPixelSize(Context context, @DimenRes int resId) {
436 return context.getResources().getDimensionPixelSize(resId);
437 }
438}