2017-11-07 12:23:58 -08:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2017 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;
|
|
|
|
|
|
2018-05-16 12:23:12 -07:00
|
|
|
import static com.android.launcher3.LauncherState.FAST_OVERVIEW;
|
|
|
|
|
import static com.android.launcher3.LauncherState.OVERVIEW;
|
|
|
|
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_FADE;
|
|
|
|
|
import static com.android.launcher3.anim.AnimatorSetBuilder.ANIM_OVERVIEW_SCALE;
|
2018-04-04 10:23:36 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.AGGRESSIVE_EASE_IN_OUT;
|
2018-03-21 09:32:27 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
2018-05-04 12:10:55 -07:00
|
|
|
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_START_INTERPOLATOR;
|
|
|
|
|
import static com.android.quickstep.QuickScrubController.QUICK_SCRUB_TRANSLATION_Y_FACTOR;
|
2018-03-15 12:48:51 +00:00
|
|
|
import static com.android.quickstep.views.LauncherRecentsView.TRANSLATION_Y_FACTOR;
|
2018-04-04 10:23:36 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.ADJACENT_SCALE;
|
2018-04-11 17:19:08 -07:00
|
|
|
import static com.android.quickstep.views.RecentsViewContainer.CONTENT_ALPHA;
|
2017-12-22 17:33:02 -08:00
|
|
|
|
2018-03-21 09:32:27 -07:00
|
|
|
import android.animation.ValueAnimator;
|
|
|
|
|
import android.annotation.TargetApi;
|
|
|
|
|
import android.os.Build;
|
2018-05-04 12:10:55 -07:00
|
|
|
import android.view.animation.Interpolator;
|
2017-11-07 12:23:58 -08:00
|
|
|
|
|
|
|
|
import com.android.launcher3.Launcher;
|
|
|
|
|
import com.android.launcher3.LauncherState;
|
|
|
|
|
import com.android.launcher3.LauncherStateManager.AnimationConfig;
|
|
|
|
|
import com.android.launcher3.LauncherStateManager.StateHandler;
|
2017-12-07 12:45:49 -08:00
|
|
|
import com.android.launcher3.anim.AnimatorSetBuilder;
|
2018-05-04 12:10:55 -07:00
|
|
|
import com.android.launcher3.anim.Interpolators;
|
2018-03-21 09:32:27 -07:00
|
|
|
import com.android.launcher3.anim.PropertySetter;
|
|
|
|
|
import com.android.quickstep.views.LauncherRecentsView;
|
2018-04-11 17:19:08 -07:00
|
|
|
import com.android.quickstep.views.RecentsViewContainer;
|
2017-11-07 12:23:58 -08:00
|
|
|
|
2018-03-21 09:32:27 -07:00
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
2017-11-07 12:23:58 -08:00
|
|
|
public class RecentsViewStateController implements StateHandler {
|
|
|
|
|
|
|
|
|
|
private final Launcher mLauncher;
|
2018-03-21 09:32:27 -07:00
|
|
|
private final LauncherRecentsView mRecentsView;
|
2018-04-11 17:19:08 -07:00
|
|
|
private final RecentsViewContainer mRecentsViewContainer;
|
2018-01-26 16:45:23 -08:00
|
|
|
|
2017-11-07 12:23:58 -08:00
|
|
|
public RecentsViewStateController(Launcher launcher) {
|
|
|
|
|
mLauncher = launcher;
|
2017-12-06 10:25:07 -08:00
|
|
|
mRecentsView = launcher.getOverviewPanel();
|
2018-04-11 17:19:08 -07:00
|
|
|
mRecentsViewContainer = launcher.getOverviewPanelContainer();
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setState(LauncherState state) {
|
2018-04-11 17:19:08 -07:00
|
|
|
mRecentsViewContainer.setContentAlpha(state.overviewUi ? 1 : 0);
|
2018-04-04 10:23:36 -07:00
|
|
|
float[] scaleTranslationYFactor = state.getOverviewScaleAndTranslationYFactor(mLauncher);
|
|
|
|
|
mRecentsView.setAdjacentScale(scaleTranslationYFactor[0]);
|
|
|
|
|
mRecentsView.setTranslationYFactor(scaleTranslationYFactor[1]);
|
2018-03-02 14:57:46 -08:00
|
|
|
if (state.overviewUi) {
|
2018-03-26 15:33:41 -07:00
|
|
|
mRecentsView.updateEmptyMessage();
|
2018-03-13 16:44:00 -07:00
|
|
|
mRecentsView.resetTaskVisuals();
|
2018-02-13 11:28:12 -08:00
|
|
|
}
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2017-12-15 13:05:42 -08:00
|
|
|
public void setStateWithAnimation(final LauncherState toState,
|
2017-12-07 12:45:49 -08:00
|
|
|
AnimatorSetBuilder builder, AnimationConfig config) {
|
2018-04-19 11:39:34 -07:00
|
|
|
if (!config.playAtomicComponent()) {
|
|
|
|
|
// The entire recents animation is played atomically.
|
|
|
|
|
return;
|
|
|
|
|
}
|
2018-04-27 12:33:24 -05:00
|
|
|
PropertySetter setter = config.getPropertySetter(builder);
|
2018-04-04 10:23:36 -07:00
|
|
|
float[] scaleTranslationYFactor = toState.getOverviewScaleAndTranslationYFactor(mLauncher);
|
2018-05-16 12:23:12 -07:00
|
|
|
Interpolator scaleInterpolator = builder.getInterpolator(ANIM_OVERVIEW_SCALE, LINEAR);
|
|
|
|
|
setter.setFloat(mRecentsView, ADJACENT_SCALE, scaleTranslationYFactor[0], scaleInterpolator);
|
|
|
|
|
Interpolator transYInterpolator = scaleInterpolator;
|
|
|
|
|
if (mLauncher.getStateManager().getState() == OVERVIEW && toState == FAST_OVERVIEW) {
|
2018-05-04 12:10:55 -07:00
|
|
|
transYInterpolator = Interpolators.clampToProgress(QUICK_SCRUB_START_INTERPOLATOR, 0,
|
|
|
|
|
QUICK_SCRUB_TRANSLATION_Y_FACTOR);
|
|
|
|
|
}
|
|
|
|
|
setter.setFloat(mRecentsView, TRANSLATION_Y_FACTOR, scaleTranslationYFactor[1],
|
|
|
|
|
transYInterpolator);
|
2018-04-11 17:19:08 -07:00
|
|
|
setter.setFloat(mRecentsViewContainer, CONTENT_ALPHA, toState.overviewUi ? 1 : 0,
|
2018-05-16 12:23:12 -07:00
|
|
|
builder.getInterpolator(ANIM_OVERVIEW_FADE, AGGRESSIVE_EASE_IN_OUT));
|
2018-04-04 10:23:36 -07:00
|
|
|
|
|
|
|
|
if (!toState.overviewUi) {
|
|
|
|
|
builder.addOnFinishRunnable(mRecentsView::resetTaskVisuals);
|
|
|
|
|
}
|
2018-03-14 12:05:00 +00:00
|
|
|
|
|
|
|
|
if (toState.overviewUi) {
|
2018-03-21 09:32:27 -07:00
|
|
|
ValueAnimator updateAnim = ValueAnimator.ofFloat(0, 1);
|
|
|
|
|
updateAnim.addUpdateListener(valueAnimator -> {
|
2018-03-14 12:05:00 +00:00
|
|
|
// While animating into recents, update the visible task data as needed
|
|
|
|
|
mRecentsView.loadVisibleTaskData();
|
|
|
|
|
});
|
2018-03-21 09:32:27 -07:00
|
|
|
updateAnim.setDuration(config.duration);
|
|
|
|
|
builder.play(updateAnim);
|
2018-03-26 15:33:41 -07:00
|
|
|
mRecentsView.updateEmptyMessage();
|
2018-03-14 12:05:00 +00:00
|
|
|
}
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
|
|
|
|
}
|