diff options
Diffstat (limited to 'com/android/systemui/recents/views/RecentsView.java')
-rw-r--r-- | com/android/systemui/recents/views/RecentsView.java | 141 |
1 files changed, 94 insertions, 47 deletions
diff --git a/com/android/systemui/recents/views/RecentsView.java b/com/android/systemui/recents/views/RecentsView.java index 5f12a04b..c7edb9ae 100644 --- a/com/android/systemui/recents/views/RecentsView.java +++ b/com/android/systemui/recents/views/RecentsView.java @@ -16,6 +16,10 @@ package com.android.systemui.recents.views; +import static android.app.ActivityManager.StackId.INVALID_STACK_ID; + +import android.animation.Animator; +import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.ActivityOptions.OnAnimationStartedListener; @@ -53,6 +57,7 @@ import com.android.systemui.recents.Recents; import com.android.systemui.recents.RecentsActivity; import com.android.systemui.recents.RecentsActivityLaunchState; import com.android.systemui.recents.RecentsConfiguration; +import com.android.systemui.recents.RecentsDebugFlags; import com.android.systemui.recents.events.EventBus; import com.android.systemui.recents.events.activity.DismissRecentsToHomeAnimationStarted; import com.android.systemui.recents.events.activity.DockedFirstAnimationFrameEvent; @@ -73,9 +78,9 @@ import com.android.systemui.recents.events.ui.dragndrop.DragEndEvent; import com.android.systemui.recents.events.ui.dragndrop.DragStartEvent; import com.android.systemui.recents.misc.ReferenceCountedTrigger; import com.android.systemui.recents.misc.SystemServicesProxy; -import com.android.systemui.shared.recents.utilities.Utilities; -import com.android.systemui.shared.recents.model.Task; -import com.android.systemui.shared.recents.model.TaskStack; +import com.android.systemui.recents.misc.Utilities; +import com.android.systemui.recents.model.Task; +import com.android.systemui.recents.model.TaskStack; import com.android.systemui.recents.views.RecentsTransitionHelper.AnimationSpecComposer; import com.android.systemui.recents.views.RecentsTransitionHelper.AppTransitionAnimationSpecsFuture; import com.android.systemui.stackdivider.WindowManagerProxy; @@ -109,6 +114,7 @@ public class RecentsView extends FrameLayout { private final int mStackButtonShadowColor; private boolean mAwaitingFirstLayout = true; + private boolean mLastTaskLaunchedWasFreeform; @ViewDebug.ExportedProperty(category="recents") Rect mSystemInsets = new Rect(); @@ -159,20 +165,22 @@ public class RecentsView extends FrameLayout { mEmptyView = (TextView) inflater.inflate(R.layout.recents_empty, this, false); addView(mEmptyView); - if (mStackActionButton != null) { - removeView(mStackActionButton); - } - mStackActionButton = (TextView) inflater.inflate(Recents.getConfiguration() - .isLowRamDevice - ? R.layout.recents_low_ram_stack_action_button - : R.layout.recents_stack_action_button, - this, false); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + if (mStackActionButton != null) { + removeView(mStackActionButton); + } + mStackActionButton = (TextView) inflater.inflate(Recents.getConfiguration() + .isLowRamDevice + ? R.layout.recents_low_ram_stack_action_button + : R.layout.recents_stack_action_button, + this, false); - mStackButtonShadowRadius = mStackActionButton.getShadowRadius(); - mStackButtonShadowDistance = new PointF(mStackActionButton.getShadowDx(), - mStackActionButton.getShadowDy()); - mStackButtonShadowColor = mStackActionButton.getShadowColor(); - addView(mStackActionButton); + mStackButtonShadowRadius = mStackActionButton.getShadowRadius(); + mStackButtonShadowDistance = new PointF(mStackActionButton.getShadowDx(), + mStackActionButton.getShadowDy()); + mStackButtonShadowColor = mStackActionButton.getShadowColor(); + addView(mStackActionButton); + } reevaluateStyles(); } @@ -224,6 +232,7 @@ public class RecentsView extends FrameLayout { // Reset the state mAwaitingFirstLayout = !isResumingFromVisible; + mLastTaskLaunchedWasFreeform = false; // Update the stack mTaskStackView.onReload(isResumingFromVisible); @@ -310,6 +319,13 @@ public class RecentsView extends FrameLayout { } } + /** + * Returns whether the last task launched was in the freeform stack or not. + */ + public boolean isLastTaskLaunchedFreeform() { + return mLastTaskLaunchedWasFreeform; + } + /** Launches the focused task from the first stack if possible */ public boolean launchFocusedTask(int logEvent) { if (mTaskStackView != null) { @@ -355,7 +371,9 @@ public class RecentsView extends FrameLayout { mEmptyView.setText(msgResId); mEmptyView.setVisibility(View.VISIBLE); mEmptyView.bringToFront(); - mStackActionButton.bringToFront(); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + mStackActionButton.bringToFront(); + } } /** @@ -365,7 +383,9 @@ public class RecentsView extends FrameLayout { mEmptyView.setVisibility(View.INVISIBLE); mTaskStackView.setVisibility(View.VISIBLE); mTaskStackView.bringToFront(); - mStackActionButton.bringToFront(); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + mStackActionButton.bringToFront(); + } } /** @@ -413,11 +433,13 @@ public class RecentsView extends FrameLayout { MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST)); } - // Measure the stack action button within the constraints of the space above the stack - Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect(); - measureChild(mStackActionButton, - MeasureSpec.makeMeasureSpec(buttonBounds.width(), MeasureSpec.AT_MOST), - MeasureSpec.makeMeasureSpec(buttonBounds.height(), MeasureSpec.AT_MOST)); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + // Measure the stack action button within the constraints of the space above the stack + Rect buttonBounds = mTaskStackView.mLayoutAlgorithm.getStackActionButtonRect(); + measureChild(mStackActionButton, + MeasureSpec.makeMeasureSpec(buttonBounds.width(), MeasureSpec.AT_MOST), + MeasureSpec.makeMeasureSpec(buttonBounds.height(), MeasureSpec.AT_MOST)); + } setMeasuredDimension(width, height); } @@ -451,11 +473,13 @@ public class RecentsView extends FrameLayout { mBackgroundScrim.setBounds(left, top, right, bottom); mMultiWindowBackgroundScrim.setBounds(0, 0, mTmpDisplaySize.x, mTmpDisplaySize.y); - // Layout the stack action button such that its drawable is start-aligned with the - // stack, vertically centered in the available space above the stack - Rect buttonBounds = getStackActionButtonBoundsFromStackLayout(); - mStackActionButton.layout(buttonBounds.left, buttonBounds.top, buttonBounds.right, - buttonBounds.bottom); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + // Layout the stack action button such that its drawable is start-aligned with the + // stack, vertically centered in the available space above the stack + Rect buttonBounds = getStackActionButtonBoundsFromStackLayout(); + mStackActionButton.layout(buttonBounds.left, buttonBounds.top, buttonBounds.right, + buttonBounds.bottom); + } if (mAwaitingFirstLayout) { mAwaitingFirstLayout = false; @@ -497,7 +521,7 @@ public class RecentsView extends FrameLayout { public void onDrawForeground(Canvas canvas) { super.onDrawForeground(canvas); - ArrayList<DockState> visDockStates = mTouchHandler.getVisibleDockStates(); + ArrayList<TaskStack.DockState> visDockStates = mTouchHandler.getVisibleDockStates(); for (int i = visDockStates.size() - 1; i >= 0; i--) { visDockStates.get(i).viewState.draw(canvas); } @@ -505,7 +529,7 @@ public class RecentsView extends FrameLayout { @Override protected boolean verifyDrawable(Drawable who) { - ArrayList<DockState> visDockStates = mTouchHandler.getVisibleDockStates(); + ArrayList<TaskStack.DockState> visDockStates = mTouchHandler.getVisibleDockStates(); for (int i = visDockStates.size() - 1; i >= 0; i--) { Drawable d = visDockStates.get(i).viewState.dockAreaOverlay; if (d == who) { @@ -518,6 +542,7 @@ public class RecentsView extends FrameLayout { /**** EventBus Events ****/ public final void onBusEvent(LaunchTaskEvent event) { + mLastTaskLaunchedWasFreeform = event.task.isFreeformTask(); mTransitionHelper.launchTaskFromRecents(getStack(), event.task, mTaskStackView, event.taskView, event.screenPinningRequested, event.targetWindowingMode, event.targetActivityType); @@ -528,8 +553,10 @@ public class RecentsView extends FrameLayout { public final void onBusEvent(DismissRecentsToHomeAnimationStarted event) { int taskViewExitToHomeDuration = TaskStackAnimationHelper.EXIT_TO_HOME_TRANSLATION_DURATION; - // Hide the stack action button - EventBus.getDefault().send(new HideStackActionButtonEvent()); + if (RecentsDebugFlags.Static.EnableStackActionButton) { + // Hide the stack action button + EventBus.getDefault().send(new HideStackActionButtonEvent()); + } animateBackgroundScrim(0f, taskViewExitToHomeDuration); if (Recents.getConfiguration().isLowRamDevice) { @@ -539,8 +566,8 @@ public class RecentsView extends FrameLayout { public final void onBusEvent(DragStartEvent event) { updateVisibleDockRegions(Recents.getConfiguration().getDockStatesForCurrentOrientation(), - true /* isDefaultDockState */, DockState.NONE.viewState.dockAreaAlpha, - DockState.NONE.viewState.hintTextAlpha, + true /* isDefaultDockState */, TaskStack.DockState.NONE.viewState.dockAreaAlpha, + TaskStack.DockState.NONE.viewState.hintTextAlpha, true /* animateAlpha */, false /* animateBounds */); // Temporarily hide the stack action button without changing visibility @@ -554,15 +581,15 @@ public class RecentsView extends FrameLayout { } public final void onBusEvent(DragDropTargetChangedEvent event) { - if (event.dropTarget == null || !(event.dropTarget instanceof DockState)) { + if (event.dropTarget == null || !(event.dropTarget instanceof TaskStack.DockState)) { updateVisibleDockRegions( Recents.getConfiguration().getDockStatesForCurrentOrientation(), - true /* isDefaultDockState */, DockState.NONE.viewState.dockAreaAlpha, - DockState.NONE.viewState.hintTextAlpha, + true /* isDefaultDockState */, TaskStack.DockState.NONE.viewState.dockAreaAlpha, + TaskStack.DockState.NONE.viewState.hintTextAlpha, true /* animateAlpha */, true /* animateBounds */); } else { - final DockState dockState = (DockState) event.dropTarget; - updateVisibleDockRegions(new DockState[] {dockState}, + final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; + updateVisibleDockRegions(new TaskStack.DockState[] {dockState}, false /* isDefaultDockState */, -1, -1, true /* animateAlpha */, true /* animateBounds */); } @@ -581,8 +608,8 @@ public class RecentsView extends FrameLayout { public final void onBusEvent(final DragEndEvent event) { // Handle the case where we drop onto a dock region - if (event.dropTarget instanceof DockState) { - final DockState dockState = (DockState) event.dropTarget; + if (event.dropTarget instanceof TaskStack.DockState) { + final TaskStack.DockState dockState = (TaskStack.DockState) event.dropTarget; // Hide the dock region updateVisibleDockRegions(null, false /* isDefaultDockState */, -1, -1, @@ -704,10 +731,18 @@ public class RecentsView extends FrameLayout { } public final void onBusEvent(ShowStackActionButtonEvent event) { + if (!RecentsDebugFlags.Static.EnableStackActionButton) { + return; + } + showStackActionButton(SHOW_STACK_ACTION_BUTTON_DURATION, event.translate); } public final void onBusEvent(HideStackActionButtonEvent event) { + if (!RecentsDebugFlags.Static.EnableStackActionButton) { + return; + } + hideStackActionButton(HIDE_STACK_ACTION_BUTTON_DURATION, true /* translate */); } @@ -723,6 +758,10 @@ public class RecentsView extends FrameLayout { * Shows the stack action button. */ private void showStackActionButton(final int duration, final boolean translate) { + if (!RecentsDebugFlags.Static.EnableStackActionButton) { + return; + } + final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger(); if (mStackActionButton.getVisibility() == View.INVISIBLE) { mStackActionButton.setVisibility(View.VISIBLE); @@ -755,6 +794,10 @@ public class RecentsView extends FrameLayout { * Hides the stack action button. */ private void hideStackActionButton(int duration, boolean translate) { + if (!RecentsDebugFlags.Static.EnableStackActionButton) { + return; + } + final ReferenceCountedTrigger postAnimationTrigger = new ReferenceCountedTrigger(); hideStackActionButton(duration, translate, postAnimationTrigger); postAnimationTrigger.flushLastDecrementRunnables(); @@ -765,6 +808,10 @@ public class RecentsView extends FrameLayout { */ private void hideStackActionButton(int duration, boolean translate, final ReferenceCountedTrigger postAnimationTrigger) { + if (!RecentsDebugFlags.Static.EnableStackActionButton) { + return; + } + if (mStackActionButton.getVisibility() == View.VISIBLE) { if (translate) { mStackActionButton.animate().translationY(mStackActionButton.getMeasuredHeight() @@ -811,15 +858,15 @@ public class RecentsView extends FrameLayout { /** * Updates the dock region to match the specified dock state. */ - private void updateVisibleDockRegions(DockState[] newDockStates, + private void updateVisibleDockRegions(TaskStack.DockState[] newDockStates, boolean isDefaultDockState, int overrideAreaAlpha, int overrideHintAlpha, boolean animateAlpha, boolean animateBounds) { - ArraySet<DockState> newDockStatesSet = Utilities.arrayToSet(newDockStates, - new ArraySet<DockState>()); - ArrayList<DockState> visDockStates = mTouchHandler.getVisibleDockStates(); + ArraySet<TaskStack.DockState> newDockStatesSet = Utilities.arrayToSet(newDockStates, + new ArraySet<TaskStack.DockState>()); + ArrayList<TaskStack.DockState> visDockStates = mTouchHandler.getVisibleDockStates(); for (int i = visDockStates.size() - 1; i >= 0; i--) { - DockState dockState = visDockStates.get(i); - DockState.ViewState viewState = dockState.viewState; + TaskStack.DockState dockState = visDockStates.get(i); + TaskStack.DockState.ViewState viewState = dockState.viewState; if (newDockStates == null || !newDockStatesSet.contains(dockState)) { // This is no longer visible, so hide it viewState.startAnimation(null, 0, 0, TaskStackView.SLOW_SYNC_STACK_DURATION, |