From 73492c5d7a5fdc19cfda750e4476d3188aca414e Mon Sep 17 00:00:00 2001 From: Winson Date: Wed, 9 Mar 2016 17:44:54 -0800 Subject: [PATCH] Fixing issue with animations not being cancelled. Bug: 27533931 Change-Id: I724643ec8a2c6cdaa3cade72ae40abcf9d28bae5 --- packages/SystemUI/res/values-land/dimens.xml | 3 +++ .../SystemUI/res/values-sw600dp/dimens.xml | 3 +++ packages/SystemUI/res/values/dimens.xml | 3 +++ .../systemui/recents/RecentsActivity.java | 14 +++++------ .../views/RecentsTransitionHelper.java | 24 ++++++++++++------- .../views/TaskStackLayoutAlgorithm.java | 12 ++++++---- 6 files changed, 40 insertions(+), 19 deletions(-) diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml index 26a81c8d835cf..585984c9c99f7 100644 --- a/packages/SystemUI/res/values-land/dimens.xml +++ b/packages/SystemUI/res/values-land/dimens.xml @@ -22,6 +22,9 @@ @integer/standard_notification_panel_layout_gravity + + @dimen/recents_task_bar_height + 2dp 16dp diff --git a/packages/SystemUI/res/values-sw600dp/dimens.xml b/packages/SystemUI/res/values-sw600dp/dimens.xml index 122413d2677a7..a2fa3b9769224 100644 --- a/packages/SystemUI/res/values-sw600dp/dimens.xml +++ b/packages/SystemUI/res/values-sw600dp/dimens.xml @@ -99,6 +99,9 @@ 40dp + + 100dp + 64dp diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml index 12c3a5d8cb501..93c16f95a8f86 100644 --- a/packages/SystemUI/res/values/dimens.xml +++ b/packages/SystemUI/res/values/dimens.xml @@ -295,6 +295,9 @@ 8dp + + 100dp + @dimen/recents_history_button_height diff --git a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java index cd1a27fd05156..473956fbe4d78 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java +++ b/packages/SystemUI/src/com/android/systemui/recents/RecentsActivity.java @@ -431,13 +431,6 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD mIgnoreAltTabRelease = false; mIterateTrigger.stopDozing(); - - // Workaround for b/22542869, if the RecentsActivity is started again, but without going - // through SystemUI, we need to reset the config launch flags to ensure that we do not - // wait on the system to send a signal that was never queued. - RecentsConfiguration config = Recents.getConfiguration(); - RecentsActivityLaunchState launchState = config.getLaunchState(); - launchState.reset(); } @Override @@ -453,6 +446,13 @@ public class RecentsActivity extends Activity implements ViewTreeObserver.OnPreD mIsVisible = false; EventBus.getDefault().send(new RecentsVisibilityChangedEvent(this, false)); MetricsLogger.hidden(this, MetricsEvent.OVERVIEW_ACTIVITY); + + // Workaround for b/22542869, if the RecentsActivity is started again, but without going + // through SystemUI, we need to reset the config launch flags to ensure that we do not + // wait on the system to send a signal that was never queued. + RecentsConfiguration config = Recents.getConfiguration(); + RecentsActivityLaunchState launchState = config.getLaunchState(); + launchState.reset(); } @Override diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java index dd825cb4331fe..a91bbd4b6d457 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsTransitionHelper.java @@ -105,6 +105,9 @@ public class RecentsTransitionHelper { animStartedListener = new ActivityOptions.OnAnimationStartedListener() { @Override public void onAnimationStarted() { + // If we are launching into another task, cancel the previous task's + // window transition + EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task)); EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent()); if (screenPinningRequested) { @@ -119,6 +122,9 @@ public class RecentsTransitionHelper { animStartedListener = new ActivityOptions.OnAnimationStartedListener() { @Override public void onAnimationStarted() { + // If we are launching into another task, cancel the previous task's + // window transition + EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task)); EventBus.getDefault().send(new ExitRecentsWindowFirstAnimationFrameEvent()); } }; @@ -146,10 +152,6 @@ public class RecentsTransitionHelper { animStartedListener); } } - - // If we are launching into another task, cancel the previous task's - // window transition - EventBus.getDefault().send(new CancelEnterRecentsWindowAnimationEvent(task)); } /** @@ -278,7 +280,8 @@ public class RecentsTransitionHelper { } else { layoutAlgorithm.getStackTransformScreenCoordinates(task, stackScroll, mTmpTransform, null); - specs.add(composeAnimationSpec(taskView, mTmpTransform, true /* addHeaderBitmap */)); + specs.add(composeAnimationSpec(stackView, taskView, mTmpTransform, + true /* addHeaderBitmap */)); } return specs; } @@ -299,7 +302,8 @@ public class RecentsTransitionHelper { } else { layoutAlgorithm.getStackTransformScreenCoordinates(t, stackScroll, mTmpTransform, null); - specs.add(composeAnimationSpec(tv, mTmpTransform, true /* addHeaderBitmap */)); + specs.add(composeAnimationSpec(stackView, tv, mTmpTransform, + true /* addHeaderBitmap */)); } } } @@ -318,8 +322,8 @@ public class RecentsTransitionHelper { /** * Composes a single animation spec for the given {@link TaskView} */ - private static AppTransitionAnimationSpec composeAnimationSpec(TaskView taskView, - TaskViewTransform transform, boolean addHeaderBitmap) { + private static AppTransitionAnimationSpec composeAnimationSpec(TaskStackView stackView, + TaskView taskView, TaskViewTransform transform, boolean addHeaderBitmap) { Bitmap b = null; if (addHeaderBitmap) { float scale = transform.scale; @@ -341,6 +345,10 @@ public class RecentsTransitionHelper { Rect taskRect = new Rect(); transform.rect.round(taskRect); + if (stackView.getStack().getStackFrontMostTask(false /* includeFreeformTasks */) != + taskView.getTask()) { + taskRect.bottom = 2 * Recents.getSystemServices().getDisplayRect().height(); + } return new AppTransitionAnimationSpec(taskView.getTask().key.id, b, taskRect); } } diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java index a5ed32a081d40..7f4467b37a446 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskStackLayoutAlgorithm.java @@ -222,9 +222,11 @@ public class TaskStackLayoutAlgorithm { private Range mUnfocusedRange; private Range mFocusedRange; - // The initial offset from the top of the stack + // The initial offset from the top and bottom of the stack @ViewDebug.ExportedProperty(category="recents") private int mInitialTopPeekHeight; + @ViewDebug.ExportedProperty(category="recents") + private int mInitialBottomPeekHeight; // The offset from the top when scrolled to the top of the stack @ViewDebug.ExportedProperty(category="recents") @@ -322,6 +324,8 @@ public class TaskStackLayoutAlgorithm { res.getFloat(R.integer.recents_layout_unfocused_range_max)); mFocusState = getInitialFocusState(); mInitialTopPeekHeight = res.getDimensionPixelSize(R.dimen.recents_initial_top_peek_size); + mInitialBottomPeekHeight = + res.getDimensionPixelSize(R.dimen.recents_initial_bottom_peek_size); mFocusedTopPeekHeight = res.getDimensionPixelSize(R.dimen.recents_layout_focused_top_peek_size); mFocusedBottomTaskPeekHeight = @@ -508,10 +512,10 @@ public class TaskStackLayoutAlgorithm { float initialPeekOffsetNormX = mUnfocusedCurveInterpolator.getX(initialPeekOffsetPct); float initialFocusedOffset = mStackRect.height() - mInitialTopPeekHeight - (mHeaderBarHeight * 1f) + 1; - float initialFocusedOffsetPct = (float) initialFocusedOffset / mStackRect.height(); + float initialFocusedOffsetPct = initialFocusedOffset / mStackRect.height(); float initialFocusedNormX = mUnfocusedCurveInterpolator.getX(initialFocusedOffsetPct); - int initialBottomOffset = mStackBottomOffset + mHeaderBarHeight; - float initialBottomOffsetPct = (float) initialBottomOffset / mStackRect.height(); + float initialBottomOffset = mStackBottomOffset + mInitialBottomPeekHeight; + float initialBottomOffsetPct = initialBottomOffset / mStackRect.height(); float initialBottomNormX = mUnfocusedCurveInterpolator.getX(initialBottomOffsetPct); /* // If we want to offset the top card slightly