2021-05-20 20:18:47 +00: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;
|
|
|
|
|
|
2023-01-12 18:50:36 -08:00
|
|
|
import static android.app.ActivityTaskManager.INVALID_TASK_ID;
|
|
|
|
|
|
2022-11-02 22:24:33 -07:00
|
|
|
import android.content.Intent;
|
|
|
|
|
import android.graphics.drawable.BitmapDrawable;
|
2022-11-02 14:54:31 +00:00
|
|
|
import android.view.MotionEvent;
|
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
|
|
|
import android.view.View;
|
2021-05-25 14:35:01 -07:00
|
|
|
|
2021-11-30 14:37:36 -08:00
|
|
|
import androidx.annotation.CallSuper;
|
2022-11-02 22:24:33 -07:00
|
|
|
import androidx.annotation.Nullable;
|
2021-11-30 14:37:36 -08:00
|
|
|
|
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;
|
2022-12-08 21:00:45 +00:00
|
|
|
import com.android.launcher3.util.DisplayController;
|
2023-01-12 18:50:36 -08:00
|
|
|
import com.android.launcher3.util.SplitConfigurationOptions;
|
2022-11-02 22:24:33 -07:00
|
|
|
import com.android.quickstep.views.RecentsView;
|
|
|
|
|
import com.android.quickstep.views.TaskView;
|
2023-02-01 15:22:23 +08:00
|
|
|
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
|
2022-12-02 17:38:08 -08:00
|
|
|
import com.android.systemui.shared.recents.model.Task;
|
2021-08-24 10:56:31 -07:00
|
|
|
|
2022-03-07 12:49:56 -08:00
|
|
|
import java.io.PrintWriter;
|
2022-12-02 17:38:08 -08:00
|
|
|
import java.util.function.Consumer;
|
2021-08-24 10:56:31 -07:00
|
|
|
|
2021-05-20 20:18:47 +00:00
|
|
|
/**
|
|
|
|
|
* Base class for providing different taskbar UI
|
|
|
|
|
*/
|
|
|
|
|
public class TaskbarUIController {
|
|
|
|
|
|
|
|
|
|
public static final TaskbarUIController DEFAULT = new TaskbarUIController();
|
|
|
|
|
|
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
|
|
|
// Initialized in init.
|
|
|
|
|
protected TaskbarControllers mControllers;
|
|
|
|
|
|
2021-11-30 14:37:36 -08:00
|
|
|
@CallSuper
|
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
|
|
|
protected void init(TaskbarControllers taskbarControllers) {
|
|
|
|
|
mControllers = taskbarControllers;
|
|
|
|
|
}
|
2021-05-20 20:18:47 +00:00
|
|
|
|
2021-11-30 14:37:36 -08:00
|
|
|
@CallSuper
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
mControllers = null;
|
|
|
|
|
}
|
2021-05-20 20:18:47 +00:00
|
|
|
|
|
|
|
|
protected boolean isTaskbarTouchable() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
2021-06-08 20:03:43 -07:00
|
|
|
|
2022-07-29 16:55:18 -07:00
|
|
|
/**
|
|
|
|
|
* This should only be called by TaskbarStashController so that a TaskbarUIController can
|
|
|
|
|
* disable stashing. All other controllers should use
|
|
|
|
|
* {@link TaskbarStashController#supportsVisualStashing()} as the source of truth.
|
|
|
|
|
*/
|
2022-03-24 14:47:32 -07:00
|
|
|
public boolean supportsVisualStashing() {
|
2022-07-29 16:55:18 -07:00
|
|
|
return true;
|
2022-03-24 14:47:32 -07:00
|
|
|
}
|
|
|
|
|
|
2021-07-22 14:28:04 -10:00
|
|
|
protected void onStashedInAppChanged() { }
|
2021-08-24 10:56:31 -07:00
|
|
|
|
2022-01-24 22:54:21 -05:00
|
|
|
/** Called when an icon is launched. */
|
|
|
|
|
public void onTaskbarIconLaunched(ItemInfo item) { }
|
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
|
|
|
|
|
|
|
|
public View getRootView() {
|
|
|
|
|
return mControllers.taskbarActivityContext.getDragLayer();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Called when swiping from the bottom nav region in fully gestural mode.
|
|
|
|
|
* @param inProgress True if the animation started, false if we just settled on an end target.
|
|
|
|
|
*/
|
|
|
|
|
public void setSystemGestureInProgress(boolean inProgress) {
|
|
|
|
|
mControllers.taskbarStashController.setSystemGestureInProgress(inProgress);
|
|
|
|
|
}
|
2022-03-04 10:58:53 -08:00
|
|
|
|
|
|
|
|
/**
|
2022-10-10 23:34:05 +00:00
|
|
|
* Manually closes the overlay window.
|
2022-03-04 10:58:53 -08:00
|
|
|
*/
|
2022-10-10 23:34:05 +00:00
|
|
|
public void hideOverlayWindow() {
|
2022-12-12 16:23:22 -05:00
|
|
|
if (!DisplayController.isTransientTaskbar(mControllers.taskbarActivityContext)
|
|
|
|
|
|| mControllers.taskbarAllAppsController.isOpen()) {
|
2022-12-08 21:00:45 +00:00
|
|
|
mControllers.taskbarOverlayController.hideWindow();
|
|
|
|
|
}
|
2022-03-04 10:58:53 -08:00
|
|
|
}
|
2022-03-22 17:37:03 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* User expands PiP to full-screen (or split-screen) mode, try to hide the Taskbar.
|
|
|
|
|
*/
|
|
|
|
|
public void onExpandPip() {
|
|
|
|
|
if (mControllers != null) {
|
|
|
|
|
final TaskbarStashController stashController = mControllers.taskbarStashController;
|
|
|
|
|
stashController.updateStateForFlag(TaskbarStashController.FLAG_IN_APP, true);
|
|
|
|
|
stashController.applyState();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-07 12:49:56 -08:00
|
|
|
|
2022-10-26 09:39:26 -07:00
|
|
|
/**
|
2022-12-12 16:23:22 -05:00
|
|
|
* Returns {@code true} iff taskbar is stashed.
|
2022-10-26 09:39:26 -07:00
|
|
|
*/
|
|
|
|
|
public boolean isTaskbarStashed() {
|
|
|
|
|
return mControllers.taskbarStashController.isStashed();
|
|
|
|
|
}
|
|
|
|
|
|
2022-12-12 16:23:22 -05:00
|
|
|
/**
|
|
|
|
|
* Returns {@code true} iff taskbar All Apps is open.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isTaskbarAllAppsOpen() {
|
|
|
|
|
return mControllers.taskbarAllAppsController.isOpen();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-07 13:50:49 -08:00
|
|
|
/**
|
|
|
|
|
* Called at the end of the swipe gesture on Transient taskbar.
|
|
|
|
|
*/
|
|
|
|
|
public void startTranslationSpring() {
|
|
|
|
|
mControllers.taskbarActivityContext.startTranslationSpring();
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-02 14:54:31 +00: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) {
|
|
|
|
|
return mControllers.taskbarViewController.isEventOverAnyItem(ev)
|
|
|
|
|
|| mControllers.navbarButtonsViewController.isEventOverAnyItem(ev);
|
|
|
|
|
}
|
|
|
|
|
|
2022-10-26 10:29:46 -07:00
|
|
|
/**
|
|
|
|
|
* Returns true if icons should be aligned to hotseat in the current transition.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isIconAlignedWithHotseat() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-08 15:43:29 +00:00
|
|
|
/**
|
|
|
|
|
* Returns true if hotseat icons are on top of view hierarchy when aligned in the current state.
|
|
|
|
|
*/
|
|
|
|
|
public boolean isHotseatIconOnTopWhenAligned() {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2022-03-07 12:49:56 -08:00
|
|
|
@CallSuper
|
|
|
|
|
protected void dumpLogs(String prefix, PrintWriter pw) {
|
|
|
|
|
pw.println(String.format(
|
|
|
|
|
"%sTaskbarUIController: using an instance of %s",
|
|
|
|
|
prefix,
|
|
|
|
|
getClass().getSimpleName()));
|
|
|
|
|
}
|
2022-11-02 22:24:33 -07:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Returns RecentsView. Overwritten in LauncherTaskbarUIController and
|
|
|
|
|
* FallbackTaskbarUIController with Launcher-specific implementations. Returns null for other
|
|
|
|
|
* UI controllers (like DesktopTaskbarUIController) that don't have a RecentsView.
|
|
|
|
|
*/
|
|
|
|
|
public @Nullable RecentsView getRecentsView() {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2023-01-12 18:50:36 -08:00
|
|
|
public void startSplitSelection(SplitConfigurationOptions.SplitSelectSource splitSelectSource) {
|
|
|
|
|
RecentsView recentsView = getRecentsView();
|
|
|
|
|
if (recentsView == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
recentsView.findLastActiveTaskAndRunCallback(
|
|
|
|
|
splitSelectSource.intent.getComponent(),
|
|
|
|
|
(Consumer<Task>) foundTask -> {
|
|
|
|
|
splitSelectSource.alreadyRunningTaskId = foundTask == null
|
|
|
|
|
? INVALID_TASK_ID
|
|
|
|
|
: foundTask.key.id;
|
|
|
|
|
splitSelectSource.animateCurrentTaskDismissal = foundTask != null;
|
|
|
|
|
recentsView.initiateSplitSelect(splitSelectSource);
|
|
|
|
|
}
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2022-11-02 22:24:33 -07:00
|
|
|
/**
|
|
|
|
|
* Uses the clicked Taskbar icon to launch a second app for splitscreen.
|
|
|
|
|
*/
|
|
|
|
|
public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) {
|
|
|
|
|
RecentsView recents = getRecentsView();
|
2023-01-06 16:33:51 -08:00
|
|
|
recents.findLastActiveTaskAndRunCallback(
|
2022-12-02 17:38:08 -08:00
|
|
|
info.getTargetComponent(),
|
|
|
|
|
(Consumer<Task>) foundTask -> {
|
|
|
|
|
if (foundTask != null) {
|
|
|
|
|
TaskView foundTaskView = recents.getTaskViewByTaskId(foundTask.key.id);
|
2023-01-31 10:54:19 +08:00
|
|
|
// TODO (b/266482558): This additional null check is needed because there
|
|
|
|
|
// are times when our Tasks list doesn't match our TaskViews list (like when
|
|
|
|
|
// a tile is removed during {@link RecentsView#applyLoadPlan()}. A clearer
|
|
|
|
|
// state management system is in the works so that we don't need to rely on
|
|
|
|
|
// null checks as much. See comments at ag/21152798.
|
|
|
|
|
if (foundTaskView != null) {
|
|
|
|
|
// There is already a running app of this type, use that as second app.
|
2023-02-01 15:22:23 +08:00
|
|
|
// Get index of task (0 or 1), in case it's a GroupedTaskView
|
|
|
|
|
TaskIdAttributeContainer taskAttributes =
|
2023-02-02 11:20:08 +08:00
|
|
|
foundTaskView.getTaskAttributesById(foundTask.key.id);
|
2023-01-31 10:54:19 +08:00
|
|
|
recents.confirmSplitSelect(
|
|
|
|
|
foundTaskView,
|
2023-02-02 11:20:08 +08:00
|
|
|
foundTask,
|
2023-02-01 15:22:23 +08:00
|
|
|
taskAttributes.getIconView().getDrawable(),
|
|
|
|
|
taskAttributes.getThumbnailView(),
|
|
|
|
|
taskAttributes.getThumbnailView().getThumbnail(),
|
2023-01-31 10:54:19 +08:00
|
|
|
null /* intent */);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2022-12-02 17:38:08 -08:00
|
|
|
}
|
2023-01-31 10:54:19 +08:00
|
|
|
|
|
|
|
|
// No running app of that type, create a new instance as second app.
|
|
|
|
|
recents.confirmSplitSelect(
|
|
|
|
|
null /* containerTaskView */,
|
|
|
|
|
null /* task */,
|
|
|
|
|
new BitmapDrawable(info.bitmap.icon),
|
|
|
|
|
startingView,
|
|
|
|
|
null /* thumbnail */,
|
|
|
|
|
intent);
|
2022-12-02 17:38:08 -08:00
|
|
|
}
|
|
|
|
|
);
|
2022-11-02 22:24:33 -07:00
|
|
|
}
|
2021-05-20 20:18:47 +00:00
|
|
|
}
|