diff --git a/quickstep/res/values/override.xml b/quickstep/res/values/override.xml index 73c4201a55..67be0dd113 100644 --- a/quickstep/res/values/override.xml +++ b/quickstep/res/values/override.xml @@ -29,4 +29,6 @@ com.android.launcher3.secondarydisplay.SecondaryDisplayPredictionsImpl + com.android.launcher3.taskbar.TaskbarModelCallbacksFactory + diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java index 6cf63a9193..7692760834 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacks.java @@ -57,7 +57,7 @@ public class TaskbarModelCallbacks implements private final TaskbarView mContainer; // Initialized in init. - private TaskbarControllers mControllers; + protected TaskbarControllers mControllers; // Used to defer any UI updates during the SUW unstash animation. private boolean mDeferUpdatesForSUW; diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacksFactory.kt b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacksFactory.kt new file mode 100644 index 0000000000..eb03b4abc5 --- /dev/null +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarModelCallbacksFactory.kt @@ -0,0 +1,42 @@ +/* + * 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 + +import android.content.Context +import com.android.launcher3.R +import com.android.launcher3.util.ResourceBasedOverride +import com.android.launcher3.util.ResourceBasedOverride.Overrides + +/** Creates [TaskbarModelCallbacks] instances. */ +open class TaskbarModelCallbacksFactory : ResourceBasedOverride { + + open fun create( + activityContext: TaskbarActivityContext, + container: TaskbarView, + ): TaskbarModelCallbacks = TaskbarModelCallbacks(activityContext, container) + + companion object { + @JvmStatic + fun newInstance(context: Context): TaskbarModelCallbacksFactory { + return Overrides.getObject( + TaskbarModelCallbacksFactory::class.java, + context, + R.string.taskbar_model_callbacks_factory_class, + ) + } + } +} diff --git a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java index 528a32892a..29f4f38017 100644 --- a/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java +++ b/quickstep/src/com/android/launcher3/taskbar/TaskbarViewController.java @@ -133,7 +133,8 @@ public class TaskbarViewController implements TaskbarControllers.LoggableTaskbar mTaskbarView = taskbarView; mTaskbarIconAlpha = new MultiValueAlpha(mTaskbarView, NUM_ALPHA_CHANNELS); mTaskbarIconAlpha.setUpdateVisibility(true); - mModelCallbacks = new TaskbarModelCallbacks(activity, mTaskbarView); + mModelCallbacks = TaskbarModelCallbacksFactory.newInstance(mActivity) + .create(mActivity, mTaskbarView); mTaskbarBottomMargin = activity.getDeviceProfile().taskbarBottomMargin; mStashedHandleHeight = activity.getResources() .getDimensionPixelSize(R.dimen.taskbar_stashed_handle_height); diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java index 2027bf916c..02d9d95b02 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarAllAppsController.java @@ -54,6 +54,7 @@ public final class TaskbarAllAppsController { private AppInfo[] mApps; private int mAppsModelFlags; private List mPredictedApps; + private @Nullable List mZeroStateSearchSuggestions; private boolean mDisallowGlobalDrag; private boolean mDisallowLongClick; @@ -108,6 +109,14 @@ public final class TaskbarAllAppsController { } } + /** Updates the current search suggestions. */ + public void setZeroStateSearchSuggestions(List zeroStateSearchSuggestions) { + mZeroStateSearchSuggestions = zeroStateSearchSuggestions; + if (mSearchSessionController != null) { + mSearchSessionController.setZeroStateSearchSuggestions(zeroStateSearchSuggestions); + } + } + /** Updates the current notification dots. */ public void updateNotificationDots(Predicate updatedDots) { if (mAppsView != null) { @@ -143,6 +152,9 @@ public final class TaskbarAllAppsController { mSearchSessionController = TaskbarSearchSessionController.newInstance(mOverlayContext); mOverlayContext.setSearchSessionController(mSearchSessionController); mSearchSessionController.setZeroStatePredictedItems(mPredictedApps); + if (mZeroStateSearchSuggestions != null) { + mSearchSessionController.setZeroStateSearchSuggestions(mZeroStateSearchSuggestions); + } mSearchSessionController.startLifecycle(); mSlideInView = (TaskbarAllAppsSlideInView) mOverlayContext.getLayoutInflater().inflate( diff --git a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt index 6a9dda53fd..324c1a2f69 100644 --- a/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt +++ b/quickstep/src/com/android/launcher3/taskbar/allapps/TaskbarSearchSessionController.kt @@ -35,6 +35,9 @@ open class TaskbarSearchSessionController : ResourceBasedOverride { /** Updates the predicted items shown in the zero-state. */ open fun setZeroStatePredictedItems(items: List) {} + /** Updates the search suggestions shown in the zero-state. */ + open fun setZeroStateSearchSuggestions(items: List) {} + companion object { @JvmStatic fun newInstance(context: Context): TaskbarSearchSessionController { diff --git a/res/values/config.xml b/res/values/config.xml index 436ece994e..27211fd0f0 100644 --- a/res/values/config.xml +++ b/res/values/config.xml @@ -85,6 +85,7 @@ +