blob: 008d22923025678e761aa061cc4bd75d9e483ac9 [file] [log] [blame]
Sebastian Francobd7919c2023-09-19 10:55:37 -07001package com.android.launcher3
2
Sebastian Franco0b461ef2023-12-08 12:20:07 -06003import android.annotation.TargetApi
4import android.os.Build
5import android.os.Trace
Sihua Maa44f4ac2024-06-03 18:35:39 +00006import android.util.Log
Sebastian Francobd7919c2023-09-19 10:55:37 -07007import androidx.annotation.UiThread
fbaron9d08e0f2024-04-24 11:26:01 -07008import com.android.launcher3.Flags.enableSmartspaceRemovalToggle
Sebastian Franco0b461ef2023-12-08 12:20:07 -06009import com.android.launcher3.LauncherConstants.TraceEvents
fbaron9d08e0f2024-04-24 11:26:01 -070010import com.android.launcher3.Utilities.SHOULD_SHOW_FIRST_PAGE_WIDGET
Sebastian Franco6dda7c72023-11-17 18:03:00 -060011import com.android.launcher3.WorkspaceLayoutManager.FIRST_SCREEN_ID
Sebastian Francoe4965122023-12-01 13:27:42 -060012import com.android.launcher3.allapps.AllAppsStore
Sebastian Franco6dda7c72023-11-17 18:03:00 -060013import com.android.launcher3.config.FeatureFlags
Sebastian Franco224f67a2024-04-18 18:40:40 -070014import com.android.launcher3.debug.TestEvent
15import com.android.launcher3.debug.TestEventEmitter
Sebastian Francobd7919c2023-09-19 10:55:37 -070016import com.android.launcher3.model.BgDataModel
Sebastian Franco6dda7c72023-11-17 18:03:00 -060017import com.android.launcher3.model.StringCache
Sebastian Francobd7919c2023-09-19 10:55:37 -070018import com.android.launcher3.model.data.AppInfo
19import com.android.launcher3.model.data.ItemInfo
20import com.android.launcher3.model.data.LauncherAppWidgetInfo
21import com.android.launcher3.model.data.WorkspaceItemInfo
22import com.android.launcher3.popup.PopupContainerWithArrow
23import com.android.launcher3.util.ComponentKey
Sebastian Franco69fd7422023-10-06 16:48:58 -070024import com.android.launcher3.util.IntArray as LIntArray
25import com.android.launcher3.util.IntSet as LIntSet
Sebastian Francobd7919c2023-09-19 10:55:37 -070026import com.android.launcher3.util.PackageUserKey
27import com.android.launcher3.util.Preconditions
Sebastian Franco0b461ef2023-12-08 12:20:07 -060028import com.android.launcher3.util.RunnableList
Sebastian Francoe4965122023-12-01 13:27:42 -060029import com.android.launcher3.util.TraceHelper
30import com.android.launcher3.util.ViewOnDrawExecutor
Sebastian Franco50b74c32023-11-16 11:36:49 -060031import com.android.launcher3.widget.PendingAddWidgetInfo
Sebastian Francobd7919c2023-09-19 10:55:37 -070032import com.android.launcher3.widget.model.WidgetsListBaseEntry
33import java.util.function.Predicate
34
Sihua Maa44f4ac2024-06-03 18:35:39 +000035private const val TAG = "ModelCallbacks"
36
Sebastian Francobd7919c2023-09-19 10:55:37 -070037class ModelCallbacks(private var launcher: Launcher) : BgDataModel.Callbacks {
Sebastian Franco69fd7422023-10-06 16:48:58 -070038
39 var synchronouslyBoundPages = LIntSet()
40 var pagesToBindSynchronously = LIntSet()
41
Sebastian Francoe4965122023-12-01 13:27:42 -060042 private var isFirstPagePinnedItemEnabled =
maxwenfa16a1a2024-03-15 19:05:19 -040043 (FeatureFlags.QSB_ON_FIRST_SCREEN && !enableSmartspaceRemovalToggle())
Sebastian Franco6dda7c72023-11-17 18:03:00 -060044
45 var stringCache: StringCache? = null
46
Sebastian Francoe4965122023-12-01 13:27:42 -060047 var pendingExecutor: ViewOnDrawExecutor? = null
48
49 var workspaceLoading = true
50
51 /**
52 * Refreshes the shortcuts shown on the workspace.
53 *
54 * Implementation of the method from LauncherModel.Callbacks.
55 */
56 override fun startBinding() {
57 TraceHelper.INSTANCE.beginSection("startBinding")
58 // Floating panels (except the full widget sheet) are associated with individual icons. If
59 // we are starting a fresh bind, close all such panels as all the icons are about
60 // to go away.
61 AbstractFloatingView.closeOpenViews(
62 launcher,
63 true,
Sunny Goyal621918f2024-09-18 11:31:58 -070064 AbstractFloatingView.TYPE_ALL and AbstractFloatingView.TYPE_REBIND_SAFE.inv(),
Sebastian Francoe4965122023-12-01 13:27:42 -060065 )
66 workspaceLoading = true
67
68 // Clear the workspace because it's going to be rebound
69 launcher.dragController.cancelDrag()
70 launcher.workspace.clearDropTargets()
71 launcher.workspace.removeAllWorkspaceScreens()
Sihua Maf418b2e2024-03-13 12:17:27 -070072 // Avoid clearing the widget update listeners for staying up-to-date with widget info
73 launcher.appWidgetHolder.clearWidgetViews()
Sihua Maa44f4ac2024-06-03 18:35:39 +000074 // TODO(b/335141365): Remove this log after the bug is fixed.
75 Log.d(
76 TAG,
77 "startBinding: " +
78 "hotseat layout was vertical: ${launcher.hotseat?.isHasVerticalHotseat}" +
Sunny Goyal621918f2024-09-18 11:31:58 -070079 " and is setting to ${launcher.deviceProfile.isVerticalBarLayout}",
Sihua Maa44f4ac2024-06-03 18:35:39 +000080 )
Sebastian Francoe4965122023-12-01 13:27:42 -060081 launcher.hotseat?.resetLayout(launcher.deviceProfile.isVerticalBarLayout)
82 TraceHelper.INSTANCE.endSection()
83 }
84
Sebastian Franco0b461ef2023-12-08 12:20:07 -060085 @TargetApi(Build.VERSION_CODES.S)
86 override fun onInitialBindComplete(
87 boundPages: LIntSet,
88 pendingTasks: RunnableList,
Sunny Goyal72a74662024-02-14 12:32:59 -080089 onCompleteSignal: RunnableList,
Sebastian Franco0b461ef2023-12-08 12:20:07 -060090 workspaceItemCount: Int,
Sunny Goyal621918f2024-09-18 11:31:58 -070091 isBindSync: Boolean,
Sebastian Franco0b461ef2023-12-08 12:20:07 -060092 ) {
Sunny Goyal621918f2024-09-18 11:31:58 -070093 Trace.endAsyncSection(
94 TraceEvents.DISPLAY_WORKSPACE_TRACE_METHOD_NAME,
95 TraceEvents.DISPLAY_WORKSPACE_TRACE_COOKIE,
96 )
Sebastian Franco0b461ef2023-12-08 12:20:07 -060097 synchronouslyBoundPages = boundPages
98 pagesToBindSynchronously = LIntSet()
99 clearPendingBinds()
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600100 if (!launcher.isInState(LauncherState.ALL_APPS)) {
101 launcher.appsView.appsStore.enableDeferUpdates(AllAppsStore.DEFER_UPDATES_NEXT_DRAW)
102 pendingTasks.add {
103 launcher.appsView.appsStore.disableDeferUpdates(
104 AllAppsStore.DEFER_UPDATES_NEXT_DRAW
105 )
106 }
107 }
Sunny Goyale337a802024-02-14 15:07:26 -0800108 val executor =
109 ViewOnDrawExecutor(pendingTasks) {
110 if (pendingExecutor == it) {
111 pendingExecutor = null
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600112 }
113 }
Sunny Goyale337a802024-02-14 15:07:26 -0800114 pendingExecutor = executor
Sunny Goyal72a74662024-02-14 12:32:59 -0800115
116 if (Flags.enableWorkspaceInflation()) {
117 // Finish the executor as soon as the pending inflation is completed
118 onCompleteSignal.add(executor::markCompleted)
119 } else {
120 // Pending executor is already completed, wait until first draw to run the tasks
121 executor.attachTo(launcher)
122 }
Sunny Goyale337a802024-02-14 15:07:26 -0800123 launcher.bindComplete(workspaceItemCount, isBindSync)
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600124 }
125
Sebastian Francoe4965122023-12-01 13:27:42 -0600126 /**
Sebastian Franco6196b902023-12-06 11:39:52 -0600127 * Callback saying that there aren't any more items to bind.
128 *
129 * Implementation of the method from LauncherModel.Callbacks.
130 */
131 override fun finishBindingItems(pagesBoundFirst: LIntSet?) {
132 TraceHelper.INSTANCE.beginSection("finishBindingItems")
133 val deviceProfile = launcher.deviceProfile
134 launcher.workspace.restoreInstanceStateForRemainingPages()
135 workspaceLoading = false
136 launcher.processActivityResult()
137 val currentPage =
138 if (pagesBoundFirst != null && !pagesBoundFirst.isEmpty)
139 launcher.workspace.getPageIndexForScreenId(pagesBoundFirst.array[0])
140 else PagedView.INVALID_PAGE
141 // When undoing the removal of the last item on a page, return to that page.
142 // Since we are just resetting the current page without user interaction,
143 // override the previous page so we don't log the page switch.
144 launcher.workspace.setCurrentPage(currentPage, currentPage /* overridePrevPage */)
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600145 pagesToBindSynchronously = LIntSet()
Sebastian Franco6196b902023-12-06 11:39:52 -0600146
147 // Cache one page worth of icons
148 launcher.viewCache.setCacheSize(
149 R.layout.folder_application,
Sunny Goyal621918f2024-09-18 11:31:58 -0700150 deviceProfile.numFolderColumns * deviceProfile.numFolderRows,
Sebastian Franco6196b902023-12-06 11:39:52 -0600151 )
152 launcher.viewCache.setCacheSize(R.layout.folder_page, 2)
153 TraceHelper.INSTANCE.endSection()
154 launcher.workspace.removeExtraEmptyScreen(/* stripEmptyScreens= */ true)
Sihua Maa44f4ac2024-06-03 18:35:39 +0000155 launcher.workspace.pageIndicator.setPauseScroll(
156 /*pause=*/ false,
Sunny Goyal621918f2024-09-18 11:31:58 -0700157 deviceProfile.isTwoPanels,
Sihua Maa44f4ac2024-06-03 18:35:39 +0000158 )
Sebastian Franco224f67a2024-04-18 18:40:40 -0700159 TestEventEmitter.INSTANCE.get(launcher).sendEvent(TestEvent.WORKSPACE_FINISH_LOADING)
Sebastian Franco6196b902023-12-06 11:39:52 -0600160 }
161
162 /**
Sebastian Francoe4965122023-12-01 13:27:42 -0600163 * Clear any pending bind callbacks. This is called when is loader is planning to perform a full
164 * rebind from scratch.
165 */
166 override fun clearPendingBinds() {
167 pendingExecutor?.cancel() ?: return
168 pendingExecutor = null
169
170 // We might have set this flag previously and forgot to clear it.
171 launcher.appsView.appsStore.disableDeferUpdatesSilently(
172 AllAppsStore.DEFER_UPDATES_NEXT_DRAW
173 )
174 }
175
Sebastian Francobd7919c2023-09-19 10:55:37 -0700176 override fun preAddApps() {
177 // If there's an undo snackbar, force it to complete to ensure empty screens are removed
178 // before trying to add new items.
179 launcher.modelWriter.commitDelete()
180 val snackbar =
181 AbstractFloatingView.getOpenView<AbstractFloatingView>(
182 launcher,
Sunny Goyal621918f2024-09-18 11:31:58 -0700183 AbstractFloatingView.TYPE_SNACKBAR,
Sebastian Francobd7919c2023-09-19 10:55:37 -0700184 )
185 snackbar?.post { snackbar.close(true) }
186 }
187
188 @UiThread
189 override fun bindAllApplications(
190 apps: Array<AppInfo?>?,
191 flags: Int,
Sunny Goyal621918f2024-09-18 11:31:58 -0700192 packageUserKeytoUidMap: Map<PackageUserKey?, Int?>?,
Sebastian Francobd7919c2023-09-19 10:55:37 -0700193 ) {
194 Preconditions.assertUIThread()
195 val hadWorkApps = launcher.appsView.shouldShowTabs()
196 launcher.appsView.appsStore.setApps(apps, flags, packageUserKeytoUidMap)
197 PopupContainerWithArrow.dismissInvalidPopup(launcher)
Alex Chau61d19382024-02-12 17:36:57 +0000198 if (
199 hadWorkApps != launcher.appsView.shouldShowTabs() &&
200 launcher.stateManager.state == LauncherState.ALL_APPS
201 ) {
Sebastian Francobd7919c2023-09-19 10:55:37 -0700202 launcher.stateManager.goToState(LauncherState.NORMAL)
203 }
204 }
205
206 /**
207 * Copies LauncherModel's map of activities to shortcut counts to Launcher's. This is necessary
208 * because LauncherModel's map is updated in the background, while Launcher runs on the UI.
209 */
210 override fun bindDeepShortcutMap(deepShortcutMapCopy: HashMap<ComponentKey?, Int?>?) {
211 launcher.popupDataProvider.setDeepShortcutMap(deepShortcutMapCopy)
212 }
213
214 override fun bindIncrementalDownloadProgressUpdated(app: AppInfo?) {
215 launcher.appsView.appsStore.updateProgressBar(app)
216 }
217
218 override fun bindWidgetsRestored(widgets: ArrayList<LauncherAppWidgetInfo?>?) {
219 launcher.workspace.widgetsRestored(widgets)
220 }
221
222 /**
223 * Some shortcuts were updated in the background. Implementation of the method from
224 * LauncherModel.Callbacks.
225 *
226 * @param updated list of shortcuts which have changed.
227 */
228 override fun bindWorkspaceItemsChanged(updated: List<WorkspaceItemInfo?>) {
229 if (updated.isNotEmpty()) {
230 launcher.workspace.updateWorkspaceItems(updated, launcher)
231 PopupContainerWithArrow.dismissInvalidPopup(launcher)
232 }
233 }
234
235 /**
236 * Update the state of a package, typically related to install state. Implementation of the
237 * method from LauncherModel.Callbacks.
238 */
239 override fun bindRestoreItemsChange(updates: HashSet<ItemInfo?>?) {
240 launcher.workspace.updateRestoreItems(updates, launcher)
241 }
242
243 /**
244 * A package was uninstalled/updated. We take both the super set of packageNames in addition to
245 * specific applications to remove, the reason being that this can be called when a package is
246 * updated as well. In that scenario, we only remove specific components from the workspace and
247 * hotseat, where as package-removal should clear all items by package name.
248 */
249 override fun bindWorkspaceComponentsRemoved(matcher: Predicate<ItemInfo?>?) {
250 launcher.workspace.removeItemsByMatcher(matcher)
251 launcher.dragController.onAppsRemoved(matcher)
252 PopupContainerWithArrow.dismissInvalidPopup(launcher)
253 }
254
Shamali Pea078cb2024-11-04 21:35:38 +0000255 override fun bindAllWidgets(
256 allWidgets: List<WidgetsListBaseEntry>,
257 defaultWidgets: List<WidgetsListBaseEntry>,
258 ) {
259 launcher.widgetPickerDataProvider.setWidgets(allWidgets, defaultWidgets)
Sebastian Francobd7919c2023-09-19 10:55:37 -0700260 }
Sebastian Franco69fd7422023-10-06 16:48:58 -0700261
262 /** Returns the ids of the workspaces to bind. */
263 override fun getPagesToBindSynchronously(orderedScreenIds: LIntArray): LIntSet {
264 // If workspace binding is still in progress, getCurrentPageScreenIds won't be
265 // accurate, and we should use mSynchronouslyBoundPages that's set during initial binding.
266 val visibleIds =
267 when {
268 !pagesToBindSynchronously.isEmpty -> pagesToBindSynchronously
Sebastian Francoe4965122023-12-01 13:27:42 -0600269 !workspaceLoading -> launcher.workspace.currentPageScreenIds
Sebastian Franco69fd7422023-10-06 16:48:58 -0700270 else -> synchronouslyBoundPages
271 }
272 // Launcher IntArray has the same name as Kotlin IntArray
273 val result = LIntSet()
274 if (visibleIds.isEmpty) {
275 return result
276 }
277 val actualIds = orderedScreenIds.clone()
278 val firstId = visibleIds.first()
279 val pairId = launcher.workspace.getScreenPair(firstId)
280 // Double check that actual screenIds contains the visibleId, as empty screens are hidden
281 // in single panel.
282 if (actualIds.contains(firstId)) {
283 result.add(firstId)
284 if (launcher.deviceProfile.isTwoPanels && actualIds.contains(pairId)) {
285 result.add(pairId)
286 }
287 } else if (
288 LauncherAppState.getIDP(launcher).supportedProfiles.any(DeviceProfile::isTwoPanels) &&
289 actualIds.contains(pairId)
290 ) {
291 // Add the right panel if left panel is hidden when switching display, due to empty
292 // pages being hidden in single panel.
293 result.add(pairId)
294 }
295 return result
296 }
Sebastian Franco50b74c32023-11-16 11:36:49 -0600297
298 override fun bindSmartspaceWidget() {
299 val cl: CellLayout? =
300 launcher.workspace.getScreenWithId(WorkspaceLayoutManager.FIRST_SCREEN_ID)
301 val spanX = InvariantDeviceProfile.INSTANCE.get(launcher).numSearchContainerColumns
302
303 if (cl?.isRegionVacant(0, 0, spanX, 1) != true) {
304 return
305 }
306
307 val widgetsListBaseEntry: WidgetsListBaseEntry =
Shamali P66614042024-07-19 21:29:39 +0000308 launcher.widgetPickerDataProvider.get().allWidgets.firstOrNull {
309 item: WidgetsListBaseEntry ->
Sebastian Franco50b74c32023-11-16 11:36:49 -0600310 item.mPkgItem.packageName == BuildConfig.APPLICATION_ID
Sihua Maa44f4ac2024-06-03 18:35:39 +0000311 } ?: return
Sebastian Franco50b74c32023-11-16 11:36:49 -0600312
313 val info =
314 PendingAddWidgetInfo(
315 widgetsListBaseEntry.mWidgets[0].widgetInfo,
Sunny Goyal621918f2024-09-18 11:31:58 -0700316 LauncherSettings.Favorites.CONTAINER_DESKTOP,
Sebastian Franco50b74c32023-11-16 11:36:49 -0600317 )
318 launcher.addPendingItem(
319 info,
320 info.container,
321 WorkspaceLayoutManager.FIRST_SCREEN_ID,
322 intArrayOf(0, 0),
323 info.spanX,
Sunny Goyal621918f2024-09-18 11:31:58 -0700324 info.spanY,
Sebastian Franco50b74c32023-11-16 11:36:49 -0600325 )
326 }
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600327
Sebastian Franco6196b902023-12-06 11:39:52 -0600328 override fun bindScreens(orderedScreenIds: LIntArray) {
Shamali Pef4b1022024-02-19 18:05:27 +0000329 launcher.workspace.pageIndicator.setPauseScroll(
330 /*pause=*/ true,
Sunny Goyal621918f2024-09-18 11:31:58 -0700331 launcher.deviceProfile.isTwoPanels,
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600332 )
333 val firstScreenPosition = 0
334 if (
micky387e6bebdc2024-12-28 16:17:56 -0500335 (getQsbOnFirstScreen() && isFirstPagePinnedItemEnabled && !SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600336 orderedScreenIds.indexOf(FIRST_SCREEN_ID) != firstScreenPosition
337 ) {
338 orderedScreenIds.removeValue(FIRST_SCREEN_ID)
339 orderedScreenIds.add(firstScreenPosition, FIRST_SCREEN_ID)
340 } else if (
micky387e6bebdc2024-12-28 16:17:56 -0500341 (!getQsbOnFirstScreen() && !isFirstPagePinnedItemEnabled || SHOULD_SHOW_FIRST_PAGE_WIDGET) &&
Sihua Maa44f4ac2024-06-03 18:35:39 +0000342 orderedScreenIds.isEmpty
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600343 ) {
344 // If there are no screens, we need to have an empty screen
345 launcher.workspace.addExtraEmptyScreens()
346 }
347 bindAddScreens(orderedScreenIds)
348
349 // After we have added all the screens, if the wallpaper was locked to the default state,
350 // then notify to indicate that it can be released and a proper wallpaper offset can be
351 // computed before the next layout
352 launcher.workspace.unlockWallpaperFromDefaultPageOnNextLayout()
353 }
354
355 override fun bindAppsAdded(
Sebastian Franco6196b902023-12-06 11:39:52 -0600356 newScreens: LIntArray?,
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600357 addNotAnimated: java.util.ArrayList<ItemInfo?>?,
Sunny Goyal621918f2024-09-18 11:31:58 -0700358 addAnimated: java.util.ArrayList<ItemInfo?>?,
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600359 ) {
360 // Add the new screens
361 if (newScreens != null) {
362 // newScreens can contain an empty right panel that is already bound, but not known
363 // by BgDataModel.
364 newScreens.removeAllValues(launcher.workspace.mScreenOrder)
365 bindAddScreens(newScreens)
366 }
367
368 // We add the items without animation on non-visible pages, and with
369 // animations on the new page (which we will try and snap to).
370 if (!addNotAnimated.isNullOrEmpty()) {
371 launcher.bindItems(addNotAnimated, false)
372 }
373 if (!addAnimated.isNullOrEmpty()) {
374 launcher.bindItems(addAnimated, true)
375 }
376
377 // Remove the extra empty screen
378 launcher.workspace.removeExtraEmptyScreen(false)
379 }
380
Sebastian Franco6196b902023-12-06 11:39:52 -0600381 private fun bindAddScreens(orderedScreenIdsArg: LIntArray) {
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600382 var orderedScreenIds = orderedScreenIdsArg
383 if (launcher.deviceProfile.isTwoPanels) {
384 if (FeatureFlags.FOLDABLE_SINGLE_PAGE.get()) {
385 orderedScreenIds = filterTwoPanelScreenIds(orderedScreenIds)
386 } else {
387 // Some empty pages might have been removed while the phone was in a single panel
388 // mode, so we want to add those empty pages back.
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600389 val screenIds = LIntSet.wrap(orderedScreenIds)
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600390 orderedScreenIds.forEach { screenId: Int ->
391 screenIds.add(launcher.workspace.getScreenPair(screenId))
392 }
393 orderedScreenIds = screenIds.array
394 }
395 }
396 orderedScreenIds
397 .filterNot { screenId ->
micky387e6bebdc2024-12-28 16:17:56 -0500398 getQsbOnFirstScreen() &&
Sihua Maa44f4ac2024-06-03 18:35:39 +0000399 isFirstPagePinnedItemEnabled &&
fbaron9d08e0f2024-04-24 11:26:01 -0700400 !SHOULD_SHOW_FIRST_PAGE_WIDGET &&
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600401 screenId == WorkspaceLayoutManager.FIRST_SCREEN_ID
402 }
403 .forEach { screenId ->
404 launcher.workspace.insertNewWorkspaceScreenBeforeEmptyScreen(screenId)
405 }
406 }
407
408 /**
409 * Remove odd number because they are already included when isTwoPanels and add the pair screen
410 * if not present.
411 */
Sebastian Franco6196b902023-12-06 11:39:52 -0600412 private fun filterTwoPanelScreenIds(orderedScreenIds: LIntArray): LIntArray {
Sebastian Franco0b461ef2023-12-08 12:20:07 -0600413 val screenIds = LIntSet.wrap(orderedScreenIds)
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600414 orderedScreenIds
415 .filter { screenId -> screenId % 2 == 1 }
416 .forEach { screenId ->
417 screenIds.remove(screenId)
418 // In case the pair is not added, add it
419 if (!launcher.workspace.containsScreenId(screenId - 1)) {
420 screenIds.add(screenId - 1)
421 }
422 }
423 return screenIds.array
424 }
425
426 override fun setIsFirstPagePinnedItemEnabled(isFirstPagePinnedItemEnabled: Boolean) {
427 this.isFirstPagePinnedItemEnabled = isFirstPagePinnedItemEnabled
428 launcher.workspace.bindAndInitFirstWorkspaceScreen()
429 }
430
431 override fun bindStringCache(cache: StringCache) {
432 stringCache = cache
433 launcher.appsView.updateWorkUI()
434 }
435
micky387e6bebdc2024-12-28 16:17:56 -0500436 fun getQsbOnFirstScreen(): Boolean = Utilities.showWorkspaceQsbWidget(launcher)
437
Sebastian Franco6dda7c72023-11-17 18:03:00 -0600438 fun getIsFirstPagePinnedItemEnabled(): Boolean = isFirstPagePinnedItemEnabled
Sunny Goyal72a74662024-02-14 12:32:59 -0800439
440 override fun getItemInflater() = launcher.itemInflater
Sebastian Francobd7919c2023-09-19 10:55:37 -0700441}