Merge "Fixing model thread priority getting set to background while loading" into main
diff --git a/quickstep/res/layout/task_thumbnail_view_header.xml b/quickstep/res/layout/task_thumbnail_view_header.xml
index ecc1559..70e4a42 100644
--- a/quickstep/res/layout/task_thumbnail_view_header.xml
+++ b/quickstep/res/layout/task_thumbnail_view_header.xml
@@ -18,6 +18,7 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
+ android:id="@+id/task_thumbnail_view_header"
android:background="@drawable/task_thumbnail_header_bg">
<androidx.constraintlayout.widget.ConstraintLayout
@@ -61,6 +62,7 @@
android:layout_marginStart="@dimen/task_thumbnail_header_margin_between_views"
android:src="@drawable/task_header_close_button"
android:tint="@android:color/darker_gray"
+ android:background="@null"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
diff --git a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.kt b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.kt
index 6ee43ff..138f40a 100644
--- a/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.kt
+++ b/quickstep/src/com/android/launcher3/statehandlers/DesktopVisibilityController.kt
@@ -152,6 +152,20 @@
}
}
+ /**
+ * Returns the ID of the active desk (if any) on the display whose ID is [displayId], or
+ * [INACTIVE_DESK_ID] if no desk is currently active or the multiple desks feature is disabled.
+ */
+ fun getActiveDeskId(displayId: Int): Int {
+ if (!DesktopModeStatus.enableMultipleDesktops(context)) {
+ // When the multiple desks feature is disabled, callers should not rely on the concept
+ // of a desk ID.
+ return INACTIVE_DESK_ID
+ }
+
+ return getDisplayDeskConfig(displayId)?.activeDeskId ?: INACTIVE_DESK_ID
+ }
+
/** Returns whether a desk is currently active on the display with the given [displayId]. */
fun isInDesktopMode(displayId: Int): Boolean {
if (!DesktopModeStatus.enableMultipleDesktops(context)) {
@@ -615,6 +629,6 @@
private const val TAG = "DesktopVisController"
private const val DEBUG = false
- private const val INACTIVE_DESK_ID = -1
+ public const val INACTIVE_DESK_ID = -1
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
index bf5c0c8..f80dc90 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
@@ -197,8 +197,7 @@
final boolean isLeftRightSplit = !splitBounds.appsStackedVertically;
- final float leftOrTopTaskPercent = isLeftRightSplit
- ? splitBounds.leftTaskPercent : splitBounds.topTaskPercent;
+ final float leftOrTopTaskPercent = splitBounds.getLeftTopTaskPercent();
ConstraintLayout.LayoutParams leftTopParams = (ConstraintLayout.LayoutParams)
mThumbnailView1.getLayoutParams();
diff --git a/quickstep/src/com/android/quickstep/RecentTasksList.java b/quickstep/src/com/android/quickstep/RecentTasksList.java
index 561bab4..2c4c2f9 100644
--- a/quickstep/src/com/android/quickstep/RecentTasksList.java
+++ b/quickstep/src/com/android/quickstep/RecentTasksList.java
@@ -32,10 +32,12 @@
import android.os.Process;
import android.os.RemoteException;
import android.util.SparseBooleanArray;
+import android.window.DesktopExperienceFlags;
import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
+import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.util.LooperExecutor;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.util.DesktopTask;
@@ -354,8 +356,8 @@
int numVisibleTasks = 0;
for (GroupedTaskInfo rawTask : rawTasks) {
if (rawTask.isBaseType(TYPE_DESK)) {
- // TYPE_FREEFORM tasks is only created when desktop mode can be entered,
- // leftover TYPE_FREEFORM tasks created when flag was on should be ignored.
+ // TYPE_DESK tasks is only created when desktop mode can be entered,
+ // leftover TYPE_DESK tasks created when flag was on should be ignored.
if (DesktopModeStatus.canEnterDesktopMode(mContext)) {
List<DesktopTask> desktopTasks = createDesktopTasks(
rawTask.getBaseGroupedTask());
@@ -442,7 +444,11 @@
Set<Integer> minimizedTaskIds = minimizedTaskIdArray != null
? CollectionsKt.toSet(ArraysKt.asIterable(minimizedTaskIdArray))
: Collections.emptySet();
- if (enableSeparateExternalDisplayTasks()) {
+ if (enableSeparateExternalDisplayTasks()
+ && !DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()) {
+ // This code is not needed when the multiple desktop feature is enabled, since Shell
+ // will send a single `GroupedTaskInfo` for each desk with a unique `deskId` across
+ // all displays.
Map<Integer, List<Task>> perDisplayTasks = new HashMap<>();
for (TaskInfo taskInfo : recentTaskInfo.getTaskInfoList()) {
Task task = createTask(taskInfo, minimizedTaskIds);
@@ -450,11 +456,16 @@
k -> new ArrayList<>());
tasks.add(task);
}
- return MapsKt.map(perDisplayTasks, it -> new DesktopTask(it.getValue()));
+ // When the multiple desktop feature is disabled, there can only be up to a single desk
+ // on each display, The desk ID doesn't matter and should not be used.
+ return MapsKt.map(perDisplayTasks,
+ it -> new DesktopTask(DesktopVisibilityController.INACTIVE_DESK_ID,
+ it.getValue()));
} else {
+ final int deskId = recentTaskInfo.getDeskId();
List<Task> tasks = CollectionsKt.map(recentTaskInfo.getTaskInfoList(),
it -> createTask(it, minimizedTaskIds));
- return List.of(new DesktopTask(tasks));
+ return List.of(new DesktopTask(deskId, tasks));
}
}
diff --git a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
index a69d472..f92581e 100644
--- a/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
+++ b/quickstep/src/com/android/quickstep/TaskShortcutFactory.java
@@ -312,7 +312,7 @@
RecentsView<?, ?> recentsView = taskView.getRecentsView();
if (recentsView != null) {
dismissTaskMenuView();
- recentsView.dismissTask(taskView, true, true);
+ recentsView.dismissTaskView(taskView, true, true);
mTarget.getStatsLogManager().logger().withItemInfo(mTaskContainer.getItemInfo())
.log(LAUNCHER_SYSTEM_SHORTCUT_CLOSE_APP_TAP);
}
diff --git a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt
index e72ccbf..59ea8fa 100644
--- a/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt
+++ b/quickstep/src/com/android/quickstep/orientation/LandscapePagedViewHandler.kt
@@ -285,11 +285,7 @@
translationY = snapshotParams.topMargin.toFloat()
} else {
val topLeftTaskPlusDividerPercent =
- if (splitBounds.appsStackedVertically) {
- splitBounds.topTaskPercent + splitBounds.dividerHeightPercent
- } else {
- splitBounds.leftTaskPercent + splitBounds.dividerWidthPercent
- }
+ splitBounds.leftTopTaskPercent + splitBounds.dividerPercent
translationY =
snapshotParams.topMargin +
(taskViewHeight - snapshotParams.topMargin) * topLeftTaskPlusDividerPercent
@@ -440,15 +436,8 @@
splitInfo: SplitBounds,
desiredStagePosition: Int
) {
- val topLeftTaskPercent: Float
- val dividerBarPercent: Float
- if (splitInfo.appsStackedVertically) {
- topLeftTaskPercent = splitInfo.topTaskPercent
- dividerBarPercent = splitInfo.dividerHeightPercent
- } else {
- topLeftTaskPercent = splitInfo.leftTaskPercent
- dividerBarPercent = splitInfo.dividerWidthPercent
- }
+ val topLeftTaskPercent = splitInfo.leftTopTaskPercent
+ val dividerBarPercent = splitInfo.dividerPercent
if (desiredStagePosition == STAGE_POSITION_TOP_OR_LEFT) {
outRect.bottom = outRect.top + (outRect.height() * topLeftTaskPercent).toInt()
@@ -510,12 +499,7 @@
val totalThumbnailHeight = parentHeight - spaceAboveSnapshot
val dividerBar = getDividerBarSize(totalThumbnailHeight, splitBoundsConfig)
- val taskPercent =
- if (splitBoundsConfig.appsStackedVertically) {
- splitBoundsConfig.topTaskPercent
- } else {
- splitBoundsConfig.leftTaskPercent
- }
+ val taskPercent = splitBoundsConfig.leftTopTaskPercent
val firstTaskViewSize = Point(parentWidth, (totalThumbnailHeight * taskPercent).toInt())
val secondTaskViewSize =
Point(parentWidth, totalThumbnailHeight - firstTaskViewSize.y - dividerBar)
@@ -715,11 +699,7 @@
* @return The divider size for the group task view.
*/
protected fun getDividerBarSize(totalThumbnailHeight: Int, splitConfig: SplitBounds): Int {
- return Math.round(
- totalThumbnailHeight *
- if (splitConfig.appsStackedVertically) splitConfig.dividerHeightPercent
- else splitConfig.dividerWidthPercent
- )
+ return Math.round(totalThumbnailHeight * splitConfig.dividerPercent)
}
/**
diff --git a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
index c1e1c2b..d9ad7ce 100644
--- a/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
+++ b/quickstep/src/com/android/quickstep/orientation/PortraitPagedViewHandler.java
@@ -271,12 +271,8 @@
if (splitBounds != null) {
if (deviceProfile.isLeftRightSplit) {
if (desiredTaskId == splitBounds.rightBottomTaskId) {
- float leftTopTaskPercent = splitBounds.appsStackedVertically
- ? splitBounds.topTaskPercent
- : splitBounds.leftTaskPercent;
- float dividerThicknessPercent = splitBounds.appsStackedVertically
- ? splitBounds.dividerHeightPercent
- : splitBounds.dividerWidthPercent;
+ float leftTopTaskPercent = splitBounds.getLeftTopTaskPercent();
+ float dividerThicknessPercent = splitBounds.getDividerPercent();
translationX = ((taskViewWidth * leftTopTaskPercent)
+ (taskViewWidth * dividerThicknessPercent));
}
@@ -285,9 +281,9 @@
FrameLayout.LayoutParams snapshotParams =
(FrameLayout.LayoutParams) thumbnailViews[0]
.getLayoutParams();
- float bottomRightTaskPlusDividerPercent = splitBounds.appsStackedVertically
- ? (1f - splitBounds.topTaskPercent)
- : (1f - splitBounds.leftTaskPercent);
+ float bottomRightTaskPlusDividerPercent =
+ splitBounds.getRightBottomTaskPercent()
+ + splitBounds.getDividerPercent();
translationY = -((taskViewHeight - snapshotParams.topMargin)
* bottomRightTaskPlusDividerPercent);
}
@@ -506,12 +502,8 @@
@Override
public void setSplitTaskSwipeRect(DeviceProfile dp, Rect outRect,
SplitBounds splitInfo, int desiredStagePosition) {
- float topLeftTaskPercent = splitInfo.appsStackedVertically
- ? splitInfo.topTaskPercent
- : splitInfo.leftTaskPercent;
- float dividerBarPercent = splitInfo.appsStackedVertically
- ? splitInfo.dividerHeightPercent
- : splitInfo.dividerWidthPercent;
+ float topLeftTaskPercent = splitInfo.getLeftTopTaskPercent();
+ float dividerBarPercent = splitInfo.getDividerPercent();
int taskbarHeight = dp.isTransientTaskbar ? 0 : dp.taskbarHeight;
float scale = (float) outRect.height() / (dp.availableHeightPx - taskbarHeight);
@@ -559,9 +551,7 @@
primaryParams.topMargin = spaceAboveSnapshot;
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
- float dividerScale = splitBoundsConfig.appsStackedVertically
- ? splitBoundsConfig.dividerHeightPercent
- : splitBoundsConfig.dividerWidthPercent;
+ float dividerScale = splitBoundsConfig.getDividerPercent();
Pair<Point, Point> taskViewSizes =
getGroupedTaskViewSizes(dp, splitBoundsConfig, parentWidth, parentHeight);
if (!inSplitSelection) {
@@ -610,12 +600,8 @@
int parentHeight) {
int spaceAboveSnapshot = dp.overviewTaskThumbnailTopMarginPx;
int totalThumbnailHeight = parentHeight - spaceAboveSnapshot;
- float dividerScale = splitBoundsConfig.appsStackedVertically
- ? splitBoundsConfig.dividerHeightPercent
- : splitBoundsConfig.dividerWidthPercent;
- float taskPercent = splitBoundsConfig.appsStackedVertically
- ? splitBoundsConfig.topTaskPercent
- : splitBoundsConfig.leftTaskPercent;
+ float dividerScale = splitBoundsConfig.getDividerPercent();
+ float taskPercent = splitBoundsConfig.getLeftTopTaskPercent();
Point firstTaskViewSize = new Point();
Point secondTaskViewSize = new Point();
diff --git a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt
index 3fb4f54..9bfa2bf 100644
--- a/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt
+++ b/quickstep/src/com/android/quickstep/orientation/SeascapePagedViewHandler.kt
@@ -106,15 +106,8 @@
splitInfo: SplitBounds,
desiredStagePosition: Int
) {
- val topLeftTaskPercent: Float
- val dividerBarPercent: Float
- if (splitInfo.appsStackedVertically) {
- topLeftTaskPercent = splitInfo.topTaskPercent
- dividerBarPercent = splitInfo.dividerHeightPercent
- } else {
- topLeftTaskPercent = splitInfo.leftTaskPercent
- dividerBarPercent = splitInfo.dividerWidthPercent
- }
+ val topLeftTaskPercent = splitInfo.leftTopTaskPercent
+ val dividerBarPercent = splitInfo.dividerPercent
// In seascape, the primary thumbnail is counterintuitively placed at the physical bottom of
// the screen. This is to preserve consistency when the user rotates: From the user's POV,
@@ -166,11 +159,7 @@
} else {
if (desiredTaskId == splitBounds.leftTopTaskId) {
val bottomRightTaskPlusDividerPercent =
- if (splitBounds.appsStackedVertically) {
- 1f - splitBounds.topTaskPercent
- } else {
- 1f - splitBounds.leftTaskPercent
- }
+ splitBounds.rightBottomTaskPercent + splitBounds.dividerPercent
translationY =
banner.height -
(taskViewHeight - snapshotParams.topMargin) *
@@ -331,12 +320,7 @@
val totalThumbnailHeight = parentHeight - spaceAboveSnapshot
val dividerBar = getDividerBarSize(totalThumbnailHeight, splitBoundsConfig)
- val taskPercent =
- if (splitBoundsConfig.appsStackedVertically) {
- splitBoundsConfig.topTaskPercent
- } else {
- splitBoundsConfig.leftTaskPercent
- }
+ val taskPercent = splitBoundsConfig.leftTopTaskPercent
val firstTaskViewSize = Point(parentWidth, (totalThumbnailHeight * taskPercent).toInt())
val secondTaskViewSize =
Point(parentWidth, totalThumbnailHeight - firstTaskViewSize.y - dividerBar)
diff --git a/quickstep/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapper.kt b/quickstep/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapper.kt
index fb62268..619075f 100644
--- a/quickstep/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapper.kt
+++ b/quickstep/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapper.kt
@@ -16,6 +16,7 @@
package com.android.quickstep.recents.ui.mapper
+import android.view.View.OnClickListener
import com.android.quickstep.recents.ui.viewmodel.TaskData
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState
import com.android.quickstep.task.thumbnail.TaskThumbnailUiState.BackgroundOnly
@@ -36,29 +37,38 @@
* @param taskData The [TaskData] to convert. Can be null or a specific subclass.
* @param isLiveTile A flag indicating whether the task data represents live tile.
* @param hasHeader A flag indicating whether the UI should display a header.
+ * @param clickCloseListener A callback when the close button in the UI is clicked.
* @return A [TaskThumbnailUiState] representing the UI state for the given task data.
*/
fun toTaskThumbnailUiState(
taskData: TaskData?,
isLiveTile: Boolean,
hasHeader: Boolean,
+ clickCloseListener: OnClickListener?,
): TaskThumbnailUiState =
when {
taskData !is TaskData.Data -> Uninitialized
- isLiveTile -> createLiveTileState(taskData, hasHeader)
+ isLiveTile -> createLiveTileState(taskData, hasHeader, clickCloseListener)
isBackgroundOnly(taskData) -> BackgroundOnly(taskData.backgroundColor)
isSnapshotSplash(taskData) ->
- SnapshotSplash(createSnapshotState(taskData, hasHeader), taskData.icon)
+ SnapshotSplash(
+ createSnapshotState(taskData, hasHeader, clickCloseListener),
+ taskData.icon,
+ )
else -> Uninitialized
}
- private fun createSnapshotState(taskData: TaskData.Data, hasHeader: Boolean): Snapshot =
- if (canHeaderBeCreated(taskData, hasHeader)) {
+ private fun createSnapshotState(
+ taskData: TaskData.Data,
+ hasHeader: Boolean,
+ clickCloseListener: OnClickListener?,
+ ): Snapshot =
+ if (canHeaderBeCreated(taskData, hasHeader, clickCloseListener)) {
Snapshot.WithHeader(
taskData.thumbnailData?.thumbnail!!,
taskData.thumbnailData.rotation,
taskData.backgroundColor,
- ThumbnailHeader(taskData.icon!!, taskData.titleDescription!!),
+ ThumbnailHeader(taskData.icon!!, taskData.titleDescription!!, clickCloseListener!!),
)
} else {
Snapshot.WithoutHeader(
@@ -74,13 +84,26 @@
private fun isSnapshotSplash(taskData: TaskData.Data) =
taskData.thumbnailData?.thumbnail != null && !taskData.isLocked
- private fun canHeaderBeCreated(taskData: TaskData.Data, hasHeader: Boolean) =
- hasHeader && taskData.icon != null && taskData.titleDescription != null
+ private fun canHeaderBeCreated(
+ taskData: TaskData.Data,
+ hasHeader: Boolean,
+ clickCloseListener: OnClickListener?,
+ ) =
+ hasHeader &&
+ taskData.icon != null &&
+ taskData.titleDescription != null &&
+ clickCloseListener != null
- private fun createLiveTileState(taskData: TaskData.Data, hasHeader: Boolean) =
- if (canHeaderBeCreated(taskData, hasHeader)) {
+ private fun createLiveTileState(
+ taskData: TaskData.Data,
+ hasHeader: Boolean,
+ clickCloseListener: OnClickListener?,
+ ) =
+ if (canHeaderBeCreated(taskData, hasHeader, clickCloseListener)) {
// TODO(http://b/353965691): figure out what to do when `icon` or `titleDescription` is
// null.
- LiveTile.WithHeader(ThumbnailHeader(taskData.icon!!, taskData.titleDescription!!))
+ LiveTile.WithHeader(
+ ThumbnailHeader(taskData.icon!!, taskData.titleDescription!!, clickCloseListener!!)
+ )
} else LiveTile.WithoutHeader
}
diff --git a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailUiState.kt b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailUiState.kt
index 6118544..db593d3 100644
--- a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailUiState.kt
+++ b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailUiState.kt
@@ -19,6 +19,7 @@
import android.graphics.Bitmap
import android.graphics.drawable.Drawable
import android.view.Surface
+import android.view.View.OnClickListener
import androidx.annotation.ColorInt
sealed class TaskThumbnailUiState {
@@ -54,5 +55,9 @@
) : Snapshot()
}
- data class ThumbnailHeader(val icon: Drawable, val title: String)
+ data class ThumbnailHeader(
+ val icon: Drawable,
+ val title: String,
+ val clickCloseListener: OnClickListener,
+ )
}
diff --git a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailView.kt b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailView.kt
index e91073a..0edbacc 100644
--- a/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailView.kt
+++ b/quickstep/src/com/android/quickstep/task/thumbnail/TaskThumbnailView.kt
@@ -181,8 +181,10 @@
private fun resetViews() {
liveTileView.isInvisible = true
thumbnailView.isInvisible = true
+ thumbnailView.setImageBitmap(null)
splashBackground.alpha = 0f
splashIcon.alpha = 0f
+ splashIcon.setImageDrawable(null)
scrimView.alpha = 0f
setBackgroundColor(Color.BLACK)
taskThumbnailViewHeader?.isInvisible = true
diff --git a/quickstep/src/com/android/quickstep/util/DesktopTask.kt b/quickstep/src/com/android/quickstep/util/DesktopTask.kt
index 53ea022..fbe3bc6 100644
--- a/quickstep/src/com/android/quickstep/util/DesktopTask.kt
+++ b/quickstep/src/com/android/quickstep/util/DesktopTask.kt
@@ -20,17 +20,19 @@
/**
* A [Task] container that can contain N number of tasks that are part of the desktop in recent
- * tasks list. Note that desktops can be empty with no tasks in them.
+ * tasks list. Note that desktops can be empty with no tasks in them. The [deskId] makes sense only
+ * when the multiple desks feature is enabled.
*/
-class DesktopTask(tasks: List<Task>) : GroupTask(tasks, TaskViewType.DESKTOP) {
+class DesktopTask(val deskId: Int, tasks: List<Task>) : GroupTask(tasks, TaskViewType.DESKTOP) {
- override fun copy() = DesktopTask(tasks)
+ override fun copy() = DesktopTask(deskId, tasks)
- override fun toString() = "type=$taskViewType tasks=$tasks"
+ override fun toString() = "type=$taskViewType deskId=$deskId tasks=$tasks"
override fun equals(o: Any?): Boolean {
if (this === o) return true
if (o !is DesktopTask) return false
+ if (deskId != o.deskId) return false
return super.equals(o)
}
}
diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
index 9bb8f3d..75f3b69 100644
--- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt
@@ -345,14 +345,7 @@
explodeProgress = 0.0f
viewModel = null
visibility = VISIBLE
- taskContainers.forEach {
- contentView.removeView(it.snapshotView)
- if (enableRefactorTaskThumbnail()) {
- taskThumbnailViewPool!!.recycle(it.thumbnailView)
- } else {
- taskThumbnailViewDeprecatedPool!!.recycle(it.thumbnailViewDeprecated)
- }
- }
+ taskContainers.forEach { removeAndRecycleThumbnailView(it) }
}
@SuppressLint("RtlHardcoded")
@@ -360,19 +353,7 @@
super.updateTaskSize(lastComputedTaskSize, lastComputedGridTaskSize)
this.lastComputedTaskSize.set(lastComputedTaskSize)
- BaseContainerInterface.getTaskDimension(mContext, container.deviceProfile, tempPointF)
- val desktopSize = Size(tempPointF.x.toInt(), tempPointF.y.toInt())
- DEFAULT_BOUNDS.set(0, 0, desktopSize.width / 4, desktopSize.height / 4)
-
- fullscreenTaskPositions =
- taskContainers.map {
- DesktopTaskBoundsData(it.task.key.id, it.task.appBounds ?: DEFAULT_BOUNDS)
- }
-
- if (enableDesktopExplodedView()) {
- viewModel?.organizeDesktopTasks(desktopSize, fullscreenTaskPositions)
- }
- positionTaskWindows()
+ updateTaskPositions()
}
override fun onTaskListVisibilityChanged(visible: Boolean, changes: Int) {
@@ -458,6 +439,56 @@
ViewUtils.addAccessibleChildToList(backgroundView, outChildren)
}
+ fun removeTaskFromExplodedView(taskId: Int, animate: Boolean) {
+ if (!enableDesktopExplodedView()) {
+ Log.e(
+ TAG,
+ "removeTaskFromExplodedView called when enableDesktopExplodedView flag is false",
+ )
+ return
+ }
+
+ // Remove the task's [taskContainer] and its associated Views.
+ val taskContainer = getTaskContainerById(taskId) ?: return
+ removeAndRecycleThumbnailView(taskContainer)
+ taskContainer.destroy()
+ taskContainers = taskContainers.filterNot { it == taskContainer }
+
+ // Dismiss the current DesktopTaskView if all its windows are closed.
+ if (taskContainers.isEmpty()) {
+ recentsView?.dismissTaskView(this, animate, /* removeTask= */ true)
+ } else {
+ // Otherwise, re-position the remaining task windows.
+ // TODO(b/353949276): Implement the re-layout animations.
+ updateTaskPositions()
+ }
+ }
+
+ private fun removeAndRecycleThumbnailView(taskContainer: TaskContainer) {
+ contentView.removeView(taskContainer.snapshotView)
+ if (enableRefactorTaskThumbnail()) {
+ taskThumbnailViewPool!!.recycle(taskContainer.thumbnailView)
+ } else {
+ taskThumbnailViewDeprecatedPool!!.recycle(taskContainer.thumbnailViewDeprecated)
+ }
+ }
+
+ private fun updateTaskPositions() {
+ BaseContainerInterface.getTaskDimension(mContext, container.deviceProfile, tempPointF)
+ val desktopSize = Size(tempPointF.x.toInt(), tempPointF.y.toInt())
+ DEFAULT_BOUNDS.set(0, 0, desktopSize.width / 4, desktopSize.height / 4)
+
+ fullscreenTaskPositions =
+ taskContainers.map {
+ DesktopTaskBoundsData(it.task.key.id, it.task.appBounds ?: DEFAULT_BOUNDS)
+ }
+
+ if (enableDesktopExplodedView()) {
+ viewModel?.organizeDesktopTasks(desktopSize, fullscreenTaskPositions)
+ }
+ positionTaskWindows()
+ }
+
companion object {
private const val TAG = "DesktopTaskView"
private const val DEBUG = false
diff --git a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
index c07b7fb..5c4a35d 100644
--- a/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
+++ b/quickstep/src/com/android/quickstep/views/DigitalWellBeingToast.kt
@@ -189,11 +189,11 @@
SplitBannerConfig.SPLIT_GRID_BANNER_LARGE
// For landscape grid, for 30% width we only show icon, otherwise show icon and time
task.key.id == splitBounds.leftTopTaskId ->
- if (splitBounds.leftTaskPercent < THRESHOLD_LEFT_ICON_ONLY)
+ if (splitBounds.leftTopTaskPercent < THRESHOLD_LEFT_ICON_ONLY)
SplitBannerConfig.SPLIT_GRID_BANNER_SMALL
else SplitBannerConfig.SPLIT_GRID_BANNER_LARGE
else ->
- if (splitBounds.leftTaskPercent > THRESHOLD_RIGHT_ICON_ONLY)
+ if (splitBounds.leftTopTaskPercent > THRESHOLD_RIGHT_ICON_ONLY)
SplitBannerConfig.SPLIT_GRID_BANNER_SMALL
else SplitBannerConfig.SPLIT_GRID_BANNER_LARGE
}
diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
index 2abfb13..25011d7 100644
--- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt
@@ -189,16 +189,12 @@
val inSplitSelection = getThisTaskCurrentlyInSplitSelection() != INVALID_TASK_ID
if (enableFlexibleTwoAppSplit()) {
- val topLeftTaskPercent =
- if (deviceProfile.isLeftRightSplit) splitBoundsConfig.leftTaskPercent
- else splitBoundsConfig.topTaskPercent
- val bottomRightTaskPercent = 1 - topLeftTaskPercent
- leftTopTaskContainer.iconView.setFlexSplitAlpha(
- if (topLeftTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON) 0f else 1f
- )
- rightBottomTaskContainer.iconView.setFlexSplitAlpha(
- if (bottomRightTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON) 0f else 1f
- )
+ val topLeftTaskPercent = splitBoundsConfig.leftTopTaskPercent
+ val bottomRightTaskPercent = splitBoundsConfig.rightBottomTaskPercent
+ val hideTopLeftIcon = topLeftTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON
+ val hideBottomRightIcon = bottomRightTaskPercent < MINIMUM_RATIO_TO_SHOW_ICON
+ leftTopTaskContainer.iconView.setFlexSplitAlpha(if (hideTopLeftIcon) 0f else 1f)
+ rightBottomTaskContainer.iconView.setFlexSplitAlpha(if (hideBottomRightIcon) 0f else 1f)
}
if (enableOverviewIconMenu()) {
diff --git a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt
index 96eed87..3430b39 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt
+++ b/quickstep/src/com/android/quickstep/views/RecentsDismissUtils.kt
@@ -76,7 +76,7 @@
}
.addEndListener { _, _, _, _ ->
if (isDismissing) {
- recentsView.dismissTask(
+ recentsView.dismissTaskView(
draggedTaskView,
/* animateTaskView = */ false,
/* removeTask = */ true,
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 5a277b9..f53583a 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -676,11 +676,11 @@
MAIN_EXECUTOR,
apkRemoved -> {
if (apkRemoved) {
- dismissTask(taskId);
+ dismissTask(taskId, /*animate=*/true, /*removeTask=*/false);
} else {
mModel.isTaskRemoved(taskKey.id, taskRemoved -> {
if (taskRemoved) {
- dismissTask(taskId);
+ dismissTask(taskId, /*animate=*/true, /*removeTask=*/false);
}
}, RecentsFilterState.getFilter(mFilterState.getPackageNameToFilter()));
}
@@ -3048,8 +3048,12 @@
// Add an empty view for now until the task plan is loaded and applied
final TaskView taskView;
if (needDesktopTask) {
+ final int activeDeskId =
+ DesktopVisibilityController.INSTANCE.get(mContext).getActiveDeskId(
+ mContainer.getDisplay().getDisplayId());
taskView = getTaskViewFromPool(TaskViewType.DESKTOP);
- ((DesktopTaskView) taskView).bind(new DesktopTask(Arrays.asList(runningTasks)),
+ ((DesktopTaskView) taskView).bind(
+ new DesktopTask(activeDeskId, Arrays.asList(runningTasks)),
mOrientationState, mTaskOverlayFactory);
} else if (needGroupTaskView) {
taskView = getTaskViewFromPool(TaskViewType.GROUPED);
@@ -4627,17 +4631,27 @@
}
@UiThread
- private void dismissTask(int taskId) {
+ public void dismissTask(int taskId, boolean animate, boolean removeTask) {
TaskView taskView = getTaskViewByTaskId(taskId);
if (taskView == null) {
Log.d(TAG, "dismissTask: " + taskId + ", no associated TaskView");
return;
}
Log.d(TAG, "dismissTask: " + taskId);
- dismissTask(taskView, true /* animate */, false /* removeTask */);
+
+ if (enableDesktopExplodedView() && taskView instanceof DesktopTaskView desktopTaskView) {
+ desktopTaskView.removeTaskFromExplodedView(taskId, animate);
+
+ if (removeTask) {
+ ActivityManagerWrapper.getInstance().removeTask(taskId);
+ }
+ } else {
+ dismissTaskView(taskView, animate, removeTask);
+ }
}
- public void dismissTask(TaskView taskView, boolean animateTaskView, boolean removeTask) {
+ /** Dismisses the entire [taskView]. */
+ public void dismissTaskView(TaskView taskView, boolean animateTaskView, boolean removeTask) {
PendingAnimation pa = new PendingAnimation(DISMISS_TASK_DURATION);
createTaskDismissAnimation(pa, taskView, animateTaskView, removeTask, DISMISS_TASK_DURATION,
false /* dismissingForSplitSelection*/);
@@ -4653,7 +4667,7 @@
private void dismissCurrentTask() {
TaskView taskView = getNextPageTaskView();
if (taskView != null) {
- dismissTask(taskView, true /*animateTaskView*/, true /*removeTask*/);
+ dismissTaskView(taskView, true /*animateTaskView*/, true /*removeTask*/);
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskContainer.kt b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
index 7301cfc..2b9d036 100644
--- a/quickstep/src/com/android/quickstep/views/TaskContainer.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskContainer.kt
@@ -19,6 +19,7 @@
import android.graphics.Bitmap
import android.graphics.Matrix
import android.view.View
+import android.view.View.OnClickListener
import com.android.launcher3.Flags.enableRefactorTaskThumbnail
import com.android.launcher3.model.data.TaskViewItemInfo
import com.android.launcher3.util.SplitConfigurationOptions
@@ -108,6 +109,8 @@
overlay.destroy()
if (enableRefactorTaskThumbnail()) {
isThumbnailValid = false
+ thumbnailData = null
+ thumbnailView.onRecycle()
} else {
thumbnailViewDeprecated.setShowSplashForSplitSelection(false)
}
@@ -127,9 +130,19 @@
overlay.addChildForAccessibility(outChildren)
}
- fun setState(state: TaskData?, liveTile: Boolean, hasHeader: Boolean) {
+ fun setState(
+ state: TaskData?,
+ liveTile: Boolean,
+ hasHeader: Boolean,
+ clickCloseListener: OnClickListener?,
+ ) {
thumbnailView.setState(
- TaskUiStateMapper.toTaskThumbnailUiState(state, liveTile, hasHeader),
+ TaskUiStateMapper.toTaskThumbnailUiState(
+ state,
+ liveTile,
+ hasHeader,
+ clickCloseListener,
+ ),
state?.taskId,
)
thumbnailData = if (state is TaskData.Data) state.thumbnailData else null
diff --git a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewHeader.kt b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewHeader.kt
index 9eb294a..9a8805b 100644
--- a/quickstep/src/com/android/quickstep/views/TaskThumbnailViewHeader.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskThumbnailViewHeader.kt
@@ -19,6 +19,7 @@
import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout
+import android.widget.ImageButton
import android.widget.ImageView
import android.widget.TextView
import com.android.launcher3.R
@@ -30,9 +31,11 @@
private val headerTitleView: TextView by lazy { findViewById(R.id.header_app_title) }
private val headerIconView: ImageView by lazy { findViewById(R.id.header_app_icon) }
+ private val headerCloseButton: ImageButton by lazy { findViewById(R.id.header_close_button) }
fun setHeader(header: ThumbnailHeader) {
headerTitleView.setText(header.title)
headerIconView.setImageDrawable(header.icon)
+ headerCloseButton.setOnClickListener(header.clickCloseListener)
}
}
diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt
index ba54232..0e5382a 100644
--- a/quickstep/src/com/android/quickstep/views/TaskView.kt
+++ b/quickstep/src/com/android/quickstep/views/TaskView.kt
@@ -44,6 +44,7 @@
import androidx.core.view.updateLayoutParams
import com.android.app.animation.Interpolators
import com.android.launcher3.Flags.enableCursorHoverStates
+import com.android.launcher3.Flags.enableDesktopExplodedView
import com.android.launcher3.Flags.enableGridOnlyOverview
import com.android.launcher3.Flags.enableHoverOfChildElementsInTaskview
import com.android.launcher3.Flags.enableLargeDesktopWindowingTile
@@ -768,11 +769,27 @@
// Updating containers
val mapOfTasks = state.tasks.associateBy { it.taskId }
taskContainers.forEach { container ->
- val containerState = mapOfTasks[container.task.key.id]
+ val taskId = container.task.key.id
+ val containerState = mapOfTasks[taskId]
+ val shouldHaveHeader = (type == TaskViewType.DESKTOP) && enableDesktopExplodedView()
container.setState(
state = containerState,
liveTile = state.isLiveTile,
- hasHeader = state.hasHeader,
+ hasHeader = shouldHaveHeader,
+ clickCloseListener =
+ if (shouldHaveHeader) {
+ {
+ // Update the layout UI to remove this task from the layout grid, and
+ // remove the task from ActivityManager afterwards.
+ recentsView?.dismissTask(
+ taskId,
+ /* animate= */ true,
+ /* removeTask= */ true,
+ )
+ }
+ } else {
+ null
+ },
)
updateThumbnailValidity(container)
updateThumbnailMatrix(
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt
index bfd53ef..2cd09cc 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarOverflowTest.kt
@@ -332,7 +332,7 @@
(0..<tasksToAdd).map {
Task(Task.TaskKey(it, 0, Intent(), ComponentName("", ""), 0, 2000))
}
- recentsModel.updateRecentTasks(listOf(DesktopTask(tasks)))
+ recentsModel.updateRecentTasks(listOf(DesktopTask(deskId = 0, tasks)))
desktopTaskListener?.onTasksVisibilityChanged(
context.virtualDisplay.display.displayId,
tasksToAdd,
diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt
index c792783..002c988 100644
--- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarRecentAppsControllerTest.kt
@@ -877,7 +877,7 @@
val allTasks =
ArrayList<GroupTask>().apply {
if (!runningTasks.isEmpty()) {
- add(DesktopTask(ArrayList(runningTasks)))
+ add(DesktopTask(deskId = 0, ArrayList(runningTasks)))
}
addAll(recentTasks)
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
index de6920b..99a34ea 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/inputconsumers/NavHandleLongPressInputConsumerTest.java
@@ -28,6 +28,7 @@
import static com.android.launcher3.logging.StatsLogManager.LauncherLatencyEvent.LAUNCHER_LATENCY_CONTEXTUAL_SEARCH_LPNH_ABANDON;
import static com.android.launcher3.util.Executors.MAIN_EXECUTOR;
import static com.android.quickstep.DeviceConfigWrapper.DEFAULT_LPNH_TIMEOUT_MS;
+import static com.android.quickstep.inputconsumers.NavHandleLongPressInputConsumer.MIN_TIME_TO_LOG_ABANDON_MS;
import static com.google.common.truth.Truth.assertThat;
@@ -147,8 +148,7 @@
public void testDelegateDisallowsTouchInterceptAfterTouchDown() {
// Touch down and wait the minimum abandonment time.
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(NavHandleLongPressInputConsumer.MIN_TIME_TO_LOG_ABANDON_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(MIN_TIME_TO_LOG_ABANDON_MS);
// Delegate should still get touches unless long press is triggered.
verify(mDelegate).onMotionEvent(any());
@@ -173,8 +173,7 @@
@Test
public void testLongPressTriggered() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
assertTrue(mLongPressTriggered.get());
@@ -191,10 +190,8 @@
@Test
public void testLongPressTriggeredWithSlightVerticalMovement() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
- -(TOUCH_SLOP - 1)));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE, 1));
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
assertTrue(mLongPressTriggered.get());
@@ -207,10 +204,8 @@
@Test
public void testLongPressTriggeredWithSlightHorizontalMovement() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
- mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE, mScreenWidth / 2f + 1, 0));
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
assertTrue(mLongPressTriggered.get());
@@ -230,8 +225,7 @@
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
// We have entered the second stage, so the normal timeout shouldn't trigger.
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -241,9 +235,8 @@
// After an extended time, the long press should trigger.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
+ sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
assertTrue(mLongPressTriggered.get());
@@ -264,8 +257,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
// We have not entered the second stage, so the normal timeout should trigger.
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_ACTIVE);
assertTrue(mLongPressTriggered.get());
@@ -281,16 +273,14 @@
@Test
public void testLongPressAbortedByTouchUp() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(MIN_TIME_TO_LOG_ABANDON_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_UP));
// Wait past the long press timeout, to be extra sure it wouldn't have triggered.
- SystemClock.sleep(20);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -303,16 +293,14 @@
@Test
public void testLongPressAbortedByTouchCancel() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(MIN_TIME_TO_LOG_ABANDON_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_CANCEL));
// Wait past the long press timeout, to be extra sure it wouldn't have triggered.
- SystemClock.sleep(20);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -325,8 +313,7 @@
@Test
public void testLongPressAbortedByTouchSlopPassedVertically() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(MIN_TIME_TO_LOG_ABANDON_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -334,8 +321,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
-(TOUCH_SLOP + 1)));
// Wait past the long press timeout, to be extra sure it wouldn't have triggered.
- SystemClock.sleep(20);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -348,8 +334,7 @@
@Test
public void testLongPressAbortedByTouchSlopPassedHorizontally() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS - 10);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(MIN_TIME_TO_LOG_ABANDON_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -357,8 +342,7 @@
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP + 1), 0));
// Wait past the long press timeout, to be extra sure it wouldn't have triggered.
- SystemClock.sleep(20);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -379,8 +363,7 @@
mUnderTest.onMotionEvent(generateCenteredMotionEventWithYOffset(ACTION_MOVE,
-(TOUCH_SLOP - 1)));
// Normal duration shouldn't trigger.
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -391,9 +374,8 @@
// Wait past the extended long press timeout, to be sure it wouldn't have triggered.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
+ sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -418,8 +400,7 @@
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_MOVE,
mScreenWidth / 2f - (TOUCH_SLOP - 1), 0));
// Normal duration shouldn't trigger.
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -430,9 +411,8 @@
// Wait past the extended long press timeout, to be sure it wouldn't have triggered.
float extendedDurationMultiplier =
(DeviceConfigWrapper.get().getTwoStageDurationPercentage() / 100f);
- SystemClock.sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
+ sleep((long) (DEFAULT_LPNH_TIMEOUT_MS
* (extendedDurationMultiplier - 1))); // -1 because we already waited 1x
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
assertFalse(mLongPressTriggered.get());
@@ -450,8 +430,7 @@
public void testTouchOutsideNavHandleIgnored() {
// Touch the far left side of the screen. (y=0 is top of navbar region, picked arbitrarily)
mUnderTest.onMotionEvent(generateMotionEvent(ACTION_DOWN, 0, 0));
- SystemClock.sleep(DEFAULT_LPNH_TIMEOUT_MS);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(DEFAULT_LPNH_TIMEOUT_MS);
// Should be ignored because the x position was not centered in the navbar region.
assertThat(mUnderTest.mState).isEqualTo(DelegateInputConsumer.STATE_INACTIVE);
@@ -484,8 +463,7 @@
@Test
public void testNoLogsForShortTouch() {
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_DOWN));
- SystemClock.sleep(10);
- InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ sleep(10);
mUnderTest.onMotionEvent(generateCenteredMotionEvent(ACTION_UP));
verifyNoMoreInteractions(mStatsLogManager);
verifyNoMoreInteractions(mStatsLogger);
@@ -509,6 +487,11 @@
mDownTimeMs = 0;
}
+ private static void sleep(long sleepMs) {
+ SystemClock.sleep(sleepMs);
+ InstrumentationRegistry.getInstrumentation().waitForIdleSync();
+ }
+
/** Generate a motion event centered horizontally in the screen. */
private MotionEvent generateCenteredMotionEvent(int motionAction) {
return generateCenteredMotionEventWithYOffset(motionAction, 0);
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt
index 10be6fd..6790567 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/data/TasksRepositoryTest.kt
@@ -64,7 +64,7 @@
/* snapPosition = */ SNAP_TO_2_50_50,
),
),
- DesktopTask(tasks.subList(3, 6)),
+ DesktopTask(deskId = 0, tasks.subList(3, 6)),
)
private val recentsModel = FakeRecentTasksDataSource()
private val taskThumbnailDataSource = FakeTaskThumbnailDataSource()
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapperTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapperTest.kt
index 124045f..7ca194a 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapperTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/recents/ui/mapper/TaskUiStateMapperTest.kt
@@ -21,6 +21,7 @@
import android.graphics.drawable.ShapeDrawable
import android.platform.test.annotations.EnableFlags
import android.view.Surface
+import android.view.View
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.android.launcher3.Flags
import com.android.quickstep.recents.ui.viewmodel.TaskData
@@ -43,6 +44,7 @@
taskData = null,
isLiveTile = false,
hasHeader = false,
+ clickCloseListener = null,
)
assertThat(result).isEqualTo(TaskThumbnailUiState.Uninitialized)
}
@@ -57,6 +59,7 @@
taskData = input,
isLiveTile = true,
hasHeader = false,
+ clickCloseListener = null,
)
assertThat(result).isEqualTo(LiveTile.WithoutHeader)
}
@@ -72,14 +75,18 @@
TASK_DATA.copy(isLocked = true),
TASK_DATA.copy(title = null),
)
+ val closeCallback = View.OnClickListener {}
val expected =
- LiveTile.WithHeader(header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION))
+ LiveTile.WithHeader(
+ header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION, closeCallback)
+ )
inputs.forEach { taskData ->
val result =
TaskUiStateMapper.toTaskThumbnailUiState(
taskData = taskData,
isLiveTile = true,
hasHeader = true,
+ clickCloseListener = closeCallback,
)
assertThat(result).isEqualTo(expected)
}
@@ -101,6 +108,7 @@
taskData = taskData,
isLiveTile = true,
hasHeader = true,
+ clickCloseListener = {},
)
assertThat(result).isEqualTo(LiveTile.WithoutHeader)
}
@@ -113,6 +121,7 @@
taskData = TASK_DATA,
isLiveTile = false,
hasHeader = false,
+ clickCloseListener = null,
)
val expected =
@@ -133,6 +142,7 @@
@Test
fun taskData_isStaticTile_withHeader_returns_SnapshotSplashWithHeader() {
val inputs = listOf(TASK_DATA, TASK_DATA.copy(title = null))
+ val closeCallback = View.OnClickListener {}
val expected =
TaskThumbnailUiState.SnapshotSplash(
snapshot =
@@ -140,7 +150,7 @@
backgroundColor = TASK_BACKGROUND_COLOR,
bitmap = TASK_THUMBNAIL,
thumbnailRotation = Surface.ROTATION_0,
- header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION),
+ header = ThumbnailHeader(TASK_ICON, TASK_TITLE_DESCRIPTION, closeCallback),
),
splash = TASK_ICON,
)
@@ -150,6 +160,7 @@
taskData = taskData,
isLiveTile = false,
hasHeader = true,
+ clickCloseListener = closeCallback,
)
assertThat(result).isEqualTo(expected)
}
@@ -176,6 +187,7 @@
taskData = taskData,
isLiveTile = false,
hasHeader = true,
+ clickCloseListener = {},
)
assertThat(result).isInstanceOf(TaskThumbnailUiState.SnapshotSplash::class.java)
@@ -191,6 +203,7 @@
taskData = TASK_DATA.copy(thumbnailData = null),
isLiveTile = false,
hasHeader = false,
+ clickCloseListener = null,
)
val expected = TaskThumbnailUiState.BackgroundOnly(TASK_BACKGROUND_COLOR)
@@ -204,6 +217,7 @@
taskData = TASK_DATA.copy(isLocked = true),
isLiveTile = false,
hasHeader = false,
+ clickCloseListener = null,
)
val expected = TaskThumbnailUiState.BackgroundOnly(TASK_BACKGROUND_COLOR)
@@ -212,6 +226,7 @@
private companion object {
const val TASK_TITLE_DESCRIPTION = "Title Description 1"
+ var TASK_ID = 1
val TASK_ICON = ShapeDrawable()
val TASK_THUMBNAIL = Bitmap.createBitmap(1, 1, Bitmap.Config.ARGB_8888)
val TASK_THUMBNAIL_DATA =
@@ -219,7 +234,7 @@
val TASK_BACKGROUND_COLOR = Color.rgb(1, 2, 3)
val TASK_DATA =
TaskData.Data(
- 1,
+ TASK_ID,
title = "Task 1",
titleDescription = TASK_TITLE_DESCRIPTION,
icon = TASK_ICON,
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/DesktopTaskTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/DesktopTaskTest.kt
index 7aed579..6fbf482 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/DesktopTaskTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/DesktopTaskTest.kt
@@ -29,35 +29,42 @@
@Test
fun testDesktopTask_sameInstance_isEqual() {
- val task = DesktopTask(createTasks(1))
+ val task = DesktopTask(deskId = 0, createTasks(1))
assertThat(task).isEqualTo(task)
}
@Test
fun testDesktopTask_identicalConstructor_isEqual() {
- val task1 = DesktopTask(createTasks(1))
- val task2 = DesktopTask(createTasks(1))
+ val task1 = DesktopTask(deskId = 0, createTasks(1))
+ val task2 = DesktopTask(deskId = 0, createTasks(1))
assertThat(task1).isEqualTo(task2)
}
@Test
fun testDesktopTask_copy_isEqual() {
- val task1 = DesktopTask(createTasks(1))
+ val task1 = DesktopTask(deskId = 0, createTasks(1))
val task2 = task1.copy()
assertThat(task1).isEqualTo(task2)
}
@Test
- fun testDesktopTask_differentId_isNotEqual() {
- val task1 = DesktopTask(createTasks(1))
- val task2 = DesktopTask(createTasks(2))
+ fun testDesktopTask_differentDeskIds_isNotEqual() {
+ val task1 = DesktopTask(deskId = 0, createTasks(1))
+ val task2 = DesktopTask(deskId = 1, createTasks(1))
+ assertThat(task1).isNotEqualTo(task2)
+ }
+
+ @Test
+ fun testDesktopTask_differentTaskIds_isNotEqual() {
+ val task1 = DesktopTask(deskId = 0, createTasks(1))
+ val task2 = DesktopTask(deskId = 0, createTasks(2))
assertThat(task1).isNotEqualTo(task2)
}
@Test
fun testDesktopTask_differentLength_isNotEqual() {
- val task1 = DesktopTask(createTasks(1))
- val task2 = DesktopTask(createTasks(1, 2))
+ val task1 = DesktopTask(deskId = 0, createTasks(1))
+ val task2 = DesktopTask(deskId = 0, createTasks(1, 2))
assertThat(task1).isNotEqualTo(task2)
}
diff --git a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt
index fa043b9..67fc62f 100644
--- a/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt
+++ b/quickstep/tests/multivalentTests/src/com/android/quickstep/util/GroupTaskTest.kt
@@ -98,7 +98,7 @@
@Test
fun testGroupTask_differentType_isNotEqual() {
val task1 = SingleTask(createTask(1))
- val task2 = DesktopTask(listOf(createTask(1)))
+ val task2 = DesktopTask(deskId = 0, listOf(createTask(1)))
assertThat(task1).isNotEqualTo(task2)
}
diff --git a/res/drawable/private_space_install_app_icon.xml b/res/drawable/private_space_install_app_icon.xml
index cfec2b1..1e7fe43 100644
--- a/res/drawable/private_space_install_app_icon.xml
+++ b/res/drawable/private_space_install_app_icon.xml
@@ -13,19 +13,7 @@
~ See the License for the specific language governing permissions and
~ limitations under the License.
-->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="60dp"
- android:height="60dp"
- android:viewportWidth="60"
- android:viewportHeight="60">
- <group>
- <clip-path
- android:pathData="M30 0H30A30 30 0 0 1 60 30V30A30 30 0 0 1 30 60H30A30 30 0 0 1 0 30V30A30 30 0 0 1 30 0Z" />
- <path
- android:pathData="M30 0H30A30 30 0 0 1 60 30V30A30 30 0 0 1 30 60H30A30 30 0 0 1 0 30V30A30 30 0 0 1 30 0Z"
- android:fillColor="@color/material_color_surface_container_lowest" />
- <path
- android:pathData="M29 31h-6v-2h6v-6h2v6h6v2h-6v6h-2v-6Z"
- android:fillColor="@color/material_color_on_surface" />
- </group>
-</vector>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@color/material_color_surface_container_lowest"/>
+ <foreground android:drawable="@drawable/private_space_install_app_icon_foreground" />
+</adaptive-icon>
diff --git a/res/drawable/private_space_install_app_icon_foreground.xml b/res/drawable/private_space_install_app_icon_foreground.xml
new file mode 100644
index 0000000..d55abe7
--- /dev/null
+++ b/res/drawable/private_space_install_app_icon_foreground.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?><!--
+ ~ Copyright (C) 2025 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.
+ -->
+
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="60dp"
+ android:height="60dp"
+ android:viewportWidth="60"
+ android:viewportHeight="60">
+ <path
+ android:pathData="M29 31h-6v-2h6v-6h2v6h6v2h-6v6h-2v-6Z"
+ android:fillColor="@color/material_color_on_surface" />
+</vector>
diff --git a/src/com/android/launcher3/graphics/GridCustomizationsProxy.java b/src/com/android/launcher3/graphics/GridCustomizationsProxy.java
index 01c9d7e..062c753 100644
--- a/src/com/android/launcher3/graphics/GridCustomizationsProxy.java
+++ b/src/com/android/launcher3/graphics/GridCustomizationsProxy.java
@@ -377,7 +377,9 @@
if (Flags.newCustomizationPickerUi()
&& com.android.launcher3.Flags.enableLauncherIconShapes()) {
String shapeKey = message.getData().getString(KEY_SHAPE_KEY);
- renderer.updateShape(shapeKey);
+ if (!TextUtils.isEmpty(shapeKey)) {
+ renderer.updateShape(shapeKey);
+ }
}
break;
case MESSAGE_ID_UPDATE_GRID:
diff --git a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
index 332a6bb..740b87b 100644
--- a/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
+++ b/src/com/android/launcher3/graphics/LauncherPreviewRenderer.java
@@ -28,6 +28,7 @@
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET;
+import static com.android.launcher3.graphics.ThemeManager.PREF_ICON_SHAPE;
import static com.android.launcher3.model.ModelUtils.currentScreenContentFilter;
import android.app.Fragment;
@@ -137,12 +138,13 @@
private final String mPrefName;
- public PreviewContext(Context base, String gridName) {
+ public PreviewContext(Context base, String gridName, String shapeKey) {
super(base);
mPrefName = "preview-" + UUID.randomUUID().toString();
LauncherPrefs prefs =
new ProxyPrefs(this, getSharedPreferences(mPrefName, MODE_PRIVATE));
prefs.put(GRID_NAME, gridName);
+ prefs.put(PREF_ICON_SHAPE, shapeKey);
initDaggerComponent(
DaggerLauncherPreviewRenderer_PreviewAppComponent.builder().bindPrefs(prefs));
}
diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
index 6fe5804..4dd9c5b 100644
--- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
+++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java
@@ -73,7 +73,6 @@
import java.util.ArrayList;
import java.util.Map;
-import java.util.Objects;
import java.util.concurrent.TimeUnit;
/** Render preview using surface view. */
@@ -120,6 +119,7 @@
if (mGridName == null) {
mGridName = LauncherPrefs.get(context).get(GRID_NAME);
}
+ mShapeKey = LauncherPrefs.get(context).get(PREF_ICON_SHAPE);
mWallpaperColors = bundle.getParcelable(KEY_COLORS);
if (Flags.newCustomizationPickerUi()) {
updateColorOverrides(bundle);
@@ -225,8 +225,8 @@
*
* @param shapeKey key for the IconShape model
*/
- public void updateShape(@Nullable String shapeKey) {
- if (Objects.equals(mShapeKey, shapeKey)) {
+ public void updateShape(String shapeKey) {
+ if (shapeKey.equals(mShapeKey)) {
Log.w(TAG, "Preview shape already set, skipping. shape=" + mShapeKey);
return;
}
@@ -332,12 +332,10 @@
private void loadModelData() {
final Context inflationContext = getPreviewContext();
if (!mGridName.equals(LauncherPrefs.INSTANCE.get(mContext).get(GRID_NAME))
- || mShapeKey != null) {
+ || !mShapeKey.equals(LauncherPrefs.INSTANCE.get(mContext).get(PREF_ICON_SHAPE))) {
// Start the migration
- PreviewContext previewContext = new PreviewContext(inflationContext, mGridName);
- if (mShapeKey != null) {
- LauncherPrefs.INSTANCE.get(previewContext).put(PREF_ICON_SHAPE, mShapeKey);
- }
+ PreviewContext previewContext =
+ new PreviewContext(inflationContext, mGridName, mShapeKey);
// Copy existing data to preview DB
LauncherDbUtils.copyTable(LauncherAppState.getInstance(mContext)
.getModel().getModelDbController().getDb(),
diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java
index 44a7c6f..e1ef77a 100644
--- a/src/com/android/launcher3/util/SplitConfigurationOptions.java
+++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java
@@ -127,10 +127,10 @@
/** This rect represents the actual gap between the two apps */
public final Rect visualDividerBounds;
// This class is orientation-agnostic, so we compute both for later use
- public final float topTaskPercent;
- public final float leftTaskPercent;
- public final float dividerWidthPercent;
- public final float dividerHeightPercent;
+ private final float topTaskPercent;
+ private final float leftTaskPercent;
+ private final float dividerWidthPercent;
+ private final float dividerHeightPercent;
public final int snapPosition;
/**
@@ -190,6 +190,39 @@
dividerHeightPercent = visualDividerBounds.height() / totalHeight;
}
+ /**
+ * Returns the percentage size of the left/top task (compared to the full width/height of
+ * the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and the
+ * right task is 4 units, this method will return 0.4f.
+ */
+ public float getLeftTopTaskPercent() {
+ // topTaskPercent and leftTaskPercent are defined at creation time, and are not updated
+ // on device rotate, so we have to check appsStackedVertically to return the right
+ // creation-time measurements.
+ return appsStackedVertically ? topTaskPercent : leftTaskPercent;
+ }
+
+ /**
+ * Returns the percentage size of the divider's thickness (compared to the full width/height
+ * of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and
+ * the right task is 4 units, this method will return 0.2f.
+ */
+ public float getDividerPercent() {
+ // dividerHeightPercent and dividerWidthPercent are defined at creation time, and are
+ // not updated on device rotate, so we have to check appsStackedVertically to return
+ // the right creation-time measurements.
+ return appsStackedVertically ? dividerHeightPercent : dividerWidthPercent;
+ }
+
+ /**
+ * Returns the percentage size of the right/bottom task (compared to the full width/height
+ * of the split pair). E.g. if the left task is 4 units wide, the divider is 2 units, and
+ * the right task is 4 units, this method will return 0.4f.
+ */
+ public float getRightBottomTaskPercent() {
+ return 1 - (getLeftTopTaskPercent() + getDividerPercent());
+ }
+
@Override
public String toString() {
return "LeftTop: " + leftTopBounds + ", taskId: " + leftTopTaskId + "\n"