Merge "[DenserUI] Add feature flag for app icon in inline shortcuts." into tm-qpr-dev
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 49dec1e..ab52adb 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -877,9 +877,9 @@
* (potentially breaking a split pair).
*/
private void launchFromTaskbarPreservingSplitIfVisible(RecentsView recents, ItemInfo info) {
- recents.findLastActiveTaskAndRunCallback(
+ recents.getSplitSelectController().findLastActiveTaskAndRunCallback(
info.getTargetComponent(),
- (Consumer<Task>) foundTask -> {
+ foundTask -> {
if (foundTask != null) {
TaskView foundTaskView =
recents.getTaskViewByTaskId(foundTask.key.id);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
index c03c916..37d9090 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarBackgroundRenderer.kt
@@ -20,6 +20,7 @@
import android.graphics.Color
import android.graphics.Paint
import android.graphics.Path
+import android.graphics.RectF
import com.android.launcher3.R
import com.android.launcher3.Utilities.mapRange
import com.android.launcher3.Utilities.mapToRange
@@ -30,7 +31,8 @@
/** Helps draw the taskbar background, made up of a rectangle plus two inverted rounded corners. */
class TaskbarBackgroundRenderer(context: TaskbarActivityContext) {
- val paint: Paint = Paint()
+ val paint = Paint()
+ val lastDrawnTransientRect = RectF()
var backgroundHeight = context.deviceProfile.taskbarSize.toFloat()
var translationYForSwipe = 0f
@@ -131,7 +133,11 @@
val radius = newBackgroundHeight / 2f
val bottomMarginProgress = bottomMargin * ((1f - progress) / 2f)
- canvas.translate(0f, canvas.height - bottomMargin + bottomMarginProgress)
+ // Aligns the bottom with the bottom of the stashed handle.
+ val bottom =
+ canvas.height - bottomMargin +
+ bottomMarginProgress +
+ (-mapRange(1f - progress, 0f, stashedHandleHeight / 2f) + translationYForSwipe)
// Draw shadow.
val shadowAlpha =
@@ -143,19 +149,14 @@
setColorAlphaBound(Color.BLACK, Math.round(shadowAlpha))
)
- // Aligns the bottom with the bottom of the stashed handle.
- val bottom =
- (-mapRange(1f - progress, 0f, stashedHandleHeight / 2f) + translationYForSwipe)
-
- canvas.drawRoundRect(
+ lastDrawnTransientRect.set(
transientBackgroundBounds.left + halfWidthDelta,
bottom - newBackgroundHeight,
transientBackgroundBounds.right - halfWidthDelta,
- bottom,
- radius,
- radius,
- paint
+ bottom
)
+
+ canvas.drawRoundRect(lastDrawnTransientRect, radius, radius, paint)
}
canvas.restore()
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index d1fea7b..45df9d6 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -33,6 +33,7 @@
import android.graphics.Canvas;
import android.graphics.Point;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.os.UserHandle;
import android.util.Pair;
@@ -69,11 +70,13 @@
import com.android.launcher3.shortcuts.ShortcutDragPreviewProvider;
import com.android.launcher3.testing.TestLogging;
import com.android.launcher3.testing.shared.TestProtocol;
+import com.android.launcher3.util.DisplayController;
import com.android.launcher3.util.IntSet;
import com.android.launcher3.util.ItemInfoMatcher;
import com.android.quickstep.util.LogUtils;
import com.android.quickstep.util.MultiValueUpdateListener;
import com.android.systemui.shared.recents.model.Task;
+import com.android.wm.shell.draganddrop.DragAndDropConstants;
import java.io.PrintWriter;
import java.util.Arrays;
@@ -310,9 +313,6 @@
if (mDisallowGlobalDrag) {
AbstractFloatingView.closeAllOpenViewsExcept(mActivity, TYPE_TASKBAR_ALL_APPS);
} else {
- // stash the transient taskbar
- mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
-
AbstractFloatingView.closeAllOpenViews(mActivity);
}
@@ -395,6 +395,15 @@
com.android.launcher3.logging.InstanceId launcherInstanceId = instanceIds.second;
intent.putExtra(ClipDescription.EXTRA_LOGGING_INSTANCE_ID, internalInstanceId);
+ if (DisplayController.isTransientTaskbar(mActivity)) {
+ // Tell WM Shell to ignore drag events in the provided transient taskbar region.
+ TaskbarDragLayer dragLayer = mControllers.taskbarActivityContext.getDragLayer();
+ int[] locationOnScreen = dragLayer.getLocationOnScreen();
+ RectF disallowExternalDropRegion = new RectF(dragLayer.getLastDrawnTransientRect());
+ disallowExternalDropRegion.offset(locationOnScreen[0], locationOnScreen[1]);
+ intent.putExtra(DragAndDropConstants.EXTRA_DISALLOW_HIT_REGION,
+ disallowExternalDropRegion);
+ }
ClipData clipData = new ClipData(clipDescription, new ClipData.Item(intent));
if (btv.startDragAndDrop(clipData, shadowBuilder, null /* localState */,
@@ -421,9 +430,6 @@
if (dragEvent.getResult()) {
maybeOnDragEnd();
} else {
- // un-stash the transient taskbar in case drag and drop was canceled
- mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(false);
-
// This will take care of calling maybeOnDragEnd() after the animation
animateGlobalDragViewToOriginalPosition(btv, dragEvent);
}
@@ -451,6 +457,9 @@
mControllers.taskbarAutohideSuspendController.updateFlag(
TaskbarAutohideSuspendController.FLAG_AUTOHIDE_SUSPEND_DRAGGING, false);
mActivity.onDragEnd();
+ // Note, this must be done last to ensure no AutohideSuspendFlags are active, as that
+ // will prevent us from stashing until the timeout.
+ mControllers.taskbarStashController.updateAndAnimateTransientTaskbar(true);
}
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
index 7114849..58d6244 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragLayer.java
@@ -20,6 +20,7 @@
import android.content.Context;
import android.graphics.Canvas;
+import android.graphics.RectF;
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
@@ -183,6 +184,11 @@
invalidate();
}
+ /** Returns the bounds in DragLayer coordinates of where the transient background was drawn. */
+ protected RectF getLastDrawnTransientRect() {
+ return mBackgroundRenderer.getLastDrawnTransientRect();
+ }
+
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
TestLogging.recordMotionEvent(TestProtocol.SEQUENCE_MAIN, "Touch event", ev);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index 1c6aca7..0b86155 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -38,7 +38,6 @@
import com.android.launcher3.anim.AnimatorListeners;
import com.android.launcher3.statemanager.StateManager;
import com.android.launcher3.uioverrides.QuickstepLauncher;
-import com.android.launcher3.uioverrides.states.OverviewState;
import com.android.launcher3.util.MultiPropertyFactory.MultiProperty;
import com.android.launcher3.util.window.RefreshRateTracker;
import com.android.quickstep.RecentsAnimationCallbacks;
@@ -119,11 +118,10 @@
mLauncherState = finalState;
updateStateForFlag(FLAG_TRANSITION_STATE_RUNNING, false);
applyState();
- boolean finalStateOverview = finalState instanceof OverviewState;
boolean disallowLongClick = finalState == LauncherState.OVERVIEW_SPLIT_SELECT;
com.android.launcher3.taskbar.Utilities.setOverviewDragState(
- mControllers, finalStateOverview /*disallowGlobalDrag*/,
- disallowLongClick, finalStateOverview /*allowInitialSplitSelection*/);
+ mControllers, finalState.disallowTaskbarGlobalDrag(),
+ disallowLongClick, finalState.allowTaskbarInitialSplitSelection());
}
};
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index 24a089c..3479255 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -189,9 +189,9 @@
if (recentsView == null) {
return;
}
- recentsView.findLastActiveTaskAndRunCallback(
+ recentsView.getSplitSelectController().findLastActiveTaskAndRunCallback(
splitSelectSource.intent.getComponent(),
- (Consumer<Task>) foundTask -> {
+ foundTask -> {
splitSelectSource.alreadyRunningTaskId = foundTask == null
? INVALID_TASK_ID
: foundTask.key.id;
@@ -206,9 +206,9 @@
*/
public void triggerSecondAppForSplit(ItemInfoWithIcon info, Intent intent, View startingView) {
RecentsView recents = getRecentsView();
- recents.findLastActiveTaskAndRunCallback(
+ recents.getSplitSelectController().findLastActiveTaskAndRunCallback(
info.getTargetComponent(),
- (Consumer<Task>) foundTask -> {
+ foundTask -> {
if (foundTask != null) {
TaskView foundTaskView = recents.getTaskViewByTaskId(foundTask.key.id);
// TODO (b/266482558): This additional null check is needed because there
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 46cd045..3dbe6c8 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -579,9 +579,9 @@
RecentsView recentsView = getOverviewPanel();
// Check if there is already an instance of this app running, if so, initiate the split
// using that.
- recentsView.findLastActiveTaskAndRunCallback(
+ mSplitSelectStateController.findLastActiveTaskAndRunCallback(
splitSelectSource.intent.getComponent(),
- (Consumer<Task>) foundTask -> {
+ foundTask -> {
splitSelectSource.alreadyRunningTaskId = foundTask == null
? INVALID_TASK_ID
: foundTask.key.id;
@@ -595,8 +595,7 @@
}
/** TODO(b/266482558) Migrate into SplitSelectStateController or someplace split specific. */
- private void startSplitToHome(
- SplitSelectSource source) {
+ private void startSplitToHome(SplitSelectSource source) {
AbstractFloatingView.closeAllOpenViews(this);
int splitPlaceholderSize = getResources().getDimensionPixelSize(
R.dimen.split_placeholder_size);
@@ -604,14 +603,14 @@
R.dimen.split_placeholder_inset);
Rect tempRect = new Rect();
- SplitSelectStateController controller = getSplitSelectStateController();
- controller.setInitialTaskSelect(source.intent, source.position.stagePosition,
- source.itemInfo, source.splitEvent, source.alreadyRunningTaskId);
+ mSplitSelectStateController.setInitialTaskSelect(source.intent,
+ source.position.stagePosition, source.itemInfo, source.splitEvent,
+ source.alreadyRunningTaskId);
RecentsView recentsView = getOverviewPanel();
recentsView.getPagedOrientationHandler().getInitialSplitPlaceholderBounds(
splitPlaceholderSize, splitPlaceholderInset, getDeviceProfile(),
- controller.getActiveSplitStagePosition(), tempRect);
+ mSplitSelectStateController.getActiveSplitStagePosition(), tempRect);
PendingAnimation anim = new PendingAnimation(TABLET_HOME_TO_SPLIT.getDuration());
RectF startingTaskRect = new RectF();
@@ -620,12 +619,12 @@
floatingTaskView.setAlpha(1);
floatingTaskView.addStagingAnimation(anim, startingTaskRect, tempRect,
false /* fadeWithThumbnail */, true /* isStagedTask */);
- controller.setFirstFloatingTaskView(floatingTaskView);
+ mSplitSelectStateController.setFirstFloatingTaskView(floatingTaskView);
anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationCancel(Animator animation) {
getDragLayer().removeView(floatingTaskView);
- controller.resetState();
+ mSplitSelectStateController.resetState();
}
});
anim.buildAnim().start();
@@ -1156,14 +1155,12 @@
// Launcher to first restore into Overview state, wait for the relevant tasks and icons to
// load in, and then proceed to OverviewSplitSelect.
if (isInState(OVERVIEW_SPLIT_SELECT)) {
- SplitSelectStateController splitSelectStateController =
- ((RecentsView) getOverviewPanel()).getSplitSelectController();
// Launcher will restart in Overview and then transition to OverviewSplitSelect.
outState.putIBinder(PENDING_SPLIT_SELECT_INFO, ObjectWrapper.wrap(
new PendingSplitSelectInfo(
- splitSelectStateController.getInitialTaskId(),
- splitSelectStateController.getActiveSplitStagePosition(),
- splitSelectStateController.getSplitEvent())
+ mSplitSelectStateController.getInitialTaskId(),
+ mSplitSelectStateController.getActiveSplitStagePosition(),
+ mSplitSelectStateController.getSplitEvent())
));
outState.putInt(RUNTIME_STATE, OVERVIEW.ordinal);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
index 95eb128..8125fc8 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/BackgroundAppState.java
@@ -116,6 +116,18 @@
return super.isTaskbarAlignedWithHotseat(launcher);
}
+ @Override
+ public boolean disallowTaskbarGlobalDrag() {
+ // Enable global drag in overview
+ return false;
+ }
+
+ @Override
+ public boolean allowTaskbarInitialSplitSelection() {
+ // Disallow split select from taskbar items in overview
+ return false;
+ }
+
public static float[] getOverviewScaleAndOffsetForBackgroundState(
BaseDraggingActivity activity) {
return new float[] {
diff --git a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
index d075750..233ed46 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/states/OverviewState.java
@@ -124,6 +124,18 @@
}
@Override
+ public boolean disallowTaskbarGlobalDrag() {
+ // Disable global drag in overview
+ return true;
+ }
+
+ @Override
+ public boolean allowTaskbarInitialSplitSelection() {
+ // Allow split select from taskbar items in overview
+ return true;
+ }
+
+ @Override
public String getDescription(Launcher launcher) {
return launcher.getString(R.string.accessibility_recent_apps);
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index 1b2bfc9..51afb5b 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -29,6 +29,7 @@
import android.app.ActivityOptions;
import android.app.ActivityThread;
import android.app.PendingIntent;
+import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
import android.content.pm.PackageManager;
@@ -59,6 +60,7 @@
import com.android.launcher3.testing.shared.TestProtocol;
import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
+import com.android.quickstep.RecentsModel;
import com.android.quickstep.SystemUiProxy;
import com.android.quickstep.TaskAnimationManager;
import com.android.quickstep.TaskViewUtils;
@@ -79,10 +81,12 @@
private final Context mContext;
private final Handler mHandler;
+ private final RecentsModel mRecentTasksModel;
private StatsLogManager mStatsLogManager;
private final SystemUiProxy mSystemUiProxy;
private final StateManager mStateManager;
- private final DepthController mDepthController;
+ @Nullable
+ private DepthController mDepthController;
private @StagePosition int mStagePosition;
private ItemInfo mItemInfo;
private Intent mInitialTaskIntent;
@@ -110,6 +114,7 @@
mSystemUiProxy = SystemUiProxy.INSTANCE.get(mContext);
mStateManager = stateManager;
mDepthController = depthController;
+ mRecentTasksModel = RecentsModel.INSTANCE.get(context);
}
/**
@@ -149,6 +154,50 @@
}
/**
+ * Pulls the list of active Tasks from RecentsModel, and finds the most recently active Task
+ * matching a given ComponentName. Then uses that Task (which could be null) with the given
+ * callback.
+ *
+ * Used in various task-switching or splitscreen operations when we need to check if there is a
+ * currently running Task of a certain type and use the most recent one.
+ */
+ public void findLastActiveTaskAndRunCallback(ComponentName componentName,
+ Consumer<Task> callback) {
+ mRecentTasksModel.getTasks(taskGroups -> {
+ Task lastActiveTask = null;
+ // Loop through tasks in reverse, since they are ordered with most-recent tasks last.
+ for (int i = taskGroups.size() - 1; i >= 0; i--) {
+ GroupTask groupTask = taskGroups.get(i);
+ Task task1 = groupTask.task1;
+ if (isInstanceOfComponent(task1, componentName)) {
+ lastActiveTask = task1;
+ break;
+ }
+ Task task2 = groupTask.task2;
+ if (isInstanceOfComponent(task2, componentName)) {
+ lastActiveTask = task2;
+ break;
+ }
+ }
+
+ callback.accept(lastActiveTask);
+ });
+ }
+
+ /**
+ * Checks if a given Task is the most recently-active Task of type componentName. Used for
+ * selecting already-running Tasks for splitscreen.
+ */
+ public boolean isInstanceOfComponent(@Nullable Task task, ComponentName componentName) {
+ // Exclude the task that is already staged
+ if (task == null || task.key.id == mInitialTaskId) {
+ return false;
+ }
+
+ return task.key.baseIntent.getComponent().equals(componentName);
+ }
+
+ /**
* To be called when the actual tasks ({@link #mInitialTaskId}, {@link #mSecondTaskId}) are
* to be launched. Call after launcher side animations are complete.
*/
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index 5ecc05a..bcb109c 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -1285,53 +1285,6 @@
return null;
}
- /**
- * Pulls the list of active Tasks from RecentsModel, and finds the most recently active Task
- * matching a given ComponentName. Then uses that Task (which could be null) with the given
- * callback.
- *
- * Used in various task-switching or splitscreen operations when we need to check if there is a
- * currently running Task of a certain type and use the most recent one.
- */
- public void findLastActiveTaskAndRunCallback(ComponentName componentName,
- Consumer<Task> callback) {
- mModel.getTasks(taskGroups -> {
- Task lastActiveTask = null;
- // Loop through tasks in reverse, since they are ordered with most-recent tasks last.
- for (int i = taskGroups.size() - 1; i >= 0; i--) {
- GroupTask groupTask = taskGroups.get(i);
- Task task1 = groupTask.task1;
- if (isInstanceOfComponent(task1, componentName)) {
- lastActiveTask = task1;
- break;
- }
- Task task2 = groupTask.task2;
- if (isInstanceOfComponent(task2, componentName)) {
- lastActiveTask = task2;
- break;
- }
- }
-
- callback.accept(lastActiveTask);
- });
- }
-
- /**
- * Checks if a given Task is the most recently-active Task of type componentName. Used for
- * selecting already-running Tasks for splitscreen.
- */
- public boolean isInstanceOfComponent(@Nullable Task task, ComponentName componentName) {
- if (task == null) {
- return false;
- }
- // Exclude the task that is already staged
- if (mSplitHiddenTaskView != null && mSplitHiddenTaskView.getTask().equals(task)) {
- return false;
- }
-
- return task.key.baseIntent.getComponent().equals(componentName);
- }
-
public void setOverviewStateEnabled(boolean enabled) {
mOverviewStateEnabled = enabled;
updateTaskStackListenerState();
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java
index b109e8a..9e28608 100644
--- a/src/com/android/launcher3/BubbleTextView.java
+++ b/src/com/android/launcher3/BubbleTextView.java
@@ -374,9 +374,7 @@
@UiThread
protected void applyIconAndLabel(ItemInfoWithIcon info) {
- boolean useTheme = mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER
- || mDisplay == DISPLAY_TASKBAR;
- int flags = useTheme ? FLAG_THEMED : 0;
+ int flags = shouldUseTheme() ? FLAG_THEMED : 0;
if (mHideBadge) {
flags |= FLAG_NO_BADGE;
}
@@ -388,6 +386,11 @@
applyLabel(info);
}
+ protected boolean shouldUseTheme() {
+ return mDisplay == DISPLAY_WORKSPACE || mDisplay == DISPLAY_FOLDER
+ || mDisplay == DISPLAY_TASKBAR;
+ }
+
@UiThread
private void applyLabel(ItemInfoWithIcon info) {
setText(info.title);
diff --git a/src/com/android/launcher3/LauncherState.java b/src/com/android/launcher3/LauncherState.java
index 81fbe79..b8d13ed 100644
--- a/src/com/android/launcher3/LauncherState.java
+++ b/src/com/android/launcher3/LauncherState.java
@@ -226,6 +226,20 @@
}
/**
+ * Returns whether taskbar global drag is disallowed in this state.
+ */
+ public boolean disallowTaskbarGlobalDrag() {
+ return false;
+ }
+
+ /**
+ * Returns whether the taskbar shortcut should trigger split selection mode.
+ */
+ public boolean allowTaskbarInitialSplitSelection() {
+ return false;
+ }
+
+ /**
* Fraction shift in the vertical translation UI and related properties
*
* @see com.android.launcher3.allapps.AllAppsTransitionController