From ec52ed9f99f66a7bf3a866cca26142e8c38cd7fe Mon Sep 17 00:00:00 2001 From: Vinit Nayak Date: Tue, 23 Jan 2024 15:58:02 -0800 Subject: [PATCH] Intercept clicks for non-supported split targets on workspace * If we're in split selection state we disable the following - G icon on PSB - Lens icon on PSB - Smartspace - Widgets Bug: 295467097 Test: Enter split contextual and observe split instructions view going boing when tapping on unsupported target Flag: com.android.wm.shell.enable_split_contextual Change-Id: Ia7783472f3de9359c2784788be5f35596cbc8deb --- .../uioverrides/QuickstepInteractionHandler.java | 5 +---- .../launcher3/uioverrides/QuickstepLauncher.java | 14 ++++++++++++-- .../android/launcher3/views/ActivityContext.java | 13 +++++++++++++ 3 files changed, 26 insertions(+), 6 deletions(-) diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java index 22f24f185a..039c0a0ad8 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepInteractionHandler.java @@ -28,10 +28,8 @@ import android.util.Log; import android.util.Pair; import android.view.View; import android.widget.RemoteViews; -import android.widget.Toast; import android.window.SplashScreen; -import com.android.launcher3.R; import com.android.launcher3.Utilities; import com.android.launcher3.logging.StatsLogManager; import com.android.launcher3.model.data.ItemInfo; @@ -63,8 +61,7 @@ class QuickstepInteractionHandler implements RemoteViews.InteractionHandler { // Log metric StatsLogManager.StatsLogger logger = mLauncher.getStatsLogManager().logger(); logger.log(LAUNCHER_SPLIT_WIDGET_ATTEMPT); - Toast.makeText(hostView.getContext(), R.string.split_widgets_not_supported, - Toast.LENGTH_SHORT).show(); + mLauncher.handleIncorrectSplitTargetSelection(); return true; } Pair options = remoteResponse.getLaunchOptions(view); diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java index 32d10b04ef..ac0e53e3d2 100644 --- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java @@ -36,6 +36,7 @@ import static com.android.launcher3.LauncherState.OVERVIEW; import static com.android.launcher3.LauncherState.OVERVIEW_MODAL_TASK; import static com.android.launcher3.LauncherState.OVERVIEW_SPLIT_SELECT; import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent; +import static com.android.launcher3.config.FeatureFlags.enableSplitContextually; import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition; @@ -676,7 +677,7 @@ public class QuickstepLauncher extends Launcher { splitSelectSource.alreadyRunningTaskId = taskWasFound ? foundTask.key.id : INVALID_TASK_ID; - if (FeatureFlags.enableSplitContextually()) { + if (enableSplitContextually()) { startSplitToHome(splitSelectSource); } else { recentsView.initiateSplitSelect(splitSelectSource); @@ -761,7 +762,7 @@ public class QuickstepLauncher extends Launcher { super.onPause(); - if (FeatureFlags.enableSplitContextually()) { + if (enableSplitContextually()) { // If Launcher pauses before both split apps are selected, exit split screen. if (!mSplitSelectStateController.isBothSplitAppsConfirmed() && !mSplitSelectStateController.isLaunchingFirstAppFullscreen()) { @@ -1352,6 +1353,15 @@ public class QuickstepLauncher extends Launcher { return (mTaskbarUIController != null && mTaskbarUIController.hasBubbles()); } + @Override + public boolean handleIncorrectSplitTargetSelection() { + if (enableSplitContextually() && !mSplitSelectStateController.isSplitSelectActive()) { + return false; + } + mSplitSelectStateController.getSplitInstructionsView().goBoing(); + return true; + } + private static final class LauncherTaskViewController extends TaskViewTouchController { diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java index c5317e3d5c..230a651698 100644 --- a/src/com/android/launcher3/views/ActivityContext.java +++ b/src/com/android/launcher3/views/ActivityContext.java @@ -154,6 +154,19 @@ public interface ActivityContext { return false; } + /** + * Handle user tapping on unsupported target when in split selection mode. + * See {@link #isSplitSelectionActive()} + * + * @return {@code true} if this method will handle the incorrect target selection, + * {@code false} if it could not be handled or if not possible to handle based on + * current split state + */ + default boolean handleIncorrectSplitTargetSelection() { + // Overridden + return false; + } + /** * The root view to support drag-and-drop and popup support. */