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;
|
|
|
|
|
|
2021-02-03 18:00:30 +00:00
|
|
|
import static com.android.launcher3.LauncherState.CLEAR_ALL_BUTTON;
|
|
|
|
|
import static com.android.launcher3.LauncherState.OVERVIEW_ACTIONS;
|
2021-02-22 14:49:27 -08:00
|
|
|
import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT;
|
|
|
|
|
import static com.android.launcher3.LauncherState.SPLIT_PLACHOLDER_VIEW;
|
2019-04-24 11:32:59 -07:00
|
|
|
import static com.android.launcher3.anim.Interpolators.LINEAR;
|
2020-07-17 13:06:57 -07:00
|
|
|
import static com.android.launcher3.states.StateAnimationConfig.ANIM_OVERVIEW_ACTIONS_FADE;
|
2018-06-06 15:39:13 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.CONTENT_ALPHA;
|
2019-05-12 13:24:51 -05:00
|
|
|
import static com.android.quickstep.views.RecentsView.FULLSCREEN_PROGRESS;
|
2020-04-27 16:26:55 -07:00
|
|
|
import static com.android.quickstep.views.RecentsView.TASK_MODALNESS;
|
2021-02-22 14:49:27 -08:00
|
|
|
import static com.android.quickstep.views.SplitPlaceholderView.ALPHA_FLOAT;
|
Prevent setting task thumbnail during swipe to overview
Previously we were setting the incorrect thumbnail when
swiping to overview, then taking a task screenshot right
when the animation ends and replacing the first thumbnail.
This sometimes caused a flicker of the old thumbnail, now
we avoid setting the thumbnail at all for the taskview that
is being swiped up.
Another edge case handled here is when switching nav modes
and then immediately entering overview, Recents receives an
onConfigChange for changing task icon size. That would cause
all taskviews to null out both their existing icon and
thumbnail, now only the icon gets nulled out.
Existing issue where switching to 3 button nav and then
entering overview shows blank icon, doesn't register for
receiving the updated task snapshot fast enough.
Fixes: 179307265
Test: Ask assistant for weather, swipe to overview
Ask assistant for time, swipe to overview, no flicker
Switch nav modes to gesture, swipe to overview.
There's a flicker for config change, but thumbnail is correct
Change-Id: I300b29f999f6d6876f82bc0189b44f4c10ae33fe
2021-03-16 18:27:32 -07:00
|
|
|
import static com.android.quickstep.views.TaskView.FLAG_UPDATE_ALL;
|
2017-12-22 17:33:02 -08:00
|
|
|
|
2018-03-21 09:32:27 -07:00
|
|
|
import android.annotation.TargetApi;
|
|
|
|
|
import android.os.Build;
|
2019-01-15 13:19:06 -08:00
|
|
|
import android.util.FloatProperty;
|
|
|
|
|
|
2019-04-24 11:32:59 -07:00
|
|
|
import androidx.annotation.NonNull;
|
|
|
|
|
|
2020-03-26 15:28:36 -07:00
|
|
|
import com.android.launcher3.BaseQuickstepLauncher;
|
2017-11-07 12:23:58 -08:00
|
|
|
import com.android.launcher3.LauncherState;
|
2020-03-06 14:52:17 -08:00
|
|
|
import com.android.launcher3.anim.AnimationSuccessListener;
|
2020-03-13 13:01:33 -07:00
|
|
|
import com.android.launcher3.anim.PendingAnimation;
|
2019-04-24 11:32:59 -07:00
|
|
|
import com.android.launcher3.anim.PropertySetter;
|
2020-03-13 13:01:33 -07:00
|
|
|
import com.android.launcher3.states.StateAnimationConfig;
|
2020-04-15 16:36:27 -07:00
|
|
|
import com.android.launcher3.util.MultiValueAlpha;
|
2019-04-24 11:32:59 -07:00
|
|
|
import com.android.quickstep.views.ClearAllButton;
|
2018-03-21 09:32:27 -07:00
|
|
|
import com.android.quickstep.views.LauncherRecentsView;
|
2019-01-15 13:19:06 -08:00
|
|
|
import com.android.quickstep.views.RecentsView;
|
2017-11-07 12:23:58 -08:00
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
/**
|
|
|
|
|
* State handler for handling UI changes for {@link LauncherRecentsView}. In addition to managing
|
|
|
|
|
* the basic view properties, this class also manages changes in the task visuals.
|
|
|
|
|
*/
|
2018-03-21 09:32:27 -07:00
|
|
|
@TargetApi(Build.VERSION_CODES.O)
|
2019-01-15 13:19:06 -08:00
|
|
|
public final class RecentsViewStateController extends
|
|
|
|
|
BaseRecentsViewStateController<LauncherRecentsView> {
|
2018-01-26 16:45:23 -08:00
|
|
|
|
2020-03-26 15:28:36 -07:00
|
|
|
public RecentsViewStateController(BaseQuickstepLauncher launcher) {
|
2019-01-15 13:19:06 -08:00
|
|
|
super(launcher);
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2019-01-15 13:19:06 -08:00
|
|
|
public void setState(@NonNull LauncherState state) {
|
|
|
|
|
super.setState(state);
|
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
|
|
|
}
|
2020-07-17 13:06:57 -07:00
|
|
|
setAlphas(PropertySetter.NO_ANIM_PROPERTY_SETTER, new StateAnimationConfig(), state);
|
2019-05-12 13:24:51 -05:00
|
|
|
mRecentsView.setFullscreenProgress(state.getOverviewFullscreenProgress());
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2020-03-13 13:01:33 -07:00
|
|
|
void setStateWithAnimationInternal(@NonNull LauncherState toState,
|
|
|
|
|
@NonNull StateAnimationConfig config, @NonNull PendingAnimation builder) {
|
|
|
|
|
super.setStateWithAnimationInternal(toState, config, builder);
|
2018-04-04 10:23:36 -07:00
|
|
|
|
2018-03-14 12:05:00 +00:00
|
|
|
if (toState.overviewUi) {
|
2020-03-06 14:52:17 -08:00
|
|
|
// While animating into recents, update the visible task data as needed
|
Prevent setting task thumbnail during swipe to overview
Previously we were setting the incorrect thumbnail when
swiping to overview, then taking a task screenshot right
when the animation ends and replacing the first thumbnail.
This sometimes caused a flicker of the old thumbnail, now
we avoid setting the thumbnail at all for the taskview that
is being swiped up.
Another edge case handled here is when switching nav modes
and then immediately entering overview, Recents receives an
onConfigChange for changing task icon size. That would cause
all taskviews to null out both their existing icon and
thumbnail, now only the icon gets nulled out.
Existing issue where switching to 3 button nav and then
entering overview shows blank icon, doesn't register for
receiving the updated task snapshot fast enough.
Fixes: 179307265
Test: Ask assistant for weather, swipe to overview
Ask assistant for time, swipe to overview, no flicker
Switch nav modes to gesture, swipe to overview.
There's a flicker for config change, but thumbnail is correct
Change-Id: I300b29f999f6d6876f82bc0189b44f4c10ae33fe
2021-03-16 18:27:32 -07:00
|
|
|
builder.addOnFrameCallback(() -> mRecentsView.loadVisibleTaskData(FLAG_UPDATE_ALL));
|
2018-03-26 15:33:41 -07:00
|
|
|
mRecentsView.updateEmptyMessage();
|
2020-03-06 14:52:17 -08:00
|
|
|
} else {
|
2020-05-12 15:18:49 -07:00
|
|
|
builder.addListener(
|
2020-03-06 14:52:17 -08:00
|
|
|
AnimationSuccessListener.forRunnable(mRecentsView::resetTaskVisuals));
|
2018-03-14 12:05:00 +00:00
|
|
|
}
|
2019-04-24 11:32:59 -07:00
|
|
|
|
2021-02-22 14:49:27 -08:00
|
|
|
// Create or dismiss split screen select animations
|
|
|
|
|
LauncherState currentState = mLauncher.getStateManager().getState();
|
|
|
|
|
if (isSplitSelectionState(toState) && !isSplitSelectionState(currentState)) {
|
|
|
|
|
builder.add(mRecentsView.createSplitSelectInitAnimation().buildAnim());
|
|
|
|
|
} else if (!isSplitSelectionState(toState) && isSplitSelectionState(currentState)) {
|
|
|
|
|
builder.add(mRecentsView.cancelSplitSelect(true).buildAnim());
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 13:06:57 -07:00
|
|
|
setAlphas(builder, config, toState);
|
2020-03-13 13:01:33 -07:00
|
|
|
builder.setFloat(mRecentsView, FULLSCREEN_PROGRESS,
|
|
|
|
|
toState.getOverviewFullscreenProgress(), LINEAR);
|
2019-04-24 11:32:59 -07:00
|
|
|
}
|
|
|
|
|
|
2021-02-22 14:49:27 -08:00
|
|
|
/**
|
|
|
|
|
* @return true if {@param toState} is {@link LauncherState#OVERVIEW_SPLIT_SELECT}
|
|
|
|
|
*/
|
|
|
|
|
private boolean isSplitSelectionState(@NonNull LauncherState toState) {
|
|
|
|
|
return toState == OVERVIEW_SPLIT_SELECT;
|
|
|
|
|
}
|
|
|
|
|
|
2020-07-17 13:06:57 -07:00
|
|
|
private void setAlphas(PropertySetter propertySetter, StateAnimationConfig config,
|
|
|
|
|
LauncherState state) {
|
2021-03-19 14:47:03 +00:00
|
|
|
float clearAllButtonAlpha = state.areElementsVisible(mLauncher, CLEAR_ALL_BUTTON) ? 1 : 0;
|
2019-04-24 11:32:59 -07:00
|
|
|
propertySetter.setFloat(mRecentsView.getClearAllButton(), ClearAllButton.VISIBILITY_ALPHA,
|
2021-02-03 18:00:30 +00:00
|
|
|
clearAllButtonAlpha, LINEAR);
|
2021-03-19 14:47:03 +00:00
|
|
|
float overviewButtonAlpha = state.areElementsVisible(mLauncher, OVERVIEW_ACTIONS)
|
|
|
|
|
&& mRecentsView.shouldShowOverviewActionsForState(state) ? 1 : 0;
|
2020-04-15 16:36:27 -07:00
|
|
|
propertySetter.setFloat(mLauncher.getActionsView().getVisibilityAlpha(),
|
2021-02-03 18:00:30 +00:00
|
|
|
MultiValueAlpha.VALUE, overviewButtonAlpha, config.getInterpolator(
|
2020-07-17 13:06:57 -07:00
|
|
|
ANIM_OVERVIEW_ACTIONS_FADE, LINEAR));
|
2021-02-22 14:49:27 -08:00
|
|
|
|
|
|
|
|
float splitPlaceholderAlpha = state.areElementsVisible(mLauncher, SPLIT_PLACHOLDER_VIEW) ?
|
|
|
|
|
1 : 0;
|
|
|
|
|
propertySetter.setFloat(mRecentsView.getSplitPlaceholder(), ALPHA_FLOAT,
|
|
|
|
|
splitPlaceholderAlpha, LINEAR);
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|
2019-01-15 13:19:06 -08:00
|
|
|
|
2020-04-27 16:26:55 -07:00
|
|
|
@Override
|
|
|
|
|
FloatProperty<RecentsView> getTaskModalnessProperty() {
|
|
|
|
|
return TASK_MODALNESS;
|
|
|
|
|
}
|
|
|
|
|
|
2019-01-15 13:19:06 -08:00
|
|
|
@Override
|
|
|
|
|
FloatProperty<RecentsView> getContentAlphaProperty() {
|
|
|
|
|
return CONTENT_ALPHA;
|
|
|
|
|
}
|
2017-11-07 12:23:58 -08:00
|
|
|
}
|