Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 60147fc0 authored by Josh's avatar Josh
Browse files

Hiding launcher shortcuts

Launcher shortcuts are now redundant and are going to be removed b/327141011

in the meantime we're hiding them manually.

Test: NONE
Flag: com.android.systemui.keyboard_shortcut_helper_rewrite
Fixes: 359801767
Change-Id: Idd22f87d392033ee697807a394e773e2657cbb70
parent 1f80f071
Loading
Loading
Loading
Loading
+19 −3
Original line number Diff line number Diff line
@@ -63,7 +63,11 @@ constructor(
                if (categories.isEmpty()) {
                    ShortcutsUiState.Inactive
                } else {
                    val filteredCategories = filterCategoriesBySearchQuery(query, categories)
                    /* temporarily hiding launcher shortcut categories until b/327141011
                     * is completed. */
                    val categoriesWithLauncherExcluded = excludeLauncherApp(categories)
                    val filteredCategories =
                        filterCategoriesBySearchQuery(query, categoriesWithLauncherExcluded)
                    ShortcutsUiState.Active(
                        searchQuery = query,
                        shortcutCategories = filteredCategories,
@@ -77,15 +81,27 @@ constructor(
                initialValue = ShortcutsUiState.Inactive
            )

    private suspend fun excludeLauncherApp(
        categories: List<ShortcutCategory>
    ): List<ShortcutCategory> {
        val launcherAppCategory =
            categories.firstOrNull { it.type is CurrentApp && isLauncherApp(it.type.packageName) }
        return if (launcherAppCategory != null) {
            categories - launcherAppCategory
        } else {
            categories
        }
    }

    private suspend fun getDefaultSelectedCategory(
        categories: List<ShortcutCategory>
    ): ShortcutCategoryType? {
        val currentAppShortcuts =
            categories.firstOrNull { it.type is CurrentApp && !isAppLauncher(it.type.packageName) }
            categories.firstOrNull { it.type is CurrentApp && !isLauncherApp(it.type.packageName) }
        return currentAppShortcuts?.type ?: categories.firstOrNull()?.type
    }

    private suspend fun isAppLauncher(packageName: String): Boolean {
    private suspend fun isLauncherApp(packageName: String): Boolean {
        return withContext(backgroundDispatcher) {
            roleManager
                .getRoleHoldersAsUser(RoleManager.ROLE_HOME, userTracker.userHandle)