Merge "[Toast] Introduce SysUI's animation library to the transition manager." into tm-qpr-dev
diff --git a/quickstep/res/values/strings.xml b/quickstep/res/values/strings.xml
index 761934e..4f30791 100644
--- a/quickstep/res/values/strings.xml
+++ b/quickstep/res/values/strings.xml
@@ -231,20 +231,20 @@
<string name="accessibility_rotate_button">Rotate screen</string>
<!-- ******* Taskbar Edu ******* -->
- <!-- Accessibility title for the taskbar education window. [CHAR_LIMIT=NONE] -->
+ <!-- Accessibility title for the Taskbar education window. [CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_a11y_title">Taskbar education</string>
- <!-- Accessibility text spoken when the taskbar education panel appears [CHAR_LIMIT=NONE] -->
+ <!-- Accessibility text spoken when the Taskbar education panel appears [CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_opened">Taskbar education appeared</string>
- <!-- Accessibility text spoken when the taskbar education panel disappears [CHAR_LIMIT=NONE] -->
+ <!-- Accessibility text spoken when the Taskbar education panel disappears [CHAR_LIMIT=NONE] -->
<string name="taskbar_edu_closed">Taskbar education closed</string>
- <!-- Text in dialog that lets a user know how they can use the taskbar to use multiple apps at once on their device. [CHAR_LIMIT=60] -->
+ <!-- Text in dialog that lets a user know how they can use the Taskbar to use multiple apps at once on their device. [CHAR_LIMIT=60] -->
<string name="taskbar_edu_splitscreen">Drag an app to the side to use 2 apps at once</string>
- <!-- Text in dialog that lets a user know how they can show the taskbar on their device. [CHAR_LIMIT=60] -->
- <string name="taskbar_edu_stashing">Short swipe up to show the taskbar</string>
- <!-- Text in dialog that lets a user know how the taskbar suggests apps based on their usage. [CHAR_LIMIT=60] -->
+ <!-- Text in dialog that lets a user know how they can show the Taskbar on their device. [CHAR_LIMIT=60] -->
+ <string name="taskbar_edu_stashing">Slow swipe up to show the Taskbar</string>
+ <!-- Text in dialog that lets a user know how the Taskbar suggests apps based on their usage. [CHAR_LIMIT=60] -->
<string name="taskbar_edu_suggestions">Get app suggestions based on your routine</string>
- <!-- Title in dialog that shows a user what they can do with the taskbar. [CHAR_LIMIT=60] -->
- <string name="taskbar_edu_features">Do more with the taskbar</string>
+ <!-- Title in dialog that shows a user what they can do with the Taskbar. [CHAR_LIMIT=60] -->
+ <string name="taskbar_edu_features">Do more with the Taskbar</string>
<!-- Text on button to go to the next screen of a tutorial [CHAR_LIMIT=16] -->
<string name="taskbar_edu_next">Next</string>
<!-- Text on button to go to the previous screen of a tutorial [CHAR_LIMIT=16] -->
@@ -267,13 +267,13 @@
<string name="taskbar_button_notifications">Notifications</string>
<!-- Content description for quick settings button [CHAR_LIMIT=16] -->
<string name="taskbar_button_quick_settings">Quick Settings</string>
- <!-- Accessibility title for the taskbar window. [CHAR_LIMIT=NONE] -->
+ <!-- Accessibility title for the Taskbar window. [CHAR_LIMIT=NONE] -->
<string name="taskbar_a11y_title">Taskbar</string>
- <!-- Accessibility title for the taskbar window on phones. [CHAR_LIMIT=NONE] -->
+ <!-- Accessibility title for the Taskbar window on phones. [CHAR_LIMIT=NONE] -->
<string name="taskbar_phone_a11y_title">Navigation bar</string>
- <!-- Label for moving drop target to the top or left side of the screen, depending on orientation (from the taskbar only). -->
+ <!-- Label for moving drop target to the top or left side of the screen, depending on orientation (from the Taskbar only). -->
<string name="move_drop_target_top_or_left">Move to top/left</string>
- <!-- Label for moving drop target to the bottom or right side of the screen, depending on orientation (from the taskbar only). -->
+ <!-- Label for moving drop target to the bottom or right side of the screen, depending on orientation (from the Taskbar only). -->
<string name="move_drop_target_bottom_or_right">Move to bottom/right</string>
</resources>
diff --git a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
index 45d1b11..184ea71 100644
--- a/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
+++ b/quickstep/src/com/android/launcher3/popup/QuickstepSystemShortcut.java
@@ -15,38 +15,14 @@
*/
package com.android.launcher3.popup;
-import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE;
-import static com.android.launcher3.util.SplitConfigurationOptions.getLogEventForPosition;
-import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SPLIT;
-
-import android.animation.Animator;
-import android.animation.AnimatorListenerAdapter;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.graphics.Rect;
-import android.graphics.RectF;
-import android.graphics.drawable.BitmapDrawable;
-import android.graphics.drawable.Drawable;
-import android.util.Log;
import android.view.View;
-import androidx.annotation.Nullable;
-
-import com.android.launcher3.AbstractFloatingView;
-import com.android.launcher3.R;
-import com.android.launcher3.anim.PendingAnimation;
-import com.android.launcher3.logging.StatsLogManager;
import com.android.launcher3.model.data.ItemInfo;
-import com.android.launcher3.model.data.WorkspaceItemInfo;
+import com.android.launcher3.splitscreen.SplitShortcut;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
-import com.android.quickstep.util.SplitSelectStateController;
-import com.android.quickstep.views.FloatingTaskView;
-import com.android.quickstep.views.RecentsView;
-import com.android.systemui.shared.recents.model.Task;
-import java.util.function.Consumer;
-
+/** {@link SystemShortcut.Factory} implementation to create workspace split shortcuts */
public interface QuickstepSystemShortcut {
String TAG = QuickstepSystemShortcut.class.getSimpleName();
@@ -58,116 +34,12 @@
originalView, position);
}
- class SplitSelectSystemShortcut extends SystemShortcut<QuickstepLauncher> {
-
- private final int mSplitPlaceholderSize;
- private final int mSplitPlaceholderInset;
-
- private final Rect mTempRect = new Rect();
- private final SplitPositionOption mPosition;
+ class SplitSelectSystemShortcut extends SplitShortcut<QuickstepLauncher> {
public SplitSelectSystemShortcut(QuickstepLauncher launcher, ItemInfo itemInfo,
View originalView, SplitPositionOption position) {
- super(position.iconResId, position.textResId, launcher, itemInfo, originalView);
-
- mPosition = position;
-
- mSplitPlaceholderSize = launcher.getResources().getDimensionPixelSize(
- R.dimen.split_placeholder_size);
- mSplitPlaceholderInset = launcher.getResources().getDimensionPixelSize(
- R.dimen.split_placeholder_inset);
- }
-
- @Override
- public void onClick(View view) {
- // Initiate splitscreen from the Home screen or Home All Apps
- Bitmap bitmap;
- Intent intent;
- if (mItemInfo instanceof WorkspaceItemInfo) {
- final WorkspaceItemInfo workspaceItemInfo = (WorkspaceItemInfo) mItemInfo;
- bitmap = workspaceItemInfo.bitmap.icon;
- intent = workspaceItemInfo.intent;
- } else if (mItemInfo instanceof com.android.launcher3.model.data.AppInfo) {
- final com.android.launcher3.model.data.AppInfo appInfo =
- (com.android.launcher3.model.data.AppInfo) mItemInfo;
- bitmap = appInfo.bitmap.icon;
- intent = appInfo.intent;
- } else {
- Log.e(TAG, "unknown item type");
- return;
- }
-
- StatsLogManager.EventEnum splitEvent = getLogEventForPosition(mPosition.stagePosition);
- RecentsView recentsView = mTarget.getOverviewPanel();
- // Check if there is already an instance of this app running, if so, initiate the split
- // using that.
- recentsView.findLastActiveTaskAndRunCallback(
- intent.getComponent(),
- (Consumer<Task>) foundTask -> {
- SplitSelectSource source = new SplitSelectSource(mOriginalView,
- new BitmapDrawable(bitmap), intent, mPosition, mItemInfo,
- splitEvent, foundTask);
- if (ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE.get()) {
- startSplitToHome(source);
- } else {
- recentsView.initiateSplitSelect(source);
- }
- }
- );
- }
-
- private void startSplitToHome(SplitSelectSource source) {
- AbstractFloatingView.closeAllOpenViews(mTarget);
-
- SplitSelectStateController controller = mTarget.getSplitSelectStateController();
- controller.setInitialTaskSelect(source.intent, source.position.stagePosition,
- source.itemInfo, source.splitEvent, source.alreadyRunningTask);
-
- RecentsView recentsView = mTarget.getOverviewPanel();
- recentsView.getPagedOrientationHandler().getInitialSplitPlaceholderBounds(
- mSplitPlaceholderSize, mSplitPlaceholderInset, mTarget.getDeviceProfile(),
- controller.getActiveSplitStagePosition(), mTempRect);
-
- PendingAnimation anim = new PendingAnimation(TABLET_HOME_TO_SPLIT.getDuration());
- RectF startingTaskRect = new RectF();
- final FloatingTaskView floatingTaskView = FloatingTaskView.getFloatingTaskView(mTarget,
- source.view, null /* thumbnail */, source.drawable, startingTaskRect);
- floatingTaskView.setAlpha(1);
- floatingTaskView.addStagingAnimation(anim, startingTaskRect, mTempRect,
- false /* fadeWithThumbnail */, true /* isStagedTask */);
- controller.setFirstFloatingTaskView(floatingTaskView);
- anim.addListener(new AnimatorListenerAdapter() {
- @Override
- public void onAnimationCancel(Animator animation) {
- mTarget.getDragLayer().removeView(floatingTaskView);
- controller.resetState();
- }
- });
- anim.buildAnim().start();
- }
- }
-
- class SplitSelectSource {
-
- public final View view;
- public final Drawable drawable;
- public final Intent intent;
- public final SplitPositionOption position;
- public final ItemInfo itemInfo;
- public final StatsLogManager.EventEnum splitEvent;
- @Nullable
- public final Task alreadyRunningTask;
-
- public SplitSelectSource(View view, Drawable drawable, Intent intent,
- SplitPositionOption position, ItemInfo itemInfo,
- StatsLogManager.EventEnum splitEvent, @Nullable Task foundTask) {
- this.view = view;
- this.drawable = drawable;
- this.intent = intent;
- this.position = position;
- this.itemInfo = itemInfo;
- this.splitEvent = splitEvent;
- this.alreadyRunningTask = foundTask;
+ super(position.iconResId, position.textResId, launcher, itemInfo, originalView,
+ position);
}
}
}
diff --git a/quickstep/src/com/android/launcher3/splitscreen/SplitShortcut.kt b/quickstep/src/com/android/launcher3/splitscreen/SplitShortcut.kt
new file mode 100644
index 0000000..20c8c44
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/splitscreen/SplitShortcut.kt
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 2023 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.splitscreen
+
+import android.content.Context
+import android.content.Intent
+import android.graphics.Bitmap
+import android.graphics.drawable.BitmapDrawable
+import android.util.Log
+import android.view.View
+import com.android.launcher3.model.data.ItemInfo
+import com.android.launcher3.model.data.WorkspaceItemInfo
+import com.android.launcher3.popup.QuickstepSystemShortcut
+import com.android.launcher3.popup.SystemShortcut
+import com.android.launcher3.util.SplitConfigurationOptions
+import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource
+import com.android.launcher3.views.ActivityContext
+
+/**
+ * Shortcut to allow starting split. Default interaction for [onClick] is to launch
+ * split selection mode
+ */
+abstract class SplitShortcut<T>(
+ iconResId: Int,
+ labelResId: Int,
+ target: T,
+ itemInfo: ItemInfo?,
+ originalView: View?,
+ protected val position: SplitPositionOption
+) : SystemShortcut<T>(iconResId, labelResId, target, itemInfo, originalView) where
+T : Context?,
+T : ActivityContext? {
+ private val TAG = SystemShortcut::class.java.simpleName
+
+ // Initiate splitscreen from the Home screen or Home All Apps
+ protected val splitSelectSource: SplitSelectSource?
+ get() {
+ // Initiate splitscreen from the Home screen or Home All Apps
+ val bitmap: Bitmap
+ val intent: Intent
+ when (mItemInfo) {
+ is WorkspaceItemInfo -> {
+ val workspaceItemInfo = mItemInfo
+ bitmap = workspaceItemInfo.bitmap.icon
+ intent = workspaceItemInfo.intent
+ }
+ is com.android.launcher3.model.data.AppInfo -> {
+ val appInfo = mItemInfo
+ bitmap = appInfo.bitmap.icon
+ intent = appInfo.intent
+ }
+ else -> {
+ Log.e(TAG, "unknown item type")
+ return null
+ }
+ }
+ val splitEvent =
+ SplitConfigurationOptions.getLogEventForPosition(position.stagePosition)
+ return SplitSelectSource(
+ mOriginalView,
+ BitmapDrawable(bitmap),
+ intent,
+ position,
+ mItemInfo,
+ splitEvent
+ )
+ }
+
+ /** Starts split selection on the provided [mTarget] */
+ override fun onClick(view: View?) {
+ val splitSelectSource = splitSelectSource
+ if (splitSelectSource == null) {
+ Log.w(QuickstepSystemShortcut.TAG, "no split selection source")
+ return
+ }
+ mTarget!!.startSplitSelection(splitSelectSource)
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 8a5b2c5..accbf21 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.taskbar;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.content.pm.PackageManager.FEATURE_PC;
import static android.os.Trace.TRACE_TAG_APP;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
@@ -92,6 +93,7 @@
import com.android.launcher3.util.NavigationMode;
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.SettingsCache;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
import com.android.launcher3.util.TraceHelper;
import com.android.launcher3.util.ViewCache;
import com.android.launcher3.views.ActivityContext;
@@ -754,6 +756,11 @@
}
}
+ @Override
+ public void startSplitSelection(SplitSelectSource splitSelectSource) {
+ mControllers.uiController.startSplitSelection(splitSelectSource);
+ }
+
protected void onTaskbarIconClicked(View view) {
Object tag = view.getTag();
if (tag instanceof Task) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
index d9773d4..62f1293 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarLauncherStateController.java
@@ -125,7 +125,8 @@
mControllers.taskbarDragController.setDisallowLongClick(disallowLongClick);
mControllers.taskbarAllAppsController.setDisallowGlobalDrag(disallowGlobalDrag);
mControllers.taskbarAllAppsController.setDisallowLongClick(disallowLongClick);
- mControllers.taskbarPopupController.setHideSplitOptions(disallowGlobalDrag);
+ mControllers.taskbarPopupController.setAllowInitialSplitSelection(
+ disallowGlobalDrag);
}
};
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
index 9b27c9d..30d6eb4 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarPopupController.java
@@ -17,11 +17,9 @@
import static com.android.launcher3.util.SplitConfigurationOptions.getLogEventForPosition;
-import android.content.ClipDescription;
import android.content.Intent;
import android.content.pm.LauncherApps;
import android.graphics.Point;
-import android.os.Bundle;
import android.util.Pair;
import android.view.MotionEvent;
import android.view.View;
@@ -46,6 +44,7 @@
import com.android.launcher3.popup.PopupLiveUpdateHandler;
import com.android.launcher3.popup.SystemShortcut;
import com.android.launcher3.shortcuts.DeepShortcutView;
+import com.android.launcher3.splitscreen.SplitShortcut;
import com.android.launcher3.util.ComponentKey;
import com.android.launcher3.util.LauncherBindableItemsContainer;
import com.android.launcher3.util.PackageUserKey;
@@ -75,7 +74,7 @@
// Initialized in init.
private TaskbarControllers mControllers;
- private boolean mHideSplitOptions;
+ private boolean mAllowInitialSplitSelection;
public TaskbarPopupController(TaskbarActivityContext context) {
mContext = context;
@@ -101,8 +100,8 @@
mPopupDataProvider.setDeepShortcutMap(deepShortcutMapCopy);
}
- public void setHideSplitOptions(boolean hideSplitOptions) {
- mHideSplitOptions = hideSplitOptions;
+ public void setAllowInitialSplitSelection(boolean allowInitialSplitSelection) {
+ mAllowInitialSplitSelection = allowInitialSplitSelection;
}
private void updateNotificationDots(Predicate<PackageUserKey> updatedDots) {
@@ -188,13 +187,9 @@
}
// Create a Stream of all applicable system shortcuts
- // TODO(b/227800345): Add "Split bottom" option when tablet is in portrait mode.
private Stream<SystemShortcut.Factory> getSystemShortcuts() {
// concat a Stream of split options with a Stream of APP_INFO
Stream<SystemShortcut.Factory> appInfo = Stream.of(APP_INFO);
- if (mHideSplitOptions) {
- return appInfo;
- }
return Stream.concat(
Utilities.getSplitPositionOptions(mContext.getDeviceProfile())
@@ -261,7 +256,7 @@
private SystemShortcut.Factory<BaseTaskbarContext> createSplitShortcutFactory(
SplitPositionOption position) {
return (context, itemInfo, originalView) -> new TaskbarSplitShortcut(context, itemInfo,
- originalView, position);
+ originalView, position, mAllowInitialSplitSelection);
}
/**
@@ -269,32 +264,43 @@
* from the taskbar, as if the user performed a drag and drop split.
* Includes an onClick method that initiates the actual split.
*/
- private static class TaskbarSplitShortcut extends SystemShortcut<BaseTaskbarContext> {
- private final SplitPositionOption mPosition;
+ private static class TaskbarSplitShortcut extends
+ SplitShortcut<BaseTaskbarContext> {
+ /**
+ * If {@code true}, clicking this shortcut will not attempt to start a split app directly,
+ * but be the first app in split selection mode
+ */
+ private final boolean mAllowInitialSplitSelection;
- TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo, View originalView,
- SplitPositionOption position) {
- super(position.iconResId, position.textResId, context, itemInfo, originalView);
- mPosition = position;
- }
+ TaskbarSplitShortcut(BaseTaskbarContext context, ItemInfo itemInfo, View originalView,
+ SplitPositionOption position, boolean allowInitialSplitSelection) {
+ super(position.iconResId, position.textResId, context, itemInfo, originalView,
+ position);
+ mAllowInitialSplitSelection = allowInitialSplitSelection;
+ }
@Override
public void onClick(View view) {
+ AbstractFloatingView.closeAllOpenViews(mTarget);
+ if (mAllowInitialSplitSelection) {
+ super.onClick(view);
+ return;
+ }
+
// Initiate splitscreen from the in-app Taskbar or Taskbar All Apps
Pair<InstanceId, com.android.launcher3.logging.InstanceId> instanceIds =
LogUtils.getShellShareableInstanceId();
mTarget.getStatsLogManager().logger()
.withItemInfo(mItemInfo)
.withInstanceId(instanceIds.second)
- .log(getLogEventForPosition(mPosition.stagePosition));
+ .log(getLogEventForPosition(getPosition().stagePosition));
- AbstractFloatingView.closeAllOpenViews(mTarget);
if (mItemInfo.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
WorkspaceItemInfo workspaceItemInfo = (WorkspaceItemInfo) mItemInfo;
SystemUiProxy.INSTANCE.get(mTarget).startShortcut(
workspaceItemInfo.getIntent().getPackage(),
workspaceItemInfo.getDeepShortcutId(),
- mPosition.stagePosition,
+ getPosition().stagePosition,
null,
workspaceItemInfo.user,
instanceIds.first);
@@ -305,7 +311,7 @@
null,
mItemInfo.user),
new Intent(),
- mPosition.stagePosition,
+ getPosition().stagePosition,
null,
instanceIds.first);
}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
index ef79b8e..999db3b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarStashController.java
@@ -184,12 +184,13 @@
flags -> {
boolean inApp = hasAnyFlag(flags, FLAGS_IN_APP);
boolean stashedInApp = hasAnyFlag(flags, FLAGS_STASHED_IN_APP);
+ boolean stashedSysUIState = hasAnyFlag(flags, FLAG_STASHED_IN_SYSUI_STATE);
boolean stashedLauncherState = hasAnyFlag(flags, FLAG_IN_STASHED_LAUNCHER_STATE);
boolean stashedInTaskbarAllApps =
hasAnyFlag(flags, FLAG_STASHED_IN_TASKBAR_ALL_APPS);
boolean stashedForSmallScreen = hasAnyFlag(flags, FLAG_STASHED_SMALL_SCREEN);
return (inApp && stashedInApp) || (!inApp && stashedLauncherState)
- || stashedInTaskbarAllApps || stashedForSmallScreen;
+ || stashedInTaskbarAllApps || stashedForSmallScreen || stashedSysUIState;
});
public TaskbarStashController(TaskbarActivityContext activity) {
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index ebb37a8..1c11bf7 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
+
import android.content.Intent;
import android.graphics.drawable.BitmapDrawable;
import android.view.MotionEvent;
@@ -26,6 +28,7 @@
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
import com.android.launcher3.util.DisplayController;
+import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
import com.android.systemui.shared.recents.model.Task;
@@ -165,6 +168,23 @@
return null;
}
+ public void startSplitSelection(SplitConfigurationOptions.SplitSelectSource splitSelectSource) {
+ RecentsView recentsView = getRecentsView();
+ if (recentsView == null) {
+ return;
+ }
+ recentsView.findLastActiveTaskAndRunCallback(
+ splitSelectSource.intent.getComponent(),
+ (Consumer<Task>) foundTask -> {
+ splitSelectSource.alreadyRunningTaskId = foundTask == null
+ ? INVALID_TASK_ID
+ : foundTask.key.id;
+ splitSelectSource.animateCurrentTaskDismissal = foundTask != null;
+ recentsView.initiateSplitSelect(splitSelectSource);
+ }
+ );
+ }
+
/**
* Uses the clicked Taskbar icon to launch a second app for splitscreen.
*/
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
index 2fcd64b..db584d8 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarView.java
@@ -15,8 +15,9 @@
*/
package com.android.launcher3.taskbar;
+import static android.content.pm.PackageManager.FEATURE_PC;
+
import android.content.Context;
-import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.graphics.Rect;
@@ -81,6 +82,9 @@
// Only non-null when device supports having an All Apps button.
private @Nullable View mAllAppsButton;
+ // Only non-null when device supports having an All Apps button.
+ private @Nullable View mTaskbarDivider;
+
private View mQsb;
public TaskbarView(@NonNull Context context) {
@@ -119,13 +123,16 @@
mThemeIconsBackground = calculateThemeIconsBackground();
- if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()
+ && !mActivityContext.getPackageManager().hasSystemFeature(FEATURE_PC)) {
mAllAppsButton = LayoutInflater.from(context)
.inflate(R.layout.taskbar_all_apps_button, this, false);
mAllAppsButton.setPadding(mItemPadding, mItemPadding, mItemPadding, mItemPadding);
mAllAppsButton.setScaleX(mIsRtl ? -1 : 1);
- if (mActivityContext.getPackageManager().hasSystemFeature(PackageManager.FEATURE_PC)) {
- mAllAppsButton.setVisibility(GONE);
+
+ if (FeatureFlags.ENABLE_TASKBAR_PINNING.get()) {
+ mTaskbarDivider = LayoutInflater.from(context).inflate(R.layout.taskbar_divider,
+ this, false);
}
}
@@ -159,6 +166,9 @@
if (mAllAppsButton != null) {
mAllAppsButton.setOnClickListener(mControllerCallbacks.getAllAppsButtonClickListener());
}
+ if (mTaskbarDivider != null) {
+ //TODO(b/265434705): set long press listener
+ }
}
private void removeAndRecycle(View view) {
@@ -180,6 +190,10 @@
if (mAllAppsButton != null) {
removeView(mAllAppsButton);
+
+ if (mTaskbarDivider != null) {
+ removeView(mTaskbarDivider);
+ }
}
removeView(mQsb);
@@ -256,8 +270,11 @@
}
if (mAllAppsButton != null) {
- int index = mIsRtl ? getChildCount() : 0;
- addView(mAllAppsButton, index);
+ addView(mAllAppsButton, mIsRtl ? getChildCount() : 0);
+
+ if (mTaskbarDivider != null) {
+ addView(mTaskbarDivider, mIsRtl ? (getChildCount() - 1) : 1);
+ }
}
if (mActivityContext.getDeviceProfile().isQsbInline) {
addView(mQsb, mIsRtl ? getChildCount() : 0);
@@ -328,6 +345,11 @@
int qsbTop = (bottom - top - deviceProfile.hotseatQsbHeight) / 2;
int qsbBottom = qsbTop + deviceProfile.hotseatQsbHeight;
child.layout(qsbStart, qsbTop, qsbEnd, qsbBottom);
+ } else if (child == mTaskbarDivider) {
+ iconEnd += mItemMarginLeftRight;
+ int iconStart = iconEnd - mIconTouchSize;
+ child.layout(iconStart, mIconLayoutBounds.top, iconEnd, mIconLayoutBounds.bottom);
+ iconEnd = iconStart + mItemMarginLeftRight;
} else {
iconEnd -= mItemMarginLeftRight;
int iconStart = iconEnd - mIconTouchSize;
diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
index d7a0b03..3edb375 100644
--- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java
@@ -15,6 +15,8 @@
*/
package com.android.launcher3.taskbar.overlay;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
+
import android.content.Context;
import android.view.View;
@@ -28,7 +30,13 @@
import com.android.launcher3.taskbar.TaskbarControllers;
import com.android.launcher3.taskbar.TaskbarDragController;
import com.android.launcher3.taskbar.TaskbarStashController;
+import com.android.launcher3.taskbar.TaskbarUIController;
import com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
+import com.android.quickstep.views.RecentsView;
+import com.android.systemui.shared.recents.model.Task;
+
+import java.util.function.Consumer;
/**
* Window context for the taskbar overlays such as All Apps and EDU.
@@ -46,6 +54,7 @@
// We automatically stash taskbar when All Apps is opened in gesture navigation mode.
private final boolean mWillTaskbarBeVisuallyStashed;
private final int mStashedTaskbarHeight;
+ private final TaskbarUIController mUiController;
public TaskbarOverlayContext(
Context windowContext,
@@ -61,6 +70,8 @@
TaskbarStashController taskbarStashController = controllers.taskbarStashController;
mWillTaskbarBeVisuallyStashed = taskbarStashController.supportsVisualStashing();
mStashedTaskbarHeight = taskbarStashController.getStashedHeight();
+
+ mUiController = controllers.uiController;
}
boolean willTaskbarBeVisuallyStashed() {
@@ -111,6 +122,11 @@
}
@Override
+ public void startSplitSelection(SplitSelectSource splitSelectSource) {
+ mUiController.startSplitSelection(splitSelectSource);
+ }
+
+ @Override
public DotInfo getDotInfoForItem(ItemInfo info) {
return mTaskbarContext.getDotInfoForItem(info);
}
diff --git a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
index 30850b9..abbd01d 100644
--- a/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
+++ b/quickstep/src/com/android/launcher3/uioverrides/QuickstepLauncher.java
@@ -15,6 +15,7 @@
*/
package com.android.launcher3.uioverrides;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.os.Trace.TRACE_TAG_APP;
import static android.view.WindowManager.LayoutParams.PRIVATE_FLAG_OPTIMIZE_MEASURE;
import static android.view.accessibility.AccessibilityEvent.TYPE_VIEW_FOCUSED;
@@ -32,6 +33,7 @@
import static com.android.launcher3.anim.Interpolators.EMPHASIZED;
import static com.android.launcher3.compat.AccessibilityManagerCompat.sendCustomAccessibilityEvent;
import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE;
+import static com.android.launcher3.config.FeatureFlags.ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE;
import static com.android.launcher3.config.FeatureFlags.ENABLE_WIDGET_PICKER_DEPTH;
import static com.android.launcher3.logging.StatsLogManager.LauncherEvent.LAUNCHER_APP_LAUNCH_TAP;
import static com.android.launcher3.model.data.ItemInfo.NO_MATCHING_ID;
@@ -46,8 +48,11 @@
import static com.android.launcher3.util.DisplayController.CHANGE_ACTIVE_SCREEN;
import static com.android.launcher3.util.DisplayController.CHANGE_NAVIGATION_MODE;
import static com.android.launcher3.util.Executors.UI_HELPER_EXECUTOR;
+import static com.android.quickstep.util.SplitAnimationTimings.TABLET_HOME_TO_SPLIT;
import static com.android.systemui.shared.system.ActivityManagerWrapper.CLOSE_SYSTEM_WINDOWS_REASON_HOME_KEY;
+import android.animation.Animator;
+import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
@@ -57,6 +62,8 @@
import android.content.IntentSender;
import android.content.SharedPreferences;
import android.content.res.Configuration;
+import android.graphics.Rect;
+import android.graphics.RectF;
import android.hardware.SensorManager;
import android.hardware.devicestate.DeviceStateManager;
import android.media.permission.SafeCloseable;
@@ -80,6 +87,7 @@
import androidx.annotation.Nullable;
import com.android.app.viewcapture.ViewCapture;
+import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.DeviceProfile;
import com.android.launcher3.Launcher;
import com.android.launcher3.LauncherSettings.Favorites;
@@ -92,6 +100,7 @@
import com.android.launcher3.Workspace;
import com.android.launcher3.accessibility.LauncherAccessibilityDelegate;
import com.android.launcher3.anim.AnimatorPlaybackController;
+import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.appprediction.PredictionRowView;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.dragndrop.DragOptions;
@@ -133,6 +142,7 @@
import com.android.launcher3.util.PendingSplitSelectInfo;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SplitConfigurationOptions.SplitPositionOption;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
import com.android.launcher3.util.TouchController;
import com.android.launcher3.widget.LauncherWidgetHolder;
import com.android.quickstep.OverviewCommandHelper;
@@ -150,9 +160,11 @@
import com.android.quickstep.util.SplitWithKeyboardShortcutController;
import com.android.quickstep.util.TISBindHelper;
import com.android.quickstep.views.DesktopTaskView;
+import com.android.quickstep.views.FloatingTaskView;
import com.android.quickstep.views.OverviewActionsView;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
+import com.android.systemui.shared.recents.model.Task;
import com.android.systemui.shared.system.ActivityManagerWrapper;
import com.android.systemui.unfold.UnfoldSharedComponent;
import com.android.systemui.unfold.UnfoldTransitionFactory;
@@ -168,6 +180,7 @@
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
+import java.util.function.Consumer;
import java.util.function.Predicate;
import java.util.stream.Stream;
@@ -362,7 +375,7 @@
Stream<SystemShortcut.Factory> 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.
+ // TODO(b/266482558): Pull it out of PagedOrentationHandler for split from workspace.
List<SplitPositionOption> positions =
recentsView.getPagedOrientationHandler().getSplitPositionOptions(
mDeviceProfile);
@@ -549,6 +562,64 @@
}
@Override
+ public void startSplitSelection(SplitSelectSource splitSelectSource) {
+ RecentsView recentsView = getOverviewPanel();
+ // Check if there is already an instance of this app running, if so, initiate the split
+ // using that.
+ recentsView.findLastActiveTaskAndRunCallback(
+ splitSelectSource.intent.getComponent(),
+ (Consumer<Task>) foundTask -> {
+ splitSelectSource.alreadyRunningTaskId = foundTask == null
+ ? INVALID_TASK_ID
+ : foundTask.key.id;
+ if (ENABLE_SPLIT_FROM_WORKSPACE_TO_WORKSPACE.get()) {
+ startSplitToHome(splitSelectSource);
+ } else {
+ recentsView.initiateSplitSelect(splitSelectSource);
+ }
+ }
+ );
+ }
+
+ /** TODO(b/266482558) Migrate into SplitSelectStateController or someplace split specific. */
+ private void startSplitToHome(
+ SplitSelectSource source) {
+ AbstractFloatingView.closeAllOpenViews(this);
+ int splitPlaceholderSize = getResources().getDimensionPixelSize(
+ R.dimen.split_placeholder_size);
+ int splitPlaceholderInset = getResources().getDimensionPixelSize(
+ 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);
+
+ RecentsView recentsView = getOverviewPanel();
+ recentsView.getPagedOrientationHandler().getInitialSplitPlaceholderBounds(
+ splitPlaceholderSize, splitPlaceholderInset, getDeviceProfile(),
+ controller.getActiveSplitStagePosition(), tempRect);
+
+ PendingAnimation anim = new PendingAnimation(TABLET_HOME_TO_SPLIT.getDuration());
+ RectF startingTaskRect = new RectF();
+ final FloatingTaskView floatingTaskView = FloatingTaskView.getFloatingTaskView(this,
+ source.view, null /* thumbnail */, source.drawable, startingTaskRect);
+ floatingTaskView.setAlpha(1);
+ floatingTaskView.addStagingAnimation(anim, startingTaskRect, tempRect,
+ false /* fadeWithThumbnail */, true /* isStagedTask */);
+ controller.setFirstFloatingTaskView(floatingTaskView);
+ anim.addListener(new AnimatorListenerAdapter() {
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ getDragLayer().removeView(floatingTaskView);
+ controller.resetState();
+ }
+ });
+ anim.buildAnim().start();
+ }
+
+
+ @Override
protected void onResume() {
super.onResume();
diff --git a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
index bcaae99..db6d56b 100644
--- a/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
+++ b/quickstep/src/com/android/quickstep/fallback/FallbackRecentsView.java
@@ -34,9 +34,9 @@
import com.android.launcher3.anim.AnimatorPlaybackController;
import com.android.launcher3.anim.PendingAnimation;
import com.android.launcher3.logging.StatsLogManager;
-import com.android.launcher3.popup.QuickstepSystemShortcut;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.util.SplitConfigurationOptions;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
import com.android.quickstep.FallbackActivityInterface;
import com.android.quickstep.GestureState;
import com.android.quickstep.RecentsActivity;
@@ -269,7 +269,7 @@
}
@Override
- public void initiateSplitSelect(QuickstepSystemShortcut.SplitSelectSource splitSelectSource) {
+ public void initiateSplitSelect(SplitSelectSource splitSelectSource) {
super.initiateSplitSelect(splitSelectSource);
mActivity.getStateManager().goToState(OVERVIEW_SPLIT_SELECT);
}
diff --git a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
index 45ffa1c..ab70272 100644
--- a/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
+++ b/quickstep/src/com/android/quickstep/inputconsumers/ProgressDelegateInputConsumer.java
@@ -20,6 +20,7 @@
import static com.android.launcher3.touch.SingleAxisSwipeDetector.DIRECTION_POSITIVE;
import static com.android.launcher3.touch.SingleAxisSwipeDetector.VERTICAL;
import static com.android.quickstep.MultiStateCallback.DEBUG_STATES;
+import static com.android.quickstep.OverviewComponentObserver.startHomeIntentSafely;
import static com.android.quickstep.util.ActiveGestureLog.INTENT_EXTRA_LOG_TRACE_ID;
import android.animation.ObjectAnimator;
@@ -102,8 +103,7 @@
mStateCallback = new MultiStateCallback(STATE_NAMES);
mStateCallback.runOnceAtState(STATE_TARGET_RECEIVED | STATE_HANDLER_INVALIDATED,
this::endRemoteAnimation);
- mStateCallback.runOnceAtState(STATE_TARGET_RECEIVED | STATE_FLING_FINISHED,
- this::onFlingFinished);
+ mStateCallback.runOnceAtState(STATE_FLING_FINISHED, this::onFlingFinished);
mSwipeDetector = new SingleAxisSwipeDetector(mContext, this, VERTICAL);
mSwipeDetector.setDetectableScrollConditions(DIRECTION_POSITIVE, false);
@@ -159,10 +159,12 @@
}
private void onFlingFinished() {
+ boolean endToRecents = mFlingEndsOnHome == null ? true : mFlingEndsOnHome;
if (mRecentsAnimationController != null) {
- boolean endToRecents = mFlingEndsOnHome == null ? true : mFlingEndsOnHome;
mRecentsAnimationController.finishController(endToRecents /* toRecents */,
null /* callback */, false /* sendUserLeaveHint */);
+ } else if (endToRecents) {
+ startHomeIntentSafely(mContext, null);
}
}
diff --git a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
index 681f068..e5d54d7 100644
--- a/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
+++ b/quickstep/src/com/android/quickstep/util/SplitSelectStateController.java
@@ -90,6 +90,8 @@
private Intent mSecondTaskIntent;
private int mSecondTaskId = INVALID_TASK_ID;
private boolean mRecentsAnimationRunning;
+ /** If {@code true}, animates the existing task view split placeholder view */
+ private boolean mAnimateCurrentTaskDismissal;
@Nullable
private UserHandle mUser;
/** If not null, this is the TaskView we want to launch from */
@@ -111,22 +113,15 @@
}
/**
- * To be called after first task selected in Overview.
+ * @param alreadyRunningTask if set to {@link android.app.ActivityTaskManager#INVALID_TASK_ID}
+ * then @param intent will be used to launch the initial task
+ * @param intent will be ignored if @param alreadyRunningTask is set
*/
- public void setInitialTaskSelect(Task task, @StagePosition int stagePosition,
- StatsLogManager.EventEnum splitEvent, ItemInfo itemInfo) {
- mInitialTaskId = task.key.id;
- setInitialData(stagePosition, splitEvent, itemInfo);
- }
-
- /**
- * To be called after first task selected from home or all apps.
- */
- public void setInitialTaskSelect(Intent intent, @StagePosition int stagePosition,
+ public void setInitialTaskSelect(@Nullable Intent intent, @StagePosition int stagePosition,
@NonNull ItemInfo itemInfo, StatsLogManager.EventEnum splitEvent,
- @Nullable Task alreadyRunningTask) {
- if (alreadyRunningTask != null) {
- mInitialTaskId = alreadyRunningTask.key.id;
+ int alreadyRunningTask) {
+ if (alreadyRunningTask != INVALID_TASK_ID) {
+ mInitialTaskId = alreadyRunningTask;
} else {
mInitialTaskIntent = intent;
mUser = itemInfo.user;
@@ -348,6 +343,14 @@
return null;
}
+ public boolean isAnimateCurrentTaskDismissal() {
+ return mAnimateCurrentTaskDismissal;
+ }
+
+ public void setAnimateCurrentTaskDismissal(boolean animateCurrentTaskDismissal) {
+ mAnimateCurrentTaskDismissal = animateCurrentTaskDismissal;
+ }
+
/**
* Requires Shell Transitions
*/
@@ -454,6 +457,7 @@
mLaunchingTaskView = null;
mItemInfo = null;
mSplitEvent = null;
+ mAnimateCurrentTaskDismissal = false;
}
/**
diff --git a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
index cf033a6..886fc80 100644
--- a/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/LauncherRecentsView.java
@@ -34,13 +34,13 @@
import com.android.launcher3.AbstractFloatingView;
import com.android.launcher3.LauncherState;
import com.android.launcher3.logging.StatsLogManager;
-import com.android.launcher3.popup.QuickstepSystemShortcut;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statehandlers.DesktopVisibilityController;
import com.android.launcher3.statemanager.StateManager.StateListener;
import com.android.launcher3.uioverrides.QuickstepLauncher;
import com.android.launcher3.util.PendingSplitSelectInfo;
import com.android.launcher3.util.SplitConfigurationOptions;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
import com.android.quickstep.LauncherActivityInterface;
import com.android.quickstep.RotationTouchHelper;
import com.android.quickstep.util.SplitSelectStateController;
@@ -199,7 +199,7 @@
}
@Override
- public void initiateSplitSelect(QuickstepSystemShortcut.SplitSelectSource splitSelectSource) {
+ public void initiateSplitSelect(SplitSelectSource splitSelectSource) {
super.initiateSplitSelect(splitSelectSource);
mActivity.getStateManager().goToState(LauncherState.OVERVIEW_SPLIT_SELECT);
}
diff --git a/quickstep/src/com/android/quickstep/views/RecentsView.java b/quickstep/src/com/android/quickstep/views/RecentsView.java
index cdc0574..8facb0a 100644
--- a/quickstep/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/src/com/android/quickstep/views/RecentsView.java
@@ -16,6 +16,7 @@
package com.android.quickstep.views;
+import static android.app.ActivityTaskManager.INVALID_TASK_ID;
import static android.view.Surface.ROTATION_0;
import static android.view.View.MeasureSpec.EXACTLY;
import static android.view.View.MeasureSpec.makeMeasureSpec;
@@ -144,7 +145,6 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.icons.cache.HandlerRunnable;
import com.android.launcher3.logging.StatsLogManager;
-import com.android.launcher3.popup.QuickstepSystemShortcut;
import com.android.launcher3.statehandlers.DepthController;
import com.android.launcher3.statemanager.BaseState;
import com.android.launcher3.statemanager.StatefulActivity;
@@ -156,6 +156,7 @@
import com.android.launcher3.util.ResourceBasedOverride.Overrides;
import com.android.launcher3.util.RunnableList;
import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource;
import com.android.launcher3.util.SplitConfigurationOptions.StagePosition;
import com.android.launcher3.util.Themes;
import com.android.launcher3.util.TranslateEdgeEffect;
@@ -677,7 +678,7 @@
private SplitInstructionsView mSplitInstructionsView;
@Nullable
- private QuickstepSystemShortcut.SplitSelectSource mSplitSelectSource;
+ private SplitSelectSource mSplitSelectSource;
/**
* Keeps track of the index of the TaskView that split screen was initialized with so we know
@@ -1607,8 +1608,9 @@
// If we are entering Overview as a result of initiating a split from somewhere else
// (e.g. split from Home), we need to make sure the staged app is not drawn as a thumbnail.
- Task stagedTaskToBeRemovedFromGrid =
- mSplitSelectSource != null ? mSplitSelectSource.alreadyRunningTask : null;
+ int stagedTaskIdToBeRemovedFromGrid = mSplitSelectSource != null
+ ? mSplitSelectSource.alreadyRunningTaskId
+ : INVALID_TASK_ID;
// update the map of instance counts
mFilterState.updateInstanceCountMap(taskGroups);
@@ -1617,8 +1619,8 @@
// taskGroups backwards populates the thumbnail grid from least recent to most recent.
for (int i = taskGroups.size() - 1; i >= 0; i--) {
GroupTask groupTask = taskGroups.get(i);
- boolean isRemovalNeeded = stagedTaskToBeRemovedFromGrid != null
- && groupTask.containsTask(stagedTaskToBeRemovedFromGrid.key.id);
+ boolean isRemovalNeeded = stagedTaskIdToBeRemovedFromGrid != INVALID_TASK_ID
+ && groupTask.containsTask(stagedTaskIdToBeRemovedFromGrid);
TaskView taskView;
if (isRemovalNeeded && groupTask.hasMultipleTasks()) {
@@ -1632,7 +1634,7 @@
addView(taskView);
if (isRemovalNeeded && groupTask.hasMultipleTasks()) {
- if (groupTask.task1.equals(stagedTaskToBeRemovedFromGrid)) {
+ if (groupTask.task1.key.id == stagedTaskIdToBeRemovedFromGrid) {
taskView.bind(groupTask.task2, mOrientationState);
} else {
taskView.bind(groupTask.task1, mOrientationState);
@@ -3019,7 +3021,7 @@
RectF startingTaskRect = new RectF();
safeRemoveDragLayerView(mFirstFloatingTaskView);
- if (mSplitHiddenTaskView != null) {
+ if (mSplitSelectStateController.isAnimateCurrentTaskDismissal()) {
// Create the split select animation from Overview
mSplitHiddenTaskView.setThumbnailVisibility(INVISIBLE);
anim.setViewAlpha(mSplitHiddenTaskView.getIconView(), 0, clampToProgress(LINEAR,
@@ -4393,29 +4395,38 @@
initiateSplitSelect(taskView, defaultSplitPosition, LAUNCHER_OVERVIEW_ACTIONS_SPLIT);
}
+ /** TODO(b/266477929): Consolidate this call w/ the one below */
public void initiateSplitSelect(TaskView taskView, @StagePosition int stagePosition,
StatsLogManager.EventEnum splitEvent) {
mSplitHiddenTaskView = taskView;
- mSplitSelectStateController.setInitialTaskSelect(taskView.getTask(),
- stagePosition, splitEvent, taskView.getItemInfo());
+ mSplitSelectStateController.setInitialTaskSelect(null /*intent*/,
+ stagePosition, taskView.getItemInfo(), splitEvent, taskView.mTask.key.id);
+ mSplitSelectStateController.setAnimateCurrentTaskDismissal(
+ true /*animateCurrentTaskDismissal*/);
mSplitHiddenTaskViewIndex = indexOfChild(taskView);
}
/**
- * Called when staging a split from Home/AllApps, using the icon long-press menu.
+ * Called when staging a split from Home/AllApps/Overview (Taskbar),
+ * using the icon long-press menu.
+ * Attempts to initiate split with an existing taskView, if one exists
*/
- public void initiateSplitSelect(QuickstepSystemShortcut.SplitSelectSource splitSelectSource) {
+ public void initiateSplitSelect(SplitSelectSource splitSelectSource) {
mSplitSelectSource = splitSelectSource;
+ mSplitHiddenTaskView = getTaskViewByTaskId(splitSelectSource.alreadyRunningTaskId);
+ mSplitHiddenTaskViewIndex = indexOfChild(mSplitHiddenTaskView);
+ mSplitSelectStateController
+ .setAnimateCurrentTaskDismissal(splitSelectSource.animateCurrentTaskDismissal);
mSplitSelectStateController.setInitialTaskSelect(splitSelectSource.intent,
splitSelectSource.position.stagePosition, splitSelectSource.itemInfo,
- splitSelectSource.splitEvent, splitSelectSource.alreadyRunningTask);
+ splitSelectSource.splitEvent, splitSelectSource.alreadyRunningTaskId);
}
/**
* Modifies a PendingAnimation with the animations for entering split staging
*/
public void createSplitSelectInitAnimation(PendingAnimation builder, int duration) {
- if (mSplitHiddenTaskView != null) {
+ if (mSplitSelectStateController.isAnimateCurrentTaskDismissal()) {
// Splitting from Overview
createTaskDismissAnimation(builder, mSplitHiddenTaskView, true, false, duration,
true /* dismissingForSplitSelection*/);
diff --git a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
index 0b8bc10..aed26d3 100644
--- a/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
+++ b/quickstep/tests/src/com/android/quickstep/TaplTestsTaskbar.java
@@ -18,6 +18,7 @@
import static androidx.test.InstrumentationRegistry.getInstrumentation;
import static com.android.quickstep.TaskbarModeSwitchRule.Mode.PERSISTENT;
+import static com.android.quickstep.TaskbarModeSwitchRule.Mode.TRANSIENT;
import static junit.framework.TestCase.assertEquals;
@@ -82,19 +83,31 @@
}
@Test
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchApp() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
}
@Test
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchApp() throws Exception {
+ getTaskbar().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testOpenMenu() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME).openMenu();
}
@Test
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientOpenMenu() throws Exception {
+ getTaskbar().getAppIcon(TEST_APP_NAME).openMenu();
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchShortcut() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
@@ -103,9 +116,18 @@
}
@Test
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchShortcut() throws Exception {
+ getTaskbar().getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
@ScreenRecord // b/231615831
@PortraitLandscape
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchAppInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
@@ -114,7 +136,16 @@
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchAppInSplitscreen() throws Exception {
+ getTaskbar().getAppIcon(TEST_APP_NAME).dragToSplitscreen(
+ TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchShortcutInSplitscreen() throws Exception {
getTaskbar().getAppIcon(TEST_APP_NAME)
.openDeepShortcutMenu()
@@ -123,19 +154,42 @@
}
@Test
- @TaskbarModeSwitch
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchShortcutInSplitscreen() throws Exception {
+ getTaskbar().getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchApp_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
}
@Test
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchApp_FromTaskbarAllApps() throws Exception {
+ getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testOpenMenu_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu();
}
@Test
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientOpenMenu_FromTaskbarAllApps() throws Exception {
+ getTaskbar().openAllApps().getAppIcon(TEST_APP_NAME).openMenu();
+ }
+
+ @Test
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchShortcut_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
.getAppIcon(TEST_APP_NAME)
@@ -145,9 +199,19 @@
}
@Test
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchShortcut_FromTaskbarAllApps() throws Exception {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .launch(TEST_APP_PACKAGE);
+ }
+
+ @Test
@ScreenRecord // b/231615831
@PortraitLandscape
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
.getAppIcon(TEST_APP_NAME)
@@ -157,7 +221,17 @@
@Test
@ScreenRecord // b/231615831
@PortraitLandscape
- @TaskbarModeSwitch
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchAppInSplitscreen_FromTaskbarAllApps() throws Exception {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ @TaskbarModeSwitch(mode = PERSISTENT)
public void testLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
getTaskbar().openAllApps()
.getAppIcon(TEST_APP_NAME)
@@ -166,6 +240,18 @@
.dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
}
+ @Test
+ @ScreenRecord // b/231615831
+ @PortraitLandscape
+ @TaskbarModeSwitch(mode = TRANSIENT)
+ public void testTransientLaunchShortcutInSplitscreen_FromTaskbarAllApps() throws Exception {
+ getTaskbar().openAllApps()
+ .getAppIcon(TEST_APP_NAME)
+ .openDeepShortcutMenu()
+ .getMenuItem("Shortcut 1")
+ .dragToSplitscreen(TEST_APP_PACKAGE, CALCULATOR_APP_PACKAGE);
+ }
+
private Taskbar getTaskbar() {
Taskbar taskbar = mLauncher.getLaunchedAppState().getTaskbar();
List<String> taskbarIconNames = taskbar.getIconNames();
diff --git a/res/layout/taskbar_divider.xml b/res/layout/taskbar_divider.xml
new file mode 100644
index 0000000..e25e7a3
--- /dev/null
+++ b/res/layout/taskbar_divider.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2023 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.
+-->
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/taskbar_divider_container"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content">
+
+ <View
+ android:id="@+id/taskbar_divider_bar"
+ android:layout_height="32dp"
+ android:layout_width="2dp"
+ android:layout_gravity="center"
+ android:background="@drawable/bg_rounded_corner_bottom_sheet_handle" />
+ <!-- TODO(b/265347148): Create separate drawable -->
+</FrameLayout>
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index d041dfe..321aef5 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -93,6 +93,8 @@
-->
<dimen name="fastscroll_width">58dp</dimen>
<dimen name="fastscroll_end_margin">-26dp</dimen>
+ <!-- Extra margin between bottom of the scrollbar and the search bar protection layer. -->
+ <dimen name="fastscroll_bottom_margin_floating_search">4dp</dimen>
<!-- PagedView -->
<dimen name="fling_threshold_velocity">500dp</dimen>
@@ -139,11 +141,6 @@
<dimen name="arrow_toast_elevation">2dp</dimen>
<dimen name="arrow_toast_arrow_width">10dp</dimen>
- <!-- Search bar in All Apps -->
- <dimen name="all_apps_header_max_elevation">3dp</dimen>
- <dimen name="all_apps_header_scroll_to_elevation">16dp</dimen>
- <dimen name="all_apps_header_shadow_height">6dp</dimen>
-
<dimen name="all_apps_divider_margin_vertical">8dp</dimen>
<!-- Floating action button inside work tab to toggle work profile -->
diff --git a/src/com/android/launcher3/FastScrollRecyclerView.java b/src/com/android/launcher3/FastScrollRecyclerView.java
index 2f927d3..3504b24 100644
--- a/src/com/android/launcher3/FastScrollRecyclerView.java
+++ b/src/com/android/launcher3/FastScrollRecyclerView.java
@@ -77,11 +77,15 @@
return getPaddingTop();
}
+ public int getScrollBarMarginBottom() {
+ return getPaddingBottom();
+ }
+
/**
* Returns the height of the fast scroll bar
*/
public int getScrollbarTrackHeight() {
- return mScrollbar.getHeight() - getScrollBarTop() - getPaddingBottom();
+ return mScrollbar.getHeight() - getScrollBarTop() - getScrollBarMarginBottom();
}
/**
diff --git a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
index 95e61b8..3bb8fb4 100644
--- a/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/ActivityAllAppsContainerView.java
@@ -143,7 +143,7 @@
private boolean mRebindAdaptersAfterSearchAnimation;
private int mNavBarScrimHeight = 0;
private SearchRecyclerView mSearchRecyclerView;
- private SearchAdapterProvider<?> mMainAdapterProvider;
+ protected SearchAdapterProvider<?> mMainAdapterProvider;
private View mBottomSheetHandleArea;
private boolean mHasWorkApps;
private float[] mBottomSheetCornerRadii;
@@ -202,9 +202,12 @@
protected void initContent() {
mMainAdapterProvider = createMainAdapterProvider();
- mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN));
- mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK));
- mAH.set(SEARCH, new AdapterHolder(SEARCH));
+ mAH.set(AdapterHolder.MAIN, new AdapterHolder(AdapterHolder.MAIN,
+ new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, null)));
+ mAH.set(AdapterHolder.WORK, new AdapterHolder(AdapterHolder.WORK,
+ new AlphabeticalAppsList<>(mActivityContext, mAllAppsStore, mWorkManager)));
+ mAH.set(SEARCH, new AdapterHolder(SEARCH,
+ new AlphabeticalAppsList<>(mActivityContext, null, null)));
getLayoutInflater().inflate(R.layout.all_apps_content, this);
mHeader = findViewById(R.id.all_apps_header);
@@ -212,9 +215,9 @@
mBottomSheetHandleArea = findViewById(R.id.bottom_sheet_handle_area);
mSearchRecyclerView = findViewById(R.id.search_results_list_view);
- // Add the search box next to the header
+ // Add the search box above everything else.
mSearchContainer = inflateSearchBox();
- addView(mSearchContainer, indexOfChild(mHeader) + 1);
+ addView(mSearchContainer);
mSearchUiManager = (SearchUiManager) mSearchContainer;
}
@@ -344,7 +347,7 @@
mAH.get(i).mRecyclerView.scrollToTop();
}
}
- if (isHeaderVisible()) {
+ if (mHeader != null && mHeader.getVisibility() == VISIBLE) {
mHeader.reset(animate);
}
// Reset the base recycler view after transitioning home.
@@ -466,6 +469,16 @@
}
setupHeader();
+ if (FeatureFlags.ENABLE_FLOATING_SEARCH_BAR.get()) {
+ // Keep the scroller above the search bar.
+ RelativeLayout.LayoutParams scrollerLayoutParams =
+ (LayoutParams) findViewById(R.id.fast_scroller).getLayoutParams();
+ scrollerLayoutParams.addRule(RelativeLayout.ABOVE, R.id.search_container_all_apps);
+ scrollerLayoutParams.removeRule(RelativeLayout.ALIGN_PARENT_BOTTOM);
+ scrollerLayoutParams.bottomMargin = getResources().getDimensionPixelSize(
+ R.dimen.fastscroll_bottom_margin_floating_search);
+ }
+
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.MAIN).mRecyclerView);
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.WORK).mRecyclerView);
mAllAppsStore.registerIconContainer(mAH.get(AdapterHolder.SEARCH).mRecyclerView);
@@ -627,10 +640,9 @@
layoutParams.removeRule(RelativeLayout.ALIGN_PARENT_TOP);
}
- protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList,
- BaseAdapterProvider[] adapterProviders) {
+ protected BaseAllAppsAdapter<T> createAdapter(AlphabeticalAppsList<T> appsList) {
return new AllAppsGridAdapter<>(mActivityContext, getLayoutInflater(), appsList,
- adapterProviders);
+ mMainAdapterProvider);
}
// TODO(b/216683257): Remove when Taskbar All Apps supports search.
@@ -1001,10 +1013,6 @@
return rv == null ? null : rv.getScrollbar();
}
- public boolean isHeaderVisible() {
- return mHeader != null && mHeader.getVisibility() == View.VISIBLE;
- }
-
/**
* Adds an update listener to animator that adds springs to the animation.
*/
@@ -1155,15 +1163,10 @@
final Rect mPadding = new Rect();
AllAppsRecyclerView mRecyclerView;
- AdapterHolder(int type) {
+ AdapterHolder(int type, AlphabeticalAppsList<T> appsList) {
mType = type;
- mAppsList = new AlphabeticalAppsList<>(mActivityContext,
- isSearch() ? null : mAllAppsStore,
- isWork() ? mWorkManager : null);
- BaseAdapterProvider[] adapterProviders =
- new BaseAdapterProvider[]{mMainAdapterProvider};
-
- mAdapter = createAdapter(mAppsList, adapterProviders);
+ mAppsList = appsList;
+ mAdapter = createAdapter(mAppsList);
mAppsList.setAdapter(mAdapter);
mLayoutManager = mAdapter.getLayoutManager();
}
diff --git a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
index 112d47e..866932a 100644
--- a/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
+++ b/src/com/android/launcher3/allapps/AllAppsGridAdapter.java
@@ -29,6 +29,7 @@
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.RecyclerView.Adapter;
+import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.util.ScrollableLayoutManager;
import com.android.launcher3.views.ActivityContext;
@@ -73,8 +74,8 @@
public AllAppsGridAdapter(T activityContext, LayoutInflater inflater,
- AlphabeticalAppsList apps, BaseAdapterProvider[] adapterProviders) {
- super(activityContext, inflater, apps, adapterProviders);
+ AlphabeticalAppsList apps, SearchAdapterProvider<?> adapterProvider) {
+ super(activityContext, inflater, apps, adapterProvider);
mGridLayoutMgr = new AppsGridLayoutManager(mActivityContext);
mGridLayoutMgr.setSpanSizeLookup(new GridSpanSizer());
setAppsPerRow(activityContext.getDeviceProfile().numShownAllAppsColumns);
@@ -195,11 +196,9 @@
public void setAppsPerRow(int appsPerRow) {
mAppsPerRow = appsPerRow;
int totalSpans = mAppsPerRow;
- for (BaseAdapterProvider adapterProvider : mAdapterProviders) {
- for (int itemPerRow : adapterProvider.getSupportedItemsPerRowArray()) {
- if (totalSpans % itemPerRow != 0) {
- totalSpans *= itemPerRow;
- }
+ for (int itemPerRow : mAdapterProvider.getSupportedItemsPerRowArray()) {
+ if (totalSpans % itemPerRow != 0) {
+ totalSpans *= itemPerRow;
}
}
mGridLayoutMgr.setSpanCount(totalSpans);
@@ -226,9 +225,8 @@
if (isIconViewType(viewType)) {
return totalSpans / mAppsPerRow;
} else {
- BaseAdapterProvider adapterProvider = getAdapterProvider(viewType);
- if (adapterProvider != null) {
- return totalSpans / adapterProvider.getItemsPerRow(viewType, mAppsPerRow);
+ if (mAdapterProvider.isViewSupported(viewType)) {
+ return totalSpans / mAdapterProvider.getItemsPerRow(viewType, mAppsPerRow);
}
// Section breaks span the full width
diff --git a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
index 7789191..6b45fe6 100644
--- a/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsRecyclerView.java
@@ -261,12 +261,19 @@
}
}
+ @Override
public int getScrollBarTop() {
return ActivityContext.lookupContext(getContext()).getAppsView().isSearchSupported()
? getResources().getDimensionPixelOffset(R.dimen.all_apps_header_top_padding)
: 0;
}
+ @Override
+ public int getScrollBarMarginBottom() {
+ return getRootWindowInsets() == null ? 0
+ : getRootWindowInsets().getSystemWindowInsetBottom();
+ }
+
public RecyclerViewFastScroller getScrollbar() {
return mScrollbar;
}
diff --git a/src/com/android/launcher3/allapps/BaseAdapterProvider.java b/src/com/android/launcher3/allapps/BaseAdapterProvider.java
deleted file mode 100644
index 308294c..0000000
--- a/src/com/android/launcher3/allapps/BaseAdapterProvider.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * Copyright (C) 2021 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.allapps;
-
-import android.view.LayoutInflater;
-import android.view.ViewGroup;
-
-/**
- * A UI expansion wrapper providing for providing dynamic recyclerview items
- */
-public abstract class BaseAdapterProvider {
-
- /**
- * Returns whether or not viewType can be handled by searchProvider
- */
- public abstract boolean isViewSupported(int viewType);
-
- /**
- * Called from RecyclerView.Adapter#onBindViewHolder
- */
- public abstract void onBindView(AllAppsGridAdapter.ViewHolder holder, int position);
-
- /**
- * Called from RecyclerView.Adapter#onCreateViewHolder
- */
- public abstract AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
- ViewGroup parent, int viewType);
-
- /**
- * Returns supported item per row combinations supported
- */
- public int[] getSupportedItemsPerRowArray() {
- return new int[]{};
- }
-
- /**
- * Returns how many cells a view should span
- */
- public int getItemsPerRow(int viewType, int appsPerRow) {
- return appsPerRow;
- }
-
-}
diff --git a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
index 42f8b0c..7040de5 100644
--- a/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
+++ b/src/com/android/launcher3/allapps/BaseAllAppsAdapter.java
@@ -27,18 +27,16 @@
import android.view.ViewGroup;
import android.widget.TextView;
-import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.BubbleTextView;
import com.android.launcher3.R;
+import com.android.launcher3.allapps.search.SearchAdapterProvider;
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.views.ActivityContext;
-import java.util.Arrays;
-
/**
* Adapter for all the apps.
*
@@ -65,8 +63,7 @@
public static final int VIEW_TYPE_MASK_DIVIDER = VIEW_TYPE_ALL_APPS_DIVIDER;
public static final int VIEW_TYPE_MASK_ICON = VIEW_TYPE_ICON;
-
- protected final BaseAdapterProvider[] mAdapterProviders;
+ protected final SearchAdapterProvider<?> mAdapterProvider;
/**
* ViewHolder for each icon.
@@ -146,7 +143,7 @@
private final int mExtraHeight;
public BaseAllAppsAdapter(T activityContext, LayoutInflater inflater,
- AlphabeticalAppsList<T> apps, BaseAdapterProvider[] adapterProviders) {
+ AlphabeticalAppsList<T> apps, SearchAdapterProvider<?> adapterProvider) {
Resources res = activityContext.getResources();
mActivityContext = activityContext;
mApps = apps;
@@ -154,7 +151,7 @@
mOnIconClickListener = mActivityContext.getItemOnClickListener();
- mAdapterProviders = adapterProviders;
+ mAdapterProvider = adapterProvider;
mExtraHeight = res.getDimensionPixelSize(R.dimen.all_apps_height_extra);
}
@@ -216,9 +213,8 @@
return new ViewHolder(mLayoutInflater.inflate(
R.layout.work_apps_paused, parent, false));
default:
- BaseAdapterProvider adapterProvider = getAdapterProvider(viewType);
- if (adapterProvider != null) {
- return adapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
+ if (mAdapterProvider.isViewSupported(viewType)) {
+ return mAdapterProvider.onCreateViewHolder(mLayoutInflater, parent, viewType);
}
throw new RuntimeException("Unexpected view type" + viewType);
}
@@ -250,19 +246,13 @@
((WorkEduCard) holder.itemView).setPosition(position);
break;
default:
- BaseAdapterProvider adapterProvider = getAdapterProvider(holder.getItemViewType());
- if (adapterProvider != null) {
- adapterProvider.onBindView(holder, position);
+ if (mAdapterProvider.isViewSupported(holder.getItemViewType())) {
+ mAdapterProvider.onBindView(holder, position);
}
}
}
@Override
- public void onViewRecycled(@NonNull ViewHolder holder) {
- super.onViewRecycled(holder);
- }
-
- @Override
public boolean onFailedToRecycleView(ViewHolder holder) {
// Always recycle and we will reset the view when it is bound
return true;
@@ -283,10 +273,4 @@
return (viewType & viewTypeMask) != 0;
}
- @Nullable
- protected BaseAdapterProvider getAdapterProvider(int viewType) {
- return Arrays.stream(mAdapterProviders).filter(
- adapterProvider -> adapterProvider.isViewSupported(viewType)).findFirst().orElse(
- null);
- }
}
diff --git a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
index 20edf8a..714304b 100644
--- a/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
+++ b/src/com/android/launcher3/allapps/search/DefaultSearchAdapterProvider.java
@@ -15,12 +15,10 @@
*/
package com.android.launcher3.allapps.search;
-import android.graphics.Canvas;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
-import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;
import com.android.launcher3.BubbleTextView;
@@ -38,13 +36,7 @@
public DefaultSearchAdapterProvider(ActivityContext launcher) {
super(launcher);
- mDecoration = new RecyclerView.ItemDecoration() {
- @Override
- public void onDraw(@NonNull Canvas c, @NonNull RecyclerView parent,
- @NonNull RecyclerView.State state) {
- super.onDraw(c, parent, state);
- }
- };
+ mDecoration = new RecyclerView.ItemDecoration() { };
}
@Override
diff --git a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
index 4f7f9af..15756f5 100644
--- a/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
+++ b/src/com/android/launcher3/allapps/search/SearchAdapterProvider.java
@@ -16,11 +16,13 @@
package com.android.launcher3.allapps.search;
+import android.view.LayoutInflater;
import android.view.View;
+import android.view.ViewGroup;
import androidx.recyclerview.widget.RecyclerView;
-import com.android.launcher3.allapps.BaseAdapterProvider;
+import com.android.launcher3.allapps.AllAppsGridAdapter;
import com.android.launcher3.views.ActivityContext;
/**
@@ -28,7 +30,7 @@
*
* @param <T> Context for this adapter provider.
*/
-public abstract class SearchAdapterProvider<T extends ActivityContext> extends BaseAdapterProvider {
+public abstract class SearchAdapterProvider<T extends ActivityContext> {
protected final T mLauncher;
@@ -56,4 +58,34 @@
* Clear the highlighted view.
*/
public abstract void clearHighlightedItem();
+
+ /**
+ * Returns whether or not viewType can be handled by searchProvider
+ */
+ public abstract boolean isViewSupported(int viewType);
+
+ /**
+ * Called from RecyclerView.Adapter#onBindViewHolder
+ */
+ public abstract void onBindView(AllAppsGridAdapter.ViewHolder holder, int position);
+
+ /**
+ * Called from RecyclerView.Adapter#onCreateViewHolder
+ */
+ public abstract AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
+ ViewGroup parent, int viewType);
+
+ /**
+ * Returns supported item per row combinations supported
+ */
+ public int[] getSupportedItemsPerRowArray() {
+ return new int[]{};
+ }
+
+ /**
+ * Returns how many cells a view should span
+ */
+ public int getItemsPerRow(int viewType, int appsPerRow) {
+ return appsPerRow;
+ }
}
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 0e25984c..69bba69 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -40,6 +40,7 @@
public abstract class SystemShortcut<T extends Context & ActivityContext> extends ItemInfo
implements View.OnClickListener {
+ private static final String TAG = SystemShortcut.class.getSimpleName();
private final int mIconResId;
protected final int mLabelResId;
protected int mAccessibilityActionId;
diff --git a/src/com/android/launcher3/util/SplitConfigurationOptions.java b/src/com/android/launcher3/util/SplitConfigurationOptions.java
index 19a3948..8c5e782 100644
--- a/src/com/android/launcher3/util/SplitConfigurationOptions.java
+++ b/src/com/android/launcher3/util/SplitConfigurationOptions.java
@@ -21,11 +21,15 @@
import static java.lang.annotation.RetentionPolicy.SOURCE;
+import android.content.Intent;
import android.graphics.Rect;
+import android.graphics.drawable.Drawable;
+import android.view.View;
import androidx.annotation.IntDef;
import com.android.launcher3.logging.StatsLogManager;
+import com.android.launcher3.model.data.ItemInfo;
import java.lang.annotation.Retention;
@@ -190,4 +194,35 @@
return position == STAGE_POSITION_TOP_OR_LEFT ? STAGE_POSITION_BOTTOM_OR_RIGHT
: STAGE_POSITION_TOP_OR_LEFT;
}
+
+ public static class SplitSelectSource {
+
+ /** Keep in sync w/ ActivityTaskManager#INVALID_TASK_ID (unreference-able) */
+ private static final int INVALID_TASK_ID = -1;
+
+ public final View view;
+ public final Drawable drawable;
+ public final Intent intent;
+ public final SplitPositionOption position;
+ public final ItemInfo itemInfo;
+ public final StatsLogManager.EventEnum splitEvent;
+ /** Represents the taskId of the first app to start in split screen */
+ public int alreadyRunningTaskId = INVALID_TASK_ID;
+ /**
+ * If {@code true}, animates the view represented by {@link #alreadyRunningTaskId} into the
+ * split placeholder view
+ */
+ public boolean animateCurrentTaskDismissal;
+
+ public SplitSelectSource(View view, Drawable drawable, Intent intent,
+ SplitPositionOption position, ItemInfo itemInfo,
+ StatsLogManager.EventEnum splitEvent) {
+ this.view = view;
+ this.drawable = drawable;
+ this.intent = intent;
+ this.position = position;
+ this.itemInfo = itemInfo;
+ this.splitEvent = splitEvent;
+ }
+ }
}
diff --git a/src/com/android/launcher3/views/ActivityContext.java b/src/com/android/launcher3/views/ActivityContext.java
index 36f5f4d..fe60eba 100644
--- a/src/com/android/launcher3/views/ActivityContext.java
+++ b/src/com/android/launcher3/views/ActivityContext.java
@@ -72,6 +72,7 @@
import com.android.launcher3.util.PackageManagerHelper;
import com.android.launcher3.util.Preconditions;
import com.android.launcher3.util.RunnableList;
+import com.android.launcher3.util.SplitConfigurationOptions;
import com.android.launcher3.util.ViewCache;
import java.util.List;
@@ -132,6 +133,12 @@
return null;
}
+ /** Called when the first app in split screen has been selected */
+ default void startSplitSelection(
+ SplitConfigurationOptions.SplitSelectSource splitSelectSource) {
+ // Overridden, intentionally empty
+ }
+
/**
* The root view to support drag-and-drop and popup support.
*/
diff --git a/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java b/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java
deleted file mode 100644
index 0931cd4..0000000
--- a/tests/tapl/com/android/launcher3/tapl/AllAppsQsb.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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.tapl;
-
-import androidx.test.uiautomator.UiObject2;
-
-/**
- * Operations on AllApp screen qsb.
- */
-class AllAppsQsb extends Qsb {
-
- private final UiObject2 mAllAppsContainer;
-
- AllAppsQsb(LauncherInstrumentation launcher, UiObject2 allAppsContainer) {
- super(launcher);
- mAllAppsContainer = allAppsContainer;
- waitForQsbObject();
- }
-
- @Override
- protected UiObject2 waitForQsbObject() {
- return mLauncher.waitForObjectInContainer(mAllAppsContainer, "search_container_all_apps");
- }
-}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
index 8ac1aef..50b03aa 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeAllApps.java
@@ -115,13 +115,4 @@
}
}
}
-
- /**
- * Return the QSB UI object on the AllApps screen.
- * @return the QSB UI object.
- */
- @NonNull
- public Qsb getQsb() {
- return new AllAppsQsb(mLauncher, verifyActiveContainer());
- }
}
diff --git a/tests/tapl/com/android/launcher3/tapl/HomeQsb.java b/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
index 20d09a1..c365708 100644
--- a/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
+++ b/tests/tapl/com/android/launcher3/tapl/HomeQsb.java
@@ -15,23 +15,69 @@
*/
package com.android.launcher3.tapl;
+import androidx.annotation.NonNull;
+import androidx.test.uiautomator.By;
+import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiObject2;
+import androidx.test.uiautomator.Until;
/**
- * Operations on Home screen qsb.
+ * Operations on home screen qsb.
*/
-class HomeQsb extends Qsb {
+public class HomeQsb {
- private final UiObject2 mHotSeat;
+ private final LauncherInstrumentation mLauncher;
+ private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
+ private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
- HomeQsb(LauncherInstrumentation launcher, UiObject2 hotseat) {
- super(launcher);
- mHotSeat = hotseat;
- waitForQsbObject();
+
+ HomeQsb(LauncherInstrumentation launcher) {
+ mLauncher = launcher;
+ mLauncher.waitForLauncherObject("search_container_hotseat");
}
- @Override
- protected UiObject2 waitForQsbObject() {
- return mLauncher.waitForObjectInContainer(mHotSeat, "search_container_hotseat");
+ /**
+ * Launch assistant app by tapping mic icon on qsb.
+ */
+ @NonNull
+ public LaunchedAppState launchAssistant() {
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to click assistant mic icon button");
+ LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
+
+ LauncherInstrumentation.log("HomeQsb.launchAssistant before click "
+ + assistantIcon.getVisibleCenter() + " in "
+ + mLauncher.getVisibleBounds(assistantIcon));
+
+ mLauncher.clickLauncherObject(assistantIcon);
+
+ try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
+ // assert Assistant App Launched
+ BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
+ mLauncher.assertTrue(
+ "assistant app didn't start: (" + selector + ")",
+ mLauncher.getDevice().wait(Until.hasObject(selector),
+ LauncherInstrumentation.WAIT_TIME_MS)
+ );
+ return new LaunchedAppState(mLauncher);
+ }
+ }
+ }
+
+ /**
+ * Show search result page from tapping qsb.
+ */
+ public SearchResultFromQsb showSearchResult() {
+ try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
+ "want to open search result page");
+ LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
+ mLauncher.clickLauncherObject(
+ mLauncher.waitForLauncherObject("search_container_hotseat"));
+ try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
+ "clicked qsb to open search result page")) {
+ return new SearchResultFromQsb(mLauncher);
+ }
+ }
}
}
diff --git a/tests/tapl/com/android/launcher3/tapl/Qsb.java b/tests/tapl/com/android/launcher3/tapl/Qsb.java
deleted file mode 100644
index 6bc4f21..0000000
--- a/tests/tapl/com/android/launcher3/tapl/Qsb.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * 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.tapl;
-
-import androidx.annotation.NonNull;
-import androidx.test.uiautomator.By;
-import androidx.test.uiautomator.BySelector;
-import androidx.test.uiautomator.UiObject2;
-import androidx.test.uiautomator.Until;
-
-/**
- * Operations on qsb from either Home screen or AllApp screen.
- */
-public abstract class Qsb {
-
- private static final String ASSISTANT_APP_PACKAGE = "com.google.android.googlequicksearchbox";
- private static final String ASSISTANT_ICON_RES_ID = "mic_icon";
- protected final LauncherInstrumentation mLauncher;
-
- protected Qsb(LauncherInstrumentation launcher) {
- mLauncher = launcher;
- }
-
- // Waits for the quick search box.
- protected abstract UiObject2 waitForQsbObject();
- /**
- * Launch assistant app by tapping mic icon on qsb.
- */
-
- @NonNull
- public LaunchedAppState launchAssistant() {
- try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to click assistant mic icon button");
- LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
- UiObject2 assistantIcon = mLauncher.waitForLauncherObject(ASSISTANT_ICON_RES_ID);
-
- LauncherInstrumentation.log("Qsb.launchAssistant before click "
- + assistantIcon.getVisibleCenter() + " in "
- + mLauncher.getVisibleBounds(assistantIcon));
-
- mLauncher.clickLauncherObject(assistantIcon);
-
- try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer("clicked")) {
- // assert Assistant App Launched
- BySelector selector = By.pkg(ASSISTANT_APP_PACKAGE);
- mLauncher.assertTrue(
- "assistant app didn't start: (" + selector + ")",
- mLauncher.getDevice().wait(Until.hasObject(selector),
- LauncherInstrumentation.WAIT_TIME_MS)
- );
- return new LaunchedAppState(mLauncher);
- }
- }
- }
-
- /**
- * Show search result page from tapping qsb.
- */
- public SearchResultFromQsb showSearchResult() {
- try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
- "want to open search result page");
- LauncherInstrumentation.Closable e = mLauncher.eventsCheck()) {
- mLauncher.clickLauncherObject(waitForQsbObject());
- // wait for the result rendering to complete
- mLauncher.waitForIdle();
- try (LauncherInstrumentation.Closable c2 = mLauncher.addContextLayer(
- "clicked qsb to open search result page")) {
- return new SearchResultFromQsb(mLauncher);
- }
- }
- }
-}
diff --git a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
index 80176e9..80e4116 100644
--- a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
+++ b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java
@@ -23,7 +23,7 @@
import java.util.ArrayList;
/**
- * Operations on search result page opened from qsb.
+ * Operations on search result page opened from home screen qsb.
*/
public class SearchResultFromQsb {
// The input resource id in the search box.
diff --git a/tests/tapl/com/android/launcher3/tapl/Workspace.java b/tests/tapl/com/android/launcher3/tapl/Workspace.java
index 62665de..473cfb9 100644
--- a/tests/tapl/com/android/launcher3/tapl/Workspace.java
+++ b/tests/tapl/com/android/launcher3/tapl/Workspace.java
@@ -118,11 +118,10 @@
*
* The qsb must already be visible when calling this method.
*/
- @NonNull
- public Qsb getQsb() {
+ public HomeQsb getQsb() {
try (LauncherInstrumentation.Closable c = mLauncher.addContextLayer(
"want to get the home qsb")) {
- return new HomeQsb(mLauncher, mHotseat);
+ return new HomeQsb(mLauncher);
}
}