Introduce initial A-Z app drawer to taskbar.
Invoking the drawer is currently hooked up to tapping empty space on the
taskbar. Apps can be launched, and drag-n-drop split screen works. The
drawer can only be dismissed by acting on an app icon or tapping the
taskbar again.
Test: Manual
Bug: 204696617
Change-Id: I7c5fdbc7d54d8209f6f15ef80bfeb5e9b80cf647
diff --git a/quickstep/res/layout/taskbar.xml b/quickstep/res/layout/taskbar.xml
index 3b1d217..c7743ea 100644
--- a/quickstep/res/layout/taskbar.xml
+++ b/quickstep/res/layout/taskbar.xml
@@ -82,4 +82,8 @@
android:clipToOutline="true"
android:layout_gravity="bottom"/>
+ <include
+ layout="@layout/taskbar_all_apps"
+ android:visibility="gone" />
+
</com.android.launcher3.taskbar.TaskbarDragLayer>
\ No newline at end of file
diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml
new file mode 100644
index 0000000..4dbbcc7
--- /dev/null
+++ b/quickstep/res/layout/taskbar_all_apps.xml
@@ -0,0 +1,44 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+<com.android.launcher3.taskbar.TaskbarAllAppsContainerView xmlns:android="http://schemas.android.com/apk/res/android"
+ android:id="@+id/apps_view"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:clipChildren="true"
+ android:clipToPadding="false"
+ android:focusable="false"
+ android:saveEnabled="false"
+ android:theme="?attr/allAppsTheme">
+
+ <include
+ layout="@layout/all_apps_rv_layout"
+ android:visibility="gone" />
+
+ <com.android.launcher3.allapps.FloatingHeaderView
+ android:id="@+id/all_apps_header"
+ android:layout_width="match_parent"
+ android:layout_height="wrap_content"
+ android:layout_below="@id/search_container_all_apps"
+ android:clipToPadding="false"
+ android:paddingTop="@dimen/all_apps_header_top_padding"
+ android:orientation="vertical">
+
+ <include layout="@layout/all_apps_personal_work_tabs" />
+ </com.android.launcher3.allapps.FloatingHeaderView>
+
+ <include layout="@layout/all_apps_fast_scroller" />
+</com.android.launcher3.taskbar.TaskbarAllAppsContainerView>
diff --git a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
index d2ac7c1..4132c68 100644
--- a/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/LauncherTaskbarUIController.java
@@ -37,8 +37,8 @@
import com.android.launcher3.config.FeatureFlags;
import com.android.launcher3.logging.InstanceId;
import com.android.launcher3.logging.InstanceIdSequence;
+import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
-import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.OnboardingPrefs;
import com.android.quickstep.AnimatedFloat;
import com.android.quickstep.RecentsAnimationCallbacks;
@@ -238,7 +238,7 @@
}
@Override
- public void onTaskbarIconLaunched(WorkspaceItemInfo item) {
+ public void onTaskbarIconLaunched(ItemInfo item) {
InstanceId instanceId = new InstanceIdSequence().newInstanceId();
mLauncher.logAppLaunch(mControllers.taskbarActivityContext.getStatsLogManager(), item,
instanceId);
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
index 6a59bc2..be6376d 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarActivityContext.java
@@ -64,6 +64,7 @@
import com.android.launcher3.folder.Folder;
import com.android.launcher3.folder.FolderIcon;
import com.android.launcher3.logger.LauncherAtom;
+import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.FolderInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
@@ -100,6 +101,7 @@
private final LayoutInflater mLayoutInflater;
private final TaskbarDragLayer mDragLayer;
+ private final TaskbarAllAppsContainerView mAppsView;
private final TaskbarControllers mControllers;
private DeviceProfile mDeviceProfile;
@@ -152,6 +154,7 @@
TaskbarScrimView taskbarScrimView = mDragLayer.findViewById(R.id.taskbar_scrim);
FrameLayout navButtonsView = mDragLayer.findViewById(R.id.navbuttons_view);
StashedHandleView stashedHandleView = mDragLayer.findViewById(R.id.stashed_handle);
+ mAppsView = mDragLayer.findViewById(R.id.apps_view);
Display display = windowContext.getDisplay();
Context c = display.getDisplayId() == Display.DEFAULT_DISPLAY
@@ -189,7 +192,8 @@
new TaskbarEduController(this),
new TaskbarAutohideSuspendController(this),
new TaskbarPopupController(this),
- new TaskbarForceVisibleImmersiveController(this));
+ new TaskbarForceVisibleImmersiveController(this),
+ new TaskbarAllAppsViewController(this, mAppsView));
}
public void init(TaskbarSharedState sharedState) {
@@ -280,6 +284,11 @@
}
@Override
+ public TaskbarAllAppsContainerView getAppsView() {
+ return mAppsView;
+ }
+
+ @Override
public DeviceProfile getDeviceProfile() {
return mDeviceProfile;
}
@@ -619,11 +628,8 @@
String packageName = intent.getPackage();
getSystemService(LauncherApps.class)
.startShortcut(packageName, id, null, null, info.user);
- } else if (info.user.equals(Process.myUserHandle())) {
- startActivity(intent);
} else {
- getSystemService(LauncherApps.class).startMainActivity(
- intent.getComponent(), info.user, intent.getSourceBounds(), null);
+ startItemInfoActivity(info);
}
mControllers.uiController.onTaskbarIconLaunched(info);
@@ -633,11 +639,32 @@
Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
}
}
+ } else if (tag instanceof AppInfo) {
+ startItemInfoActivity((AppInfo) tag);
} else {
Log.e(TAG, "Unknown type clicked: " + tag);
}
AbstractFloatingView.closeAllOpenViews(this);
+ mControllers.taskbarAllAppsViewController.hide();
+ }
+
+ private void startItemInfoActivity(ItemInfo info) {
+ Intent intent = new Intent(info.getIntent())
+ .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+ try {
+ if (info.user.equals(Process.myUserHandle())) {
+ // TODO(b/216683257): Use startActivityForResult for search results that require it.
+ startActivity(intent);
+ } else {
+ getSystemService(LauncherApps.class).startMainActivity(
+ intent.getComponent(), info.user, intent.getSourceBounds(), null);
+ }
+ } catch (NullPointerException | ActivityNotFoundException | SecurityException e) {
+ Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT)
+ .show();
+ Log.e(TAG, "Unable to launch. tag=" + info + " intent=" + intent, e);
+ }
}
/**
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsContainerView.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsContainerView.java
new file mode 100644
index 0000000..d6eb716
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsContainerView.java
@@ -0,0 +1,86 @@
+/*
+ * 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.taskbar;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.view.WindowInsets;
+
+import androidx.recyclerview.widget.RecyclerView;
+
+import com.android.launcher3.allapps.AllAppsGridAdapter;
+import com.android.launcher3.allapps.BaseAllAppsContainerView;
+import com.android.launcher3.allapps.search.SearchAdapterProvider;
+
+/** All apps container accessible from taskbar. */
+public class TaskbarAllAppsContainerView extends BaseAllAppsContainerView<TaskbarActivityContext> {
+ public TaskbarAllAppsContainerView(Context context) {
+ this(context, null);
+ }
+
+ public TaskbarAllAppsContainerView(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public TaskbarAllAppsContainerView(Context context, AttributeSet attrs, int defStyleAttr) {
+ super(context, attrs, defStyleAttr);
+ }
+
+ @Override
+ protected SearchAdapterProvider<?> createMainAdapterProvider() {
+ // Task bar all apps does not yet support search, so this implementation is minimal.
+ return new SearchAdapterProvider<TaskbarActivityContext>(mActivityContext) {
+ @Override
+ public boolean launchHighlightedItem() {
+ return false;
+ }
+
+ @Override
+ public View getHighlightedItem() {
+ return null;
+ }
+
+ @Override
+ public RecyclerView.ItemDecoration getDecorator() {
+ return null;
+ }
+
+ @Override
+ public boolean isViewSupported(int viewType) {
+ return false;
+ }
+
+ @Override
+ public void onBindView(AllAppsGridAdapter.ViewHolder holder, int position) { }
+
+ @Override
+ public AllAppsGridAdapter.ViewHolder onCreateViewHolder(LayoutInflater layoutInflater,
+ ViewGroup parent, int viewType) {
+ return null;
+ }
+ };
+ }
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ // TODO(b/204696617): Switch to status bar insets once they work.
+ setInsets(insets.getInsets(WindowInsets.Type.tappableElement()).toRect());
+ return super.onApplyWindowInsets(insets);
+ }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java
new file mode 100644
index 0000000..fb807aa
--- /dev/null
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarAllAppsViewController.java
@@ -0,0 +1,104 @@
+/*
+ * 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.taskbar;
+
+import android.view.View;
+
+import com.android.launcher3.DropTarget;
+import com.android.launcher3.R;
+import com.android.launcher3.config.FeatureFlags;
+import com.android.launcher3.dragndrop.DragController;
+import com.android.launcher3.dragndrop.DragOptions;
+import com.android.launcher3.model.data.AppInfo;
+
+/** Handles the {@link TaskbarAllAppsContainerView} initialization and updates. */
+public final class TaskbarAllAppsViewController implements DragController.DragListener {
+
+ private final TaskbarActivityContext mContext;
+ private final TaskbarAllAppsContainerView mAppsView;
+
+ private TaskbarControllers mControllers; // Initialized in init.
+ private boolean mIsOpen;
+
+ public TaskbarAllAppsViewController(
+ TaskbarActivityContext context, TaskbarAllAppsContainerView appsView) {
+ mContext = context;
+ mAppsView = appsView;
+ }
+
+ /** Initialize the controller. */
+ public void init(TaskbarControllers controllers) {
+ if (!FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ return;
+ }
+ mControllers = controllers;
+
+ mAppsView.setOnIconLongClickListener(icon -> {
+ mControllers.taskbarDragController.addDragListener(this);
+ mControllers.taskbarDragController.startDragOnLongClick(icon);
+ return true;
+ });
+
+ // TODO(b/205803230): Remove once entry point button is implemented.
+ mContext.getDragLayer().findViewById(R.id.taskbar_view).setOnClickListener(v -> {
+ if (mIsOpen) {
+ hide();
+ } else {
+ show();
+ }
+ });
+ }
+
+ /** The taskbar apps view. */
+ public TaskbarAllAppsContainerView getAppsView() {
+ return mAppsView;
+ }
+
+ /** Binds the current {@link AppInfo} instances to the {@link TaskbarAllAppsContainerView}. */
+ public void setApps(AppInfo[] apps, int flags) {
+ if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ mAppsView.getAppsStore().setApps(apps, flags);
+ }
+ }
+
+ /** Opens the {@link TaskbarAllAppsContainerView}. */
+ public void show() {
+ if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ mIsOpen = true;
+ mContext.setTaskbarWindowFullscreen(true);
+ mAppsView.setVisibility(View.VISIBLE);
+ }
+ }
+
+ /** Hides the {@link TaskbarAllAppsContainerView}. */
+ public void hide() {
+ if (FeatureFlags.ENABLE_ALL_APPS_IN_TASKBAR.get()) {
+ mIsOpen = false;
+ mContext.setTaskbarWindowFullscreen(false);
+ mAppsView.setVisibility(View.GONE);
+ }
+ }
+
+ @Override
+ public void onDragStart(DropTarget.DragObject dragObject, DragOptions options) {
+ mControllers.taskbarDragController.removeDragListener(this);
+ mIsOpen = false;
+ mAppsView.setVisibility(View.GONE);
+ }
+
+ @Override
+ public void onDragEnd() { }
+}
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
index 8364137..21fbb3b 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java
@@ -48,6 +48,7 @@
public final TaskbarAutohideSuspendController taskbarAutohideSuspendController;
public final TaskbarPopupController taskbarPopupController;
public final TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController;
+ public final TaskbarAllAppsViewController taskbarAllAppsViewController;
@Nullable private LoggableTaskbarController[] mControllersToLog = null;
@@ -72,7 +73,8 @@
TaskbarEduController taskbarEduController,
TaskbarAutohideSuspendController taskbarAutoHideSuspendController,
TaskbarPopupController taskbarPopupController,
- TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController) {
+ TaskbarForceVisibleImmersiveController taskbarForceVisibleImmersiveController,
+ TaskbarAllAppsViewController taskbarAllAppsViewController) {
this.taskbarActivityContext = taskbarActivityContext;
this.taskbarDragController = taskbarDragController;
this.navButtonController = navButtonController;
@@ -89,6 +91,7 @@
this.taskbarAutohideSuspendController = taskbarAutoHideSuspendController;
this.taskbarPopupController = taskbarPopupController;
this.taskbarForceVisibleImmersiveController = taskbarForceVisibleImmersiveController;
+ this.taskbarAllAppsViewController = taskbarAllAppsViewController;
}
/**
@@ -112,6 +115,7 @@
taskbarEduController.init(this);
taskbarPopupController.init(this);
taskbarForceVisibleImmersiveController.init(this);
+ taskbarAllAppsViewController.init(this);
mControllersToLog = new LoggableTaskbarController[] {
taskbarDragController, navButtonController, navbarButtonsViewController,
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
index 3323104..e152915 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarDragController.java
@@ -182,7 +182,7 @@
dragLayerX,
dragLayerY,
(View target, DropTarget.DragObject d, boolean success) -> {} /* DragSource */,
- (WorkspaceItemInfo) btv.getTag(),
+ (ItemInfo) btv.getTag(),
/* dragVisualizeOffset = */ null,
dragRect,
scale * iconScale,
@@ -289,8 +289,8 @@
Object tag = btv.getTag();
ClipDescription clipDescription = null;
Intent intent = null;
- if (tag instanceof WorkspaceItemInfo) {
- WorkspaceItemInfo item = (WorkspaceItemInfo) tag;
+ if (tag instanceof ItemInfo) {
+ ItemInfo item = (ItemInfo) tag;
LauncherApps launcherApps = mActivity.getSystemService(LauncherApps.class);
clipDescription = new ClipDescription(item.title,
new String[] {
@@ -300,14 +300,15 @@
});
intent = new Intent();
if (item.itemType == LauncherSettings.Favorites.ITEM_TYPE_DEEP_SHORTCUT) {
+ String deepShortcutId = ((WorkspaceItemInfo) item).getDeepShortcutId();
intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT,
launcherApps.getShortcutIntent(
item.getIntent().getPackage(),
- item.getDeepShortcutId(),
+ deepShortcutId,
null,
item.user));
intent.putExtra(Intent.EXTRA_PACKAGE_NAME, item.getIntent().getPackage());
- intent.putExtra(Intent.EXTRA_SHORTCUT_ID, item.getDeepShortcutId());
+ intent.putExtra(Intent.EXTRA_SHORTCUT_ID, deepShortcutId);
} else {
intent.putExtra(ClipDescriptionCompat.EXTRA_PENDING_INTENT,
LauncherAppsCompat.getMainActivityLaunchIntent(launcherApps,
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
index 910752a..2bafccd 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java
@@ -21,6 +21,7 @@
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.model.BgDataModel;
import com.android.launcher3.model.BgDataModel.FixedContainerItems;
+import com.android.launcher3.model.data.AppInfo;
import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.WorkspaceItemInfo;
import com.android.launcher3.util.ComponentKey;
@@ -198,6 +199,11 @@
mControllers.taskbarPopupController.setDeepShortcutMap(deepShortcutMapCopy);
}
+ @Override
+ public void bindAllApplications(AppInfo[] apps, int flags) {
+ mControllers.taskbarAllAppsViewController.setApps(apps, flags);
+ }
+
protected void dumpLogs(String prefix, PrintWriter pw) {
pw.println(prefix + "TaskbarModelCallbacks:");
diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
index abad906..07b851f 100644
--- a/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
+++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarUIController.java
@@ -19,8 +19,8 @@
import androidx.annotation.CallSuper;
+import com.android.launcher3.model.data.ItemInfo;
import com.android.launcher3.model.data.ItemInfoWithIcon;
-import com.android.launcher3.model.data.WorkspaceItemInfo;
import java.util.stream.Stream;
@@ -54,7 +54,8 @@
return Stream.empty();
}
- public void onTaskbarIconLaunched(WorkspaceItemInfo item) { }
+ /** Called when an icon is launched. */
+ public void onTaskbarIconLaunched(ItemInfo item) { }
public View getRootView() {
return mControllers.taskbarActivityContext.getDragLayer();