TaskView.java revision 8873754f66527d2cc9feab295dd4eef23298212a
1/* 2 * Copyright (C) 2014 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.recents.views; 18 19import android.animation.Animator; 20import android.animation.AnimatorSet; 21import android.animation.ObjectAnimator; 22import android.animation.ValueAnimator; 23import android.content.Context; 24import android.content.res.Resources; 25import android.graphics.Color; 26import android.graphics.Outline; 27import android.graphics.Paint; 28import android.graphics.Point; 29import android.graphics.PorterDuff; 30import android.graphics.PorterDuffColorFilter; 31import android.graphics.Rect; 32import android.util.AttributeSet; 33import android.util.FloatProperty; 34import android.util.Property; 35import android.view.MotionEvent; 36import android.view.View; 37import android.view.ViewDebug; 38import android.view.ViewOutlineProvider; 39import android.widget.Toast; 40 41import com.android.internal.logging.MetricsLogger; 42import com.android.internal.logging.MetricsProto.MetricsEvent; 43import com.android.systemui.Interpolators; 44import com.android.systemui.R; 45import com.android.systemui.recents.Recents; 46import com.android.systemui.recents.RecentsActivity; 47import com.android.systemui.recents.RecentsConfiguration; 48import com.android.systemui.recents.events.EventBus; 49import com.android.systemui.recents.events.activity.LaunchTaskEvent; 50import com.android.systemui.recents.events.ui.DismissTaskViewEvent; 51import com.android.systemui.recents.events.ui.TaskViewDismissedEvent; 52import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent; 53import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent; 54import com.android.systemui.recents.misc.ReferenceCountedTrigger; 55import com.android.systemui.recents.misc.SystemServicesProxy; 56import com.android.systemui.recents.misc.Utilities; 57import com.android.systemui.recents.model.Task; 58import com.android.systemui.recents.model.TaskStack; 59 60import java.util.ArrayList; 61 62import static android.app.ActivityManager.StackId.INVALID_STACK_ID; 63 64/** 65 * A {@link TaskView} represents a fixed view of a task. Because the TaskView's layout is directed 66 * solely by the {@link TaskStackView}, we make it a fixed size layout which allows relayouts down 67 * the view hierarchy, but not upwards from any of its children (the TaskView will relayout itself 68 * with the previous bounds if any child requests layout). 69 */ 70public class TaskView extends FixedSizeFrameLayout implements Task.TaskCallbacks, 71 TaskStackAnimationHelper.Callbacks, View.OnClickListener, View.OnLongClickListener { 72 73 /** The TaskView callbacks */ 74 interface TaskViewCallbacks { 75 void onTaskViewClipStateChanged(TaskView tv); 76 } 77 78 /** 79 * The dim overlay is generally calculated from the task progress, but occasionally (like when 80 * launching) needs to be animated independently of the task progress. This call is only used 81 * when animating the task into Recents, when the header dim is already applied 82 */ 83 public static final Property<TaskView, Float> DIM_ALPHA_WITHOUT_HEADER = 84 new FloatProperty<TaskView>("dimAlphaWithoutHeader") { 85 @Override 86 public void setValue(TaskView tv, float dimAlpha) { 87 tv.setDimAlphaWithoutHeader(dimAlpha); 88 } 89 90 @Override 91 public Float get(TaskView tv) { 92 return tv.getDimAlpha(); 93 } 94 }; 95 96 /** 97 * The dim overlay is generally calculated from the task progress, but occasionally (like when 98 * launching) needs to be animated independently of the task progress. 99 */ 100 public static final Property<TaskView, Float> DIM_ALPHA = 101 new FloatProperty<TaskView>("dimAlpha") { 102 @Override 103 public void setValue(TaskView tv, float dimAlpha) { 104 tv.setDimAlpha(dimAlpha); 105 } 106 107 @Override 108 public Float get(TaskView tv) { 109 return tv.getDimAlpha(); 110 } 111 }; 112 113 /** 114 * The dim overlay is generally calculated from the task progress, but occasionally (like when 115 * launching) needs to be animated independently of the task progress. 116 */ 117 public static final Property<TaskView, Float> VIEW_OUTLINE_ALPHA = 118 new FloatProperty<TaskView>("viewOutlineAlpha") { 119 @Override 120 public void setValue(TaskView tv, float alpha) { 121 tv.getViewBounds().setAlpha(alpha); 122 } 123 124 @Override 125 public Float get(TaskView tv) { 126 return tv.getViewBounds().getAlpha(); 127 } 128 }; 129 130 @ViewDebug.ExportedProperty(category="recents") 131 float mDimAlpha; 132 PorterDuffColorFilter mDimColorFilter = new PorterDuffColorFilter(0, PorterDuff.Mode.SRC_ATOP); 133 Paint mDimLayerPaint = new Paint(); 134 float mActionButtonTranslationZ; 135 136 @ViewDebug.ExportedProperty(deepExport=true, prefix="task_") 137 Task mTask; 138 @ViewDebug.ExportedProperty(category="recents") 139 boolean mTaskDataLoaded; 140 @ViewDebug.ExportedProperty(category="recents") 141 boolean mClipViewInStack = true; 142 @ViewDebug.ExportedProperty(category="recents") 143 boolean mTouchExplorationEnabled; 144 @ViewDebug.ExportedProperty(category="recents") 145 boolean mIsDisabledInSafeMode; 146 @ViewDebug.ExportedProperty(deepExport=true, prefix="view_bounds_") 147 AnimateableViewBounds mViewBounds; 148 149 private AnimatorSet mTransformAnimation; 150 private ArrayList<Animator> mTmpAnimators = new ArrayList<>(); 151 152 View mContent; 153 @ViewDebug.ExportedProperty(deepExport=true, prefix="thumbnail_") 154 TaskViewThumbnail mThumbnailView; 155 @ViewDebug.ExportedProperty(deepExport=true, prefix="header_") 156 TaskViewHeader mHeaderView; 157 View mActionButtonView; 158 TaskViewCallbacks mCb; 159 160 @ViewDebug.ExportedProperty(category="recents") 161 Point mDownTouchPos = new Point(); 162 163 private Toast mDisabledAppToast; 164 165 public TaskView(Context context) { 166 this(context, null); 167 } 168 169 public TaskView(Context context, AttributeSet attrs) { 170 this(context, attrs, 0); 171 } 172 173 public TaskView(Context context, AttributeSet attrs, int defStyleAttr) { 174 this(context, attrs, defStyleAttr, 0); 175 } 176 177 public TaskView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { 178 super(context, attrs, defStyleAttr, defStyleRes); 179 RecentsConfiguration config = Recents.getConfiguration(); 180 Resources res = context.getResources(); 181 mViewBounds = new AnimateableViewBounds(this, res.getDimensionPixelSize( 182 R.dimen.recents_task_view_shadow_rounded_corners_radius)); 183 if (config.fakeShadows) { 184 setBackground(new FakeShadowDrawable(res, config)); 185 } 186 setOutlineProvider(mViewBounds); 187 setOnLongClickListener(this); 188 } 189 190 /** Set callback */ 191 void setCallbacks(TaskViewCallbacks cb) { 192 mCb = cb; 193 } 194 195 /** Resets this TaskView for reuse. */ 196 void onResume(boolean isResumingFromVisible) { 197 resetNoUserInteractionState(); 198 readSystemFlags(); 199 if (!isResumingFromVisible) { 200 resetViewProperties(); 201 setClipViewInStack(false); 202 } 203 setCallbacks(null); 204 } 205 206 /** Gets the task */ 207 public Task getTask() { 208 return mTask; 209 } 210 211 /** Returns the view bounds. */ 212 AnimateableViewBounds getViewBounds() { 213 return mViewBounds; 214 } 215 216 @Override 217 protected void onAttachedToWindow() { 218 super.onAttachedToWindow(); 219 readSystemFlags(); 220 } 221 222 @Override 223 protected void onFinishInflate() { 224 // Bind the views 225 mContent = findViewById(R.id.task_view_content); 226 mHeaderView = (TaskViewHeader) findViewById(R.id.task_view_bar); 227 mThumbnailView = (TaskViewThumbnail) findViewById(R.id.task_view_thumbnail); 228 mActionButtonView = findViewById(R.id.lock_to_app_fab); 229 mActionButtonView.setOutlineProvider(new ViewOutlineProvider() { 230 @Override 231 public void getOutline(View view, Outline outline) { 232 // Set the outline to match the FAB background 233 outline.setOval(0, 0, mActionButtonView.getWidth(), mActionButtonView.getHeight()); 234 outline.setAlpha(0.35f); 235 } 236 }); 237 mActionButtonView.setOnClickListener(this); 238 mActionButtonTranslationZ = mActionButtonView.getTranslationZ(); 239 } 240 241 @Override 242 protected void onSizeChanged(int w, int h, int oldw, int oldh) { 243 super.onSizeChanged(w, h, oldw, oldh); 244 if (w > 0 && h > 0) { 245 mHeaderView.onTaskViewSizeChanged(w, h); 246 mThumbnailView.onTaskViewSizeChanged(w, h); 247 } 248 } 249 250 @Override 251 public boolean hasOverlappingRendering() { 252 return false; 253 } 254 255 @Override 256 public boolean onInterceptTouchEvent(MotionEvent ev) { 257 if (ev.getAction() == MotionEvent.ACTION_DOWN) { 258 mDownTouchPos.set((int) (ev.getX() * getScaleX()), (int) (ev.getY() * getScaleY())); 259 } 260 return super.onInterceptTouchEvent(ev); 261 } 262 263 264 @Override 265 protected void measureContents(int width, int height) { 266 int widthWithoutPadding = width - mPaddingLeft - mPaddingRight; 267 int heightWithoutPadding = height - mPaddingTop - mPaddingBottom; 268 269 // Measure the content 270 mContent.measure(MeasureSpec.makeMeasureSpec(widthWithoutPadding, MeasureSpec.EXACTLY), 271 MeasureSpec.makeMeasureSpec(heightWithoutPadding, MeasureSpec.EXACTLY)); 272 273 // Optimization: Prevent overdraw of the thumbnail under the header view 274 mThumbnailView.updateClipToTaskBar(mHeaderView); 275 276 setMeasuredDimension(width, height); 277 } 278 279 void updateViewPropertiesToTaskTransform(TaskViewTransform toTransform, 280 AnimationProps toAnimation, ValueAnimator.AnimatorUpdateListener updateCallback) { 281 RecentsConfiguration config = Recents.getConfiguration(); 282 cancelTransformAnimation(); 283 284 // Compose the animations for the transform 285 mTmpAnimators.clear(); 286 toTransform.applyToTaskView(this, mTmpAnimators, toAnimation, !config.fakeShadows); 287 if (toAnimation.isImmediate()) { 288 if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) { 289 setDimAlpha(toTransform.dimAlpha); 290 } 291 if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) { 292 mViewBounds.setAlpha(toTransform.viewOutlineAlpha); 293 } 294 // Manually call back to the animator listener and update callback 295 if (toAnimation.getListener() != null) { 296 toAnimation.getListener().onAnimationEnd(null); 297 } 298 if (updateCallback != null) { 299 updateCallback.onAnimationUpdate(null); 300 } 301 } else { 302 // Both the progress and the update are a function of the bounds movement of the task 303 if (Float.compare(getDimAlpha(), toTransform.dimAlpha) != 0) { 304 ObjectAnimator anim = ObjectAnimator.ofFloat(this, DIM_ALPHA, getDimAlpha(), 305 toTransform.dimAlpha); 306 mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, anim)); 307 } 308 if (Float.compare(mViewBounds.getAlpha(), toTransform.viewOutlineAlpha) != 0) { 309 ObjectAnimator anim = ObjectAnimator.ofFloat(this, VIEW_OUTLINE_ALPHA, 310 mViewBounds.getAlpha(), toTransform.viewOutlineAlpha); 311 mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, anim)); 312 } 313 if (updateCallback != null) { 314 ValueAnimator updateCallbackAnim = ValueAnimator.ofInt(0, 1); 315 updateCallbackAnim.addUpdateListener(updateCallback); 316 mTmpAnimators.add(toAnimation.apply(AnimationProps.BOUNDS, updateCallbackAnim)); 317 } 318 319 // Create the animator 320 mTransformAnimation = toAnimation.createAnimator(mTmpAnimators); 321 mTransformAnimation.start(); 322 } 323 } 324 325 /** Resets this view's properties */ 326 void resetViewProperties() { 327 cancelTransformAnimation(); 328 setDimAlpha(0); 329 setVisibility(View.VISIBLE); 330 getViewBounds().reset(); 331 getHeaderView().reset(); 332 TaskViewTransform.reset(this); 333 334 mActionButtonView.setScaleX(1f); 335 mActionButtonView.setScaleY(1f); 336 mActionButtonView.setAlpha(0f); 337 mActionButtonView.setTranslationZ(mActionButtonTranslationZ); 338 } 339 340 /** 341 * Cancels any current transform animations. 342 */ 343 public void cancelTransformAnimation() { 344 Utilities.cancelAnimationWithoutCallbacks(mTransformAnimation); 345 } 346 347 /** Enables/disables handling touch on this task view. */ 348 void setTouchEnabled(boolean enabled) { 349 setOnClickListener(enabled ? this : null); 350 } 351 352 /** Animates this task view if the user does not interact with the stack after a certain time. */ 353 void startNoUserInteractionAnimation() { 354 mHeaderView.startNoUserInteractionAnimation(); 355 } 356 357 /** Mark this task view that the user does has not interacted with the stack after a certain time. */ 358 void setNoUserInteractionState() { 359 mHeaderView.setNoUserInteractionState(); 360 } 361 362 /** Resets the state tracking that the user has not interacted with the stack after a certain time. */ 363 void resetNoUserInteractionState() { 364 mHeaderView.resetNoUserInteractionState(); 365 } 366 367 /** Dismisses this task. */ 368 void dismissTask() { 369 // Animate out the view and call the callback 370 final TaskView tv = this; 371 DismissTaskViewEvent dismissEvent = new DismissTaskViewEvent(tv, mTask); 372 dismissEvent.addPostAnimationCallback(new Runnable() { 373 @Override 374 public void run() { 375 EventBus.getDefault().send(new TaskViewDismissedEvent(mTask, tv)); 376 } 377 }); 378 EventBus.getDefault().send(dismissEvent); 379 } 380 381 /** 382 * Returns whether this view should be clipped, or any views below should clip against this 383 * view. 384 */ 385 boolean shouldClipViewInStack() { 386 // Never clip for freeform tasks or if invisible 387 if (mTask.isFreeformTask() || getVisibility() != View.VISIBLE) { 388 return false; 389 } 390 return mClipViewInStack; 391 } 392 393 /** Sets whether this view should be clipped, or clipped against. */ 394 void setClipViewInStack(boolean clip) { 395 if (clip != mClipViewInStack) { 396 mClipViewInStack = clip; 397 if (mCb != null) { 398 mCb.onTaskViewClipStateChanged(this); 399 } 400 } 401 } 402 403 public TaskViewHeader getHeaderView() { 404 return mHeaderView; 405 } 406 407 /** 408 * Sets the current dim. 409 */ 410 public void setDimAlpha(float dimAlpha) { 411 mDimAlpha = dimAlpha; 412 mThumbnailView.setDimAlpha(dimAlpha); 413 mHeaderView.setDimAlpha(dimAlpha); 414 } 415 416 /** 417 * Sets the current dim without updating the header's dim. 418 */ 419 public void setDimAlphaWithoutHeader(float dimAlpha) { 420 mDimAlpha = dimAlpha; 421 mThumbnailView.setDimAlpha(dimAlpha); 422 } 423 424 /** 425 * Returns the current dim. 426 */ 427 public float getDimAlpha() { 428 return mDimAlpha; 429 } 430 431 /** 432 * Explicitly sets the focused state of this task. 433 */ 434 public void setFocusedState(boolean isFocused, boolean requestViewFocus) { 435 SystemServicesProxy ssp = Recents.getSystemServices(); 436 if (isFocused) { 437 if (requestViewFocus && !isFocused()) { 438 requestFocus(); 439 } 440 if (requestViewFocus && !isAccessibilityFocused() && ssp.isTouchExplorationEnabled()) { 441 requestAccessibilityFocus(); 442 } 443 } else { 444 if (isAccessibilityFocused() && ssp.isTouchExplorationEnabled()) { 445 clearAccessibilityFocus(); 446 } 447 } 448 } 449 450 /** 451 * Shows the action button. 452 * @param fadeIn whether or not to animate the action button in. 453 * @param fadeInDuration the duration of the action button animation, only used if 454 * {@param fadeIn} is true. 455 */ 456 public void showActionButton(boolean fadeIn, int fadeInDuration) { 457 mActionButtonView.setVisibility(View.VISIBLE); 458 459 if (fadeIn && mActionButtonView.getAlpha() < 1f) { 460 mActionButtonView.animate() 461 .alpha(1f) 462 .scaleX(1f) 463 .scaleY(1f) 464 .setDuration(fadeInDuration) 465 .setInterpolator(Interpolators.ALPHA_IN) 466 .start(); 467 } else { 468 mActionButtonView.setScaleX(1f); 469 mActionButtonView.setScaleY(1f); 470 mActionButtonView.setAlpha(1f); 471 mActionButtonView.setTranslationZ(mActionButtonTranslationZ); 472 } 473 } 474 475 /** 476 * Immediately hides the action button. 477 * 478 * @param fadeOut whether or not to animate the action button out. 479 */ 480 public void hideActionButton(boolean fadeOut, int fadeOutDuration, boolean scaleDown, 481 final Animator.AnimatorListener animListener) { 482 if (fadeOut && mActionButtonView.getAlpha() > 0f) { 483 if (scaleDown) { 484 float toScale = 0.9f; 485 mActionButtonView.animate() 486 .scaleX(toScale) 487 .scaleY(toScale); 488 } 489 mActionButtonView.animate() 490 .alpha(0f) 491 .setDuration(fadeOutDuration) 492 .setInterpolator(Interpolators.ALPHA_OUT) 493 .withEndAction(new Runnable() { 494 @Override 495 public void run() { 496 if (animListener != null) { 497 animListener.onAnimationEnd(null); 498 } 499 mActionButtonView.setVisibility(View.INVISIBLE); 500 } 501 }) 502 .start(); 503 } else { 504 mActionButtonView.setAlpha(0f); 505 mActionButtonView.setVisibility(View.INVISIBLE); 506 if (animListener != null) { 507 animListener.onAnimationEnd(null); 508 } 509 } 510 } 511 512 /**** TaskStackAnimationHelper.Callbacks Implementation ****/ 513 514 @Override 515 public void onPrepareLaunchTargetForEnterAnimation() { 516 // These values will be animated in when onStartLaunchTargetEnterAnimation() is called 517 setDimAlphaWithoutHeader(0); 518 mActionButtonView.setAlpha(0f); 519 } 520 521 @Override 522 public void onStartLaunchTargetEnterAnimation(TaskViewTransform transform, int duration, 523 boolean screenPinningEnabled, ReferenceCountedTrigger postAnimationTrigger) { 524 // Dim the view after the app window transitions down into recents 525 postAnimationTrigger.increment(); 526 AnimationProps animation = new AnimationProps(duration, Interpolators.ALPHA_OUT); 527 Animator anim = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this, 528 DIM_ALPHA_WITHOUT_HEADER, getDimAlpha(), transform.dimAlpha)); 529 anim.addListener(postAnimationTrigger.decrementOnAnimationEnd()); 530 anim.start(); 531 532 if (screenPinningEnabled) { 533 showActionButton(true /* fadeIn */, duration /* fadeInDuration */); 534 } 535 } 536 537 @Override 538 public void onStartLaunchTargetLaunchAnimation(int duration, boolean screenPinningRequested, 539 ReferenceCountedTrigger postAnimationTrigger) { 540 // Un-dim the view before/while launching the target 541 AnimationProps animation = new AnimationProps(duration, Interpolators.ALPHA_OUT); 542 Animator anim = animation.apply(AnimationProps.DIM_ALPHA, ObjectAnimator.ofFloat(this, 543 DIM_ALPHA, getDimAlpha(), 0)); 544 anim.start(); 545 546 postAnimationTrigger.increment(); 547 hideActionButton(true /* fadeOut */, duration, 548 !screenPinningRequested /* scaleDown */, 549 postAnimationTrigger.decrementOnAnimationEnd()); 550 } 551 552 /**** TaskCallbacks Implementation ****/ 553 554 public void onTaskBound(Task t) { 555 SystemServicesProxy ssp = Recents.getSystemServices(); 556 mTask = t; 557 mTask.addCallback(this); 558 mIsDisabledInSafeMode = !mTask.isSystemApp && ssp.isInSafeMode(); 559 } 560 561 @Override 562 public void onTaskDataLoaded(Task task) { 563 // Bind each of the views to the new task data 564 mThumbnailView.rebindToTask(mTask, mIsDisabledInSafeMode); 565 mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled, mIsDisabledInSafeMode); 566 mTaskDataLoaded = true; 567 } 568 569 @Override 570 public void onTaskDataUnloaded() { 571 // Unbind each of the views from the task data and remove the task callback 572 mTask.removeCallback(this); 573 mThumbnailView.unbindFromTask(); 574 mHeaderView.unbindFromTask(mTouchExplorationEnabled); 575 mTaskDataLoaded = false; 576 } 577 578 @Override 579 public void onTaskStackIdChanged() { 580 mHeaderView.rebindToTask(mTask, mTouchExplorationEnabled, mIsDisabledInSafeMode); 581 } 582 583 /**** View.OnClickListener Implementation ****/ 584 585 @Override 586 public void onClick(final View v) { 587 if (mIsDisabledInSafeMode) { 588 Context context = getContext(); 589 String msg = context.getString(R.string.recents_launch_disabled_message, mTask.title); 590 if (mDisabledAppToast != null) { 591 mDisabledAppToast.cancel(); 592 } 593 mDisabledAppToast = Toast.makeText(context, msg, Toast.LENGTH_SHORT); 594 mDisabledAppToast.show(); 595 return; 596 } 597 598 boolean screenPinningRequested = false; 599 if (v == mActionButtonView) { 600 // Reset the translation of the action button before we animate it out 601 mActionButtonView.setTranslationZ(0f); 602 screenPinningRequested = true; 603 } 604 EventBus.getDefault().send(new LaunchTaskEvent(this, mTask, null, INVALID_STACK_ID, 605 screenPinningRequested)); 606 607 MetricsLogger.action(v.getContext(), MetricsEvent.ACTION_OVERVIEW_SELECT, 608 mTask.key.getComponent().toString()); 609 } 610 611 /**** View.OnLongClickListener Implementation ****/ 612 613 @Override 614 public boolean onLongClick(View v) { 615 SystemServicesProxy ssp = Recents.getSystemServices(); 616 // Since we are clipping the view to the bounds, manually do the hit test 617 Rect clipBounds = new Rect(mViewBounds.mClipBounds); 618 clipBounds.scale(getScaleX()); 619 boolean inBounds = clipBounds.contains(mDownTouchPos.x, mDownTouchPos.y); 620 if (v == this && inBounds && !ssp.hasDockedTask()) { 621 // Start listening for drag events 622 setClipViewInStack(false); 623 624 mDownTouchPos.x += ((1f - getScaleX()) * getWidth()) / 2; 625 mDownTouchPos.y += ((1f - getScaleY()) * getHeight()) / 2; 626 627 EventBus.getDefault().register(this, RecentsActivity.EVENT_BUS_PRIORITY + 1); 628 EventBus.getDefault().send(new DragStartEvent(mTask, this, mDownTouchPos)); 629 return true; 630 } 631 return false; 632 } 633 634 /**** Events ****/ 635 636 public final void onBusEvent(DragEndEvent event) { 637 if (!(event.dropTarget instanceof TaskStack.DockState)) { 638 event.addPostAnimationCallback(new Runnable() { 639 @Override 640 public void run() { 641 // Animate the drag view back from where it is, to the view location, then after 642 // it returns, update the clip state 643 setClipViewInStack(true); 644 } 645 }); 646 } 647 EventBus.getDefault().unregister(this); 648 } 649 650 /** 651 * Reads current system flags related to accessibility and screen pinning. 652 */ 653 private void readSystemFlags() { 654 SystemServicesProxy ssp = Recents.getSystemServices(); 655 mTouchExplorationEnabled = ssp.isTouchExplorationEnabled(); 656 } 657} 658