Add smartspace as a widget to first page (implementation 2)

Flag: SMARTSPACE_AS_A_WIDGET
Test: verify that the smartspace gets replaced with a smartspace widget
Bug: 300140279
Change-Id: I42c170de5e2a9fd3d24d99bb8b09cf412c55e3a5
This commit is contained in:
fbaron
2023-09-25 11:34:56 -07:00
committed by Federico Baron
parent 94f7b53a54
commit e58aaf1802
16 changed files with 119 additions and 15 deletions

View File

@@ -16,6 +16,7 @@
package com.android.launcher3.model;
import static com.android.launcher3.BuildConfig.WIDGET_ON_FIRST_SCREEN;
import static com.android.launcher3.LauncherSettings.Favorites.TABLE_NAME;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_HAS_SHORTCUT_PERMISSION;
import static com.android.launcher3.model.BgDataModel.Callbacks.FLAG_QUIET_MODE_CHANGE_PERMISSION;
@@ -57,6 +58,7 @@ import com.android.launcher3.DeviceProfile;
import com.android.launcher3.InvariantDeviceProfile;
import com.android.launcher3.LauncherAppState;
import com.android.launcher3.LauncherModel;
import com.android.launcher3.LauncherPrefs;
import com.android.launcher3.LauncherSettings.Favorites;
import com.android.launcher3.Utilities;
import com.android.launcher3.config.FeatureFlags;
@@ -296,6 +298,19 @@ public class LoaderTask implements Runnable {
logASplit("bindWidgets");
verifyNotStopped();
if (LauncherPrefs.get(mApp.getContext()).get(LauncherPrefs.SHOULD_SHOW_SMARTSPACE)) {
mLauncherBinder.bindSmartspaceWidget();
// Turn off pref.
LauncherPrefs.get(mApp.getContext()).putSync(
LauncherPrefs.backedUpItem(
LauncherPrefs.SHOULD_SHOW_SMARTSPACE_KEY,
WIDGET_ON_FIRST_SCREEN,
true)
.to(false));
logASplit("bindSmartspaceWidget");
verifyNotStopped();
}
if (FeatureFlags.CHANGE_MODEL_DELEGATE_LOADING_ORDER.get()) {
mModelDelegate.loadAndBindOtherItems(mLauncherBinder.mCallbacksList);
logASplit("otherDelegateItems");