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 Original line Diff line number Diff line
@@ -197,6 +197,7 @@ private fun ActiveShortcutHelper(
            shortcutsUiState.shouldShowResetButton,
            shortcutsUiState.shouldShowResetButton,
            shortcutsUiState.isCustomizationModeEnabled,
            shortcutsUiState.isCustomizationModeEnabled,
            onCustomizationModeToggled,
            onCustomizationModeToggled,
            shortcutsUiState.isExtendedAppCategoryFlagEnabled,
            modifier,
            modifier,
            onShortcutCustomizationRequested,
            onShortcutCustomizationRequested,
        )
        )
@@ -390,6 +391,7 @@ private fun ShortcutHelperTwoPane(
    shouldShowResetButton: Boolean,
    shouldShowResetButton: Boolean,
    isCustomizationModeEnabled: Boolean,
    isCustomizationModeEnabled: Boolean,
    onCustomizationModeToggled: (isCustomizing: Boolean) -> Unit,
    onCustomizationModeToggled: (isCustomizing: Boolean) -> Unit,
    isExtendedAppCategoryFlagEnabled: Boolean,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
) {
) {
@@ -435,9 +437,12 @@ private fun ShortcutHelperTwoPane(
            Spacer(modifier = Modifier.width(24.dp))
            Spacer(modifier = Modifier.width(24.dp))
            EndSidePanel(
            EndSidePanel(
                searchQuery,
                searchQuery,
                Modifier.fillMaxSize().padding(top = 8.dp).semantics { isTraversalGroup = true },
                isCustomizationModeEnabled,
                onCustomizationModeToggled,
                selectedCategory,
                selectedCategory,
                isCustomizing = isCustomizationModeEnabled,
                isCustomizing = isCustomizationModeEnabled,
                isExtendedAppCategoryFlagEnabled,
                Modifier.fillMaxSize().padding(top = 8.dp).semantics { isTraversalGroup = true },
                onShortcutCustomizationRequested = onShortcutCustomizationRequested,
                onShortcutCustomizationRequested = onShortcutCustomizationRequested,
            )
            )
        }
        }
@@ -504,9 +509,12 @@ private fun DoneButton(onClick: () -> Unit) {
@Composable
@Composable
private fun EndSidePanel(
private fun EndSidePanel(
    searchQuery: String,
    searchQuery: String,
    modifier: Modifier,
    isCustomizationModeEnabled: Boolean,
    onCustomizationModeToggled: (isCustomizing: Boolean) -> Unit,
    category: ShortcutCategoryUi?,
    category: ShortcutCategoryUi?,
    isCustomizing: Boolean,
    isCustomizing: Boolean,
    isExtendedAppCategoryFlagEnabled: Boolean,
    modifier: Modifier = Modifier,
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
    onShortcutCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
) {
) {
    val listState = rememberLazyListState()
    val listState = rememberLazyListState()
@@ -515,7 +523,11 @@ private fun EndSidePanel(
        NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
        NoSearchResultsText(horizontalPadding = 24.dp, fillHeight = false)
        return
        return
    }
    }
    LazyColumn(modifier = modifier, state = listState) {
    LazyColumn(
        modifier = modifier,
        state = listState,
        horizontalAlignment = Alignment.CenterHorizontally,
    ) {
        items(category.subCategories) { subcategory ->
        items(category.subCategories) { subcategory ->
            SubCategoryContainerDualPane(
            SubCategoryContainerDualPane(
                searchQuery = searchQuery,
                searchQuery = searchQuery,
@@ -540,6 +552,22 @@ private fun EndSidePanel(
            )
            )
            Spacer(modifier = Modifier.height(8.dp))
            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,
                        label = shortcut.label,
                        defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom },
                        defaultShortcutCommand = shortcut.commands.firstOrNull { !it.isCustom },
                        packageName = shortcut.pkgName,
                        packageName = shortcut.pkgName,
                        className = shortcut.className
                        className = shortcut.className,
                    )
                    )
                )
                )
            },
            },
+1 −0
Original line number Original line Diff line number Diff line
@@ -25,6 +25,7 @@ sealed interface ShortcutsUiState {
        val shortcutCategories: List<ShortcutCategoryUi>,
        val shortcutCategories: List<ShortcutCategoryUi>,
        val defaultSelectedCategory: ShortcutCategoryType?,
        val defaultSelectedCategory: ShortcutCategoryType?,
        val isShortcutCustomizerFlagEnabled: Boolean = false,
        val isShortcutCustomizerFlagEnabled: Boolean = false,
        val isExtendedAppCategoryFlagEnabled: Boolean = false,
        val shouldShowResetButton: Boolean = false,
        val shouldShowResetButton: Boolean = false,
        val isCustomizationModeEnabled: Boolean = false,
        val isCustomizationModeEnabled: Boolean = false,
    ) : ShortcutsUiState
    ) : ShortcutsUiState
+2 −0
Original line number Original line 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.Tv
import androidx.compose.material.icons.filled.VerticalSplit
import androidx.compose.material.icons.filled.VerticalSplit
import com.android.compose.ui.graphics.painter.DrawablePainter
import com.android.compose.ui.graphics.painter.DrawablePainter
import com.android.systemui.Flags.extendedAppsShortcutCategory
import com.android.systemui.Flags.keyboardShortcutHelperShortcutCustomizer
import com.android.systemui.Flags.keyboardShortcutHelperShortcutCustomizer
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.keyboard.shortcut.domain.interactor.ShortcutHelperCategoriesInteractor
import com.android.systemui.keyboard.shortcut.domain.interactor.ShortcutHelperCategoriesInteractor
@@ -98,6 +99,7 @@ constructor(
                        defaultSelectedCategory = getDefaultSelectedCategory(filteredCategories),
                        defaultSelectedCategory = getDefaultSelectedCategory(filteredCategories),
                        isShortcutCustomizerFlagEnabled =
                        isShortcutCustomizerFlagEnabled =
                            keyboardShortcutHelperShortcutCustomizer(),
                            keyboardShortcutHelperShortcutCustomizer(),
                        isExtendedAppCategoryFlagEnabled = extendedAppsShortcutCategory(),
                        shouldShowResetButton = shouldShowResetButton(shortcutCategoriesUi),
                        shouldShowResetButton = shouldShowResetButton(shortcutCategoriesUi),
                        isCustomizationModeEnabled = isCustomizationModeEnabled,
                        isCustomizationModeEnabled = isCustomizationModeEnabled,
                    )
                    )