Merge "Update KQS launch task callbacks" into main

This commit is contained in:
Schneider Victor-tulias
2024-02-23 19:54:44 +00:00
committed by Android (Google) Code Review
9 changed files with 76 additions and 8 deletions
@@ -16,7 +16,10 @@
package com.android.launcher3.taskbar;
import androidx.annotation.Nullable;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.quickstep.util.TISBindHelper;
/**
* A data source which integrates with a Launcher instance, used specifically for a
@@ -50,4 +53,10 @@ public class DesktopTaskbarUIController extends TaskbarUIController {
public boolean supportsVisualStashing() {
return false;
}
@Nullable
@Override
protected TISBindHelper getTISBindHelper() {
return mLauncher.getTISBindHelper();
}
}
@@ -21,11 +21,14 @@ import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_STASH
import android.animation.Animator;
import androidx.annotation.Nullable;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.statemanager.StateManager;
import com.android.quickstep.RecentsActivity;
import com.android.quickstep.TopTaskTracker;
import com.android.quickstep.fallback.RecentsState;
import com.android.quickstep.util.TISBindHelper;
import com.android.quickstep.views.RecentsView;
import java.util.stream.Stream;
@@ -124,4 +127,10 @@ public class FallbackTaskbarUIController extends TaskbarUIController {
.get(mControllers.taskbarActivityContext).getCachedTopTask(true);
return topTask.isHomeTask() || topTask.isRecentsTask();
}
@Nullable
@Override
protected TISBindHelper getTISBindHelper() {
return mRecentsActivity.getTISBindHelper();
}
}
@@ -147,7 +147,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
KeyboardQuickSwitchTaskView taskView = (KeyboardQuickSwitchTaskView) layoutInflater.inflate(
R.layout.keyboard_quick_switch_taskview, mContent, false);
taskView.setId(View.generateViewId());
taskView.setOnClickListener(v -> mViewCallbacks.launchTappedTask(index));
taskView.setOnClickListener(v -> mViewCallbacks.launchTaskAt(index));
LayoutParams lp = new LayoutParams(width, mTaskViewHeight);
// Create a left-to-right ordering of views (or right-to-left in RTL locales)
@@ -186,7 +186,7 @@ public class KeyboardQuickSwitchView extends ConstraintLayout {
KeyboardQuickSwitchTaskView overviewButton =
(KeyboardQuickSwitchTaskView) layoutInflater.inflate(
R.layout.keyboard_quick_switch_overview, this, false);
overviewButton.setOnClickListener(v -> mViewCallbacks.launchTappedTask(MAX_TASKS));
overviewButton.setOnClickListener(v -> mViewCallbacks.launchTaskAt(MAX_TASKS));
overviewButton.<TextView>findViewById(R.id.text).setText(overflowString);
@@ -22,7 +22,6 @@ import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
import android.animation.Animator;
import android.app.ActivityOptions;
import android.view.KeyEvent;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.window.RemoteTransition;
@@ -137,7 +136,6 @@ public class KeyboardQuickSwitchViewController {
}
// Even with a valid index, this can be null if the user tries to quick switch before the
// views have been added in the KeyboardQuickSwitchView.
View taskView = mKeyboardQuickSwitchView.getTaskAt(index);
GroupTask task = mControllerCallbacks.getTaskAt(index);
if (task == null) {
return Math.max(0, index);
@@ -198,13 +196,18 @@ public class KeyboardQuickSwitchViewController {
&& keyCode != KeyEvent.KEYCODE_DPAD_RIGHT
&& keyCode != KeyEvent.KEYCODE_DPAD_LEFT
&& keyCode != KeyEvent.KEYCODE_GRAVE
&& keyCode != KeyEvent.KEYCODE_ESCAPE) {
&& keyCode != KeyEvent.KEYCODE_ESCAPE
&& keyCode != KeyEvent.KEYCODE_ENTER) {
return false;
}
if (keyCode == KeyEvent.KEYCODE_GRAVE || keyCode == KeyEvent.KEYCODE_ESCAPE) {
closeQuickSwitchView(true);
return true;
}
if (keyCode == KeyEvent.KEYCODE_ENTER) {
launchTaskAt(mCurrentFocusIndex);
return true;
}
if (!allowTraversal) {
return false;
}
@@ -234,9 +237,10 @@ public class KeyboardQuickSwitchViewController {
mCurrentFocusIndex = index;
}
void launchTappedTask(int index) {
KeyboardQuickSwitchViewController.this.launchTaskAt(index);
closeQuickSwitchView(true);
void launchTaskAt(int index) {
mCurrentFocusIndex = Utilities.boundToRange(
index, 0, mKeyboardQuickSwitchView.getChildCount() - 1);
mControllers.taskbarActivityContext.launchKeyboardFocusedTask();
}
void updateThumbnailInBackground(Task task, Consumer<ThumbnailData> callback) {
@@ -52,6 +52,7 @@ import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.RecentsAnimationCallbacks;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.TISBindHelper;
import com.android.quickstep.views.RecentsView;
import java.io.PrintWriter;
@@ -428,6 +429,12 @@ public class LauncherTaskbarUIController extends TaskbarUIController {
mTaskbarLauncherStateController.resetIconAlignment();
}
@Nullable
@Override
protected TISBindHelper getTISBindHelper() {
return mLauncher.getTISBindHelper();
}
@Override
public void dumpLogs(String prefix, PrintWriter pw) {
super.dumpLogs(prefix, pw);
@@ -1485,6 +1485,10 @@ public class TaskbarActivityContext extends BaseTaskbarContext {
btv.post(() -> mControllers.taskbarPopupController.showForIcon(btv));
}
public void launchKeyboardFocusedTask() {
mControllers.uiController.launchKeyboardFocusedTask();
}
public boolean isInApp() {
return mControllers.taskbarStashController.isInApp();
}
@@ -20,6 +20,7 @@ import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT;
import static com.android.launcher3.LauncherSettings.Favorites.CONTAINER_HOTSEAT_PREDICTION;
import static com.android.launcher3.taskbar.TaskbarStashController.FLAG_IN_APP;
import static com.android.quickstep.OverviewCommandHelper.TYPE_HIDE;
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
@@ -38,7 +39,9 @@ import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.OverviewCommandHelper;
import com.android.quickstep.util.GroupTask;
import com.android.quickstep.util.TISBindHelper;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.quickstep.views.TaskView.TaskIdAttributeContainer;
@@ -361,6 +364,28 @@ public class TaskbarUIController {
/** Adjusts the hotseat for the bubble bar. */
public void adjustHotseatForBubbleBar(boolean isBubbleBarVisible) {}
@Nullable
protected TISBindHelper getTISBindHelper() {
return null;
}
/**
* Launches the focused task in the Keyboard Quick Switch view through the OverviewCommandHelper
* <p>
* Use this helper method when the focused task may be the overview task.
*/
public void launchKeyboardFocusedTask() {
TISBindHelper tisBindHelper = getTISBindHelper();
if (tisBindHelper == null) {
return;
}
OverviewCommandHelper overviewCommandHelper = tisBindHelper.getOverviewCommandHelper();
if (overviewCommandHelper == null) {
return;
}
overviewCommandHelper.addCommand(TYPE_HIDE);
}
/**
* Adjusts the taskbar based on the visibility of the launcher.
* @param isVisible True if launcher is visible, false otherwise.
@@ -1360,6 +1360,11 @@ public class QuickstepLauncher extends Launcher {
return (mTaskbarUIController != null && mTaskbarUIController.hasBubbles());
}
@NonNull
public TISBindHelper getTISBindHelper() {
return mTISBindHelper;
}
@Override
public boolean handleIncorrectSplitTargetSelection() {
if (!enableSplitContextually() || !mSplitSelectStateController.isSplitSelectActive()) {
@@ -498,4 +498,9 @@ public final class RecentsActivity extends StatefulActivity<RecentsState> {
OverviewCommandHelper overviewCommandHelper = mTISBindHelper.getOverviewCommandHelper();
return overviewCommandHelper == null || overviewCommandHelper.canStartHomeSafely();
}
@NonNull
public TISBindHelper getTISBindHelper() {
return mTISBindHelper;
}
}