Cancel ongoing dismiss animation when Launcher state changes.
Fix: 410744889 Test: Manual Flag: com.android.launcher3.enable_expressive_dismiss_task_motion Change-Id: I5e81de6762e7d0ea47f8574599901aac1bb8bb77
This commit is contained in:
1 parent
b28d1fc453
commit
9ee290e81f
14 files changed
+57
-9
No files matched your search
@@ -425,6 +425,7 @@ public class NavbarButtonsViewController implements TaskbarControllers.LoggableT
|
||||
mSeparateWindowParent = new BaseDragLayer<>(mContext, null, 0) {
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = new TouchController[0];
|
||||
}
|
||||
|
||||
|
||||
@@ -126,6 +126,7 @@ public class TaskbarDragLayer extends BaseDragLayer<TaskbarActivityContext> {
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = mControllerCallbacks.getTouchControllers();
|
||||
}
|
||||
|
||||
|
||||
@@ -67,6 +67,7 @@ class VoiceInteractionWindowController(val context: TaskbarActivityContext) :
|
||||
separateWindowForTaskbarBackground =
|
||||
object : BaseDragLayer<TaskbarActivityContext>(context, null, 0) {
|
||||
override fun recreateControllers() {
|
||||
super.recreateControllers()
|
||||
mControllers = emptyArray()
|
||||
}
|
||||
|
||||
|
||||
@@ -71,6 +71,7 @@ public class TaskbarOverlayDragLayer extends
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
List<TouchController> controllers = new ArrayList<>();
|
||||
controllers.add(mContainer.getDragController());
|
||||
controllers.addAll(mTouchControllers);
|
||||
|
||||
+22
-3
@@ -28,6 +28,9 @@ import com.android.launcher3.Utilities.boundToRange
|
||||
import com.android.launcher3.Utilities.debugLog
|
||||
import com.android.launcher3.Utilities.isRtl
|
||||
import com.android.launcher3.Utilities.mapToRange
|
||||
import com.android.launcher3.statemanager.BaseState
|
||||
import com.android.launcher3.statemanager.StateManager.StateListener
|
||||
import com.android.launcher3.statemanager.StatefulContainer
|
||||
import com.android.launcher3.touch.SingleAxisSwipeDetector
|
||||
import com.android.launcher3.util.MSDLPlayerWrapper
|
||||
import com.android.launcher3.util.TouchController
|
||||
@@ -40,12 +43,13 @@ import kotlin.math.abs
|
||||
import kotlin.math.ceil
|
||||
|
||||
/** Touch controller for handling task view card dismiss swipes */
|
||||
class TaskViewDismissTouchController<CONTAINER>(
|
||||
class TaskViewDismissTouchController<CONTAINER, T : BaseState<T>>(
|
||||
private val container: CONTAINER,
|
||||
private val taskViewRecentsTouchContext: TaskViewRecentsTouchContext,
|
||||
) : TouchController, SingleAxisSwipeDetector.Listener where
|
||||
CONTAINER : Context,
|
||||
CONTAINER : RecentsViewContainer {
|
||||
CONTAINER : RecentsViewContainer,
|
||||
CONTAINER : StatefulContainer<T> {
|
||||
private val recentsView: RecentsView<*, *> = container.getOverviewPanel()
|
||||
private val detector: SingleAxisSwipeDetector =
|
||||
SingleAxisSwipeDetector(
|
||||
@@ -55,7 +59,13 @@ CONTAINER : RecentsViewContainer {
|
||||
)
|
||||
private val isRtl = isRtl(container.resources)
|
||||
private val upDirection: Int = recentsView.pagedOrientationHandler.getUpDirection(isRtl)
|
||||
|
||||
private val stateListener =
|
||||
object : StateListener<T> {
|
||||
override fun onStateTransitionStart(toState: T) {
|
||||
springAnimation?.cancel()
|
||||
clearState()
|
||||
}
|
||||
}
|
||||
private val tempTaskThumbnailBounds = Rect()
|
||||
|
||||
private var taskBeingDragged: TaskView? = null
|
||||
@@ -68,6 +78,14 @@ CONTAINER : RecentsViewContainer {
|
||||
private var isBlockedDuringDismissal = false
|
||||
private var canInterceptTouch = false
|
||||
|
||||
init {
|
||||
container.getStateManager().addStateListener(stateListener)
|
||||
}
|
||||
|
||||
override fun onTouchControllerDestroyed() {
|
||||
container.getStateManager().removeStateListener(stateListener)
|
||||
}
|
||||
|
||||
private fun canInterceptTouch(ev: MotionEvent): Boolean =
|
||||
when {
|
||||
// Don't intercept swipes on the nav bar, as user might be trying to go home during a
|
||||
@@ -261,6 +279,7 @@ CONTAINER : RecentsViewContainer {
|
||||
taskBeingDragged,
|
||||
velocity,
|
||||
isDismissing,
|
||||
dismissLength,
|
||||
dismissThreshold,
|
||||
finalPosition,
|
||||
/* shouldRemoveTaskView= */ isDismissing,
|
||||
|
||||
@@ -55,6 +55,7 @@ public class RecentsDragLayer<T extends Context & RecentsViewContainer
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = enableExpressiveDismissTaskMotion()
|
||||
? new TouchController[]{
|
||||
new TaskViewLaunchTouchController<>(mContainer,
|
||||
|
||||
@@ -65,6 +65,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
draggedTaskView,
|
||||
velocity = 0f,
|
||||
isDismissing = true,
|
||||
dismissLength = 0,
|
||||
dismissThreshold = 0,
|
||||
finalPosition = 0f,
|
||||
shouldRemoveTaskView,
|
||||
@@ -88,6 +89,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
draggedTaskView,
|
||||
velocity,
|
||||
isDismissing = true,
|
||||
dismissLength,
|
||||
dismissThreshold,
|
||||
finalPosition,
|
||||
shouldRemoveTaskView,
|
||||
@@ -107,6 +109,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
draggedTaskView: TaskView?,
|
||||
velocity: Float,
|
||||
isDismissing: Boolean,
|
||||
dismissLength: Int,
|
||||
dismissThreshold: Int,
|
||||
finalPosition: Float,
|
||||
shouldRemoveTaskView: Boolean,
|
||||
@@ -160,7 +163,7 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
SpringAnimation(draggedTaskView, taskDismissFloatProperty)
|
||||
.setSpring(createExpressiveDismissSpringForce())
|
||||
.setStartVelocity(startVelocity)
|
||||
.addUpdateListener { _, currentDisplacement, _ ->
|
||||
.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)
|
||||
@@ -185,8 +188,16 @@ class RecentsDismissUtils(private val recentsView: RecentsView<*, *>) {
|
||||
) {
|
||||
toRunOnEnd()
|
||||
}
|
||||
// End dismissed task animation once beyond the screen so next animations play.
|
||||
if (isDismissing && abs(currentDisplacement) >= abs(dismissLength)) {
|
||||
(animation as SpringAnimation).skipToEnd()
|
||||
}
|
||||
}
|
||||
.addEndListener { _, canceled, value, _ ->
|
||||
// Do not run animations if dismissed task animation is canceled, unless it has
|
||||
// already animated off screen.
|
||||
if (!canceled || abs(value) >= abs(dismissLength)) toRunOnEnd()
|
||||
}
|
||||
.addEndListener { _, _, _, _ -> toRunOnEnd() }
|
||||
if (!isDismissing) {
|
||||
addNeighborSettlingSpringAnimations(
|
||||
draggedTaskView,
|
||||
|
||||
@@ -7003,11 +7003,11 @@ public abstract class RecentsView<
|
||||
* spring in response to the perceived impact of the settling task.
|
||||
*/
|
||||
public SpringAnimation runTaskDismissSettlingSpringAnimation(TaskView draggedTaskView,
|
||||
float velocity, boolean isDismissing, int dismissThreshold, float finalPosition,
|
||||
boolean shouldRemoveTaskView, boolean isSplitSelection,
|
||||
float velocity, boolean isDismissing, int dismissLength, int dismissThreshold,
|
||||
float finalPosition, boolean shouldRemoveTaskView, boolean isSplitSelection,
|
||||
@NonNull Function0<Unit> onEndRunnable) {
|
||||
return mDismissUtils.createTaskDismissSettlingSpringAnimation(draggedTaskView, velocity,
|
||||
isDismissing, dismissThreshold, finalPosition, shouldRemoveTaskView,
|
||||
isDismissing, dismissLength, dismissThreshold, finalPosition, shouldRemoveTaskView,
|
||||
isSplitSelection, onEndRunnable);
|
||||
}
|
||||
|
||||
|
||||
@@ -124,6 +124,7 @@ public class DragLayer extends BaseDragLayer<Launcher> implements LauncherOverla
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = mContainer.createTouchControllers();
|
||||
}
|
||||
|
||||
|
||||
@@ -39,6 +39,7 @@ public class SimpleDragLayer<T extends Context & ActivityContext> extends BaseDr
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = new TouchController[] {};
|
||||
}
|
||||
}
|
||||
@@ -64,6 +64,7 @@ public class SecondaryDragLayer extends BaseDragLayer<SecondaryDisplayLauncher>
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = new TouchController[]{new CloseAllAppsTouchController(),
|
||||
mContainer.getDragController()};
|
||||
}
|
||||
|
||||
@@ -33,4 +33,7 @@ public interface TouchController {
|
||||
boolean onControllerInterceptTouchEvent(MotionEvent ev);
|
||||
|
||||
default void dump(String prefix, PrintWriter writer) { }
|
||||
|
||||
/** Called when touch controllers are destroyed during recreation. */
|
||||
default void onTouchControllerDestroyed() { }
|
||||
}
|
||||
@@ -128,7 +128,13 @@ public abstract class BaseDragLayer<T extends Context & ActivityContext>
|
||||
/**
|
||||
* Called to reinitialize touch controllers.
|
||||
*/
|
||||
public abstract void recreateControllers();
|
||||
public void recreateControllers() {
|
||||
if (mControllers != null) {
|
||||
for (TouchController controller : mControllers) {
|
||||
controller.onTouchControllerDestroyed();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as {@link #isEventOverView(View, MotionEvent, View)} where evView == this drag layer.
|
||||
|
||||
@@ -60,6 +60,7 @@ public class ActivityContextWrapper extends BaseContext {
|
||||
|
||||
@Override
|
||||
public void recreateControllers() {
|
||||
super.recreateControllers();
|
||||
mControllers = new TouchController[0];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user