Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 1 | /* |
| 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 | |
| 17 | package com.android.systemui.statusbar.phone; |
| 18 | |
| 19 | import android.animation.Animator; |
| 20 | import android.animation.AnimatorListenerAdapter; |
| 21 | import android.animation.AnimatorSet; |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 22 | import android.animation.ArgbEvaluator; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 23 | import android.animation.ObjectAnimator; |
| 24 | import android.animation.ValueAnimator; |
| 25 | import android.animation.ValueAnimator.AnimatorUpdateListener; |
| 26 | import android.content.Context; |
| 27 | import android.graphics.Canvas; |
| 28 | import android.graphics.Paint; |
| 29 | import android.graphics.Rect; |
| 30 | import android.os.Handler; |
| 31 | import android.os.RemoteException; |
Matthew Ng | f41f7c3 | 2018-01-22 17:57:05 -0800 | [diff] [blame] | 32 | import android.os.SystemProperties; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 33 | import android.util.Log; |
| 34 | import android.util.Slog; |
| 35 | import android.view.Display; |
| 36 | import android.view.GestureDetector; |
| 37 | import android.view.MotionEvent; |
| 38 | import android.view.View; |
| 39 | import android.view.ViewConfiguration; |
| 40 | import android.view.WindowManager; |
| 41 | import android.view.WindowManagerGlobal; |
| 42 | import android.view.animation.DecelerateInterpolator; |
| 43 | import android.view.animation.Interpolator; |
| 44 | import android.support.annotation.DimenRes; |
| 45 | import com.android.systemui.Dependency; |
| 46 | import com.android.systemui.OverviewProxyService; |
| 47 | import com.android.systemui.R; |
| 48 | import com.android.systemui.plugins.statusbar.phone.NavGesture.GestureHelper; |
| 49 | import com.android.systemui.shared.recents.IOverviewProxy; |
| 50 | import com.android.systemui.shared.recents.utilities.Utilities; |
| 51 | |
| 52 | import static android.view.WindowManagerPolicyConstants.NAV_BAR_LEFT; |
| 53 | import static android.view.WindowManagerPolicyConstants.NAV_BAR_BOTTOM; |
Matthew Ng | bd82457 | 2018-01-17 16:25:56 -0800 | [diff] [blame] | 54 | import static com.android.systemui.OverviewProxyService.DEBUG_OVERVIEW_PROXY; |
| 55 | import static com.android.systemui.OverviewProxyService.TAG_OPS; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 56 | |
| 57 | /** |
| 58 | * Class to detect gestures on the navigation bar and implement quick scrub and switch. |
| 59 | */ |
| 60 | public class QuickScrubController extends GestureDetector.SimpleOnGestureListener implements |
| 61 | GestureHelper { |
| 62 | |
| 63 | private static final String TAG = "QuickScrubController"; |
| 64 | private static final int QUICK_SWITCH_FLING_VELOCITY = 0; |
| 65 | private static final int ANIM_DURATION_MS = 200; |
| 66 | private static final long LONG_PRESS_DELAY_MS = 150; |
| 67 | |
| 68 | /** |
| 69 | * For quick step, set a damping value to allow the button to stick closer its origin position |
| 70 | * when dragging before quick scrub is active. |
| 71 | */ |
| 72 | private static final int SWITCH_STICKINESS = 4; |
| 73 | |
| 74 | private NavigationBarView mNavigationBarView; |
| 75 | private GestureDetector mGestureDetector; |
| 76 | |
| 77 | private boolean mDraggingActive; |
| 78 | private boolean mQuickScrubActive; |
| 79 | 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 Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 86 | private float mTrackAlpha; |
| 87 | private int mLightTrackColor; |
| 88 | private int mDarkTrackColor; |
| 89 | private float mDarkIntensity; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 90 | |
| 91 | private final Handler mHandler = new Handler(); |
| 92 | private final Interpolator mQuickScrubEndInterpolator = new DecelerateInterpolator(); |
| 93 | private final Rect mTrackRect = new Rect(); |
| 94 | private final Rect mHomeButtonRect = new Rect(); |
| 95 | private final Paint mTrackPaint = new Paint(); |
| 96 | private final int mScrollTouchSlop; |
| 97 | private final OverviewProxyService mOverviewEventSender; |
| 98 | private final Display mDisplay; |
| 99 | private final int mTrackThickness; |
| 100 | private final int mTrackPadding; |
| 101 | private final ValueAnimator mTrackAnimator; |
| 102 | private final ValueAnimator mButtonAnimator; |
| 103 | private final AnimatorSet mQuickScrubEndAnimator; |
| 104 | private final Context mContext; |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 105 | private final ArgbEvaluator mTrackColorEvaluator = new ArgbEvaluator(); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 106 | |
| 107 | private final AnimatorUpdateListener mTrackAnimatorListener = valueAnimator -> { |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 108 | mTrackAlpha = (float) valueAnimator.getAnimatedValue(); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 109 | mNavigationBarView.invalidate(); |
| 110 | }; |
| 111 | |
| 112 | private final AnimatorUpdateListener mButtonTranslationListener = animator -> { |
| 113 | int pos = (int) animator.getAnimatedValue(); |
| 114 | if (!mQuickScrubActive) { |
| 115 | pos = mDragPositive ? Math.min((int) mTranslation, pos) : Math.max((int) mTranslation, pos); |
| 116 | } |
| 117 | final View homeView = mNavigationBarView.getHomeButton().getCurrentView(); |
| 118 | if (mIsVertical) { |
| 119 | homeView.setTranslationY(pos); |
| 120 | } else { |
| 121 | homeView.setTranslationX(pos); |
| 122 | } |
| 123 | }; |
| 124 | |
| 125 | private AnimatorListenerAdapter mQuickScrubEndListener = new AnimatorListenerAdapter() { |
| 126 | @Override |
| 127 | public void onAnimationEnd(Animator animation) { |
| 128 | mNavigationBarView.getHomeButton().setClickable(true); |
| 129 | mQuickScrubActive = false; |
| 130 | mTranslation = 0; |
| 131 | } |
| 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 Ng | f41f7c3 | 2018-01-22 17:57:05 -0800 | [diff] [blame] | 140 | if (!isQuickScrubEnabled() || mQuickScrubActive) { |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 141 | return false; |
| 142 | } |
| 143 | float velocityX = mIsRTL ? -velX : velX; |
| 144 | float absVelY = Math.abs(velY); |
| 145 | final boolean isValidFling = velocityX > QUICK_SWITCH_FLING_VELOCITY && |
| 146 | mIsVertical ? (absVelY > velocityX) : (velocityX > absVelY); |
| 147 | if (isValidFling) { |
| 148 | mDraggingActive = false; |
| 149 | mButtonAnimator.setIntValues((int) mTranslation, 0); |
| 150 | mButtonAnimator.start(); |
| 151 | mHandler.removeCallbacks(mLongPressRunnable); |
| 152 | try { |
| 153 | final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy(); |
| 154 | overviewProxy.onQuickSwitch(); |
Matthew Ng | bd82457 | 2018-01-17 16:25:56 -0800 | [diff] [blame] | 155 | if (DEBUG_OVERVIEW_PROXY) { |
| 156 | Log.d(TAG_OPS, "Quick Switch"); |
| 157 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 158 | } catch (RemoteException e) { |
| 159 | Log.e(TAG, "Failed to send start of quick switch.", e); |
| 160 | } |
| 161 | } |
| 162 | return true; |
| 163 | } |
| 164 | }; |
| 165 | |
| 166 | public QuickScrubController(Context context) { |
| 167 | mContext = context; |
| 168 | mScrollTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); |
| 169 | mDisplay = ((WindowManager) context.getSystemService( |
| 170 | Context.WINDOW_SERVICE)).getDefaultDisplay(); |
| 171 | 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 Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 175 | mTrackPaint.setAlpha(0); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 176 | |
| 177 | mTrackAnimator = ObjectAnimator.ofFloat(); |
| 178 | mTrackAnimator.addUpdateListener(mTrackAnimatorListener); |
| 179 | mButtonAnimator = ObjectAnimator.ofInt(); |
| 180 | mButtonAnimator.addUpdateListener(mButtonTranslationListener); |
| 181 | mQuickScrubEndAnimator = new AnimatorSet(); |
| 182 | mQuickScrubEndAnimator.playTogether(mTrackAnimator, mButtonAnimator); |
| 183 | mQuickScrubEndAnimator.setDuration(ANIM_DURATION_MS); |
| 184 | mQuickScrubEndAnimator.addListener(mQuickScrubEndListener); |
| 185 | mQuickScrubEndAnimator.setInterpolator(mQuickScrubEndInterpolator); |
| 186 | } |
| 187 | |
| 188 | public void setComponents(NavigationBarView navigationBarView) { |
| 189 | mNavigationBarView = navigationBarView; |
| 190 | } |
| 191 | |
| 192 | @Override |
| 193 | public boolean onInterceptTouchEvent(MotionEvent event) { |
| 194 | final IOverviewProxy overviewProxy = mOverviewEventSender.getProxy(); |
| 195 | final ButtonDispatcher homeButton = mNavigationBarView.getHomeButton(); |
| 196 | if (overviewProxy == null) { |
| 197 | homeButton.setDelayTouchFeedback(false); |
| 198 | return false; |
| 199 | } |
| 200 | mGestureDetector.onTouchEvent(event); |
| 201 | int action = event.getAction(); |
| 202 | switch (action & MotionEvent.ACTION_MASK) { |
| 203 | case MotionEvent.ACTION_DOWN: { |
| 204 | int x = (int) event.getX(); |
| 205 | int y = (int) event.getY(); |
Matthew Ng | f41f7c3 | 2018-01-22 17:57:05 -0800 | [diff] [blame] | 206 | if (isQuickScrubEnabled() && mHomeButtonRect.contains(x, y)) { |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 207 | mTouchDownX = x; |
| 208 | mTouchDownY = y; |
| 209 | homeButton.setDelayTouchFeedback(true); |
| 210 | mHandler.postDelayed(mLongPressRunnable, LONG_PRESS_DELAY_MS); |
| 211 | } else { |
Matthew Ng | f41f7c3 | 2018-01-22 17:57:05 -0800 | [diff] [blame] | 212 | homeButton.setDelayTouchFeedback(false); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 213 | mTouchDownX = mTouchDownY = -1; |
| 214 | } |
| 215 | break; |
| 216 | } |
| 217 | case MotionEvent.ACTION_MOVE: { |
| 218 | if (mTouchDownX != -1) { |
| 219 | int x = (int) event.getX(); |
| 220 | int y = (int) event.getY(); |
| 221 | int xDiff = Math.abs(x - mTouchDownX); |
| 222 | int yDiff = Math.abs(y - mTouchDownY); |
Matthew Ng | e0903c9 | 2018-01-17 15:32:41 -0800 | [diff] [blame] | 223 | boolean exceededTouchSlopX = xDiff > mScrollTouchSlop && xDiff > yDiff; |
| 224 | boolean exceededTouchSlopY = yDiff > mScrollTouchSlop && yDiff > xDiff; |
| 225 | boolean exceededTouchSlop, exceededPerpendicularTouchSlop; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 226 | int pos, touchDown, offset, trackSize; |
Matthew Ng | e0903c9 | 2018-01-17 15:32:41 -0800 | [diff] [blame] | 227 | |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 228 | if (mIsVertical) { |
Matthew Ng | e0903c9 | 2018-01-17 15:32:41 -0800 | [diff] [blame] | 229 | exceededTouchSlop = exceededTouchSlopY; |
| 230 | exceededPerpendicularTouchSlop = exceededTouchSlopX; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 231 | pos = y; |
| 232 | touchDown = mTouchDownY; |
| 233 | offset = pos - mTrackRect.top; |
| 234 | trackSize = mTrackRect.height(); |
| 235 | } else { |
Matthew Ng | e0903c9 | 2018-01-17 15:32:41 -0800 | [diff] [blame] | 236 | exceededTouchSlop = exceededTouchSlopX; |
| 237 | exceededPerpendicularTouchSlop = exceededTouchSlopY; |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 238 | pos = x; |
| 239 | touchDown = mTouchDownX; |
| 240 | offset = pos - mTrackRect.left; |
| 241 | trackSize = mTrackRect.width(); |
| 242 | } |
Matthew Ng | e0903c9 | 2018-01-17 15:32:41 -0800 | [diff] [blame] | 243 | // Do not start scrubbing when dragging in the perpendicular direction |
| 244 | if (!mDraggingActive && exceededPerpendicularTouchSlop) { |
| 245 | mHandler.removeCallbacksAndMessages(null); |
| 246 | return false; |
| 247 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 248 | if (!mDragPositive) { |
| 249 | offset -= mIsVertical ? mTrackRect.height() : mTrackRect.width(); |
| 250 | } |
| 251 | |
| 252 | // Control the button movement |
| 253 | if (!mDraggingActive && exceededTouchSlop) { |
| 254 | boolean allowDrag = !mDragPositive |
| 255 | ? offset < 0 && pos < touchDown : offset >= 0 && pos > touchDown; |
| 256 | if (allowDrag) { |
| 257 | mDownOffset = offset; |
| 258 | homeButton.setClickable(false); |
| 259 | mDraggingActive = true; |
| 260 | } |
| 261 | } |
| 262 | if (mDraggingActive && (mDragPositive && offset >= 0 |
| 263 | || !mDragPositive && offset <= 0)) { |
| 264 | float scrubFraction = |
| 265 | Utilities.clamp(Math.abs(offset) * 1f / trackSize, 0, 1); |
| 266 | mTranslation = !mDragPositive |
| 267 | ? Utilities.clamp(offset - mDownOffset, -trackSize, 0) |
| 268 | : Utilities.clamp(offset - mDownOffset, 0, trackSize); |
| 269 | if (mQuickScrubActive) { |
| 270 | try { |
| 271 | overviewProxy.onQuickScrubProgress(scrubFraction); |
Matthew Ng | bd82457 | 2018-01-17 16:25:56 -0800 | [diff] [blame] | 272 | if (DEBUG_OVERVIEW_PROXY) { |
| 273 | Log.d(TAG_OPS, "Quick Scrub Progress:" + scrubFraction); |
| 274 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 275 | } catch (RemoteException e) { |
| 276 | Log.e(TAG, "Failed to send progress of quick scrub.", e); |
| 277 | } |
| 278 | } else { |
| 279 | mTranslation /= SWITCH_STICKINESS; |
| 280 | } |
| 281 | if (mIsVertical) { |
| 282 | homeButton.getCurrentView().setTranslationY(mTranslation); |
| 283 | } else { |
| 284 | homeButton.getCurrentView().setTranslationX(mTranslation); |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 | break; |
| 289 | } |
| 290 | case MotionEvent.ACTION_CANCEL: |
| 291 | case MotionEvent.ACTION_UP: |
| 292 | endQuickScrub(); |
| 293 | break; |
| 294 | } |
| 295 | return mDraggingActive || mQuickScrubActive; |
| 296 | } |
| 297 | |
| 298 | @Override |
| 299 | public void onDraw(Canvas canvas) { |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 300 | int color = (int) mTrackColorEvaluator.evaluate(mDarkIntensity, mLightTrackColor, |
| 301 | mDarkTrackColor); |
| 302 | mTrackPaint.setColor(color); |
| 303 | mTrackPaint.setAlpha((int) (mTrackPaint.getAlpha() * mTrackAlpha)); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 304 | canvas.drawRect(mTrackRect, mTrackPaint); |
| 305 | } |
| 306 | |
| 307 | @Override |
| 308 | public void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 309 | final int width = right - left; |
| 310 | final int height = bottom - top; |
| 311 | final int x1, x2, y1, y2; |
| 312 | if (mIsVertical) { |
| 313 | x1 = (width - mTrackThickness) / 2; |
| 314 | x2 = x1 + mTrackThickness; |
| 315 | y1 = mDragPositive ? height / 2 : mTrackPadding; |
| 316 | y2 = y1 + height / 2 - mTrackPadding; |
| 317 | } else { |
| 318 | y1 = (height - mTrackThickness) / 2; |
| 319 | y2 = y1 + mTrackThickness; |
| 320 | x1 = mDragPositive ? width / 2 : mTrackPadding; |
| 321 | x2 = x1 + width / 2 - mTrackPadding; |
| 322 | } |
| 323 | mTrackRect.set(x1, y1, x2, y2); |
| 324 | |
| 325 | // Get the touch rect of the home button location |
| 326 | View homeView = mNavigationBarView.getHomeButton().getCurrentView(); |
Matthew Ng | a5612a0 | 2018-01-17 12:28:41 -0800 | [diff] [blame] | 327 | if (homeView != null) { |
| 328 | int[] globalHomePos = homeView.getLocationOnScreen(); |
| 329 | int[] globalNavBarPos = mNavigationBarView.getLocationOnScreen(); |
| 330 | int homeX = globalHomePos[0] - globalNavBarPos[0]; |
| 331 | int homeY = globalHomePos[1] - globalNavBarPos[1]; |
| 332 | mHomeButtonRect.set(homeX, homeY, homeX + homeView.getMeasuredWidth(), |
| 333 | homeY + homeView.getMeasuredHeight()); |
| 334 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 335 | } |
| 336 | |
| 337 | @Override |
| 338 | public void onDarkIntensityChange(float intensity) { |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 339 | mDarkIntensity = intensity; |
| 340 | mNavigationBarView.invalidate(); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | @Override |
| 344 | public boolean onTouchEvent(MotionEvent event) { |
| 345 | if (event.getAction() == MotionEvent.ACTION_UP) { |
| 346 | endQuickScrub(); |
| 347 | } |
| 348 | return false; |
| 349 | } |
| 350 | |
| 351 | @Override |
| 352 | public void setBarState(boolean isVertical, boolean isRTL) { |
| 353 | mIsVertical = isVertical; |
| 354 | mIsRTL = isRTL; |
| 355 | try { |
| 356 | int navbarPos = WindowManagerGlobal.getWindowManagerService().getNavBarPosition(); |
| 357 | mDragPositive = navbarPos == NAV_BAR_LEFT || navbarPos == NAV_BAR_BOTTOM; |
| 358 | if (isRTL) { |
| 359 | mDragPositive = !mDragPositive; |
| 360 | } |
| 361 | } catch (RemoteException e) { |
| 362 | Slog.e(TAG, "Failed to get nav bar position.", e); |
| 363 | } |
| 364 | } |
| 365 | |
Matthew Ng | f41f7c3 | 2018-01-22 17:57:05 -0800 | [diff] [blame] | 366 | boolean isQuickScrubEnabled() { |
| 367 | return SystemProperties.getBoolean("persist.quickstep.scrub.enabled", false); |
| 368 | } |
| 369 | |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 370 | private void startQuickScrub() { |
| 371 | if (!mQuickScrubActive) { |
| 372 | mQuickScrubActive = true; |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 373 | mLightTrackColor = mContext.getColor(R.color.quick_step_track_background_light); |
| 374 | mDarkTrackColor = mContext.getColor(R.color.quick_step_track_background_dark); |
| 375 | mTrackAnimator.setFloatValues(0, 1); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 376 | mTrackAnimator.start(); |
| 377 | try { |
| 378 | mOverviewEventSender.getProxy().onQuickScrubStart(); |
Matthew Ng | bd82457 | 2018-01-17 16:25:56 -0800 | [diff] [blame] | 379 | if (DEBUG_OVERVIEW_PROXY) { |
| 380 | Log.d(TAG_OPS, "Quick Scrub Start"); |
| 381 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 382 | } catch (RemoteException e) { |
| 383 | Log.e(TAG, "Failed to send start of quick scrub.", e); |
| 384 | } |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | private void endQuickScrub() { |
| 389 | mHandler.removeCallbacks(mLongPressRunnable); |
| 390 | if (mDraggingActive || mQuickScrubActive) { |
| 391 | mButtonAnimator.setIntValues((int) mTranslation, 0); |
Matthew Ng | 7090a80 | 2018-01-19 13:36:22 -0800 | [diff] [blame] | 392 | mTrackAnimator.setFloatValues(mTrackAlpha, 0); |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 393 | mQuickScrubEndAnimator.start(); |
| 394 | try { |
| 395 | mOverviewEventSender.getProxy().onQuickScrubEnd(); |
Matthew Ng | bd82457 | 2018-01-17 16:25:56 -0800 | [diff] [blame] | 396 | if (DEBUG_OVERVIEW_PROXY) { |
| 397 | Log.d(TAG_OPS, "Quick Scrub End"); |
| 398 | } |
Matthew Ng | a8f2426 | 2017-12-19 11:54:24 -0800 | [diff] [blame] | 399 | } catch (RemoteException e) { |
| 400 | Log.e(TAG, "Failed to send end of quick scrub.", e); |
| 401 | } |
| 402 | } |
| 403 | mDraggingActive = false; |
| 404 | } |
| 405 | |
| 406 | private int getDimensionPixelSize(Context context, @DimenRes int resId) { |
| 407 | return context.getResources().getDimensionPixelSize(resId); |
| 408 | } |
| 409 | } |