Update desktop mode to identify minimized tasks

When a task is minimised, it becomes invisible but is still running.
WMShell now signals to the launcher when a task's visibility changes.
The task bar takes the visibility into account to know if a running task
is, in fact, minimised.

Test: atest NexusLauncherTests:DesktopTaskbarRunningAppsControllerTest
Flag: com.android.window.flags.enable_desktop_windowing_taskbar_running_apps
Bug: 333872717
Change-Id: Iaff6b1240d354bb3c4de8e4884948acf9bf40112
This commit is contained in:
Pierre Barbier de Reuille
2024-05-17 13:24:22 +01:00
parent 656f0e8d13
commit f60dd5471c
8 changed files with 145 additions and 38 deletions

View File

@@ -186,9 +186,20 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
// These fields, related to showing running apps, are only used for Taskbar.
private final Size mRunningAppIndicatorSize;
private final int mRunningAppIndicatorTopMargin;
private final Size mMinimizedAppIndicatorSize;
private final int mMinimizedAppIndicatorTopMargin;
private final Paint mRunningAppIndicatorPaint;
private final Rect mRunningAppIconBounds = new Rect();
private boolean mIsRunning;
private RunningAppState mRunningAppState;
/**
* Various options for the running state of an app.
*/
public enum RunningAppState {
NOT_RUNNING,
RUNNING,
MINIMIZED,
}
@ViewDebug.ExportedProperty(category = "launcher")
private boolean mStayPressed;
@@ -259,9 +270,16 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
mRunningAppIndicatorSize = new Size(
getResources().getDimensionPixelSize(R.dimen.taskbar_running_app_indicator_width),
getResources().getDimensionPixelSize(R.dimen.taskbar_running_app_indicator_height));
mMinimizedAppIndicatorSize = new Size(
getResources().getDimensionPixelSize(R.dimen.taskbar_minimized_app_indicator_width),
getResources().getDimensionPixelSize(
R.dimen.taskbar_minimized_app_indicator_height));
mRunningAppIndicatorTopMargin =
getResources().getDimensionPixelSize(
R.dimen.taskbar_running_app_indicator_top_margin);
mMinimizedAppIndicatorTopMargin =
getResources().getDimensionPixelSize(
R.dimen.taskbar_minimized_app_indicator_top_margin);
mRunningAppIndicatorPaint = new Paint();
mRunningAppIndicatorPaint.setColor(getResources().getColor(
R.color.taskbar_running_app_indicator_color, context.getTheme()));
@@ -414,8 +432,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
/** Updates whether the app this view represents is currently running. */
@UiThread
public void updateRunningState(boolean isRunning) {
mIsRunning = isRunning;
public void updateRunningState(RunningAppState runningAppState) {
mRunningAppState = runningAppState;
}
protected void setItemInfo(ItemInfoWithIcon itemInfo) {
@@ -667,18 +685,20 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver,
/** Draws a line under the app icon if this is representing a running app in Desktop Mode. */
protected void drawRunningAppIndicatorIfNecessary(Canvas canvas) {
if (!mIsRunning || mDisplay != DISPLAY_TASKBAR) {
if (mRunningAppState == RunningAppState.NOT_RUNNING || mDisplay != DISPLAY_TASKBAR) {
return;
}
getIconBounds(mRunningAppIconBounds);
// TODO(b/333872717): update color, shape, and size of indicator
int indicatorTop = mRunningAppIconBounds.bottom + mRunningAppIndicatorTopMargin;
canvas.drawRect(
mRunningAppIconBounds.centerX() - mRunningAppIndicatorSize.getWidth() / 2,
indicatorTop,
mRunningAppIconBounds.centerX() + mRunningAppIndicatorSize.getWidth() / 2,
indicatorTop + mRunningAppIndicatorSize.getHeight(),
mRunningAppIndicatorPaint);
boolean isMinimized = mRunningAppState == RunningAppState.MINIMIZED;
int indicatorTop =
mRunningAppIconBounds.bottom + (isMinimized ? mMinimizedAppIndicatorTopMargin
: mRunningAppIndicatorTopMargin);
final Size indicatorSize =
isMinimized ? mMinimizedAppIndicatorSize : mRunningAppIndicatorSize;
canvas.drawRect(mRunningAppIconBounds.centerX() - indicatorSize.getWidth() / 2,
indicatorTop, mRunningAppIconBounds.centerX() + indicatorSize.getWidth() / 2,
indicatorTop + indicatorSize.getHeight(), mRunningAppIndicatorPaint);
}
@Override