diff options
Diffstat (limited to 'quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java')
-rw-r--r-- | quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java | 37 |
1 files changed, 19 insertions, 18 deletions
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java index a293f748b9..b29ce6be14 100644 --- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchViewController.java @@ -24,7 +24,7 @@ import android.view.View; import androidx.annotation.NonNull; import androidx.annotation.Nullable; -import com.android.launcher3.anim.AnimationSuccessListener; +import com.android.launcher3.anim.AnimatorListeners; import com.android.launcher3.taskbar.overlay.TaskbarOverlayContext; import com.android.launcher3.taskbar.overlay.TaskbarOverlayDragLayer; import com.android.quickstep.SystemUiProxy; @@ -92,27 +92,19 @@ public class KeyboardQuickSwitchViewController { protected void closeQuickSwitchView(boolean animate) { if (mCloseAnimation != null) { - if (animate) { - // Let currently-running animation finish. - return; - } else { - mCloseAnimation.cancel(); + // Let currently-running animation finish. + if (!animate) { + mCloseAnimation.end(); } + return; } if (!animate) { - mCloseAnimation = null; onCloseComplete(); return; } mCloseAnimation = mKeyboardQuickSwitchView.getCloseAnimation(); - mCloseAnimation.addListener(new AnimationSuccessListener() { - @Override - public void onAnimationSuccess(Animator animator) { - mCloseAnimation = null; - onCloseComplete(); - } - }); + mCloseAnimation.addListener(AnimatorListeners.forEndCallback(this::onCloseComplete)); mCloseAnimation.start(); } @@ -141,11 +133,20 @@ public class KeyboardQuickSwitchViewController { GroupTask task = mControllerCallbacks.getTaskAt(index); if (task == null) { return Math.max(0, index); - } else if (mOnDesktop) { + } + Task task2 = task.task2; + int runningTaskId = ActivityManagerWrapper.getInstance().getRunningTask().taskId; + if (runningTaskId == task.task1.key.id + || (task2 != null && runningTaskId == task2.key.id)) { + // Ignore attempts to run the selected task if it is already running. + return -1; + } + + if (mOnDesktop) { UI_HELPER_EXECUTOR.execute(() -> SystemUiProxy.INSTANCE.get(mKeyboardQuickSwitchView.getContext()) .showDesktopApp(task.task1.key.id)); - } else if (task.task2 == null) { + } else if (task2 == null) { UI_HELPER_EXECUTOR.execute(() -> ActivityManagerWrapper.getInstance().startActivityFromRecents( task.task1.key, @@ -153,13 +154,13 @@ public class KeyboardQuickSwitchViewController { taskView == null ? mKeyboardQuickSwitchView : taskView, null) .options)); } else { - mControllers.uiController.launchSplitTasks( - taskView == null ? mKeyboardQuickSwitchView : taskView, task); + mControllers.uiController.launchSplitTasks(task); } return -1; } private void onCloseComplete() { + mCloseAnimation = null; mOverlayContext.getDragLayer().removeView(mKeyboardQuickSwitchView); mControllerCallbacks.onCloseComplete(); } |