2019-01-15 13:19:06 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2019 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;
|
|
|
|
|
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
|
|
|
|
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
2020-03-13 13:01:33 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_FADE;
|
2020-04-27 16:26:55 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_MODAL;
|
2020-03-13 13:01:33 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_SCALE;
|
|
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_X;
|
2021-04-14 13:50:04 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_TRANSLATE_Y;
|
2020-03-13 13:01:33 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.SKIP_OVERVIEW;
|
2021-04-14 13:50:04 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.ADJACENT_PAGE_HORIZONTAL_OFFSET;
|
2021-02-03 18:00:30 +00:00
|
|
|
import static com.android.quickstep.views.RecentsView.RECENTS_GRID_PROGRESS;
|
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;
|
2021-04-29 18:37:48 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.TASK_PRIMARY_SPLIT_TRANSLATION;
|
|
|
|
|
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_SPLIT_TRANSLATION;
|
2020-07-01 17:25:28 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.TASK_SECONDARY_TRANSLATION;
|
2019-01-15 13:19:06 -08:00
|
|
|
|
|
|
|
|
import android.util.FloatProperty;
|
|
|
|
|
|
2019-07-24 17:32:08 -07:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2020-03-26 15:28:36 -07:00
|
|
|
import com.android.launcher3.BaseQuickstepLauncher;
|
2019-01-15 13:19:06 -08:00
|
|
|
import com.android.launcher3.LauncherState;
|
2020-03-13 13:01:33 -07:00
|
|
|
import com.android.launcher3.anim.PendingAnimation;
|
2020-05-08 13:37:58 -07:00
|
|
|
import com.android.launcher3.statemanager.StateManager.StateHandler;
|
2020-03-13 13:01:33 -07:00
|
|
|
import com.android.launcher3.states.StateAnimationConfig;
|
2021-02-22 14:49:27 -08:00
|
|
|
import com.android.launcher3.touch.PagedOrientationHandler;
|
2020-04-01 20:13:12 -07:00
|
|
|
import com.android.quickstep.views.RecentsView;
|
2019-03-15 16:55:53 -05:00
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
/**
|
|
|
|
|
* State handler for recents view. Manages UI changes and animations for recents view based off the
|
|
|
|
|
* current {@link LauncherState}.
|
|
|
|
|
*
|
|
|
|
|
* @param <T> the recents view
|
|
|
|
|
*/
|
2020-04-01 20:13:12 -07:00
|
|
|
public abstract class BaseRecentsViewStateController<T extends RecentsView>
|
2020-05-08 13:37:58 -07:00
|
|
|
implements StateHandler<LauncherState> {
|
2019-01-15 13:19:06 -08:00
|
|
|
protected final T mRecentsView;
|
2020-03-26 15:28:36 -07:00
|
|
|
protected final BaseQuickstepLauncher mLauncher;
|
2019-01-15 13:19:06 -08:00
|
|
|
|
2020-03-26 15:28:36 -07:00
|
|
|
public BaseRecentsViewStateController(@NonNull BaseQuickstepLauncher launcher) {
|
2019-01-15 13:19:06 -08:00
|
|
|
mLauncher = launcher;
|
|
|
|
|
mRecentsView = launcher.getOverviewPanel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setState(@NonNull LauncherState state) {
|
2020-04-01 20:13:12 -07:00
|
|
|
float[] scaleAndOffset = state.getOverviewScaleAndOffset(mLauncher);
|
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(mRecentsView, scaleAndOffset[0]);
|
2021-04-14 13:50:04 -07:00
|
|
|
ADJACENT_PAGE_HORIZONTAL_OFFSET.set(mRecentsView, scaleAndOffset[1]);
|
2020-07-01 17:25:28 -07:00
|
|
|
TASK_SECONDARY_TRANSLATION.set(mRecentsView, 0f);
|
2020-03-26 15:28:36 -07:00
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
getContentAlphaProperty().set(mRecentsView, state.overviewUi ? 1f : 0);
|
2020-04-27 16:26:55 -07:00
|
|
|
getTaskModalnessProperty().set(mRecentsView, state.getOverviewModalness());
|
2021-03-11 20:16:54 +00:00
|
|
|
RECENTS_GRID_PROGRESS.set(mRecentsView,
|
|
|
|
|
state.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f);
|
2019-01-15 13:19:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-03-13 13:01:33 -07:00
|
|
|
public void setStateWithAnimation(LauncherState toState, StateAnimationConfig config,
|
|
|
|
|
PendingAnimation builder) {
|
2020-03-06 15:56:46 -08:00
|
|
|
if (config.hasAnimationFlag(SKIP_OVERVIEW)) {
|
2019-03-19 14:55:22 -05:00
|
|
|
return;
|
|
|
|
|
}
|
2020-03-13 13:01:33 -07:00
|
|
|
setStateWithAnimationInternal(toState, config, builder);
|
2019-01-15 13:19:06 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Core logic for animating the recents view UI.
|
|
|
|
|
*
|
|
|
|
|
* @param toState state to animate to
|
|
|
|
|
* @param config current animation config
|
2020-03-13 13:01:33 -07:00
|
|
|
* @param setter animator set builder
|
2019-01-15 13:19:06 -08:00
|
|
|
*/
|
|
|
|
|
void setStateWithAnimationInternal(@NonNull final LauncherState toState,
|
2020-03-13 13:01:33 -07:00
|
|
|
@NonNull StateAnimationConfig config, @NonNull PendingAnimation setter) {
|
2020-04-01 20:13:12 -07:00
|
|
|
float[] scaleAndOffset = toState.getOverviewScaleAndOffset(mLauncher);
|
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
|
|
|
setter.setFloat(mRecentsView, RECENTS_SCALE_PROPERTY, scaleAndOffset[0],
|
2020-03-26 15:28:36 -07:00
|
|
|
config.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR));
|
2021-04-14 13:50:04 -07:00
|
|
|
setter.setFloat(mRecentsView, ADJACENT_PAGE_HORIZONTAL_OFFSET, scaleAndOffset[1],
|
2020-03-26 15:28:36 -07:00
|
|
|
config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_X, LINEAR));
|
2021-05-07 14:20:38 -07:00
|
|
|
setter.setFloat(mRecentsView, TASK_SECONDARY_TRANSLATION, 0f,
|
|
|
|
|
config.getInterpolator(ANIM_OVERVIEW_TRANSLATE_Y, LINEAR));
|
2021-02-22 14:49:27 -08:00
|
|
|
PagedOrientationHandler orientationHandler =
|
|
|
|
|
((RecentsView) mLauncher.getOverviewPanel()).getPagedOrientationHandler();
|
|
|
|
|
FloatProperty taskViewsFloat = orientationHandler.getSplitSelectTaskOffset(
|
2021-04-29 18:37:48 -07:00
|
|
|
TASK_PRIMARY_SPLIT_TRANSLATION, TASK_SECONDARY_SPLIT_TRANSLATION,
|
|
|
|
|
mLauncher.getDeviceProfile());
|
2021-02-22 14:49:27 -08:00
|
|
|
setter.setFloat(mRecentsView, taskViewsFloat,
|
2021-05-05 10:28:05 -07:00
|
|
|
toState.getSplitSelectTranslation(mLauncher), LINEAR);
|
2020-03-26 15:28:36 -07:00
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
setter.setFloat(mRecentsView, getContentAlphaProperty(), toState.overviewUi ? 1 : 0,
|
2020-03-13 13:01:33 -07:00
|
|
|
config.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
|
2020-04-27 16:26:55 -07:00
|
|
|
|
|
|
|
|
setter.setFloat(
|
|
|
|
|
mRecentsView, getTaskModalnessProperty(),
|
|
|
|
|
toState.getOverviewModalness(),
|
2020-04-29 17:14:35 -07:00
|
|
|
config.getInterpolator(ANIM_OVERVIEW_MODAL, LINEAR));
|
2021-02-03 18:00:30 +00:00
|
|
|
setter.setFloat(mRecentsView, RECENTS_GRID_PROGRESS,
|
2021-03-11 20:16:54 +00:00
|
|
|
toState.displayOverviewTasksAsGrid(mLauncher.getDeviceProfile()) ? 1f : 0f, LINEAR);
|
2019-01-15 13:19:06 -08:00
|
|
|
}
|
|
|
|
|
|
2020-04-27 16:26:55 -07:00
|
|
|
abstract FloatProperty getTaskModalnessProperty();
|
|
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
/**
|
|
|
|
|
* Get property for content alpha for the recents view.
|
|
|
|
|
*
|
|
|
|
|
* @return the float property for the view's content alpha
|
|
|
|
|
*/
|
|
|
|
|
abstract FloatProperty getContentAlphaProperty();
|
|
|
|
|
}
|