diff --git a/aconfig/launcher_overview.aconfig b/aconfig/launcher_overview.aconfig index d27a2143e1..4ffffd2693 100644 --- a/aconfig/launcher_overview.aconfig +++ b/aconfig/launcher_overview.aconfig @@ -120,3 +120,10 @@ flag { purpose: PURPOSE_BUGFIX } } + +flag { + name: "enable_refactor_digital_wellbeing_toast" + namespace: "launcher_overview" + description: "Enables rewritten version of digital wellbeing toast in overview." + bug: "404838605" +} diff --git a/quickstep/res/layout/task.xml b/quickstep/res/layout/task.xml index 3aac1b63f9..1df80aeff2 100644 --- a/quickstep/res/layout/task.xml +++ b/quickstep/res/layout/task.xml @@ -52,6 +52,9 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" /> - + \ No newline at end of file diff --git a/quickstep/res/layout/task_grouped.xml b/quickstep/res/layout/task_grouped.xml index 3e6f5eda69..fe6ada98df 100644 --- a/quickstep/res/layout/task_grouped.xml +++ b/quickstep/res/layout/task_grouped.xml @@ -81,9 +81,15 @@ android:layout_height="wrap_content" android:layout_width="wrap_content" /> - + - + \ No newline at end of file diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java index 76489e0fa1..63d98d64a5 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarHoverToolTipController.java @@ -26,6 +26,7 @@ import static com.android.launcher3.taskbar.TaskbarAutohideSuspendController.FLA import android.animation.AnimatorSet; import android.animation.ObjectAnimator; import android.graphics.Rect; +import android.text.TextUtils; import android.view.ContextThemeWrapper; import android.view.MotionEvent; import android.view.View; @@ -50,7 +51,6 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener { private final TaskbarView mTaskbarView; private final View mHoverView; private final ArrowTipView mHoverToolTipView; - private final String mToolTipText; private final int mYOffset; public TaskbarHoverToolTipController(TaskbarActivityContext activity, TaskbarView taskbarView, @@ -59,17 +59,6 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener { mTaskbarView = taskbarView; mHoverView = hoverView; - if (mHoverView instanceof BubbleTextView) { - mToolTipText = ((BubbleTextView) mHoverView).getText().toString(); - } else if (mHoverView instanceof FolderIcon - && ((FolderIcon) mHoverView).mInfo.title != null) { - mToolTipText = ((FolderIcon) mHoverView).mInfo.title.toString(); - } else if (mHoverView instanceof AppPairIcon) { - mToolTipText = ((AppPairIcon) mHoverView).getTitleTextView().getText().toString(); - } else { - mToolTipText = null; - } - ContextThemeWrapper arrowContextWrapper = new ContextThemeWrapper(mActivity, R.style.ArrowTipTaskbarStyle); mHoverToolTipView = new ArrowTipView(arrowContextWrapper, /* isPointingUp = */ false, @@ -111,9 +100,15 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener { } private void maybeRevealHoverToolTip() { - if (mHoverView == null || mToolTipText == null) { + if (mHoverView == null) { return; } + + final String toolTipText = getToolTipText(); + if (TextUtils.isEmpty(toolTipText)) { + return; + } + // Do not show tooltip if taskbar icons are transitioning to hotseat. if (mActivity.isIconAlignedWithHotseat()) { return; @@ -128,7 +123,19 @@ public class TaskbarHoverToolTipController implements View.OnHoverListener { } Rect iconViewBounds = Utilities.getViewBounds(mHoverView); - mHoverToolTipView.showAtLocation(mToolTipText, iconViewBounds.centerX(), + mHoverToolTipView.showAtLocation(toolTipText, iconViewBounds.centerX(), mTaskbarView.getTop() - mYOffset, /* shouldAutoClose= */ false); } + + private String getToolTipText() { + if (mHoverView instanceof BubbleTextView btv) { + return btv.getText().toString(); + } else if (mHoverView instanceof FolderIcon icon && icon.mInfo.title != null) { + return icon.mInfo.title.toString(); + } else if (mHoverView instanceof AppPairIcon icon) { + return icon.getTitleTextView().getText().toString(); + } else { + return null; + } + } } diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java index f3cbdb5a2a..e8f7a00637 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarManager.java @@ -559,8 +559,7 @@ public class TaskbarManager implements DisplayDecorationListener { */ private void showTaskbarFromBroadcast(Intent intent) { debugPrimaryTaskbar("destroyTaskbarForDisplay"); - // TODO: make this code displayId specific - TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId()); + TaskbarActivityContext taskbar = getTaskbarForDisplay(getFocusedDisplayId()); if (ACTION_SHOW_TASKBAR.equals(intent.getAction()) && taskbar != null) { taskbar.showTaskbarFromBroadcast(); } @@ -580,7 +579,7 @@ public class TaskbarManager implements DisplayDecorationListener { * Toggles All Apps for Taskbar or Launcher depending on the current state. */ public void toggleAllAppsSearch() { - TaskbarActivityContext taskbar = getTaskbarForDisplay(getDefaultDisplayId()); + TaskbarActivityContext taskbar = getTaskbarForDisplay(getFocusedDisplayId()); if (taskbar == null) { // Home All Apps should be toggled from this class, because the controllers are not // initialized when Taskbar is disabled (i.e. TaskbarActivityContext is null). @@ -1682,6 +1681,10 @@ public class TaskbarManager implements DisplayDecorationListener { return mPrimaryDisplayId; } + private int getFocusedDisplayId() { + return SystemUiProxy.INSTANCE.get(mBaseContext).getFocusState().getFocusedDisplayId(); + } + /** * Logs debug information about the TaskbarManager for primary display. * @param debugReason A string describing the reason for the debug log. diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java index b2989cd81a..a5cc124724 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java @@ -736,7 +736,7 @@ public class TaskbarView extends FrameLayout implements FolderIcon.FolderIconPar if (taskIcon != null) { taskIcon = taskIcon.getConstantState().newDrawable().mutate(); } - btv.applyIconAndLabel(taskIcon, task.titleDescription); + btv.applyIconAndLabel(taskIcon, task.title, task.titleDescription); btv.setTag(singleTask); } diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 69966cc596..41be44d66b 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -177,6 +177,8 @@ import com.android.quickstep.RecentsModel; import com.android.quickstep.SystemUiProxy; import com.android.quickstep.TaskUtils; import com.android.quickstep.TouchInteractionService.TISBinder; +import com.android.quickstep.fallback.window.RecentsDisplayModel; +import com.android.quickstep.fallback.window.RecentsWindowManager; import com.android.quickstep.util.ActiveGestureProtoLogProxy; import com.android.quickstep.util.AsyncClockEventDelegate; import com.android.quickstep.util.LauncherUnfoldAnimationController; @@ -862,6 +864,13 @@ public class QuickstepLauncher extends Launcher implements RecentsViewContainer, if (overviewCommandHelper != null) { overviewCommandHelper.clearPendingCommands(); } + RecentsDisplayModel recentsDisplayModel = RecentsDisplayModel.getINSTANCE().get(this); + recentsDisplayModel.getActiveDisplayResources().forEach(resource -> { + RecentsWindowManager recentsWindowManager = resource.getRecentsWindowManager(); + if (recentsWindowManager != null) { + recentsWindowManager.onNewIntent(); + } + }); } public QuickstepTransitionManager getAppTransitionManager() { diff --git a/quickstep/src/com/android/quickstep/InputConsumerUtils.kt b/quickstep/src/com/android/quickstep/InputConsumerUtils.kt index 89b5b291c6..af96a8b3b6 100644 --- a/quickstep/src/com/android/quickstep/InputConsumerUtils.kt +++ b/quickstep/src/com/android/quickstep/InputConsumerUtils.kt @@ -23,6 +23,7 @@ import com.android.launcher3.statemanager.BaseState import com.android.launcher3.statemanager.StatefulContainer import com.android.launcher3.taskbar.TaskbarManager import com.android.launcher3.util.LockedUserState.Companion.get +import com.android.quickstep.fallback.window.RecentsWindowFlags import com.android.quickstep.inputconsumers.AccessibilityInputConsumer import com.android.quickstep.inputconsumers.AssistantInputConsumer import com.android.quickstep.inputconsumers.BubbleBarInputConsumer @@ -631,6 +632,7 @@ object InputConsumerUtils { inputEventReceiver, gestureState, event, + runningTask.isHomeTask, ) } } @@ -790,13 +792,16 @@ object InputConsumerUtils { inputEventReceiver: InputChannelCompat.InputEventReceiver, gestureState: GestureState, event: MotionEvent, + isHomeTask: Boolean, ): InputConsumer where T : RecentsViewContainer, T : StatefulContainer { val shouldDefer = (!overviewComponentObserver.isHomeAndOverviewSame || gestureState .getContainerInterface() .deferStartingActivity(deviceState, event)) - val disableHorizontalSwipe = deviceState.isInExclusionRegion(event) + val disableHorizontalSwipe = + deviceState.isInExclusionRegion(event) && + (!RecentsWindowFlags.enableOverviewInWindow || !isHomeTask) return OtherActivityInputConsumer( /* base= */ context, deviceState, diff --git a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java index e9f70242cd..b6046810ba 100644 --- a/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java +++ b/quickstep/src/com/android/quickstep/QuickstepTestInformationHandler.java @@ -206,7 +206,7 @@ public class QuickstepTestInformationHandler extends TestInformationHandler { @Override protected WindowInsets getWindowInsets() { RecentsViewContainer container = getRecentsViewContainer(); - WindowInsets insets = container == null + WindowInsets insets = container == null || container.getRootView() == null ? null : container.getRootView().getRootWindowInsets(); return insets == null ? super.getWindowInsets() : insets; } diff --git a/quickstep/src/com/android/quickstep/TaskIconCache.kt b/quickstep/src/com/android/quickstep/TaskIconCache.kt index f0b9b7be5c..7d428a4704 100644 --- a/quickstep/src/com/android/quickstep/TaskIconCache.kt +++ b/quickstep/src/com/android/quickstep/TaskIconCache.kt @@ -85,9 +85,9 @@ class TaskIconCache( // TODO(b/387496731): Add ensureActive() calls if they show performance benefit override suspend fun getIcon(task: Task): TaskCacheEntry { - task.icon?.let { + task.icon?.let { icon -> // Nothing to load, the icon is already loaded - return TaskCacheEntry(it, task.titleDescription ?: "", task.title) + return TaskCacheEntry(icon, task.titleDescription ?: "", task.title ?: "") } val entry = getCacheEntry(task) diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java index dc1cdde4bc..be9b4a1fc5 100644 --- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java +++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java @@ -23,6 +23,7 @@ import static com.android.quickstep.fallback.RecentsState.DEFAULT; import static com.android.quickstep.fallback.RecentsState.MODAL_TASK; import static com.android.quickstep.fallback.RecentsState.OVERVIEW_SPLIT_SELECT; +import android.animation.Animator; import android.animation.AnimatorSet; import android.content.Context; import android.util.AttributeSet; @@ -136,17 +137,22 @@ public class FallbackRecentsView setCurrentTask(-1)); - AnimatorPlaybackController controller = pa.createPlaybackController(); + pendingAnimation.addEndListener(e -> setCurrentTask(-1)); + AnimatorPlaybackController controller = pendingAnimation.createPlaybackController(); controller.dispatchOnStart(); - animatorSet.play(controller.getAnimationPlayer()); + Animator homeDismissAnimator = controller.getAnimationPlayer(); + if (animatorSet != null) { + animatorSet.play(homeDismissAnimator); + } else { + homeDismissAnimator.setDuration(0).start(); + } } } } diff --git a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt index bc08af2da6..fe387fdc64 100644 --- a/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt +++ b/quickstep/src/com/android/quickstep/fallback/window/RecentsWindowManager.kt @@ -297,6 +297,10 @@ class RecentsWindowManager(context: Context, wallpaperColorHints: Int) : stateManager.moveToRestState() } + fun onNewIntent() { + cleanupRecentsWindow() + } + private fun cleanupRecentsWindow() { RecentsWindowProtoLogProxy.logCleanup(isShowing()) if (isShowing()) { diff --git a/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt b/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt index fac0c0a0bb..9f762e724c 100644 --- a/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt +++ b/quickstep/src/com/android/quickstep/recents/ui/viewmodel/TaskViewModel.kt @@ -34,6 +34,7 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.MutableStateFlow import kotlinx.coroutines.flow.combine +import kotlinx.coroutines.flow.debounce import kotlinx.coroutines.flow.distinctUntilChanged import kotlinx.coroutines.flow.flatMapLatest import kotlinx.coroutines.flow.flowOn @@ -91,6 +92,16 @@ class TaskViewModel( val state: Flow = combine(taskData, isLiveTile, overlayEnabled, isCentralTask, ::mapToTaskTile) .distinctUntilChanged() + .debounce { state -> + // Debouncing only when thumbnails are not present gives the best results. + // This is because thumbnail loading is a decent predictor of there being no more + // emissions to come as they are typically the last emission for a TaskView. + if (state.tasks.any { (it as? TaskData.Data)?.thumbnailData?.thumbnail == null }) { + DEBOUNCE_DELAY_MS + } else { + 0 + } + } .flowOn(dispatcherProvider.background) fun bind(vararg taskId: TaskId) { @@ -150,5 +161,6 @@ class TaskViewModel( private companion object { const val TAG = "TaskViewModel" + const val DEBOUNCE_DELAY_MS = 16L } } diff --git a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt index 8b124555f1..273fc77e70 100644 --- a/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/DesktopTaskView.kt @@ -179,7 +179,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu ?.inflate() } - private fun positionTaskWindows() { + private fun positionTaskWindows(updateLayout: Boolean = false) { if (taskContainers.isEmpty()) { return } @@ -197,33 +197,33 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu val scaleWidth = taskViewWidth / screenWidth.toFloat() val scaleHeight = taskViewHeight / screenHeight.toFloat() - taskContainers.forEach { - val taskId = it.task.key.id - val fullscreenTaskPosition = - fullscreenTaskPositions.firstOrNull { it.taskId == taskId } ?: return - val overviewTaskPosition = + taskContainers.forEach { taskContainer -> + val taskId = taskContainer.task.key.id + val fullscreenTaskBounds = + fullscreenTaskPositions.firstOrNull { it.taskId == taskId }?.bounds ?: return + val overviewTaskBounds = if (enableDesktopExplodedView()) { viewModel!! .organizedDesktopTaskPositions .firstOrNull { it.taskId == taskId } - ?.let { organizedPosition -> - TEMP_OVERVIEW_TASK_POSITION.apply { - lerpRect( - fullscreenTaskPosition.bounds, - organizedPosition.bounds, - explodeProgress, - ) - } - } ?: fullscreenTaskPosition.bounds + ?.bounds ?: fullscreenTaskBounds } else { - fullscreenTaskPosition.bounds + fullscreenTaskBounds + } + val currentTaskBounds = + if (enableDesktopExplodedView()) { + TEMP_OVERVIEW_TASK_POSITION.apply { + lerpRect(fullscreenTaskBounds, overviewTaskBounds, explodeProgress) + } + } else { + fullscreenTaskBounds } if (enableDesktopExplodedView()) { getRemoteTargetHandle(taskId)?.let { remoteTargetHandle -> val fromRect = TEMP_FROM_RECTF.apply { - set(fullscreenTaskPosition.bounds) + set(fullscreenTaskBounds) scale(scaleWidth) offset( lastComputedTaskSize.left.toFloat(), @@ -232,7 +232,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } val toRect = TEMP_TO_RECTF.apply { - set(overviewTaskPosition) + set(currentTaskBounds) scale(scaleWidth) offset( lastComputedTaskSize.left.toFloat(), @@ -246,41 +246,30 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } } - val taskLeft = overviewTaskPosition.left * scaleWidth - val taskTop = overviewTaskPosition.top * scaleHeight - val taskWidth = overviewTaskPosition.width() * scaleWidth - val taskHeight = overviewTaskPosition.height() * scaleHeight - // TODO(b/394660950): Revisit the choice to update the layout when explodeProgress == 1. - // To run the explode animation in reverse, it may be simpler to use translation/scale - // for all cases where the progress is non-zero. - if (explodeProgress == 0.0f || explodeProgress == 1.0f) { - // Reset scaling and translation that may have been applied during animation. - it.snapshotView.apply { - scaleX = 1.0f - scaleY = 1.0f - translationX = 0.0f - translationY = 0.0f - } - + val overviewTaskLeft = overviewTaskBounds.left * scaleWidth + val overviewTaskTop = overviewTaskBounds.top * scaleHeight + val overviewTaskWidth = overviewTaskBounds.width() * scaleWidth + val overviewTaskHeight = overviewTaskBounds.height() * scaleHeight + if (updateLayout) { // Position the task to the same position as it would be on the desktop - it.snapshotView.updateLayoutParams { + taskContainer.snapshotView.updateLayoutParams { gravity = Gravity.LEFT or Gravity.TOP - width = taskWidth.toInt() - height = taskHeight.toInt() - leftMargin = taskLeft.toInt() - topMargin = taskTop.toInt() + width = overviewTaskWidth.toInt() + height = overviewTaskHeight.toInt() + leftMargin = overviewTaskLeft.toInt() + topMargin = overviewTaskTop.toInt() } if ( enableDesktopRecentsTransitionsCornersBugfix() && enableRefactorTaskThumbnail() ) { - it.thumbnailView.outlineBounds = - if (intersects(overviewTaskPosition, screenRect)) - Rect(overviewTaskPosition).apply { + taskContainer.thumbnailView.outlineBounds = + if (intersects(overviewTaskBounds, screenRect)) + Rect(overviewTaskBounds).apply { intersectUnchecked(screenRect) // Offset to 0,0 to transform into TaskThumbnailView's coordinate // system. - offset(-overviewTaskPosition.left, -overviewTaskPosition.top) + offset(-overviewTaskBounds.left, -overviewTaskBounds.top) left = (left * scaleWidth).roundToInt() top = (top * scaleHeight).roundToInt() right = (right * scaleWidth).roundToInt() @@ -288,17 +277,21 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu } else null } - } else { - // During the animation, apply translation and scale such that the view is - // transformed to where we want, without triggering layout. - it.snapshotView.apply { - pivotX = 0.0f - pivotY = 0.0f - translationX = taskLeft - left - translationY = taskTop - top - scaleX = taskWidth / width.toFloat() - scaleY = taskHeight / height.toFloat() - } + } + + val currentTaskLeft = currentTaskBounds.left * scaleWidth + val currentTaskTop = currentTaskBounds.top * scaleHeight + val currentTaskWidth = currentTaskBounds.width() * scaleWidth + val currentTaskHeight = currentTaskBounds.height() * scaleHeight + // During the animation, apply translation and scale such that the view is transformed + // to where we want, without triggering layout. + taskContainer.snapshotView.apply { + pivotX = 0.0f + pivotY = 0.0f + translationX = currentTaskLeft - overviewTaskLeft + translationY = currentTaskTop - overviewTaskTop + scaleX = currentTaskWidth / overviewTaskWidth + scaleY = currentTaskHeight / overviewTaskHeight } } } @@ -509,7 +502,7 @@ class DesktopTaskView @JvmOverloads constructor(context: Context, attrs: Attribu if (enableDesktopExplodedView()) { viewModel?.organizeDesktopTasks(desktopSize, fullscreenTaskPositions) } - positionTaskWindows() + positionTaskWindows(updateLayout = true) } companion object { diff --git a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt index faa9e2893b..8086f3d1f1 100644 --- a/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt +++ b/quickstep/src/com/android/quickstep/views/GroupedTaskView.kt @@ -109,6 +109,9 @@ class GroupedTaskView @JvmOverloads constructor(context: Context, attrs: Attribu else R.layout.icon_view } ?.inflate() + findViewById(R.id.bottomRight_digital_wellbeing_toast) + ?.apply { layoutResource = R.layout.digital_wellbeing_toast } + ?.inflate() } override fun onRecycle() { diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java index 3e4b953b5b..53b1301f8f 100644 --- a/quickstep/src/com/android/quickstep/views/RecentsView.java +++ b/quickstep/src/com/android/quickstep/views/RecentsView.java @@ -2771,6 +2771,7 @@ public abstract class RecentsView< } if (enableRefactorTaskThumbnail()) { mRecentsViewModel.onReset(); + getTaskViews().forEach(TaskView::cancelJobs); } } diff --git a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt index f7cb7bef78..c0b0e9a817 100644 --- a/quickstep/src/com/android/quickstep/views/TaskMenuView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskMenuView.kt @@ -429,6 +429,7 @@ constructor(context: Context?, attrs: AttributeSet?, defStyleAttr: Int = 0) : var additionalTranslationX = 0f if ( + taskView.pagedOrientationHandler.isLayoutNaturalToLauncher && taskContainer.stagePosition == SplitConfigurationOptions.STAGE_POSITION_BOTTOM_OR_RIGHT ) { // Animate menu and icon when split task would display off the side of the screen. diff --git a/quickstep/src/com/android/quickstep/views/TaskView.kt b/quickstep/src/com/android/quickstep/views/TaskView.kt index fa3fd91615..c52b26bb6f 100644 --- a/quickstep/src/com/android/quickstep/views/TaskView.kt +++ b/quickstep/src/com/android/quickstep/views/TaskView.kt @@ -780,6 +780,10 @@ constructor( else R.layout.icon_view } ?.inflate() + + findViewById(R.id.digital_wellbeing_toast) + ?.apply { layoutResource = R.layout.digital_wellbeing_toast } + ?.inflate() } override fun onAttachedToWindow() = @@ -888,17 +892,21 @@ constructor( return thumbnailPosition } - override fun onDetachedFromWindow() = - traceSection("TaskView.onDetachedFromWindow") { - super.onDetachedFromWindow() - if (enableRefactorTaskThumbnail()) { - // The jobs are being cancelled in the background thread. So we make a copy of the - // list to prevent cleaning a new job that might be added to this list during - // onAttach or another moment in the lifecycle. - val coroutineJobsToCancel = coroutineJobs.toList() - coroutineJobs.clear() + override fun onDetachedFromWindow() { + super.onDetachedFromWindow() + cancelJobs() + } + + fun cancelJobs() = + traceSection("TaskView.cancelJobs") { + // The jobs are being cancelled in the background thread. So we make a copy of the + // list to prevent cleaning a new job that might be added to this list during + // onAttach or another moment in the lifecycle. + val coroutineJobsToCancel = coroutineJobs.toList() + coroutineJobs.clear() + if (coroutineJobsToCancel.isNotEmpty()) { coroutineScope.launch(dispatcherProvider.background) { - traceSection("TaskView.onDetachedFromWindow.cancellingJobs") { + traceSection("TaskView.cancelJobs.cancellingJobs") { coroutineJobsToCancel.forEach { it.cancel("TaskView detaching from window") } diff --git a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.kt b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.kt index d2b9fcf2c5..529174a253 100644 --- a/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.kt +++ b/quickstep/tests/multivalentTests/src/com/android/launcher3/taskbar/TaskbarHoverToolTipControllerTest.kt @@ -147,6 +147,15 @@ class TaskbarHoverToolTipControllerTest { assertThat(isHoverToolTipOpen).isFalse() } + @Test + fun onHover_emptyTitle_noTooltip() { + runOnMainSync { + iconView.text = "" + iconView.dispatchGenericMotionEvent(HOVER_ENTER) + } + assertThat(isHoverToolTipOpen).isFalse() + } + companion object { private val HOVER_EXIT = MotionEvent.obtain(0, 0, ACTION_HOVER_EXIT, 0f, 0f, 0) private val HOVER_ENTER = MotionEvent.obtain(0, 0, ACTION_HOVER_ENTER, 0f, 0f, 0) diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java index b207d4ac8f..fc60bec151 100644 --- a/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java +++ b/quickstep/tests/src/com/android/quickstep/TaplTestsQuickstep.java @@ -31,6 +31,7 @@ import static org.junit.Assume.assumeTrue; import android.content.Intent; import android.content.res.Configuration; +import android.platform.test.annotations.EnableFlags; import androidx.annotation.NonNull; import androidx.test.filters.LargeTest; @@ -39,6 +40,7 @@ import androidx.test.runner.AndroidJUnit4; import androidx.test.uiautomator.By; import androidx.test.uiautomator.Until; +import com.android.launcher3.Flags; import com.android.launcher3.LauncherState; import com.android.launcher3.tapl.BaseOverview; import com.android.launcher3.tapl.LaunchedAppState; @@ -65,6 +67,7 @@ import org.junit.Test; import org.junit.runner.RunWith; import java.util.Comparator; +import java.util.Optional; import java.util.function.Consumer; import java.util.function.Function; @@ -560,20 +563,21 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape + @EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW) public void testDismissBottomRow() throws Exception { assumeTrue(mLauncher.isTablet()); mLauncher.goHome().switchToOverview().dismissAllTasks(); startTestAppsWithCheck(); + Overview overview = mLauncher.goHome().switchToOverview(); assertIsInState("Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW); final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount); - OverviewTask bottomTask = overview.getCurrentTasksForTablet().stream().max( - Comparator.comparingInt(OverviewTask::getTaskCenterY)).get(); - assertNotNull("bottomTask null", bottomTask); - - bottomTask.dismiss(); + Optional bottomTask = overview.getCurrentTasksForTablet().stream().max( + Comparator.comparingInt(OverviewTask::getTaskCenterY)); + assertTrue("bottomTask null", bottomTask.isPresent()); + bottomTask.get().dismiss(); runOnRecentsView(recentsView -> assertEquals( "Dismissing a bottomTask didn't remove 1 bottomTask from Overview", numTasks - 1, recentsView.getTaskViewCount())); @@ -581,34 +585,38 @@ public class TaplTestsQuickstep extends AbstractQuickStepTest { @Test @PortraitLandscape + @EnableFlags(value = Flags.FLAG_ENABLE_GRID_ONLY_OVERVIEW) public void testDismissLastGridRow() throws Exception { assumeTrue(mLauncher.isTablet()); mLauncher.goHome().switchToOverview().dismissAllTasks(); startTestAppsWithCheck(); startTestActivity(3); startTestActivity(4); - runOnRecentsView( - recentsView -> assertNotEquals("Grid overview should have unequal row counts", - recentsView.getTopRowTaskCountForTablet(), - recentsView.getBottomRowTaskCountForTablet())); + runOnRecentsView(recentsView -> assertNotEquals( + "Grid overview should have unequal row counts", + recentsView.getTopRowTaskCountForTablet(), + recentsView.getBottomRowTaskCountForTablet())); Overview overview = mLauncher.goHome().switchToOverview(); assertIsInState("Launcher internal state didn't switch to Overview", ExpectedState.OVERVIEW); + overview.flingForwardUntilClearAllVisible(); assertTrue("Clear All not visible.", overview.isClearAllVisible()); final Integer numTasks = getFromRecentsView(RecentsView::getTaskViewCount); - OverviewTask lastGridTask = overview.getCurrentTasksForTablet().stream().min( - Comparator.comparingInt(OverviewTask::getTaskCenterX)).get(); - assertNotNull("lastGridTask null.", lastGridTask); + Optional lastGridTask = overview.getCurrentTasksForTablet().stream().min( + Comparator.comparingInt(OverviewTask::getTaskCenterX)); + assertTrue("lastGridTask null.", lastGridTask.isPresent()); - lastGridTask.dismiss(); - - runOnRecentsView(recentsView -> assertEquals( - "Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview", - numTasks - 1, recentsView.getTaskViewCount())); - runOnRecentsView(recentsView -> assertEquals("Grid overview should have equal row counts.", - recentsView.getTopRowTaskCountForTablet(), - recentsView.getBottomRowTaskCountForTablet())); + lastGridTask.get().dismiss(); + runOnRecentsView(recentsView -> { + assertEquals( + "Dismissing a lastGridTask didn't remove 1 lastGridTask from Overview", + numTasks - 1, recentsView.getTaskViewCount()); + assertEquals( + "Grid overview should have equal row counts.", + recentsView.getTopRowTaskCountForTablet(), + recentsView.getBottomRowTaskCountForTablet()); + }); assertTrue("Clear All not visible.", overview.isClearAllVisible()); } diff --git a/res/layout/all_apps_personal_work_tabs.xml b/res/layout/all_apps_personal_work_tabs.xml index 1435f8203d..f81ea977e7 100644 --- a/res/layout/all_apps_personal_work_tabs.xml +++ b/res/layout/all_apps_personal_work_tabs.xml @@ -37,7 +37,7 @@ android:contentDescription="@string/all_apps_personal_tab_content_description" android:textColor="@color/all_apps_tab_text" android:textSize="14sp" - style="?android:attr/borderlessButtonStyle" /> + style="@style/AllAppsPersonalWorkTabStyle" />