From 7a5809e47b88c14787c91814a0ae707dae780b7a Mon Sep 17 00:00:00 2001 From: Brian Isganitis Date: Wed, 17 May 2023 21:54:16 +0000 Subject: [PATCH] Add initial support for search session in Taskbar All Apps. A search session is represented as a stub ResourceBasedOverride that can be extended for controlling a search session. Test: Manual (including aosp Quickstep) Bug: 216683257 Flag: ENABLE_ALL_APPS_SEARCH_IN_TASKBAR Change-Id: I9cf4b5f84feec5215840d456b601c6a9f7c4c211 --- quickstep/res/layout/taskbar_all_apps.xml | 17 ++---- .../res/layout/taskbar_all_apps_sheet.xml | 26 ++++++++++ .../launcher3/taskbar/TaskbarControllers.java | 1 + .../allapps/TaskbarAllAppsController.java | 48 +++++++++++++---- .../allapps/TaskbarSearchSessionController.kt | 52 +++++++++++++++++++ .../overlay/TaskbarOverlayContext.java | 14 +++++ res/values/config.xml | 1 + 7 files changed, 137 insertions(+), 22 deletions(-) create mode 100644 quickstep/res/layout/taskbar_all_apps_sheet.xml create mode 100644 quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt diff --git a/quickstep/res/layout/taskbar_all_apps.xml b/quickstep/res/layout/taskbar_all_apps.xml index 976cd9e2a7..e234165d61 100644 --- a/quickstep/res/layout/taskbar_all_apps.xml +++ b/quickstep/res/layout/taskbar_all_apps.xml @@ -14,18 +14,11 @@ See the License for the specific language governing permissions and limitations under the License. --> - - - - + android:clipChildren="true" + android:clipToPadding="false" + android:focusable="false" + android:saveEnabled="false" /> diff --git a/quickstep/res/layout/taskbar_all_apps_sheet.xml b/quickstep/res/layout/taskbar_all_apps_sheet.xml new file mode 100644 index 0000000000..a1d5fa6414 --- /dev/null +++ b/quickstep/res/layout/taskbar_all_apps_sheet.xml @@ -0,0 +1,26 @@ + + + + + + diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java index 66c2eb3314..3cd151d7e8 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarControllers.java @@ -226,6 +226,7 @@ public class TaskbarControllers { taskbarPopupController.onDestroy(); taskbarForceVisibleImmersiveController.onDestroy(); taskbarOverlayController.onDestroy(); + taskbarAllAppsController.onDestroy(); navButtonController.onDestroy(); taskbarInsetsController.onDestroy(); voiceInteractionWindowController.onDestroy(); diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index e0a502bdb2..4ac779fdfc 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -45,8 +45,10 @@ import java.util.function.Predicate; public final class TaskbarAllAppsController { private TaskbarControllers mControllers; + private @Nullable TaskbarOverlayContext mOverlayContext; private @Nullable TaskbarAllAppsSlideInView mSlideInView; private @Nullable TaskbarAllAppsContainerView mAppsView; + private @Nullable TaskbarSearchSessionController mSearchSessionController; // Application data models. private AppInfo[] mApps; @@ -70,6 +72,11 @@ public final class TaskbarAllAppsController { } } + /** Clean up the controller. */ + public void onDestroy() { + cleanUpOverlay(); + } + /** Updates the current {@link AppInfo} instances. */ public void setApps(AppInfo[] apps, int flags, Map map) { mApps = apps; @@ -96,6 +103,9 @@ public final class TaskbarAllAppsController { .findFixedRowByType(PredictionRowView.class) .setPredictedApps(mPredictedApps); } + if (mSearchSessionController != null) { + mSearchSessionController.setZeroStatePredictedItems(predictedApps); + } } /** Updates the current notification dots. */ @@ -127,20 +137,25 @@ public final class TaskbarAllAppsController { // to catch invalid states. mControllers.getSharedState().allAppsVisible = true; - TaskbarOverlayContext overlayContext = - mControllers.taskbarOverlayController.requestWindow(); - mSlideInView = (TaskbarAllAppsSlideInView) overlayContext.getLayoutInflater().inflate( - R.layout.taskbar_all_apps, overlayContext.getDragLayer(), false); + mOverlayContext = mControllers.taskbarOverlayController.requestWindow(); + + // Initialize search session for All Apps. + mSearchSessionController = TaskbarSearchSessionController.newInstance(mOverlayContext); + mOverlayContext.setSearchSessionController(mSearchSessionController); + mSearchSessionController.setZeroStatePredictedItems(mPredictedApps); + mSearchSessionController.startLifecycle(); + + mSlideInView = (TaskbarAllAppsSlideInView) mOverlayContext.getLayoutInflater().inflate( + R.layout.taskbar_all_apps_sheet, mOverlayContext.getDragLayer(), false); mSlideInView.addOnCloseListener(() -> { mControllers.getSharedState().allAppsVisible = false; - mSlideInView = null; - mAppsView = null; + cleanUpOverlay(); }); TaskbarAllAppsViewController viewController = new TaskbarAllAppsViewController( - overlayContext, mSlideInView, mControllers); + mOverlayContext, mSlideInView, mControllers); viewController.show(animate); - mAppsView = overlayContext.getAppsView(); + mAppsView = mOverlayContext.getAppsView(); mAppsView.getAppsStore().setApps(mApps, mAppsModelFlags, mPackageUserKeytoUidMap); mAppsView.getFloatingHeaderView() .findFixedRowByType(PredictionRowView.class) @@ -149,8 +164,21 @@ public final class TaskbarAllAppsController { // Create a shared drag layer between taskbar and taskbarAllApps so that when dragging // starts and taskbarAllApps can close, but the drag layer that the view is being dragged in // doesn't also close - overlayContext.getDragController().setDisallowGlobalDrag(mDisallowGlobalDrag); - overlayContext.getDragController().setDisallowLongClick(mDisallowLongClick); + mOverlayContext.getDragController().setDisallowGlobalDrag(mDisallowGlobalDrag); + mOverlayContext.getDragController().setDisallowLongClick(mDisallowLongClick); + } + + private void cleanUpOverlay() { + if (mSearchSessionController != null) { + mSearchSessionController.onDestroy(); + mSearchSessionController = null; + } + if (mOverlayContext != null) { + mOverlayContext.setSearchSessionController(null); + mOverlayContext = null; + } + mSlideInView = null; + mAppsView = null; } @VisibleForTesting diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt new file mode 100644 index 0000000000..6a9dda53fd --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt @@ -0,0 +1,52 @@ +/* + * 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.taskbar.allapps + +import android.content.Context +import com.android.launcher3.R +import com.android.launcher3.config.FeatureFlags +import com.android.launcher3.model.data.ItemInfo +import com.android.launcher3.util.ResourceBasedOverride +import com.android.launcher3.util.ResourceBasedOverride.Overrides + +/** Stub for managing the Taskbar search session. */ +open class TaskbarSearchSessionController : ResourceBasedOverride { + + /** Start the search session lifecycle. */ + open fun startLifecycle() {} + + /** Destroy the search session. */ + open fun onDestroy() {} + + /** Updates the predicted items shown in the zero-state. */ + open fun setZeroStatePredictedItems(items: List) {} + + companion object { + @JvmStatic + fun newInstance(context: Context): TaskbarSearchSessionController { + if (!FeatureFlags.ENABLE_ALL_APPS_SEARCH_IN_TASKBAR.get()) { + return TaskbarSearchSessionController() + } + + return Overrides.getObject( + TaskbarSearchSessionController::class.java, + context, + R.string.taskbar_search_session_controller_class, + ) + } + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java index a642693137..cfcc1a070b 100644 --- a/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java +++ b/quickstep/src/com/android/launcher3/taskbar/overlay/TaskbarOverlayContext.java @@ -18,6 +18,8 @@ package com.android.launcher3.taskbar.overlay; import android.content.Context; import android.view.View; +import androidx.annotation.Nullable; + import com.android.launcher3.DeviceProfile; import com.android.launcher3.R; import com.android.launcher3.dot.DotInfo; @@ -29,6 +31,7 @@ import com.android.launcher3.taskbar.TaskbarControllers; import com.android.launcher3.taskbar.TaskbarDragController; import com.android.launcher3.taskbar.TaskbarUIController; import com.android.launcher3.taskbar.allapps.TaskbarAllAppsContainerView; +import com.android.launcher3.taskbar.allapps.TaskbarSearchSessionController; import com.android.launcher3.util.SplitConfigurationOptions.SplitSelectSource; /** @@ -47,6 +50,8 @@ public class TaskbarOverlayContext extends BaseTaskbarContext { private final int mStashedTaskbarHeight; private final TaskbarUIController mUiController; + private @Nullable TaskbarSearchSessionController mSearchSessionController; + public TaskbarOverlayContext( Context windowContext, TaskbarActivityContext taskbarContext, @@ -62,6 +67,15 @@ public class TaskbarOverlayContext extends BaseTaskbarContext { mUiController = controllers.uiController; } + public @Nullable TaskbarSearchSessionController getSearchSessionController() { + return mSearchSessionController; + } + + public void setSearchSessionController( + @Nullable TaskbarSearchSessionController searchSessionController) { + mSearchSessionController = searchSessionController; + } + int getStashedTaskbarHeight() { return mStashedTaskbarHeight; } diff --git a/res/values/config.xml b/res/values/config.xml index 5a6698b80e..233119d104 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -84,6 +84,7 @@ +