2020-12-22 12:40:09 -06: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-11-08 00:48:53 -08:00
|
|
|
import static com.android.launcher3.taskbar.TaskbarLauncherStateController.FLAG_RESUMED;
|
2021-10-05 01:11:08 +02:00
|
|
|
import static com.android.systemui.shared.system.WindowManagerWrapper.ITYPE_EXTRA_NAVIGATION_BAR;
|
2021-05-25 14:35:01 -07:00
|
|
|
|
2020-12-23 16:12:18 -06:00
|
|
|
import android.animation.Animator;
|
2021-10-05 01:11:08 +02:00
|
|
|
import android.annotation.ColorInt;
|
|
|
|
|
import android.os.RemoteException;
|
|
|
|
|
import android.util.Log;
|
2021-01-22 18:45:04 -08:00
|
|
|
import android.view.MotionEvent;
|
2021-10-05 01:11:08 +02:00
|
|
|
import android.view.TaskTransitionSpec;
|
|
|
|
|
import android.view.WindowManagerGlobal;
|
2020-12-22 12:40:09 -06:00
|
|
|
|
2021-05-25 14:35:01 -07:00
|
|
|
import androidx.annotation.NonNull;
|
2020-12-23 16:12:18 -06:00
|
|
|
|
2020-12-22 12:40:09 -06:00
|
|
|
import com.android.launcher3.BaseQuickstepLauncher;
|
2021-07-22 14:28:04 -10:00
|
|
|
import com.android.launcher3.DeviceProfile;
|
2020-12-23 16:12:18 -06:00
|
|
|
import com.android.launcher3.LauncherState;
|
2021-03-07 15:09:11 -08:00
|
|
|
import com.android.launcher3.QuickstepTransitionManager;
|
2021-10-05 01:11:08 +02:00
|
|
|
import com.android.launcher3.R;
|
2021-09-07 12:48:43 -07:00
|
|
|
import com.android.launcher3.Utilities;
|
2021-08-30 14:15:56 -07:00
|
|
|
import com.android.launcher3.logging.InstanceId;
|
|
|
|
|
import com.android.launcher3.logging.InstanceIdSequence;
|
2022-01-24 22:54:21 -05:00
|
|
|
import com.android.launcher3.model.data.ItemInfo;
|
2021-08-24 10:56:31 -07:00
|
|
|
import com.android.launcher3.model.data.ItemInfoWithIcon;
|
2021-08-04 13:56:43 -10:00
|
|
|
import com.android.launcher3.util.OnboardingPrefs;
|
2021-05-25 14:35:01 -07:00
|
|
|
import com.android.quickstep.AnimatedFloat;
|
2021-06-15 14:49:28 -07:00
|
|
|
import com.android.quickstep.RecentsAnimationCallbacks;
|
2021-05-25 14:35:01 -07:00
|
|
|
|
2021-08-24 10:56:31 -07:00
|
|
|
import java.util.Arrays;
|
2021-10-05 01:11:08 +02:00
|
|
|
import java.util.Set;
|
2021-08-24 10:56:31 -07:00
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
|
2020-12-22 12:40:09 -06:00
|
|
|
/**
|
2021-05-20 20:18:47 +00:00
|
|
|
* A data source which integrates with a Launcher instance
|
2020-12-22 12:40:09 -06:00
|
|
|
*/
|
2021-05-20 20:18:47 +00:00
|
|
|
public class LauncherTaskbarUIController extends TaskbarUIController {
|
2021-04-16 12:50:22 -07:00
|
|
|
|
2021-10-05 01:11:08 +02:00
|
|
|
private static final String TAG = "TaskbarUIController";
|
|
|
|
|
|
2020-12-22 12:40:09 -06:00
|
|
|
private final BaseQuickstepLauncher mLauncher;
|
|
|
|
|
|
2021-07-22 14:28:04 -10:00
|
|
|
private final DeviceProfile.OnDeviceProfileChangeListener mOnDeviceProfileChangeListener =
|
|
|
|
|
this::onStashedInAppChanged;
|
|
|
|
|
|
2021-06-01 16:54:07 -07:00
|
|
|
// Initialized in init.
|
2021-07-22 14:28:04 -10:00
|
|
|
private AnimatedFloat mTaskbarOverrideBackgroundAlpha;
|
2021-06-04 15:35:46 -07:00
|
|
|
private TaskbarKeyguardController mKeyguardController;
|
2021-11-08 00:48:53 -08:00
|
|
|
private final TaskbarLauncherStateController
|
|
|
|
|
mTaskbarLauncherStateController = new TaskbarLauncherStateController();
|
2021-09-30 10:14:34 -07:00
|
|
|
|
2021-10-12 21:41:13 -07:00
|
|
|
private final DeviceProfile.OnDeviceProfileChangeListener mProfileChangeListener =
|
|
|
|
|
new DeviceProfile.OnDeviceProfileChangeListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onDeviceProfileChanged(DeviceProfile dp) {
|
|
|
|
|
mControllers.taskbarViewController.onRotationChanged(
|
|
|
|
|
mLauncher.getDeviceProfile());
|
|
|
|
|
}
|
|
|
|
|
};
|
2021-06-15 14:49:28 -07:00
|
|
|
|
2021-10-18 16:02:21 -07:00
|
|
|
public LauncherTaskbarUIController(BaseQuickstepLauncher launcher) {
|
2020-12-22 12:40:09 -06:00
|
|
|
mLauncher = launcher;
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
2021-06-08 20:03:43 -07:00
|
|
|
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-06-01 16:54:07 -07:00
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
mTaskbarLauncherStateController.init(mControllers, mLauncher);
|
2021-07-22 14:28:04 -10:00
|
|
|
mTaskbarOverrideBackgroundAlpha = mControllers.taskbarDragLayerController
|
|
|
|
|
.getOverrideBackgroundAlpha();
|
2021-06-01 16:54:07 -07:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
mLauncher.setTaskbarUIController(this);
|
2021-06-04 15:35:46 -07:00
|
|
|
mKeyguardController = taskbarControllers.taskbarKeyguardController;
|
2021-06-17 15:18:15 -07:00
|
|
|
|
2021-09-28 15:09:25 -07:00
|
|
|
onLauncherResumedOrPaused(mLauncher.hasBeenResumed(), true /* fromInit */);
|
2021-07-22 14:28:04 -10:00
|
|
|
|
|
|
|
|
onStashedInAppChanged(mLauncher.getDeviceProfile());
|
|
|
|
|
mLauncher.addOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
2021-10-12 21:41:13 -07:00
|
|
|
mLauncher.addOnDeviceProfileChangeListener(mProfileChangeListener);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
2021-11-30 14:37:36 -08:00
|
|
|
super.onDestroy();
|
2021-06-18 12:41:22 -07:00
|
|
|
onLauncherResumedOrPaused(false);
|
2021-11-08 00:48:53 -08:00
|
|
|
mTaskbarLauncherStateController.onDestroy();
|
2021-06-17 15:18:15 -07:00
|
|
|
|
2021-07-22 14:28:04 -10:00
|
|
|
mLauncher.removeOnDeviceProfileChangeListener(mOnDeviceProfileChangeListener);
|
2021-05-20 20:18:47 +00:00
|
|
|
mLauncher.setTaskbarUIController(null);
|
2021-10-12 21:41:13 -07:00
|
|
|
mLauncher.removeOnDeviceProfileChangeListener(mProfileChangeListener);
|
2021-10-05 01:11:08 +02:00
|
|
|
updateTaskTransitionSpec(true);
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected boolean isTaskbarTouchable() {
|
2021-11-08 00:48:53 -08:00
|
|
|
return !mTaskbarLauncherStateController.isAnimatingToLauncher();
|
2020-12-23 16:12:18 -06:00
|
|
|
}
|
|
|
|
|
|
2021-12-12 11:16:29 +08:00
|
|
|
public void setShouldDelayLauncherStateAnim(boolean shouldDelayLauncherStateAnim) {
|
|
|
|
|
mTaskbarLauncherStateController.setShouldDelayLauncherStateAnim(
|
|
|
|
|
shouldDelayLauncherStateAnim);
|
|
|
|
|
}
|
|
|
|
|
|
2020-12-23 16:12:18 -06:00
|
|
|
/**
|
|
|
|
|
* Should be called from onResume() and onPause(), and animates the Taskbar accordingly.
|
|
|
|
|
*/
|
|
|
|
|
public void onLauncherResumedOrPaused(boolean isResumed) {
|
2021-09-28 15:09:25 -07:00
|
|
|
onLauncherResumedOrPaused(isResumed, false /* fromInit */);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onLauncherResumedOrPaused(boolean isResumed, boolean fromInit) {
|
2021-06-04 15:35:46 -07:00
|
|
|
if (mKeyguardController.isScreenOff()) {
|
|
|
|
|
if (!isResumed) {
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
// Resuming implicitly means device unlocked
|
|
|
|
|
mKeyguardController.setScreenOn();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2021-11-08 00:48:53 -08:00
|
|
|
mTaskbarLauncherStateController.updateStateForFlag(FLAG_RESUMED, isResumed);
|
|
|
|
|
mTaskbarLauncherStateController.applyState(
|
|
|
|
|
fromInit ? 0 : QuickstepTransitionManager.CONTENT_ALPHA_DURATION);
|
2020-12-23 16:12:18 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2021-06-15 14:49:28 -07:00
|
|
|
* Create Taskbar animation when going from an app to Launcher as part of recents transition.
|
2020-12-23 16:12:18 -06:00
|
|
|
* @param toState If known, the state we will end up in when reaching Launcher.
|
2021-06-15 14:49:28 -07:00
|
|
|
* @param callbacks callbacks to track the recents animation lifecycle. The state change is
|
|
|
|
|
* automatically reset once the recents animation finishes
|
2020-12-23 16:12:18 -06:00
|
|
|
*/
|
2021-06-15 14:49:28 -07:00
|
|
|
public Animator createAnimToLauncher(@NonNull LauncherState toState,
|
2021-08-04 22:31:08 -07:00
|
|
|
@NonNull RecentsAnimationCallbacks callbacks, long duration) {
|
2021-11-08 00:48:53 -08:00
|
|
|
return mTaskbarLauncherStateController.createAnimToLauncher(toState, callbacks, duration);
|
2020-12-23 16:12:18 -06:00
|
|
|
}
|
|
|
|
|
|
2021-01-22 18:45:04 -08:00
|
|
|
/**
|
|
|
|
|
* @param ev MotionEvent in screen coordinates.
|
|
|
|
|
* @return Whether any Taskbar item could handle the given MotionEvent if given the chance.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isEventOverAnyTaskbarItem(MotionEvent ev) {
|
2021-10-21 15:31:51 +01:00
|
|
|
return mControllers.taskbarViewController.isEventOverAnyItem(ev)
|
|
|
|
|
|| mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
|
2021-01-22 18:45:04 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isDraggingItem() {
|
2021-10-18 16:02:21 -07:00
|
|
|
return mControllers.taskbarDragController.isDragging();
|
2021-01-11 14:54:23 -06:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 14:28:04 -10:00
|
|
|
@Override
|
|
|
|
|
protected void onStashedInAppChanged() {
|
|
|
|
|
onStashedInAppChanged(mLauncher.getDeviceProfile());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onStashedInAppChanged(DeviceProfile deviceProfile) {
|
|
|
|
|
boolean taskbarStashedInApps = mControllers.taskbarStashController.isStashedInApp();
|
|
|
|
|
deviceProfile.isTaskbarPresentInApps = !taskbarStashedInApps;
|
2021-10-05 01:11:08 +02:00
|
|
|
updateTaskTransitionSpec(taskbarStashedInApps);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateTaskTransitionSpec(boolean taskbarIsHidden) {
|
|
|
|
|
try {
|
|
|
|
|
if (taskbarIsHidden) {
|
|
|
|
|
// Clear custom task transition settings when the taskbar is stashed
|
|
|
|
|
WindowManagerGlobal.getWindowManagerService().clearTaskTransitionSpec();
|
|
|
|
|
} else {
|
|
|
|
|
// Adjust task transition spec to account for taskbar being visible
|
|
|
|
|
@ColorInt int taskAnimationBackgroundColor =
|
|
|
|
|
mLauncher.getColor(R.color.taskbar_background);
|
|
|
|
|
|
|
|
|
|
TaskTransitionSpec customTaskAnimationSpec = new TaskTransitionSpec(
|
|
|
|
|
taskAnimationBackgroundColor,
|
|
|
|
|
Set.of(ITYPE_EXTRA_NAVIGATION_BAR)
|
|
|
|
|
);
|
|
|
|
|
WindowManagerGlobal.getWindowManagerService()
|
|
|
|
|
.setTaskTransitionSpec(customTaskAnimationSpec);
|
|
|
|
|
}
|
|
|
|
|
} catch (RemoteException e) {
|
|
|
|
|
// This shouldn't happen but if it does task animations won't look good until the
|
|
|
|
|
// taskbar stashing state is changed.
|
|
|
|
|
Log.e(TAG, "Failed to update task transition spec to account for new taskbar state",
|
|
|
|
|
e);
|
|
|
|
|
}
|
2021-07-22 14:28:04 -10:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Sets whether the background behind the taskbar/nav bar should be hidden.
|
|
|
|
|
*/
|
|
|
|
|
public void forceHideBackground(boolean forceHide) {
|
|
|
|
|
mTaskbarOverrideBackgroundAlpha.updateValue(forceHide ? 0 : 1);
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-24 10:56:31 -07:00
|
|
|
@Override
|
|
|
|
|
public Stream<ItemInfoWithIcon> getAppIconsForEdu() {
|
|
|
|
|
return Arrays.stream(mLauncher.getAppsView().getAppsStore().getApps());
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 16:00:20 -10:00
|
|
|
/**
|
|
|
|
|
* Starts the taskbar education flow, if the user hasn't seen it yet.
|
|
|
|
|
*/
|
|
|
|
|
public void showEdu() {
|
2022-01-25 10:09:44 +00:00
|
|
|
if (!shouldShowEdu()) {
|
2021-07-30 16:00:20 -10:00
|
|
|
return;
|
|
|
|
|
}
|
2021-08-04 13:56:43 -10:00
|
|
|
mLauncher.getOnboardingPrefs().markChecked(OnboardingPrefs.TASKBAR_EDU_SEEN);
|
2021-07-30 16:00:20 -10:00
|
|
|
|
|
|
|
|
mControllers.taskbarEduController.showEdu();
|
|
|
|
|
}
|
|
|
|
|
|
2022-01-25 10:09:44 +00:00
|
|
|
/**
|
|
|
|
|
* Whether the taskbar education should be shown.
|
|
|
|
|
*/
|
|
|
|
|
public boolean shouldShowEdu() {
|
2022-02-16 17:42:21 -08:00
|
|
|
return !Utilities.IS_RUNNING_IN_TEST_HARNESS
|
2022-01-25 10:09:44 +00:00
|
|
|
&& !mLauncher.getOnboardingPrefs().getBoolean(OnboardingPrefs.TASKBAR_EDU_SEEN);
|
|
|
|
|
}
|
|
|
|
|
|
2021-07-30 16:00:20 -10:00
|
|
|
/**
|
|
|
|
|
* Manually ends the taskbar education flow.
|
|
|
|
|
*/
|
|
|
|
|
public void hideEdu() {
|
|
|
|
|
mControllers.taskbarEduController.hideEdu();
|
|
|
|
|
}
|
|
|
|
|
|
2021-08-30 14:15:56 -07:00
|
|
|
@Override
|
2022-01-24 22:54:21 -05:00
|
|
|
public void onTaskbarIconLaunched(ItemInfo item) {
|
2021-08-30 14:15:56 -07:00
|
|
|
InstanceId instanceId = new InstanceIdSequence().newInstanceId();
|
2021-10-18 16:02:21 -07:00
|
|
|
mLauncher.logAppLaunch(mControllers.taskbarActivityContext.getStatsLogManager(), item,
|
|
|
|
|
instanceId);
|
2021-08-30 14:15:56 -07:00
|
|
|
}
|
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
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setSystemGestureInProgress(boolean inProgress) {
|
|
|
|
|
super.setSystemGestureInProgress(inProgress);
|
|
|
|
|
// Launcher's ScrimView will draw the background throughout the gesture. But once the
|
|
|
|
|
// gesture ends, start drawing taskbar's background again since launcher might stop drawing.
|
|
|
|
|
forceHideBackground(inProgress);
|
|
|
|
|
}
|
2020-12-22 12:40:09 -06:00
|
|
|
}
|