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

Commit e903a6a7 authored by Joshua Mokut's avatar Joshua Mokut Committed by Android (Google) Code Review
Browse files

Merge "Added UI Entry point for adding extra app shortcuts" into main

parents d38c6672 4e7681d5
Loading
Loading
Loading
Loading
+32 −4
Original line number Diff line number Diff line
@@ -197,6 +197,7 @@ private fun ActiveShortcutHelper(
            shortcutsUiState.shouldShowResetButton,
            shortcutsUiState.isCustomizationModeEnabled,
            onCustomizationModeToggled,
            shortcutsUiState.isExtendedAppCategoryFlagEnabled,
            modifier,
            onShortcutCustomizationRequested,
        )
@@ -390,6 +391,7 @@ private fun ShortcutHelperTwoPane(
    shouldShowResetButton: Boolean,
    isCustomizationModeEnabled: Boolean,
    onCustomizationModeToggled: (isCustomizing: Boolean) -> Unit,
    isExtendedAppCategoryFlagEnabled: Boolean,
    modifier: Modifier = Modifier,
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
) {
@@ -435,9 +437,12 @@ private fun ShortcutHelperTwoPane(
            Spacer(modifier = Modifier.width(24.dp))
            EndSidePanel(
                searchQuery,
                Modifier.fillMaxSize().padding(top = 8.dp).semantics { isTraversalGroup = true },
                isCustomizationModeEnabled,
                onCustomizationModeToggled,
                selectedCategory,
                isCustomizing = isCustomizationModeEnabled,
                isExtendedAppCategoryFlagEnabled,
                Modifier.fillMaxSize().padding(top = 8.dp).semantics { isTraversalGroup = true },
                onShortcutCustomizationRequested = onShortcutCustomizationRequested,
            )
        }
@@ -504,9 +509,12 @@ private fun DoneButton(onClick: () -> Unit) {
@Composable
private fun EndSidePanel(
    searchQuery: String,
    modifier: Modifier,
    isCustomizationModeEnabled: Boolean,
    onCustomizationModeToggled: (isCustomizing: Boolean) -> Unit,
    category: ShortcutCategoryUi?,
    isCustomizing: Boolean,
    isExtendedAppCategoryFlagEnabled: Boolean,
    modifier: Modifier = Modifier,
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
) {
    val listState = rememberLazyListState()
@@ -515,7 +523,11 @@ private fun EndSidePanel(
        NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
        return
    }
    LazyColumn(modifier = modifier, state = listState) {
    LazyColumn(
        modifier = modifier,
        state = listState,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        items(category.subCategories) { subcategory ->
            SubCategoryContainerDualPane(
                searchQuery = searchQuery,
@@ -540,6 +552,22 @@ private fun EndSidePanel(
            )
            Spacer(modifier = Modifier.height(8.dp))
        }
        if (
            category.type == ShortcutCategoryType.AppCategories &&
                !isCustomizationModeEnabled &&
                isExtendedAppCategoryFlagEnabled
        ) {
            item {
                ShortcutHelperButton(
                    onClick = { onCustomizationModeToggled(/* isCustomizing= */ true) },
                    contentColor = MaterialTheme.colorScheme.onSecondaryContainer,
                    color = MaterialTheme.colorScheme.secondaryContainer,
                    iconSource = IconSource(imageVector = Icons.Default.Add),
                    modifier = Modifier.heightIn(40.dp),
                    text = stringResource(R.string.shortcut_helper_add_shortcut_button_label),
                )
            }
        }
    }
}

@@ -670,7 +698,7 @@ private fun Shortcut(
                        label = shortcut.label,
                        defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom },
                        packageName = shortcut.pkgName,
                        className = shortcut.className
                        className = shortcut.className,
                    )
                )
            },
+1 −0
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ sealed interface ShortcutsUiState {
        val shortcutCategories: List<ShortcutCategoryUi>,
        val defaultSelectedCategory: ShortcutCategoryType?,
        val isShortcutCustomizerFlagEnabled: Boolean = false,
        val isExtendedAppCategoryFlagEnabled: Boolean = false,
        val shouldShowResetButton: Boolean = false,
        val isCustomizationModeEnabled: Boolean = false,
    ) : ShortcutsUiState
+2 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ import androidx.compose.material.icons.filled.Keyboard
import androidx.compose.material.icons.filled.Tv
import androidx.compose.material.icons.filled.VerticalSplit
import com.android.compose.ui.graphics.painter.DrawablePainter
import com.android.systemui.Flags.extendedAppsShortcutCategory
import com.android.systemui.Flags.keyboardShortcutHelperShortcutCustomizer
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyboard.shortcut.domain.interactor.ShortcutHelperCategoriesInteractor
@@ -98,6 +99,7 @@ constructor(
                        defaultSelectedCategory = getDefaultSelectedCategory(filteredCategories),
                        isShortcutCustomizerFlagEnabled =
                            keyboardShortcutHelperShortcutCustomizer(),
                        isExtendedAppCategoryFlagEnabled = extendedAppsShortcutCategory(),
                        shouldShowResetButton = shouldShowResetButton(shortcutCategoriesUi),
                        isCustomizationModeEnabled = isCustomizationModeEnabled,
                    )