2020-04-24 00:38:11 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2020 The Android Open Source Project
|
|
|
|
|
*
|
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
|
*
|
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
|
* limitations under the License.
|
|
|
|
|
*/
|
|
|
|
|
package com.android.launcher3.uioverrides.states;
|
|
|
|
|
|
|
|
|
|
import static android.view.View.VISIBLE;
|
|
|
|
|
|
|
|
|
|
import static com.android.launcher3.LauncherState.HINT_STATE;
|
|
|
|
|
import static com.android.launcher3.LauncherState.NORMAL;
|
|
|
|
|
import static com.android.launcher3.LauncherState.OVERVIEW;
|
2020-06-18 13:03:01 -07:00
|
|
|
import static com.android.launcher3.WorkspaceStateTransitionAnimation.getSpringScaleAnimator;
|
2020-04-24 00:38:11 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.ACCEL;
|
2020-07-17 13:06:57 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.ACCEL_DEACCEL;
|
2020-04-24 00:38:11 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.DEACCEL;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.DEACCEL_1_7;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.DEACCEL_3;
|
2020-05-29 11:10:10 -05:00
|
|
|
import static com.android.launcher3.anim.Interpolators.FINAL_FRAME;
|
2020-04-24 00:38:11 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.INSTANT;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.OVERSHOOT_1_2;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.clampToProgress;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_ALL_APPS_FADE;
|
2020-06-01 14:20:30 -05:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_DEPTH;
|
2020-04-24 00:38:11 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_FADE;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_SCALE;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_WORKSPACE_TRANSLATE;
|
|
|
|
|
import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON;
|
Fix adjacent task offset distance
Instead of calculating an overall distance for tasks to translate
based on RecentsView width, calculate the distance for the tasks
to the left and right of the midpoint based on how far the first
adjacent tasks in those directions are from being offscreen.
Changes made to make "distance to offscreen" calculations possible:
- Update TaskView curve scale to reach final scale as soon as it is
completely offscreen. Before, it would reach its final scale just
shy of that point (calculations were off).
- As we update RecentsView scale, calculate how much the new scale
will push out tasks that are just offscreen.
- With both above, we can calculate the scale and position of a
TaskView such that it is just offscreen, and interpolate
between its current position and that position.
Tests:
- Task comes in immediately when quick switching from home, and
doesn't shift as you swipe directly upwards.
- When swiping far up from an app, tasks come in from all the way
offscreen, and cover distance appropriately (e.g. if you're
scrolled a bit to the right when you pause, the left adjacent
app will move faster to cover the farther distance).
- Task modalness: entering Select mode now animates adjacent tasks
at the same rate as the scaling up, because they move only the
distance needed to get offscreen (before they moved way too far
and thus seemed to be much faster than the rest of the animation).
Bug: 149934536
Change-Id: Ie3fffe0e5c304cb16e7637f058f5ce72cee40aeb
Merged-In: Ie3fffe0e5c304cb16e7637f058f5ce72cee40aeb
2020-07-07 19:25:25 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY;
|
2020-04-24 00:38:11 -07:00
|
|
|
|
|
|
|
|
import android.animation.ValueAnimator;
|
|
|
|
|
import android.view.View;
|
|
|
|
|
|
|
|
|
|
import com.android.launcher3.CellLayout;
|
|
|
|
|
import com.android.launcher3.Hotseat;
|
|
|
|
|
import com.android.launcher3.LauncherState;
|
|
|
|
|
import com.android.launcher3.Workspace;
|
|
|
|
|
import com.android.launcher3.allapps.AllAppsContainerView;
|
|
|
|
|
import com.android.launcher3.states.StateAnimationConfig;
|
|
|
|
|
import com.android.launcher3.uioverrides.QuickstepLauncher;
|
|
|
|
|
import com.android.quickstep.SysUINavigationMode;
|
2020-05-13 09:28:25 -07:00
|
|
|
import com.android.quickstep.util.RecentsAtomicAnimationFactory;
|
2020-04-24 00:38:11 -07:00
|
|
|
import com.android.quickstep.views.RecentsView;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Animation factory for quickstep specific transitions
|
|
|
|
|
*/
|
2020-05-13 09:28:25 -07:00
|
|
|
public class QuickstepAtomicAnimationFactory extends
|
2021-03-02 12:28:25 -08:00
|
|
|
RecentsAtomicAnimationFactory<QuickstepLauncher, LauncherState> {
|
2020-04-24 00:38:11 -07:00
|
|
|
|
|
|
|
|
// Scale recents takes before animating in
|
|
|
|
|
private static final float RECENTS_PREPARE_SCALE = 1.33f;
|
|
|
|
|
|
2020-06-18 13:03:01 -07:00
|
|
|
// Due to use of physics, duration may differ between devices so we need to calculate and
|
|
|
|
|
// cache the value.
|
|
|
|
|
private int mHintToNormalDuration = -1;
|
|
|
|
|
|
2020-05-13 09:28:25 -07:00
|
|
|
public QuickstepAtomicAnimationFactory(QuickstepLauncher activity) {
|
2020-12-09 16:23:24 -08:00
|
|
|
super(activity);
|
2020-04-24 00:38:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void prepareForAtomicAnimation(LauncherState fromState, LauncherState toState,
|
|
|
|
|
StateAnimationConfig config) {
|
|
|
|
|
if (toState == NORMAL && fromState == OVERVIEW) {
|
|
|
|
|
config.setInterpolator(ANIM_WORKSPACE_SCALE, DEACCEL);
|
|
|
|
|
config.setInterpolator(ANIM_WORKSPACE_FADE, ACCEL);
|
2020-06-08 18:43:35 -05:00
|
|
|
config.setInterpolator(ANIM_ALL_APPS_FADE, ACCEL);
|
2020-04-24 00:38:11 -07:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_SCALE, clampToProgress(ACCEL, 0, 0.9f));
|
2020-07-17 13:06:57 -07:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, ACCEL_DEACCEL);
|
|
|
|
|
|
|
|
|
|
if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
|
|
|
|
|
config.setInterpolator(ANIM_OVERVIEW_FADE, FINAL_FRAME);
|
|
|
|
|
} else {
|
|
|
|
|
config.setInterpolator(ANIM_OVERVIEW_FADE, DEACCEL_1_7);
|
|
|
|
|
}
|
2020-04-24 00:38:11 -07:00
|
|
|
|
2020-07-17 13:06:57 -07:00
|
|
|
Workspace workspace = mActivity.getWorkspace();
|
2020-04-24 00:38:11 -07:00
|
|
|
// Start from a higher workspace scale, but only if we're invisible so we don't jump.
|
|
|
|
|
boolean isWorkspaceVisible = workspace.getVisibility() == VISIBLE;
|
|
|
|
|
if (isWorkspaceVisible) {
|
|
|
|
|
CellLayout currentChild = (CellLayout) workspace.getChildAt(
|
|
|
|
|
workspace.getCurrentPage());
|
|
|
|
|
isWorkspaceVisible = currentChild.getVisibility() == VISIBLE
|
|
|
|
|
&& currentChild.getShortcutsAndWidgets().getAlpha() > 0;
|
|
|
|
|
}
|
|
|
|
|
if (!isWorkspaceVisible) {
|
|
|
|
|
workspace.setScaleX(0.92f);
|
|
|
|
|
workspace.setScaleY(0.92f);
|
|
|
|
|
}
|
2020-05-13 09:28:25 -07:00
|
|
|
Hotseat hotseat = mActivity.getHotseat();
|
2020-04-24 00:38:11 -07:00
|
|
|
boolean isHotseatVisible = hotseat.getVisibility() == VISIBLE && hotseat.getAlpha() > 0;
|
|
|
|
|
if (!isHotseatVisible) {
|
|
|
|
|
hotseat.setScaleX(0.92f);
|
|
|
|
|
hotseat.setScaleY(0.92f);
|
2020-08-13 19:33:26 -07:00
|
|
|
AllAppsContainerView qsbContainer = mActivity.getAppsView();
|
|
|
|
|
View qsb = qsbContainer.getSearchView();
|
|
|
|
|
boolean qsbVisible = qsb.getVisibility() == VISIBLE && qsb.getAlpha() > 0;
|
|
|
|
|
if (!qsbVisible) {
|
|
|
|
|
qsbContainer.setScaleX(0.92f);
|
|
|
|
|
qsbContainer.setScaleY(0.92f);
|
2020-04-24 00:38:11 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else if ((fromState == NORMAL || fromState == HINT_STATE) && toState == OVERVIEW) {
|
2020-05-13 09:28:25 -07:00
|
|
|
if (SysUINavigationMode.getMode(mActivity) == NO_BUTTON) {
|
2020-04-24 00:38:11 -07:00
|
|
|
config.setInterpolator(ANIM_WORKSPACE_SCALE,
|
|
|
|
|
fromState == NORMAL ? ACCEL : OVERSHOOT_1_2);
|
|
|
|
|
config.setInterpolator(ANIM_WORKSPACE_TRANSLATE, ACCEL);
|
2020-07-17 13:06:57 -07:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_FADE, INSTANT);
|
2020-04-24 00:38:11 -07:00
|
|
|
} else {
|
|
|
|
|
config.setInterpolator(ANIM_WORKSPACE_SCALE, OVERSHOOT_1_2);
|
2020-07-17 13:06:57 -07:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_FADE, OVERSHOOT_1_2);
|
2020-04-24 00:38:11 -07:00
|
|
|
|
|
|
|
|
// Scale up the recents, if it is not coming from the side
|
2020-05-13 09:28:25 -07:00
|
|
|
RecentsView overview = mActivity.getOverviewPanel();
|
2020-04-24 00:38:11 -07:00
|
|
|
if (overview.getVisibility() != VISIBLE || overview.getContentAlpha() == 0) {
|
Fix adjacent task offset distance
Instead of calculating an overall distance for tasks to translate
based on RecentsView width, calculate the distance for the tasks
to the left and right of the midpoint based on how far the first
adjacent tasks in those directions are from being offscreen.
Changes made to make "distance to offscreen" calculations possible:
- Update TaskView curve scale to reach final scale as soon as it is
completely offscreen. Before, it would reach its final scale just
shy of that point (calculations were off).
- As we update RecentsView scale, calculate how much the new scale
will push out tasks that are just offscreen.
- With both above, we can calculate the scale and position of a
TaskView such that it is just offscreen, and interpolate
between its current position and that position.
Tests:
- Task comes in immediately when quick switching from home, and
doesn't shift as you swipe directly upwards.
- When swiping far up from an app, tasks come in from all the way
offscreen, and cover distance appropriately (e.g. if you're
scrolled a bit to the right when you pause, the left adjacent
app will move faster to cover the farther distance).
- Task modalness: entering Select mode now animates adjacent tasks
at the same rate as the scaling up, because they move only the
distance needed to get offscreen (before they moved way too far
and thus seemed to be much faster than the rest of the animation).
Bug: 149934536
Change-Id: Ie3fffe0e5c304cb16e7637f058f5ce72cee40aeb
Merged-In: Ie3fffe0e5c304cb16e7637f058f5ce72cee40aeb
2020-07-07 19:25:25 -07:00
|
|
|
RECENTS_SCALE_PROPERTY.set(overview, RECENTS_PREPARE_SCALE);
|
2020-04-24 00:38:11 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
config.setInterpolator(ANIM_WORKSPACE_FADE, OVERSHOOT_1_2);
|
2020-06-08 18:43:35 -05:00
|
|
|
config.setInterpolator(ANIM_ALL_APPS_FADE, OVERSHOOT_1_2);
|
2020-04-24 00:38:11 -07:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_SCALE, OVERSHOOT_1_2);
|
2020-06-01 14:20:30 -05:00
|
|
|
config.setInterpolator(ANIM_DEPTH, OVERSHOOT_1_2);
|
2020-12-09 16:23:24 -08:00
|
|
|
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_X, OVERSHOOT_1_2);
|
|
|
|
|
config.setInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, OVERSHOOT_1_2);
|
2020-06-18 13:03:01 -07:00
|
|
|
} else if (fromState == HINT_STATE && toState == NORMAL) {
|
|
|
|
|
config.setInterpolator(ANIM_DEPTH, DEACCEL_3);
|
|
|
|
|
if (mHintToNormalDuration == -1) {
|
|
|
|
|
ValueAnimator va = getSpringScaleAnimator(mActivity, mActivity.getWorkspace(),
|
|
|
|
|
toState.getWorkspaceScaleAndTranslation(mActivity).scale);
|
|
|
|
|
mHintToNormalDuration = (int) va.getDuration();
|
|
|
|
|
}
|
|
|
|
|
config.duration = Math.max(config.duration, mHintToNormalDuration);
|
2020-04-24 00:38:11 -07:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|