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

Commit 2af89258 authored by Josh's avatar Josh
Browse files

Exclude current app & input categories frm customization

We do not yet support shortcut customization for these categories

Fix: 377889079
Test: manual, on shortcut helper UI, enter customize mode, check that
Input category and current app category are not in customize mode.
Flag: com.android.systemui.keyboard_shortcut_helper_shortcut_customizer

Change-Id: I5cf75fa69353b2158948b279785e8076022810e8
parent 7af883b8
Loading
Loading
Loading
Loading
+7 −8
Original line number Diff line number Diff line
@@ -48,9 +48,7 @@ import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType.
import com.android.systemui.res.R
import javax.inject.Inject

class InputGestureMaps
@Inject
constructor(private val context: Context) {
class InputGestureMaps @Inject constructor(private val context: Context) {
    val gestureToShortcutCategoryTypeMap =
        mapOf(
            // System Category
@@ -180,7 +178,8 @@ constructor(private val context: Context) {
        )

    val shortcutLabelToKeyGestureTypeMap: Map<String, Int>
        get() = gestureToInternalKeyboardShortcutInfoLabelResIdMap.entries.associateBy({
        get() =
            gestureToInternalKeyboardShortcutInfoLabelResIdMap.entries.associateBy({
                context.getString(it.value)
            }) {
                it.key
+1 −1
Original line number Diff line number Diff line
@@ -36,9 +36,9 @@ import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCommand
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutIcon
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutKey
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutSubCategory
import kotlinx.coroutines.withContext
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
import kotlinx.coroutines.withContext

class ShortcutCategoriesUtils
@Inject
+6 −0
Original line number Diff line number Diff line
@@ -18,25 +18,31 @@ package com.android.systemui.keyboard.shortcut.shared.model

sealed interface ShortcutCategoryType {
    val isTrusted: Boolean
    val includeInCustomization: Boolean

    data object System : ShortcutCategoryType {
        override val isTrusted: Boolean = true
        override val includeInCustomization: Boolean = true
    }

    data object MultiTasking : ShortcutCategoryType {
        override val isTrusted: Boolean = true
        override val includeInCustomization: Boolean = true
    }

    data object InputMethodEditor : ShortcutCategoryType {
        override val isTrusted: Boolean = false
        override val includeInCustomization: Boolean = false
    }

    data object AppCategories : ShortcutCategoryType {
        override val isTrusted: Boolean = true
        override val includeInCustomization: Boolean = true
    }

    data class CurrentApp(val packageName: String) : ShortcutCategoryType {
        override val isTrusted: Boolean = false
        override val includeInCustomization: Boolean = false
    }
}

+1 −1
Original line number Diff line number Diff line
@@ -461,7 +461,7 @@ private fun EndSidePanel(
            SubCategoryContainerDualPane(
                searchQuery = searchQuery,
                subCategory = subcategory,
                isCustomizing = isCustomizing,
                isCustomizing = isCustomizing and category.type.includeInCustomization,
                onCustomizationRequested = { requestInfo ->
                    when (requestInfo) {
                        is ShortcutCustomizationRequestInfo.Add ->
+2 −5
Original line number Diff line number Diff line
@@ -102,10 +102,7 @@ val Kosmos.defaultShortcutCategoriesRepository by
        )
    }

val Kosmos.inputGestureMaps by
        Kosmos.Fixture {
            InputGestureMaps(applicationContext)
        }
val Kosmos.inputGestureMaps by Kosmos.Fixture { InputGestureMaps(applicationContext) }

val Kosmos.customShortcutCategoriesRepository by
    Kosmos.Fixture {
@@ -116,7 +113,7 @@ val Kosmos.customShortcutCategoriesRepository by
            testDispatcher,
            shortcutCategoriesUtils,
            applicationContext,
            inputGestureMaps
            inputGestureMaps,
        )
    }