diff --git a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java index 51c2294678..af4f49d324 100644 --- a/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java +++ b/quickstep/src/com/android/launcher3/BaseQuickstepLauncher.java @@ -21,7 +21,9 @@ import static com.android.launcher3.LauncherState.FLAG_HIDE_BACK_BUTTON; import static com.android.launcher3.LauncherState.NORMAL; import static com.android.launcher3.LauncherState.NO_OFFSET; import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE; +import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE; import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID; +import static com.android.launcher3.popup.QuickstepSystemShortcut.getSplitSelectShortcutByPosition; import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN; import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR; import static com.android.quickstep.SysUINavigationMode.Mode.NO_BUTTON; @@ -63,6 +65,7 @@ import com.android.launcher3.util.ActivityOptionsWrapper; import com.android.launcher3.util.DisplayController; import com.android.launcher3.util.IntSet; import com.android.launcher3.util.ObjectWrapper; +import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; import com.android.launcher3.util.UiThreadHelper; import com.android.quickstep.OverviewCommandHelper; import com.android.quickstep.RecentsModel; @@ -89,6 +92,7 @@ import com.android.systemui.unfold.config.UnfoldTransitionConfig; import java.io.FileDescriptor; import java.io.PrintWriter; +import java.util.ArrayList; import java.util.List; import java.util.stream.Stream; @@ -494,8 +498,20 @@ public abstract class BaseQuickstepLauncher extends Launcher @Override public Stream getSupportedShortcuts() { - return Stream.concat(Stream.of(WellbeingModel.SHORTCUT_FACTORY), - super.getSupportedShortcuts()); + Stream base = Stream.of(WellbeingModel.SHORTCUT_FACTORY); + if (ENABLE_SPLIT_FROM_WORKSPACE.get() && mDeviceProfile.isTablet) { + RecentsView recentsView = getOverviewPanel(); + // TODO: Pull it out of PagedOrentationHandler for split from workspace. + List positions = + recentsView.getPagedOrientationHandler().getSplitPositionOptions( + mDeviceProfile); + List> splitShortcuts = new ArrayList<>(); + for (SplitPositionOption position : positions) { + splitShortcuts.add(getSplitSelectShortcutByPosition(position)); + } + base = Stream.concat(base, splitShortcuts.stream()); + } + return Stream.concat(base, super.getSupportedShortcuts()); } @Override diff --git a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java new file mode 100644 index 0000000000..c40d2225b0 --- /dev/null +++ b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java @@ -0,0 +1,51 @@ +/* + * Copyright (C) 2022 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.android.launcher3.popup; + +import android.view.View; + +import com.android.launcher3.BaseQuickstepLauncher; +import com.android.launcher3.model.data.ItemInfo; +import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption; + +public interface QuickstepSystemShortcut { + + static SystemShortcut.Factory getSplitSelectShortcutByPosition( + SplitPositionOption position) { + return (activity, itemInfo) -> new QuickstepSystemShortcut.SplitSelectSystemShortcut( + activity, itemInfo, position); + } + + class SplitSelectSystemShortcut extends SystemShortcut { + + private final BaseQuickstepLauncher mLauncher; + private final ItemInfo mItemInfo; + private final SplitPositionOption mPosition; + + public SplitSelectSystemShortcut(BaseQuickstepLauncher launcher, ItemInfo itemInfo, + SplitPositionOption position) { + super(position.iconResId, position.textResId, launcher, itemInfo); + + mLauncher = launcher; + mItemInfo = itemInfo; + mPosition = position; + } + + @Override + public void onClick(View view) { + } + } +} diff --git a/src/com/android/launcher3/config/FeatureFlags.java b/src/com/android/launcher3/config/FeatureFlags.java index cd168a27aa..1d8669d82e 100644 --- a/src/com/android/launcher3/config/FeatureFlags.java +++ b/src/com/android/launcher3/config/FeatureFlags.java @@ -252,6 +252,10 @@ public final class FeatureFlags { "ENABLE_ALL_APPS_IN_TASKBAR", false, "Enables accessing All Apps from the system Taskbar."); + public static final BooleanFlag ENABLE_SPLIT_FROM_WORKSPACE = getDebugFlag( + "ENABLE_SPLIT_FROM_WORKSPACE", false, + "Enable initiating split screen from workspace."); + public static void initialize(Context context) { synchronized (sDebugFlags) { for (DebugFlag flag : sDebugFlags) {