Loading src/com/android/launcher3/Launcher.java +6 −81 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_FOLDER; import static com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE; import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType; import static com.android.launcher3.BuildConfig.QSB_ON_FIRST_SCREEN; import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY; import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; Loading Loading @@ -65,11 +64,9 @@ import static com.android.launcher3.LauncherState.NO_OFFSET; import static com.android.launcher3.LauncherState.NO_SCALE; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID; import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE; import static com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget; import static com.android.launcher3.logging.StatsLogManager.EventEnum; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; Loading Loading @@ -404,12 +401,8 @@ public class Launcher extends StatefulActivity<LauncherState> // session on the server side. protected InstanceId mAllAppsSessionLogId; private LauncherState mPrevLauncherState; private StringCache mStringCache; private StartupLatencyLogger mStartupLatencyLogger; private CellPosMapper mCellPosMapper = CellPosMapper.DEFAULT; private boolean mIsFirstPagePinnedItemEnabled = QSB_ON_FIRST_SCREEN && !ENABLE_SMARTSPACE_REMOVAL.get(); private final CannedAnimationCoordinator mAnimationCoordinator = new CannedAnimationCoordinator(this); Loading Loading @@ -2130,32 +2123,12 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void setIsFirstPagePinnedItemEnabled(boolean isFirstPagePinnedItemEnabled) { mIsFirstPagePinnedItemEnabled = isFirstPagePinnedItemEnabled; mWorkspace.bindAndInitFirstWorkspaceScreen(); mModelCallbacks.setIsFirstPagePinnedItemEnabled(isFirstPagePinnedItemEnabled); } @Override public void bindScreens(IntArray orderedScreenIds) { mWorkspace.mPageIndicator.setAreScreensBinding(true, mDeviceProfile.isTwoPanels); int firstScreenPosition = 0; if ((FeatureFlags.QSB_ON_FIRST_SCREEN && mIsFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget()) && orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition) { orderedScreenIds.removeValue(FIRST_SCREEN_ID); orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID); } else if (((!FeatureFlags.QSB_ON_FIRST_SCREEN && !mIsFirstPagePinnedItemEnabled) || shouldShowFirstPageWidget()) && orderedScreenIds.isEmpty()) { // If there are no screens, we need to have an empty screen mWorkspace.addExtraEmptyScreens(); } bindAddScreens(orderedScreenIds); // After we have added all the screens, if the wallpaper was locked to the default state, // then notify to indicate that it can be released and a proper wallpaper offset can be // computed before the next layout mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); mModelCallbacks.bindScreens(orderedScreenIds); } /** Loading @@ -2176,35 +2149,6 @@ public class Launcher extends StatefulActivity<LauncherState> return screenIds.getArray(); } private void bindAddScreens(IntArray orderedScreenIds) { if (mDeviceProfile.isTwoPanels) { if (FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds); } else { // Some empty pages might have been removed while the phone was in a single panel // mode, so we want to add those empty pages back. IntSet screenIds = IntSet.wrap(orderedScreenIds); orderedScreenIds.forEach( screenId -> screenIds.add(mWorkspace.getScreenPair(screenId))); orderedScreenIds = screenIds.getArray(); } } int count = orderedScreenIds.size(); for (int i = 0; i < count; i++) { int screenId = orderedScreenIds.get(i); if (FeatureFlags.QSB_ON_FIRST_SCREEN && mIsFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget() && screenId == FIRST_SCREEN_ID) { // No need to bind the first screen, as its always bound. continue; } mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId); } } @Override public void preAddApps() { mModelCallbacks.preAddApps(); Loading @@ -2213,25 +2157,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void bindAppsAdded(IntArray newScreens, ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated) { // Add the new screens if (newScreens != null) { // newScreens can contain an empty right panel that is already bound, but not known // by BgDataModel. newScreens.removeAllValues(mWorkspace.mScreenOrder); bindAddScreens(newScreens); } // We add the items without animation on non-visible pages, and with // animations on the new page (which we will try and snap to). if (addNotAnimated != null && !addNotAnimated.isEmpty()) { bindItems(addNotAnimated, false); } if (addAnimated != null && !addAnimated.isEmpty()) { bindItems(addAnimated, true); } // Remove the extra empty screen mWorkspace.removeExtraEmptyScreen(false); mModelCallbacks.bindAppsAdded(newScreens, addNotAnimated, addAnimated); } /** Loading Loading @@ -2881,8 +2807,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void bindStringCache(StringCache cache) { mStringCache = cache; mAppsView.updateWorkUI(); mModelCallbacks.bindStringCache(cache); } /** Loading Loading @@ -3318,7 +3243,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public StringCache getStringCache() { return mStringCache; return mModelCallbacks.getStringCache(); } /** Loading Loading @@ -3353,7 +3278,7 @@ public class Launcher extends StatefulActivity<LauncherState> } public boolean getIsFirstPagePinnedItemEnabled() { return mIsFirstPagePinnedItemEnabled; return mModelCallbacks.getIsFirstPagePinnedItemEnabled(); } /** Loading src/com/android/launcher3/ModelCallbacks.kt +123 −0 Original line number Diff line number Diff line package com.android.launcher3 import androidx.annotation.UiThread import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID import com.android.launcher3.config.FeatureFlags import com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget import com.android.launcher3.model.BgDataModel import com.android.launcher3.model.StringCache import com.android.launcher3.model.data.AppInfo import com.android.launcher3.model.data.ItemInfo import com.android.launcher3.model.data.LauncherAppWidgetInfo Loading @@ -9,7 +13,9 @@ import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.popup.PopupContainerWithArrow import com.android.launcher3.util.ComponentKey import com.android.launcher3.util.IntArray as LIntArray import com.android.launcher3.util.IntArray import com.android.launcher3.util.IntSet as LIntSet import com.android.launcher3.util.IntSet import com.android.launcher3.util.PackageUserKey import com.android.launcher3.util.Preconditions import com.android.launcher3.widget.PendingAddWidgetInfo Loading @@ -21,6 +27,11 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { var synchronouslyBoundPages = LIntSet() var pagesToBindSynchronously = LIntSet() var isFirstPagePinnedItemEnabled = (BuildConfig.QSB_ON_FIRST_SCREEN && !FeatureFlags.ENABLE_SMARTSPACE_REMOVAL.get()) var stringCache: StringCache? = null override fun preAddApps() { // If there's an undo snackbar, force it to complete to ensure empty screens are removed // before trying to add new items. Loading Loading @@ -166,4 +177,116 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { info.spanY ) } override fun bindScreens(orderedScreenIds: IntArray) { launcher.workspace.pageIndicator.setAreScreensBinding( true, launcher.deviceProfile.isTwoPanels ) val firstScreenPosition = 0 if ( (FeatureFlags.QSB_ON_FIRST_SCREEN && isFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget()) && orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition ) { orderedScreenIds.removeValue(FIRST_SCREEN_ID) orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID) } else if ( (!FeatureFlags.QSB_ON_FIRST_SCREEN && !isFirstPagePinnedItemEnabled || shouldShowFirstPageWidget()) && orderedScreenIds.isEmpty ) { // If there are no screens, we need to have an empty screen launcher.workspace.addExtraEmptyScreens() } bindAddScreens(orderedScreenIds) // After we have added all the screens, if the wallpaper was locked to the default state, // then notify to indicate that it can be released and a proper wallpaper offset can be // computed before the next layout launcher.workspace.unlockWallpaperFromDefaultPageOnNextLayout() } override fun bindAppsAdded( newScreens: IntArray?, addNotAnimated: java.util.ArrayList<ItemInfo?>?, addAnimated: java.util.ArrayList<ItemInfo?>? ) { // Add the new screens if (newScreens != null) { // newScreens can contain an empty right panel that is already bound, but not known // by BgDataModel. newScreens.removeAllValues(launcher.workspace.mScreenOrder) bindAddScreens(newScreens) } // We add the items without animation on non-visible pages, and with // animations on the new page (which we will try and snap to). if (!addNotAnimated.isNullOrEmpty()) { launcher.bindItems(addNotAnimated, false) } if (!addAnimated.isNullOrEmpty()) { launcher.bindItems(addAnimated, true) } // Remove the extra empty screen launcher.workspace.removeExtraEmptyScreen(false) } private fun bindAddScreens(orderedScreenIdsArg: IntArray) { var orderedScreenIds = orderedScreenIdsArg if (launcher.deviceProfile.isTwoPanels) { if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds) } else { // Some empty pages might have been removed while the phone was in a single panel // mode, so we want to add those empty pages back. val screenIds = IntSet.wrap(orderedScreenIds) orderedScreenIds.forEach { screenId: Int -> screenIds.add(launcher.workspace.getScreenPair(screenId)) } orderedScreenIds = screenIds.array } } orderedScreenIds .filterNot { screenId -> FeatureFlags.QSB_ON_FIRST_SCREEN && isFirstPagePinnedItemEnabled && !FeatureFlags.shouldShowFirstPageWidget() && screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID } .forEach { screenId -> launcher.workspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId) } } /** * Remove odd number because they are already included when isTwoPanels and add the pair screen * if not present. */ private fun filterTwoPanelScreenIds(orderedScreenIds: IntArray): IntArray { val screenIds = IntSet.wrap(orderedScreenIds) orderedScreenIds .filter { screenId -> screenId % 2 == 1 } .forEach { screenId -> screenIds.remove(screenId) // In case the pair is not added, add it if (!launcher.workspace.containsScreenId(screenId - 1)) { screenIds.add(screenId - 1) } } return screenIds.array } override fun setIsFirstPagePinnedItemEnabled(isFirstPagePinnedItemEnabled: Boolean) { this.isFirstPagePinnedItemEnabled = isFirstPagePinnedItemEnabled launcher.workspace.bindAndInitFirstWorkspaceScreen() } override fun bindStringCache(cache: StringCache) { stringCache = cache launcher.appsView.updateWorkUI() } fun getIsFirstPagePinnedItemEnabled(): Boolean = isFirstPagePinnedItemEnabled } Loading
src/com/android/launcher3/Launcher.java +6 −81 Original line number Diff line number Diff line Loading @@ -27,7 +27,6 @@ import static com.android.launcher3.AbstractFloatingView.TYPE_FOLDER; import static com.android.launcher3.AbstractFloatingView.TYPE_ICON_SURFACE; import static com.android.launcher3.AbstractFloatingView.TYPE_REBIND_SAFE; import static com.android.launcher3.AbstractFloatingView.getTopOpenViewWithType; import static com.android.launcher3.BuildConfig.QSB_ON_FIRST_SCREEN; import static com.android.launcher3.LauncherAnimUtils.HOTSEAT_SCALE_PROPERTY_FACTORY; import static com.android.launcher3.LauncherAnimUtils.SCALE_INDEX_WIDGET_TRANSITION; import static com.android.launcher3.LauncherAnimUtils.SPRING_LOADED_EXIT_DELAY; Loading Loading @@ -65,11 +64,9 @@ import static com.android.launcher3.LauncherState.NO_OFFSET; import static com.android.launcher3.LauncherState.NO_SCALE; import static com.android.launcher3.LauncherState.SPRING_LOADED; import static com.android.launcher3.Utilities.postAsyncCallback; import static com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID; import static com.android.launcher3.config.FeatureFlags.ENABLE_SMARTSPACE_REMOVAL; import static com.android.launcher3.config.FeatureFlags.FOLDABLE_SINGLE_PAGE; import static com.android.launcher3.config.FeatureFlags.MULTI_SELECT_EDIT_MODE; import static com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget; import static com.android.launcher3.logging.StatsLogManager.EventEnum; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_BACKGROUND; import static com.android.launcher3.logging.StatsLogManager.LAUNCHER_STATE_HOME; Loading Loading @@ -404,12 +401,8 @@ public class Launcher extends StatefulActivity<LauncherState> // session on the server side. protected InstanceId mAllAppsSessionLogId; private LauncherState mPrevLauncherState; private StringCache mStringCache; private StartupLatencyLogger mStartupLatencyLogger; private CellPosMapper mCellPosMapper = CellPosMapper.DEFAULT; private boolean mIsFirstPagePinnedItemEnabled = QSB_ON_FIRST_SCREEN && !ENABLE_SMARTSPACE_REMOVAL.get(); private final CannedAnimationCoordinator mAnimationCoordinator = new CannedAnimationCoordinator(this); Loading Loading @@ -2130,32 +2123,12 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void setIsFirstPagePinnedItemEnabled(boolean isFirstPagePinnedItemEnabled) { mIsFirstPagePinnedItemEnabled = isFirstPagePinnedItemEnabled; mWorkspace.bindAndInitFirstWorkspaceScreen(); mModelCallbacks.setIsFirstPagePinnedItemEnabled(isFirstPagePinnedItemEnabled); } @Override public void bindScreens(IntArray orderedScreenIds) { mWorkspace.mPageIndicator.setAreScreensBinding(true, mDeviceProfile.isTwoPanels); int firstScreenPosition = 0; if ((FeatureFlags.QSB_ON_FIRST_SCREEN && mIsFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget()) && orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition) { orderedScreenIds.removeValue(FIRST_SCREEN_ID); orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID); } else if (((!FeatureFlags.QSB_ON_FIRST_SCREEN && !mIsFirstPagePinnedItemEnabled) || shouldShowFirstPageWidget()) && orderedScreenIds.isEmpty()) { // If there are no screens, we need to have an empty screen mWorkspace.addExtraEmptyScreens(); } bindAddScreens(orderedScreenIds); // After we have added all the screens, if the wallpaper was locked to the default state, // then notify to indicate that it can be released and a proper wallpaper offset can be // computed before the next layout mWorkspace.unlockWallpaperFromDefaultPageOnNextLayout(); mModelCallbacks.bindScreens(orderedScreenIds); } /** Loading @@ -2176,35 +2149,6 @@ public class Launcher extends StatefulActivity<LauncherState> return screenIds.getArray(); } private void bindAddScreens(IntArray orderedScreenIds) { if (mDeviceProfile.isTwoPanels) { if (FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds); } else { // Some empty pages might have been removed while the phone was in a single panel // mode, so we want to add those empty pages back. IntSet screenIds = IntSet.wrap(orderedScreenIds); orderedScreenIds.forEach( screenId -> screenIds.add(mWorkspace.getScreenPair(screenId))); orderedScreenIds = screenIds.getArray(); } } int count = orderedScreenIds.size(); for (int i = 0; i < count; i++) { int screenId = orderedScreenIds.get(i); if (FeatureFlags.QSB_ON_FIRST_SCREEN && mIsFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget() && screenId == FIRST_SCREEN_ID) { // No need to bind the first screen, as its always bound. continue; } mWorkspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId); } } @Override public void preAddApps() { mModelCallbacks.preAddApps(); Loading @@ -2213,25 +2157,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void bindAppsAdded(IntArray newScreens, ArrayList<ItemInfo> addNotAnimated, ArrayList<ItemInfo> addAnimated) { // Add the new screens if (newScreens != null) { // newScreens can contain an empty right panel that is already bound, but not known // by BgDataModel. newScreens.removeAllValues(mWorkspace.mScreenOrder); bindAddScreens(newScreens); } // We add the items without animation on non-visible pages, and with // animations on the new page (which we will try and snap to). if (addNotAnimated != null && !addNotAnimated.isEmpty()) { bindItems(addNotAnimated, false); } if (addAnimated != null && !addAnimated.isEmpty()) { bindItems(addAnimated, true); } // Remove the extra empty screen mWorkspace.removeExtraEmptyScreen(false); mModelCallbacks.bindAppsAdded(newScreens, addNotAnimated, addAnimated); } /** Loading Loading @@ -2881,8 +2807,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public void bindStringCache(StringCache cache) { mStringCache = cache; mAppsView.updateWorkUI(); mModelCallbacks.bindStringCache(cache); } /** Loading Loading @@ -3318,7 +3243,7 @@ public class Launcher extends StatefulActivity<LauncherState> @Override public StringCache getStringCache() { return mStringCache; return mModelCallbacks.getStringCache(); } /** Loading Loading @@ -3353,7 +3278,7 @@ public class Launcher extends StatefulActivity<LauncherState> } public boolean getIsFirstPagePinnedItemEnabled() { return mIsFirstPagePinnedItemEnabled; return mModelCallbacks.getIsFirstPagePinnedItemEnabled(); } /** Loading
src/com/android/launcher3/ModelCallbacks.kt +123 −0 Original line number Diff line number Diff line package com.android.launcher3 import androidx.annotation.UiThread import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID import com.android.launcher3.config.FeatureFlags import com.android.launcher3.config.FeatureFlags.shouldShowFirstPageWidget import com.android.launcher3.model.BgDataModel import com.android.launcher3.model.StringCache import com.android.launcher3.model.data.AppInfo import com.android.launcher3.model.data.ItemInfo import com.android.launcher3.model.data.LauncherAppWidgetInfo Loading @@ -9,7 +13,9 @@ import com.android.launcher3.model.data.WorkspaceItemInfo import com.android.launcher3.popup.PopupContainerWithArrow import com.android.launcher3.util.ComponentKey import com.android.launcher3.util.IntArray as LIntArray import com.android.launcher3.util.IntArray import com.android.launcher3.util.IntSet as LIntSet import com.android.launcher3.util.IntSet import com.android.launcher3.util.PackageUserKey import com.android.launcher3.util.Preconditions import com.android.launcher3.widget.PendingAddWidgetInfo Loading @@ -21,6 +27,11 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { var synchronouslyBoundPages = LIntSet() var pagesToBindSynchronously = LIntSet() var isFirstPagePinnedItemEnabled = (BuildConfig.QSB_ON_FIRST_SCREEN && !FeatureFlags.ENABLE_SMARTSPACE_REMOVAL.get()) var stringCache: StringCache? = null override fun preAddApps() { // If there's an undo snackbar, force it to complete to ensure empty screens are removed // before trying to add new items. Loading Loading @@ -166,4 +177,116 @@ class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks { info.spanY ) } override fun bindScreens(orderedScreenIds: IntArray) { launcher.workspace.pageIndicator.setAreScreensBinding( true, launcher.deviceProfile.isTwoPanels ) val firstScreenPosition = 0 if ( (FeatureFlags.QSB_ON_FIRST_SCREEN && isFirstPagePinnedItemEnabled && !shouldShowFirstPageWidget()) && orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition ) { orderedScreenIds.removeValue(FIRST_SCREEN_ID) orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID) } else if ( (!FeatureFlags.QSB_ON_FIRST_SCREEN && !isFirstPagePinnedItemEnabled || shouldShowFirstPageWidget()) && orderedScreenIds.isEmpty ) { // If there are no screens, we need to have an empty screen launcher.workspace.addExtraEmptyScreens() } bindAddScreens(orderedScreenIds) // After we have added all the screens, if the wallpaper was locked to the default state, // then notify to indicate that it can be released and a proper wallpaper offset can be // computed before the next layout launcher.workspace.unlockWallpaperFromDefaultPageOnNextLayout() } override fun bindAppsAdded( newScreens: IntArray?, addNotAnimated: java.util.ArrayList<ItemInfo?>?, addAnimated: java.util.ArrayList<ItemInfo?>? ) { // Add the new screens if (newScreens != null) { // newScreens can contain an empty right panel that is already bound, but not known // by BgDataModel. newScreens.removeAllValues(launcher.workspace.mScreenOrder) bindAddScreens(newScreens) } // We add the items without animation on non-visible pages, and with // animations on the new page (which we will try and snap to). if (!addNotAnimated.isNullOrEmpty()) { launcher.bindItems(addNotAnimated, false) } if (!addAnimated.isNullOrEmpty()) { launcher.bindItems(addAnimated, true) } // Remove the extra empty screen launcher.workspace.removeExtraEmptyScreen(false) } private fun bindAddScreens(orderedScreenIdsArg: IntArray) { var orderedScreenIds = orderedScreenIdsArg if (launcher.deviceProfile.isTwoPanels) { if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) { orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds) } else { // Some empty pages might have been removed while the phone was in a single panel // mode, so we want to add those empty pages back. val screenIds = IntSet.wrap(orderedScreenIds) orderedScreenIds.forEach { screenId: Int -> screenIds.add(launcher.workspace.getScreenPair(screenId)) } orderedScreenIds = screenIds.array } } orderedScreenIds .filterNot { screenId -> FeatureFlags.QSB_ON_FIRST_SCREEN && isFirstPagePinnedItemEnabled && !FeatureFlags.shouldShowFirstPageWidget() && screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID } .forEach { screenId -> launcher.workspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId) } } /** * Remove odd number because they are already included when isTwoPanels and add the pair screen * if not present. */ private fun filterTwoPanelScreenIds(orderedScreenIds: IntArray): IntArray { val screenIds = IntSet.wrap(orderedScreenIds) orderedScreenIds .filter { screenId -> screenId % 2 == 1 } .forEach { screenId -> screenIds.remove(screenId) // In case the pair is not added, add it if (!launcher.workspace.containsScreenId(screenId - 1)) { screenIds.add(screenId - 1) } } return screenIds.array } override fun setIsFirstPagePinnedItemEnabled(isFirstPagePinnedItemEnabled: Boolean) { this.isFirstPagePinnedItemEnabled = isFirstPagePinnedItemEnabled launcher.workspace.bindAndInitFirstWorkspaceScreen() } override fun bindStringCache(cache: StringCache) { stringCache = cache launcher.appsView.updateWorkUI() } fun getIsFirstPagePinnedItemEnabled(): Boolean = isFirstPagePinnedItemEnabled }