From 5406817028c7d4175d9e190e67e3bbd87ca4f5de Mon Sep 17 00:00:00 2001 From: Tony Date: Sun, 12 May 2019 13:24:51 -0500 Subject: [PATCH] Add getOverviewFullscreenProgress() to LauncherState - BackgroundAppState sets this to 1, all other states set it to 0 - QuickSwitchState extends BackgroundAppState, and calculations for fullscreen scale/translation are moved to BackgroundAppState - Move fullscreen progress logic out of WindowTransformSwipeHandler and into the launcher activity controller, which uses the new RecentsView.FULLSCREEN_PROGRESS property to animate it Bug: 130020567 Change-Id: If6265fcce3749050be354742e7d2c418d11ee9bb --- .../RecentsViewStateController.java | 7 +++- .../states/BackgroundAppState.java | 38 +++++++++---------- .../uioverrides/states/QuickSwitchState.java | 25 +----------- .../LauncherActivityControllerHelper.java | 15 +++++--- .../WindowTransformSwipeHandler.java | 10 +---- .../android/quickstep/views/RecentsView.java | 29 ++++++++++++++ src/com/android/launcher3/LauncherState.java | 5 ++- 7 files changed, 68 insertions(+), 61 deletions(-) diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java index c3a7698874..1d36d1aae8 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/RecentsViewStateController.java @@ -18,6 +18,7 @@ package com.android.launcher3.uioverrides; import static com.android.launcher3.LauncherState.RECENTS_CLEAR_ALL_BUTTON; import static com.android.launcher3.anim.Interpolators.LINEAR; import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA; +import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS; import android.animation.ValueAnimator; import android.annotation.TargetApi; @@ -64,6 +65,7 @@ public final class RecentsViewStateController extends } } setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, state.getVisibleElements(mLauncher)); + mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress()); } @Override @@ -95,7 +97,10 @@ public final class RecentsViewStateController extends builder.addOnFinishRunnable(() -> mRecentsView.setHintVisibility(1f)); } - setAlphas(config.getPropertySetter(builder), toState.getVisibleElements(mLauncher)); + PropertySetter propertySetter = config.getPropertySetter(builder); + setAlphas(propertySetter, toState.getVisibleElements(mLauncher)); + float fullscreenProgress = toState.getOverviewFullscreenProgress(); + propertySetter.setFloat(mRecentsView, FULLSCREEN_PROGRESS, fullscreenProgress, LINEAR); } private void setAlphas(PropertySetter propertySetter, int visibleElements) { diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java index 140e45c514..5408af3599 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java @@ -17,14 +17,12 @@ package com.android.launcher3.uioverrides.states; import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; -import android.os.RemoteException; - import com.android.launcher3.Launcher; import com.android.launcher3.allapps.AllAppsTransitionController; -import com.android.quickstep.RecentsModel; +import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; -import com.android.systemui.shared.recents.ISystemUiProxy; +import com.android.quickstep.views.TaskView; /** * State indicating that the Launcher is behind an app @@ -35,7 +33,11 @@ public class BackgroundAppState extends OverviewState { FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY; public BackgroundAppState(int id) { - super(id, OVERVIEW_TRANSITION_MS, STATE_FLAGS); + this(id, LauncherLogProto.ContainerType.TASKSWITCHER); + } + + protected BackgroundAppState(int id, int logContainer) { + super(id, logContainer, OVERVIEW_TRANSITION_MS, STATE_FLAGS); } @Override @@ -55,23 +57,17 @@ public class BackgroundAppState extends OverviewState { public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { // Initialize the recents view scale to what it would be when starting swipe up RecentsView recentsView = launcher.getOverviewPanel(); - recentsView.getTaskSize(sTempRect); - int appWidth = launcher.getDragLayer().getWidth(); - if (recentsView.shouldUseMultiWindowTaskSizeStrategy()) { - ISystemUiProxy sysUiProxy = RecentsModel.INSTANCE.get(launcher).getSystemUiProxy(); - if (sysUiProxy != null) { - try { - // Try to use the actual non-minimized app width (launcher will be resized to - // the non-minimized bounds, which differs from the app width in landscape - // multi-window mode - appWidth = sysUiProxy.getNonMinimizedSplitScreenSecondaryBounds().width(); - } catch (RemoteException e) { - // Ignore, fall back to just using the drag layer width - } - } + if (recentsView.getTaskViewCount() == 0) { + return super.getOverviewScaleAndTranslation(launcher); } - float scale = (float) appWidth / sTempRect.width(); - return new ScaleAndTranslation(scale, 0f, 0f); + TaskView dummyTask = recentsView.getTaskViewAt(recentsView.getCurrentPage()); + return recentsView.getTempClipAnimationHelper() + .getOverviewFullscreenScaleAndTranslation(dummyTask); + } + + @Override + public float getOverviewFullscreenProgress() { + return 1; } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java index c26a1d0578..ed511f5f2f 100644 --- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java +++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/states/QuickSwitchState.java @@ -15,11 +15,8 @@ */ package com.android.launcher3.uioverrides.states; -import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS; - import com.android.launcher3.Launcher; import com.android.launcher3.userevent.nano.LauncherLogProto; -import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -28,23 +25,10 @@ import com.android.quickstep.views.TaskView; * quick switching from launcher; quick switching from an app uses WindowTransformSwipeHelper. * @see com.android.quickstep.WindowTransformSwipeHandler.GestureEndTarget#NEW_TASK */ -public class QuickSwitchState extends OverviewState { - private static final int STATE_FLAGS = - FLAG_DISABLE_RESTORE | FLAG_OVERVIEW_UI | FLAG_DISABLE_ACCESSIBILITY; +public class QuickSwitchState extends BackgroundAppState { public QuickSwitchState(int id) { - super(id, LauncherLogProto.ContainerType.APP, OVERVIEW_TRANSITION_MS, STATE_FLAGS); - } - - @Override - public ScaleAndTranslation getOverviewScaleAndTranslation(Launcher launcher) { - RecentsView recentsView = launcher.getOverviewPanel(); - if (recentsView.getTaskViewCount() == 0) { - return super.getOverviewScaleAndTranslation(launcher); - } - TaskView dummyTask = recentsView.getTaskViewAt(0); - ClipAnimationHelper clipAnimationHelper = new ClipAnimationHelper(launcher); - return clipAnimationHelper.getOverviewFullscreenScaleAndTranslation(dummyTask); + super(id, LauncherLogProto.ContainerType.APP); } @Override @@ -55,11 +39,6 @@ public class QuickSwitchState extends OverviewState { return new ScaleAndTranslation(1, 0, translationY); } - @Override - public float getVerticalProgress(Launcher launcher) { - return BACKGROUND_APP.getVerticalProgress(launcher); - } - @Override public int getVisibleElements(Launcher launcher) { return NONE; diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java index 434353d442..817d64f027 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/LauncherActivityControllerHelper.java @@ -55,7 +55,6 @@ import com.android.launcher3.compat.AccessibilityManagerCompat; import com.android.launcher3.userevent.nano.LauncherLogProto; import com.android.launcher3.views.FloatingIconView; import com.android.quickstep.SysUINavigationMode.Mode; -import com.android.quickstep.util.ClipAnimationHelper; import com.android.quickstep.util.LayoutUtils; import com.android.quickstep.views.RecentsView; import com.android.quickstep.views.TaskView; @@ -266,7 +265,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe endState.getVerticalProgress(activity)); anim.play(shiftAnim); } - playScaleDownAnim(anim, activity, endState); + playScaleDownAnim(anim, activity, fromState, endState); anim.setDuration(transitionLength * 2); AnimatorPlaybackController controller = @@ -292,7 +291,7 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe /** * Scale down recents from the center task being full screen to being in overview. */ - private void playScaleDownAnim(AnimatorSet anim, Launcher launcher, + private void playScaleDownAnim(AnimatorSet anim, Launcher launcher, LauncherState fromState, LauncherState endState) { RecentsView recentsView = launcher.getOverviewPanel(); TaskView v = recentsView.getTaskViewAt(recentsView.getCurrentPage()); @@ -300,19 +299,23 @@ public final class LauncherActivityControllerHelper implements ActivityControlHe return; } - ClipAnimationHelper clipHelper = new ClipAnimationHelper(launcher); LauncherState.ScaleAndTranslation fromScaleAndTranslation - = clipHelper.getOverviewFullscreenScaleAndTranslation(v); + = fromState.getOverviewScaleAndTranslation(launcher); LauncherState.ScaleAndTranslation endScaleAndTranslation = endState.getOverviewScaleAndTranslation(launcher); + float fromFullscreenProgress = fromState.getOverviewFullscreenProgress(); + float endFullscreenProgress = endState.getOverviewFullscreenProgress(); Animator scale = ObjectAnimator.ofFloat(recentsView, SCALE_PROPERTY, fromScaleAndTranslation.scale, endScaleAndTranslation.scale); Animator translateY = ObjectAnimator.ofFloat(recentsView, TRANSLATION_Y, fromScaleAndTranslation.translationY, endScaleAndTranslation.translationY); + Animator applyFullscreenProgress = ObjectAnimator.ofFloat(recentsView, + RecentsView.FULLSCREEN_PROGRESS, fromFullscreenProgress, endFullscreenProgress); scale.setInterpolator(LINEAR); translateY.setInterpolator(LINEAR); - anim.playTogether(scale, translateY); + applyFullscreenProgress.setInterpolator(LINEAR); + anim.playTogether(scale, translateY, applyFullscreenProgress); } @Override diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java index f2260d6694..0773904d0d 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/WindowTransformSwipeHandler.java @@ -504,6 +504,7 @@ public class WindowTransformSwipeHandler private void setupRecentsViewUi() { if (mContinuingLastGesture) { + updateSysUiFlags(mCurrentShift.value); return; } mRecentsView.onGestureAnimationStart(mRunningTaskId); @@ -677,15 +678,6 @@ public class WindowTransformSwipeHandler HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING); } } - // Update insets of the non-running tasks, as we might switch to them. - int runningTaskIndex = mRecentsView == null ? -1 : mRecentsView.getRunningTaskIndex(); - if (runningTaskIndex >= 0) { - for (int i = 0; i < mRecentsView.getTaskViewCount(); i++) { - if (i != runningTaskIndex || !mRecentsAnimationWrapper.hasTargets()) { - mRecentsView.getTaskViewAt(i).setFullscreenProgress(1 - mCurrentShift.value); - } - } - } if (mLauncherTransitionController == null || mLauncherTransitionController .getAnimationPlayer().isStarted()) { diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java index bded5ba4e5..c37965aa75 100644 --- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java @@ -142,6 +142,19 @@ public abstract class RecentsView extends PagedView impl } }; + public static final FloatProperty FULLSCREEN_PROGRESS = + new FloatProperty("fullscreenProgress") { + @Override + public void setValue(RecentsView recentsView, float v) { + recentsView.setFullscreenProgress(v); + } + + @Override + public Float get(RecentsView recentsView) { + return recentsView.mFullscreenProgress; + } + }; + protected RecentsAnimationWrapper mRecentsAnimationWrapper; protected ClipAnimationHelper mClipAnimationHelper; protected SyncRtSurfaceTransactionApplierCompat mSyncTransactionApplier; @@ -165,6 +178,7 @@ public abstract class RecentsView extends PagedView impl private final ClearAllButton mClearAllButton; private final Rect mClearAllButtonDeadZoneRect = new Rect(); private final Rect mTaskViewDeadZoneRect = new Rect(); + protected final ClipAnimationHelper mTempClipAnimationHelper; private final ScrollState mScrollState = new ScrollState(); // Keeps track of the previously known visible tasks for purposes of loading/unloading task data @@ -276,6 +290,8 @@ public abstract class RecentsView extends PagedView impl @ViewDebug.ExportedProperty(category = "launcher") private float mContentAlpha = 1; + @ViewDebug.ExportedProperty(category = "launcher") + private float mFullscreenProgress = 0; // Keeps track of task id whose visual state should not be reset private int mIgnoreResetTaskId = -1; @@ -310,6 +326,7 @@ public abstract class RecentsView extends PagedView impl mActivity = (T) BaseActivity.fromContext(context); mModel = RecentsModel.INSTANCE.get(context); mIdp = InvariantDeviceProfile.INSTANCE.get(context); + mTempClipAnimationHelper = new ClipAnimationHelper(context); mClearAllButton = (ClearAllButton) LayoutInflater.from(context) .inflate(R.layout.overview_clear_all_button, this, false); @@ -598,6 +615,14 @@ public abstract class RecentsView extends PagedView impl loadVisibleTaskData(); } + public void setFullscreenProgress(float fullscreenProgress) { + mFullscreenProgress = fullscreenProgress; + int taskCount = getTaskViewCount(); + for (int i = 0; i < taskCount; i++) { + getTaskViewAt(i).setFullscreenProgress(mFullscreenProgress); + } + } + private void updateTaskStackListenerState() { boolean handleTaskStackChanges = mOverviewStateEnabled && isAttachedToWindow() && getWindowVisibility() == VISIBLE; @@ -1714,4 +1739,8 @@ public abstract class RecentsView extends PagedView impl true /* hideOriginal */, iconLocation, false /* isOpening */, mFloatingIconView); return mFloatingIconView; } + + public ClipAnimationHelper getTempClipAnimationHelper() { + return mTempClipAnimationHelper; + } } diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java index 51079b0e6f..eff58a7013 100644 --- a/src/com/android/launcher3/LauncherState.java +++ b/src/com/android/launcher3/LauncherState.java @@ -18,7 +18,6 @@ package com.android.launcher3; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_AUTO; import static android.view.View.IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; import static android.view.accessibility.AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED; - import static com.android.launcher3.TestProtocol.ALL_APPS_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.BACKGROUND_APP_STATE_ORDINAL; import static com.android.launcher3.TestProtocol.NORMAL_STATE_ORDINAL; @@ -203,6 +202,10 @@ public class LauncherState { return UiFactory.getOverviewScaleAndTranslationForNormalState(launcher); } + public float getOverviewFullscreenProgress() { + return 0; + } + public void onStateEnabled(Launcher launcher) { dispatchWindowStateChanged(launcher); }