Merge "Use expressive dismiss for clear all." into main
This commit is contained in:
commit
becba58cff
4 files changed
+163
-66
No files matched your search
+6
-4
@@ -323,11 +323,13 @@ CONTAINER : StatefulContainer<T> {
|
||||
springAnimation =
|
||||
recentsView.runTaskDismissSettlingSpringAnimation(
|
||||
taskBeingDragged,
|
||||
velocity,
|
||||
isDismissing,
|
||||
dismissLength,
|
||||
dismissThreshold,
|
||||
finalPosition,
|
||||
RecentsDismissUtils.DismissedTaskData(
|
||||
startVelocity = velocity,
|
||||
dismissLength = dismissLength,
|
||||
finalPosition = finalPosition,
|
||||
dismissThreshold = dismissThreshold,
|
||||
),
|
||||
/* shouldRemoveTaskView= */ isDismissing,
|
||||
/* isSplitSelection= */ false,
|
||||
)
|
||||
|
||||
@@ -40,6 +40,7 @@ import com.android.quickstep.logging.SettingsChangeLogger;
|
||||
import com.android.quickstep.util.AsyncClockEventDelegate;
|
||||
import com.android.quickstep.util.ContextualSearchHapticManager;
|
||||
import com.android.quickstep.util.ContextualSearchStateManager;
|
||||
import com.android.quickstep.views.RecentsDismissUtils;
|
||||
|
||||
/**
|
||||
* Launcher Quickstep base component for Dagger injection.
|
||||
@@ -79,6 +80,8 @@ public interface QuickstepBaseAppComponent extends LauncherBaseAppComponent {
|
||||
|
||||
RecentsModel getRecentsModel();
|
||||
|
||||
RecentsDismissUtils.Factory getRecentsDismissUtilsFactory();
|
||||
|
||||
SettingsChangeLogger getSettingsChangeLogger();
|
||||
|
||||
SimpleOrientationTouchTransformer getSimpleOrientationTouchTransformer();
|
||||
|
||||
@@ -27,16 +27,24 @@ import androidx.dynamicanimation.animation.SpringForce
|
||||
import com.android.internal.jank.Cuj
|
||||
import com.android.launcher3.PagedView
|
||||
import com.android.launcher3.R
|
||||
import com.android.launcher3.concurrent.annotations.LightweightBackground
|
||||
import com.android.launcher3.concurrent.annotations.LightweightBackgroundPriority
|
||||
import com.android.launcher3.logging.StatsLogManager.LauncherEvent
|
||||
import com.android.launcher3.util.DynamicResource
|
||||
import com.android.launcher3.util.MSDLPlayerWrapper
|
||||
import com.android.launcher3.util.OverviewReleaseFlags.enableGridOnlyOverview
|
||||
import com.android.launcher3.views.ActivityContext
|
||||
import com.android.quickstep.SystemUiProxy
|
||||
import com.android.quickstep.util.TaskGridNavHelper
|
||||
import com.android.quickstep.views.RecentsView.RECENTS_SCALE_PROPERTY
|
||||
import com.android.quickstep.views.TaskView.Companion.GRID_END_TRANSLATION_X
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper
|
||||
import com.android.systemui.shared.system.InteractionJankMonitorWrapper
|
||||
import com.google.android.msdl.data.model.MSDLToken
|
||||
import com.google.common.util.concurrent.ListeningExecutorService
|
||||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import kotlin.math.abs
|
||||
import kotlin.math.max
|
||||
import kotlin.math.roundToInt
|
||||
@@ -46,7 +54,20 @@ import kotlin.math.sign
|
||||
* Helper class for [RecentsView]. This util class contains refactored and extracted functions from
|
||||
* RecentsView related to TaskView dismissal.
|
||||
*/
|
||||
class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
class RecentsDismissUtils
|
||||
@AssistedInject
|
||||
constructor(
|
||||
@Assisted private val recentsView: RecentsView<*, *>,
|
||||
private val systemUiProxy: SystemUiProxy,
|
||||
@LightweightBackground(LightweightBackgroundPriority.UI)
|
||||
private val uiHelperExecutor: ListeningExecutorService,
|
||||
private val activityManagerWrapper: ActivityManagerWrapper,
|
||||
private val msdlPlayerWrapper: MSDLPlayerWrapper,
|
||||
) {
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
fun create(recentsView: RecentsView<*, *>): RecentsDismissUtils
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs the default spring animation when a dismissed task view in overview is released.
|
||||
@@ -60,44 +81,27 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
shouldRemoveTaskView: Boolean,
|
||||
isSplitSelection: Boolean,
|
||||
): SpringSet? {
|
||||
with(recentsView) {
|
||||
if (dismissedTaskView == null || isSplitSelection) {
|
||||
return createTaskDismissSpringAnimation(
|
||||
dismissedTaskView,
|
||||
velocity = 0f,
|
||||
isDismissing = true,
|
||||
if (dismissedTaskView == null || isSplitSelection) {
|
||||
return createTaskDismissSpringAnimation(
|
||||
dismissedTaskView,
|
||||
isDismissing = true,
|
||||
DismissedTaskData(
|
||||
startVelocity = 0f,
|
||||
dismissLength = 0,
|
||||
dismissThreshold = 0,
|
||||
finalPosition = 0f,
|
||||
shouldRemoveTaskView,
|
||||
isSplitSelection,
|
||||
)
|
||||
}
|
||||
|
||||
dismissedTaskView.getThumbnailBounds(mTempRect, /* relativeToDragLayer= */ true)
|
||||
val secondaryLayerDimension: Int =
|
||||
pagedOrientationHandler.getSecondaryDimension(
|
||||
(mContainer as ActivityContext).getDragLayer()
|
||||
)
|
||||
val verticalFactor = pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat()
|
||||
val dismissLength =
|
||||
(pagedOrientationHandler.getTaskDismissLength(secondaryLayerDimension, mTempRect) *
|
||||
verticalFactor)
|
||||
.toInt()
|
||||
val dismissThreshold = (dismissLength * DEFAULT_DISMISS_THRESHOLD_FRACTION).toInt()
|
||||
val velocity = mTempRect.height().toFloat()
|
||||
val finalPosition = dismissLength.toFloat()
|
||||
return createTaskDismissSpringAnimation(
|
||||
dismissedTaskView,
|
||||
velocity,
|
||||
isDismissing = true,
|
||||
dismissLength,
|
||||
dismissThreshold,
|
||||
finalPosition,
|
||||
),
|
||||
shouldRemoveTaskView,
|
||||
isSplitSelection,
|
||||
)
|
||||
}
|
||||
return createTaskDismissSpringAnimation(
|
||||
dismissedTaskView,
|
||||
isDismissing = true,
|
||||
getDefaultDismissedTaskData(dismissedTaskView),
|
||||
shouldRemoveTaskView,
|
||||
isSplitSelection,
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -109,11 +113,8 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
*/
|
||||
fun createTaskDismissSpringAnimation(
|
||||
dismissedTaskView: TaskView?,
|
||||
velocity: Float,
|
||||
isDismissing: Boolean,
|
||||
dismissLength: Int,
|
||||
dismissThreshold: Int,
|
||||
finalPosition: Float,
|
||||
dismissedTaskData: DismissedTaskData,
|
||||
shouldRemoveTaskView: Boolean,
|
||||
isSplitSelection: Boolean,
|
||||
): SpringSet? {
|
||||
@@ -131,7 +132,8 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
val verticalFactor =
|
||||
recentsView.pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat()
|
||||
val startVelocity =
|
||||
abs(velocity).coerceAtLeast(dismissedTaskSecondaryDimension) * velocity.sign
|
||||
abs(dismissedTaskData.startVelocity).coerceAtLeast(dismissedTaskSecondaryDimension) *
|
||||
dismissedTaskData.startVelocity.sign
|
||||
|
||||
// Spring that animates the dismissed task.
|
||||
val dismissedTaskViewSpring =
|
||||
@@ -140,15 +142,18 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
createDismissedTaskViewSpringAnimation(
|
||||
dismissedTaskView,
|
||||
isDismissing,
|
||||
startVelocity,
|
||||
dismissLength,
|
||||
finalPosition,
|
||||
dismissThreshold,
|
||||
DismissedTaskData(
|
||||
startVelocity = startVelocity,
|
||||
dismissLength = dismissedTaskData.dismissLength,
|
||||
finalPosition = dismissedTaskData.finalPosition,
|
||||
dismissThreshold = dismissedTaskData.dismissThreshold,
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
// SpringSet tracking all dismiss springs before running end-snapping and relayout.
|
||||
var springSet = dismissedTaskViewSpring?.let { SpringSet(it, finalPosition) }
|
||||
var springSet =
|
||||
dismissedTaskViewSpring?.let { SpringSet(it, dismissedTaskData.finalPosition) }
|
||||
|
||||
if (isDismissing) {
|
||||
// The spring set that will reflow the tasks to fill the gap left by the dismissed task.
|
||||
@@ -173,7 +178,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
val neighborSettlingSpringSet =
|
||||
createNeighborSettlingSpringSet(dismissedTaskView, isSpringDirectionVertical = true)
|
||||
springSet.playAfterThreshold(
|
||||
driverThreshold = finalPosition,
|
||||
driverThreshold = dismissedTaskData.finalPosition,
|
||||
triggeredSpringSet = neighborSettlingSpringSet,
|
||||
minVelocity = startVelocity,
|
||||
)
|
||||
@@ -209,14 +214,22 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
return springSet.addEndListener(endRunnable).start()
|
||||
}
|
||||
|
||||
/** Default dismissed task view spring animation. */
|
||||
private fun createDismissedTaskViewSpringAnimation(
|
||||
dismissedTaskView: TaskView
|
||||
): SpringAnimation? {
|
||||
return createDismissedTaskViewSpringAnimation(
|
||||
dismissedTaskView,
|
||||
isDismissing = true,
|
||||
getDefaultDismissedTaskData(dismissedTaskView),
|
||||
)
|
||||
}
|
||||
|
||||
/** Dismissed task view spring animation. */
|
||||
private fun createDismissedTaskViewSpringAnimation(
|
||||
dismissedTaskView: TaskView,
|
||||
isDismissing: Boolean,
|
||||
startVelocity: Float,
|
||||
dismissLength: Int,
|
||||
finalPosition: Float,
|
||||
dismissThreshold: Int,
|
||||
dismissedTaskData: DismissedTaskData,
|
||||
): SpringAnimation? {
|
||||
val taskDismissFloatProperty =
|
||||
FloatPropertyCompat.createFloatPropertyCompat(
|
||||
@@ -226,15 +239,19 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
// Animate dismissed task towards dismissal or rest state.
|
||||
val dismissedTaskViewSpringAnimation =
|
||||
SpringAnimation(dismissedTaskView, taskDismissFloatProperty)
|
||||
.setSpring(createExpressiveDismissSpringForce().setFinalPosition(finalPosition))
|
||||
.setStartVelocity(startVelocity)
|
||||
.setSpring(
|
||||
createExpressiveDismissSpringForce()
|
||||
.setFinalPosition(dismissedTaskData.finalPosition)
|
||||
)
|
||||
.setStartVelocity(dismissedTaskData.startVelocity)
|
||||
.addUpdateListener { animation, currentDisplacement, _ ->
|
||||
// Play haptic as task crosses dismiss threshold from above or below.
|
||||
val previousBeyondThreshold = abs(previousDisplacement) >= abs(dismissThreshold)
|
||||
val currentBeyondThreshold = abs(currentDisplacement) >= abs(dismissThreshold)
|
||||
val previousBeyondThreshold =
|
||||
abs(previousDisplacement) >= abs(dismissedTaskData.dismissThreshold)
|
||||
val currentBeyondThreshold =
|
||||
abs(currentDisplacement) >= abs(dismissedTaskData.dismissThreshold)
|
||||
if (previousBeyondThreshold != currentBeyondThreshold) {
|
||||
MSDLPlayerWrapper.INSTANCE.get(recentsView.context)
|
||||
.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR)
|
||||
msdlPlayerWrapper.playToken(MSDLToken.SWIPE_THRESHOLD_INDICATOR)
|
||||
}
|
||||
previousDisplacement = currentDisplacement
|
||||
|
||||
@@ -246,13 +263,68 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
recentsView.redrawLiveTile()
|
||||
}
|
||||
// End dismissed task animation once beyond the screen so next animations play.
|
||||
if (isDismissing && abs(currentDisplacement) >= abs(dismissLength)) {
|
||||
if (
|
||||
isDismissing &&
|
||||
abs(currentDisplacement) >= abs(dismissedTaskData.dismissLength)
|
||||
) {
|
||||
(animation as SpringAnimation).skipToEnd()
|
||||
}
|
||||
}
|
||||
return dismissedTaskViewSpringAnimation
|
||||
}
|
||||
|
||||
private fun getDefaultDismissedTaskData(dismissedTaskView: TaskView): DismissedTaskData {
|
||||
with(recentsView) {
|
||||
dismissedTaskView.getThumbnailBounds(mTempRect, /* relativeToDragLayer= */ true)
|
||||
val secondaryLayerDimension =
|
||||
pagedOrientationHandler.getSecondaryDimension(
|
||||
(mContainer as ActivityContext).getDragLayer()
|
||||
)
|
||||
val verticalFactor = pagedOrientationHandler.getTaskDismissVerticalDirection().toFloat()
|
||||
val dismissLength =
|
||||
(pagedOrientationHandler.getTaskDismissLength(secondaryLayerDimension, mTempRect) *
|
||||
verticalFactor)
|
||||
.toInt()
|
||||
val dismissThreshold = (dismissLength * DEFAULT_DISMISS_THRESHOLD_FRACTION).toInt()
|
||||
val startVelocity = mTempRect.height().toFloat()
|
||||
val finalPosition = dismissLength.toFloat()
|
||||
return DismissedTaskData(
|
||||
startVelocity = startVelocity,
|
||||
dismissLength = dismissLength,
|
||||
finalPosition = finalPosition,
|
||||
dismissThreshold = dismissThreshold,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
/** Dismisses all */
|
||||
fun dismissAllTasks() {
|
||||
val allDismissSprings =
|
||||
recentsView.mUtils.taskViews
|
||||
.reversed()
|
||||
.filter { taskView -> recentsView.isTaskViewVisible(taskView) }
|
||||
.mapNotNull { createDismissedTaskViewSpringAnimation(it) }
|
||||
SpringSet(SpringAnimation(FloatValueHolder()).setSpring(SpringForce(1f)))
|
||||
.playTogether(allDismissSprings)
|
||||
.addEndListener {
|
||||
with(recentsView) {
|
||||
// Remove desktops first, since desks can be empty (so they have no recent
|
||||
// tasks), and closing all tasks on a desk doesn't always necessarily mean that
|
||||
// the desk will be removed. So, there are no guarantees that the below call to
|
||||
// `ActivityManagerWrapper::removeAllRecentTasks()` will be enough.
|
||||
systemUiProxy.removeAllDesks()
|
||||
|
||||
// Remove all the task views now
|
||||
finishRecentsAnimation(/* toRecents */ true, /* shouldPip */ false) {
|
||||
uiHelperExecutor.execute { activityManagerWrapper.removeAllRecentTasks() }
|
||||
removeAllTaskViews()
|
||||
startHome()
|
||||
}
|
||||
}
|
||||
}
|
||||
.start()
|
||||
}
|
||||
|
||||
/** Bounce neighboring tasks due to a canceled dismiss or the reflow of tasks after dismiss. */
|
||||
private fun createNeighborSettlingSpringSet(
|
||||
dismissedTaskView: TaskView,
|
||||
@@ -1239,6 +1311,14 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
}
|
||||
return this
|
||||
}
|
||||
|
||||
fun playTogether(springs: List<SpringAnimation>): SpringSet {
|
||||
springs.forEach {
|
||||
trackSpring(it)
|
||||
addStartListener { it.start() }
|
||||
}
|
||||
return this
|
||||
}
|
||||
}
|
||||
|
||||
data class GridEndData(
|
||||
@@ -1248,6 +1328,13 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
val currentPageSnapsToEndOfGrid: Boolean,
|
||||
)
|
||||
|
||||
data class DismissedTaskData(
|
||||
val startVelocity: Float,
|
||||
val dismissLength: Int,
|
||||
val finalPosition: Float,
|
||||
val dismissThreshold: Int,
|
||||
)
|
||||
|
||||
private companion object {
|
||||
// The additional damping to apply to tasks further from the dismissed task.
|
||||
private const val ADDITIONAL_DISMISS_DAMPING_RATIO = 0.15f
|
||||
|
||||
@@ -157,6 +157,7 @@ import com.android.launcher3.anim.PendingAnimation;
|
||||
import com.android.launcher3.anim.SpringProperty;
|
||||
import com.android.launcher3.compat.AccessibilityManagerCompat;
|
||||
import com.android.launcher3.config.FeatureFlags;
|
||||
import com.android.launcher3.dagger.LauncherComponentProvider;
|
||||
import com.android.launcher3.desktop.DesktopRecentsTransitionController;
|
||||
import com.android.launcher3.logger.LauncherAtom;
|
||||
import com.android.launcher3.logging.StatsLogManager;
|
||||
@@ -874,7 +875,8 @@ public abstract class RecentsView<
|
||||
protected final RecentsViewModel mRecentsViewModel;
|
||||
private final RecentsViewModelHelper mHelper;
|
||||
protected final RecentsViewUtils mUtils = new RecentsViewUtils(this);
|
||||
protected final RecentsDismissUtils mDismissUtils = new RecentsDismissUtils(this);
|
||||
protected final RecentsDismissUtils mDismissUtils = LauncherComponentProvider.get(
|
||||
getContext()).getRecentsDismissUtilsFactory().create(this);
|
||||
|
||||
private final Matrix mTmpMatrix = new Matrix();
|
||||
|
||||
@@ -2187,7 +2189,7 @@ public abstract class RecentsView<
|
||||
return mModel.isLoadingTasksInBackground();
|
||||
}
|
||||
|
||||
private void removeAllTaskViews() {
|
||||
protected void removeAllTaskViews() {
|
||||
// This handles an edge case where applyLoadPlan happens during a gesture when the only
|
||||
// Task is one with excludeFromRecents, in which case we should not remove it.
|
||||
CollectionsKt
|
||||
@@ -4568,7 +4570,11 @@ public abstract class RecentsView<
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private void dismissAllTasks(View view) {
|
||||
runDismissAnimation(createAllTasksDismissAnimation(DISMISS_TASK_DURATION));
|
||||
if (enableExpressiveDismissTaskMotion()) {
|
||||
mDismissUtils.dismissAllTasks();
|
||||
} else {
|
||||
runDismissAnimation(createAllTasksDismissAnimation(DISMISS_TASK_DURATION));
|
||||
}
|
||||
mContainer.getStatsLogManager().logger().log(LAUNCHER_TASK_CLEAR_ALL);
|
||||
}
|
||||
|
||||
@@ -7011,12 +7017,11 @@ public abstract class RecentsView<
|
||||
* spring in response to the perceived impact of the settling task.
|
||||
*/
|
||||
public RecentsDismissUtils.SpringSet runTaskDismissSettlingSpringAnimation(
|
||||
TaskView draggedTaskView, float velocity, boolean isDismissing, int dismissLength,
|
||||
int dismissThreshold, float finalPosition, boolean shouldRemoveTaskView,
|
||||
TaskView draggedTaskView, boolean isDismissing,
|
||||
RecentsDismissUtils.DismissedTaskData dismissedTaskData, boolean shouldRemoveTaskView,
|
||||
boolean isSplitSelection) {
|
||||
return mDismissUtils.createTaskDismissSpringAnimation(draggedTaskView, velocity,
|
||||
isDismissing, dismissLength, dismissThreshold, finalPosition, shouldRemoveTaskView,
|
||||
isSplitSelection);
|
||||
return mDismissUtils.createTaskDismissSpringAnimation(draggedTaskView, isDismissing,
|
||||
dismissedTaskData, shouldRemoveTaskView, isSplitSelection);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user