2021-10-18 16:02:21 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (C) 2021 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.taskbar;
|
|
|
|
|
|
2021-10-19 14:48:09 -07:00
|
|
|
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
|
|
|
|
|
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASHED_LAUNCHER_STATE;
|
|
|
|
|
import static com.android.launcher3.taskbar.TaskbarStashController.TASKBAR_STASH_DURATION;
|
|
|
|
|
|
|
|
|
|
import android.animation.Animator;
|
|
|
|
|
|
2022-10-13 13:18:36 +01:00
|
|
|
import com.android.launcher3.config.FeatureFlags;
|
2021-10-19 14:48:09 -07:00
|
|
|
import com.android.launcher3.statemanager.StateManager;
|
2021-10-18 16:02:21 -07:00
|
|
|
import com.android.quickstep.RecentsActivity;
|
2021-10-19 14:48:09 -07:00
|
|
|
import com.android.quickstep.fallback.RecentsState;
|
|
|
|
|
import com.android.quickstep.views.RecentsView;
|
2021-10-18 16:02:21 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* A data source which integrates with the fallback RecentsActivity instance (for 3P launchers).
|
|
|
|
|
*/
|
|
|
|
|
public class FallbackTaskbarUIController extends TaskbarUIController {
|
|
|
|
|
|
|
|
|
|
private final RecentsActivity mRecentsActivity;
|
|
|
|
|
|
2021-10-19 14:48:09 -07:00
|
|
|
private final StateManager.StateListener<RecentsState> mStateListener =
|
|
|
|
|
new StateManager.StateListener<RecentsState>() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onStateTransitionStart(RecentsState toState) {
|
|
|
|
|
animateToRecentsState(toState);
|
|
|
|
|
|
|
|
|
|
// Handle tapping on live tile.
|
2022-11-02 22:24:33 -07:00
|
|
|
getRecentsView().setTaskLaunchListener(toState == RecentsState.DEFAULT
|
2021-10-19 14:48:09 -07:00
|
|
|
? (() -> animateToRecentsState(RecentsState.BACKGROUND_APP)) : null);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
2021-10-18 16:02:21 -07:00
|
|
|
public FallbackTaskbarUIController(RecentsActivity recentsActivity) {
|
|
|
|
|
mRecentsActivity = recentsActivity;
|
|
|
|
|
}
|
2021-10-19 14:48:09 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void init(TaskbarControllers taskbarControllers) {
|
Stash taskbar when IME is present, including during gestures
- SysUI removes SYSUI_STATE_IME_SHOWING when starting a gesture from an app, but because unstashing has implications on the gesture transition (e.g. clips the bottom of the app), we defer handling the ime hiding until the gesture settles. Repurposed the flow that swaps the taskbar background during the gesture to support this case as well.
- Delay the unstash when IME is closing, to align with the end of the IME exit transition
- Remove TaskbarViewController.ALPHA_INDEX_IME now that we stash when IME is opening, since stashing already hides the taskbar icons
- Also support passing a starting progress to the stashed handle reveal animation, to allow it to be reversed when cancelled. For example, when returning to an app that has IME showing, we first start unstashing because we're in an app, but then we get the signal that IME is attached so we stash again almost immediately (within a frame or two).
Test: In both 3 button and fully gestural, open a keyboard in an app, ensure taskbar gets out of the way and then reappears at the end when the keyboard is dismissed
Bug: 202511986
Change-Id: I93c298a98ba369ea6310466ff3f802231c582687
2021-11-16 17:38:36 -08:00
|
|
|
super.init(taskbarControllers);
|
2021-10-19 14:48:09 -07:00
|
|
|
|
|
|
|
|
mRecentsActivity.setTaskbarUIController(this);
|
|
|
|
|
mRecentsActivity.getStateManager().addStateListener(mStateListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
2021-11-30 14:37:36 -08:00
|
|
|
super.onDestroy();
|
2021-10-19 14:48:09 -07:00
|
|
|
mRecentsActivity.setTaskbarUIController(null);
|
|
|
|
|
mRecentsActivity.getStateManager().removeStateListener(mStateListener);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Creates an animation to animate the taskbar for the given state (but does not start it).
|
|
|
|
|
* Currently this animation just force stashes the taskbar in Overview.
|
|
|
|
|
*/
|
|
|
|
|
public Animator createAnimToRecentsState(RecentsState toState, long duration) {
|
2022-10-13 13:18:36 +01:00
|
|
|
boolean useStashedLauncherState = toState.hasOverviewActions();
|
|
|
|
|
boolean stashedLauncherState =
|
|
|
|
|
useStashedLauncherState && !FeatureFlags.ENABLE_TASKBAR_IN_OVERVIEW.get();
|
2023-01-12 16:09:24 -08:00
|
|
|
TaskbarStashController stashController = mControllers.taskbarStashController;
|
2021-10-19 14:48:09 -07:00
|
|
|
// Set both FLAG_IN_STASHED_LAUNCHER_STATE and FLAG_IN_APP to ensure the state is respected.
|
|
|
|
|
// For all other states, just use the current stashed-in-app setting (e.g. if long clicked).
|
2023-01-12 16:09:24 -08:00
|
|
|
stashController.updateStateForFlag(FLAG_IN_STASHED_LAUNCHER_STATE, stashedLauncherState);
|
|
|
|
|
stashController.updateStateForFlag(FLAG_IN_APP, !useStashedLauncherState);
|
|
|
|
|
return stashController.createApplyStateAnimator(duration);
|
2021-10-19 14:48:09 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void animateToRecentsState(RecentsState toState) {
|
|
|
|
|
Animator anim = createAnimToRecentsState(toState, TASKBAR_STASH_DURATION);
|
|
|
|
|
if (anim != null) {
|
|
|
|
|
anim.start();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-11-02 22:24:33 -07:00
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public RecentsView getRecentsView() {
|
|
|
|
|
return mRecentsActivity.getOverviewPanel();
|
|
|
|
|
}
|
2021-10-18 16:02:21 -07:00
|
|
|
}
|