mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-02 08:56:55 +00:00
Allow user to select second split app from Taskbar
This patch makes it so that (when we enable Taskbar in Overview) users will be able to select their second app for splitscreen by tapping the Taskbar icon, or the icon in AllApps. This was done by performing a check to SplitSelectStateController when a taskbar icon is hit. If we are currently in split select mode, Taskbar/AllApps icons will no longer launch their respective fullscreen apps, but instead confirm the split attempt. The confirmed app will either be an already-running instance of the app, or a fresh instance of the app (if none is currently running). The split confirmation function is located in TaskbarUIController, where it is accessible to both LauncherTaskbarUIController (for 1P Launcher) and FallbackTaskbarUIController (for 3P launchers). Also cleans up ~2 lines of unused code from the old splitscreen instructions toast. Outstanding issues: - When selecting a second app from within AllApps, the AllApps shade does not animate away in a satisfying way - When selecting a second app and launching a fresh instance of that app, the animation appears to come from the wrong location - Intent + Intent splitting does not currently work - If the selected app is already running with multiple instances, it picks the oldest instance. Ideally, the newest instance is preferred. Bug: 251747761 Test: Manual testing with Taskbar in Overview flag enabled Change-Id: I302dc092740bb880f9134ba8e2e587c4f2c29d01
This commit is contained in:
@@ -90,6 +90,7 @@ import com.android.launcher3.util.SettingsCache;
|
||||
import com.android.launcher3.util.TraceHelper;
|
||||
import com.android.launcher3.util.ViewCache;
|
||||
import com.android.launcher3.views.ActivityContext;
|
||||
import com.android.quickstep.views.RecentsView;
|
||||
import com.android.systemui.shared.recents.model.Task;
|
||||
import com.android.systemui.shared.rotation.RotationButtonController;
|
||||
import com.android.systemui.shared.system.ActivityManagerWrapper;
|
||||
@@ -132,6 +133,7 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
private final boolean mIsUserSetupComplete;
|
||||
private final boolean mIsNavBarForceVisible;
|
||||
private final boolean mIsNavBarKidsMode;
|
||||
|
||||
private boolean mIsDestroyed = false;
|
||||
// The flag to know if the window is excluded from magnification region computation.
|
||||
private boolean mIsExcludeFromMagnificationRegion = false;
|
||||
@@ -755,42 +757,63 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
|
||||
if (info.isDisabled()) {
|
||||
ItemClickHandler.handleDisabledItemClicked(info, this);
|
||||
} else {
|
||||
Intent intent = new Intent(info.getIntent())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
|
||||
Toast.makeText(this, R.string.safemode_shortcut_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (info.isPromise()) {
|
||||
TestLogging.recordEvent(
|
||||
TestProtocol.SEQUENCE_MAIN, "start: taskbarPromiseIcon");
|
||||
intent = new PackageManagerHelper(this)
|
||||
.getMarketIntent(info.getTargetPackage())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
TaskbarUIController taskbarUIController = mControllers.uiController;
|
||||
RecentsView recents = taskbarUIController.getRecentsView();
|
||||
if (recents != null
|
||||
&& taskbarUIController.getRecentsView().isSplitSelectionActive()) {
|
||||
// If we are selecting a second app for split, launch the split tasks
|
||||
taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
|
||||
} else {
|
||||
// Else launch the selected task
|
||||
Intent intent = new Intent(info.getIntent())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
try {
|
||||
if (mIsSafeModeEnabled && !PackageManagerHelper.isSystemApp(this, intent)) {
|
||||
Toast.makeText(this, R.string.safemode_shortcut_error,
|
||||
Toast.LENGTH_SHORT).show();
|
||||
} else if (info.isPromise()) {
|
||||
TestLogging.recordEvent(
|
||||
TestProtocol.SEQUENCE_MAIN, "start: taskbarPromiseIcon");
|
||||
intent = new PackageManagerHelper(this)
|
||||
.getMarketIntent(info.getTargetPackage())
|
||||
.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
startActivity(intent);
|
||||
|
||||
} else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
TestLogging.recordEvent(
|
||||
TestProtocol.SEQUENCE_MAIN, "start: taskbarDeepShortcut");
|
||||
String id = info.getDeepShortcutId();
|
||||
String packageName = intent.getPackage();
|
||||
getSystemService(LauncherApps.class)
|
||||
.startShortcut(packageName, id, null, null, info.user);
|
||||
} else {
|
||||
startItemInfoActivity(info);
|
||||
} else if (info.itemType == Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
|
||||
TestLogging.recordEvent(
|
||||
TestProtocol.SEQUENCE_MAIN, "start: taskbarDeepShortcut");
|
||||
String id = info.getDeepShortcutId();
|
||||
String packageName = intent.getPackage();
|
||||
getSystemService(LauncherApps.class)
|
||||
.startShortcut(packageName, id, null, null, info.user);
|
||||
} else {
|
||||
startItemInfoActivity(info);
|
||||
}
|
||||
|
||||
mControllers.uiController.onTaskbarIconLaunched(info);
|
||||
} catch (NullPointerException
|
||||
| ActivityNotFoundException
|
||||
| SecurityException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
|
||||
}
|
||||
|
||||
mControllers.uiController.onTaskbarIconLaunched(info);
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
} catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
|
||||
Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
|
||||
.show();
|
||||
Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
|
||||
}
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
}
|
||||
} else if (tag instanceof AppInfo) {
|
||||
startItemInfoActivity((AppInfo) tag);
|
||||
mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag);
|
||||
AppInfo info = (AppInfo) tag;
|
||||
TaskbarUIController taskbarUIController = mControllers.uiController;
|
||||
RecentsView recents = taskbarUIController.getRecentsView();
|
||||
if (recents != null
|
||||
&& taskbarUIController.getRecentsView().isSplitSelectionActive()) {
|
||||
// If we are selecting a second app for split, launch the split tasks
|
||||
taskbarUIController.triggerSecondAppForSplit(info, info.intent, view);
|
||||
} else {
|
||||
// Else launch the selected task
|
||||
startItemInfoActivity((AppInfo) tag);
|
||||
mControllers.uiController.onTaskbarIconLaunched((AppInfo) tag);
|
||||
}
|
||||
mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
|
||||
} else {
|
||||
Log.e(TAG, "Unknown type clicked: " + tag);
|
||||
|
||||
Reference in New Issue
Block a user