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

Commit 969fe685 authored by Naresh Kumar Podishetty (xWF)'s avatar Naresh Kumar Podishetty (xWF) Committed by Android (Google) Code Review
Browse files

Revert "Added Remove shortcut Dialog UI"

This reverts commit 2b2f5e14.

Reason for revert: <Droidmonitor created revert due to b/380180994. Will be verifying through ABTD before submission.
>

Change-Id: Ia6cd6c48600c3e0f339440b2ecec304801d2aec4
parent 2b2f5e14
Loading
Loading
Loading
Loading
+2 −15
Original line number Original line Diff line number Diff line
@@ -3760,20 +3760,11 @@
         is a component that shows the user which keyboard shortcuts they can use.
         is a component that shows the user which keyboard shortcuts they can use.
         [CHAR LIMIT=NONE] -->
         [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_customize_mode_title">Customize keyboard shortcuts</string>
    <string name="shortcut_helper_customize_mode_title">Customize keyboard shortcuts</string>
    <!-- Title at the top of the keyboard shortcut helper remove shortcut dialog.
         The helper is a component that shows the user which keyboard shortcuts they can use. Also
         allows the user to add/remove custom shortcuts.[CHAR LIMIT=NONE] -->
    <string name="shortcut_customize_mode_remove_shortcut_dialog_title">Remove shortcut?</string>
    <!-- Sub title at the top of the keyboard shortcut helper customization dialog. Explains to the
    <!-- Sub title at the top of the keyboard shortcut helper customization dialog. Explains to the
         user what action they need to take in the customization dialog to assign a new custom shortcut.
         user what action they need to take in the customization dialog to assign a new custom shortcut.
         The shortcut customize dialog allows users to add/remove custom shortcuts
         The helper is a component that shows the user which keyboard shortcuts they can use.
         [CHAR LIMIT=NONE] -->
    <string name="shortcut_customize_mode_add_shortcut_description">Press key to assign shortcut</string>
    <!-- Sub title at the top of the remove custom shortcut dialog. Explains to the user what action
         they're about to take when they click remove shortcut. The shortcut customize dialog allows
         users to add/remove custom shortcuts
         [CHAR LIMIT=NONE] -->
         [CHAR LIMIT=NONE] -->
    <string name="shortcut_customize_mode_remove_shortcut_description">This will delete your custom shortcut permanently.</string>
    <string name="shortcut_helper_customize_mode_sub_title">Press key to assign shortcut</string>
    <!-- Placeholder text shown in the search box of the keyboard shortcut helper, when the user
    <!-- Placeholder text shown in the search box of the keyboard shortcut helper, when the user
         hasn't typed in anything in the search box yet. The helper is a  component that shows the
         hasn't typed in anything in the search box yet. The helper is a  component that shows the
         user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
         user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
@@ -3829,10 +3820,6 @@
         confirm and assign key combination to selected shortcut. The helper is a  component that
         confirm and assign key combination to selected shortcut. The helper is a  component that
         shows the user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
         shows the user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_customize_dialog_set_shortcut_button_label">Set shortcut</string>
    <string name="shortcut_helper_customize_dialog_set_shortcut_button_label">Set shortcut</string>
    <!-- Label on the remove shortcut button in keyboard shortcut helper customize dialog, that allows user to
         confirm and remove previously added custom shortcut. The helper is a  component that
         shows the user which keyboard shortcuts they can use. [CHAR LIMIT=NONE] -->
    <string name="shortcut_helper_customize_dialog_remove_button_label">Remove</string>
    <!-- Label on the cancel button in keyboard shortcut helper customize dialog, that allows user to
    <!-- Label on the cancel button in keyboard shortcut helper customize dialog, that allows user to
         cancel and exit shortcut customization dialog, returning to the main shortcut helper page.
         cancel and exit shortcut customization dialog, returning to the main shortcut helper page.
         The helper is a  component that shows the user which keyboard shortcuts they can use.
         The helper is a  component that shows the user which keyboard shortcuts they can use.
+3 −9
Original line number Original line Diff line number Diff line
@@ -18,14 +18,8 @@ package com.android.systemui.keyboard.shortcut.shared.model


sealed interface ShortcutCustomizationRequestInfo {
sealed interface ShortcutCustomizationRequestInfo {
    data class Add(
    data class Add(
        val label: String = "",
        val label: String,
        val categoryType: ShortcutCategoryType = ShortcutCategoryType.System,
        val categoryType: ShortcutCategoryType,
        val subCategoryLabel: String = "",
        val subCategoryLabel: String,
    ) : ShortcutCustomizationRequestInfo

    data class Delete(
        val label: String = "",
        val categoryType: ShortcutCategoryType = ShortcutCategoryType.System,
        val subCategoryLabel: String = "",
    ) : ShortcutCustomizationRequestInfo
    ) : ShortcutCustomizationRequestInfo
}
}
+9 −11
Original line number Original line Diff line number Diff line
@@ -27,10 +27,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.dp
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCustomizationRequestInfo
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCustomizationRequestInfo
import com.android.systemui.keyboard.shortcut.ui.composable.ShortcutCustomizationDialog
import com.android.systemui.keyboard.shortcut.ui.composable.AssignNewShortcutDialog
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCustomizationUiState
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCustomizationUiState
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCustomizationUiState.AddShortcutDialog
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCustomizationUiState.DeleteShortcutDialog
import com.android.systemui.keyboard.shortcut.ui.viewmodel.ShortcutCustomizationViewModel
import com.android.systemui.keyboard.shortcut.ui.viewmodel.ShortcutCustomizationViewModel
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.lifecycle.ExclusiveActivatable
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
import com.android.systemui.statusbar.phone.SystemUIDialogFactory
@@ -52,11 +50,12 @@ constructor(


    override suspend fun onActivated(): Nothing {
    override suspend fun onActivated(): Nothing {
        viewModel.shortcutCustomizationUiState.collect { uiState ->
        viewModel.shortcutCustomizationUiState.collect { uiState ->
            val shouldShowAddDialog = uiState is AddShortcutDialog && !uiState.isDialogShowing
            if (
            val shouldShowDeleteDialog = uiState is DeleteShortcutDialog && !uiState.isDialogShowing
                uiState is ShortcutCustomizationUiState.AddShortcutDialog &&
            if (shouldShowDeleteDialog || shouldShowAddDialog) {
                !uiState.isDialogShowing
                dialog = createDialog().also { it.show() }
            ) {
                viewModel.onDialogShown()
                dialog = createAddShortcutDialog().also { it.show() }
                viewModel.onAddShortcutDialogShown()
            } else if (uiState is ShortcutCustomizationUiState.Inactive) {
            } else if (uiState is ShortcutCustomizationUiState.Inactive) {
                dialog?.dismiss()
                dialog?.dismiss()
                dialog = null
                dialog = null
@@ -69,7 +68,7 @@ constructor(
        viewModel.onShortcutCustomizationRequested(requestInfo)
        viewModel.onShortcutCustomizationRequested(requestInfo)
    }
    }


    private fun createDialog(): Dialog {
    private fun createAddShortcutDialog(): Dialog {
        return dialogFactory.create(dialogDelegate = ShortcutCustomizationDialogDelegate()) { dialog
        return dialogFactory.create(dialogDelegate = ShortcutCustomizationDialogDelegate()) { dialog
            ->
            ->
            val uiState by
            val uiState by
@@ -77,7 +76,7 @@ constructor(
                initialValue = ShortcutCustomizationUiState.Inactive
                initialValue = ShortcutCustomizationUiState.Inactive
            )
            )
            val coroutineScope = rememberCoroutineScope()
            val coroutineScope = rememberCoroutineScope()
            ShortcutCustomizationDialog(
            AssignNewShortcutDialog(
                uiState = uiState,
                uiState = uiState,
                modifier = Modifier
                modifier = Modifier
                    .width(364.dp)
                    .width(364.dp)
@@ -88,7 +87,6 @@ constructor(
                onConfirmSetShortcut = {
                onConfirmSetShortcut = {
                    coroutineScope.launch { viewModel.onSetShortcut() }
                    coroutineScope.launch { viewModel.onSetShortcut() }
                },
                },
                onConfirmDeleteShortcut = { viewModel.onDeleteShortcut() },
            )
            )
            dialog.setOnDismissListener { viewModel.onDialogDismissed() }
            dialog.setOnDismissListener { viewModel.onDialogDismissed() }


+37 −76
Original line number Original line Diff line number Diff line
@@ -61,23 +61,21 @@ import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCustomizationUiSt
import com.android.systemui.res.R
import com.android.systemui.res.R


@Composable
@Composable
fun ShortcutCustomizationDialog(
fun AssignNewShortcutDialog(
    uiState: ShortcutCustomizationUiState,
    uiState: ShortcutCustomizationUiState,
    modifier: Modifier = Modifier,
    modifier: Modifier = Modifier,
    onKeyPress: (KeyEvent) -> Boolean,
    onKeyPress: (KeyEvent) -> Boolean,
    onCancel: () -> Unit,
    onCancel: () -> Unit,
    onConfirmSetShortcut: () -> Unit,
    onConfirmSetShortcut: () -> Unit,
    onConfirmDeleteShortcut: () -> Unit,
) {
) {
    when (uiState) {
    if (uiState is ShortcutCustomizationUiState.AddShortcutDialog) {
        is ShortcutCustomizationUiState.AddShortcutDialog -> {
        Column(modifier = modifier) {
        Column(modifier = modifier) {
                Title(uiState.shortcutLabel)
            Title(
                Description(
                uiState.shortcutLabel,
                    text =
                modifier = Modifier.padding(horizontal = 24.dp).width(316.dp),
                        stringResource(
                            id = R.string.shortcut_customize_mode_add_shortcut_description
            )
            )
            Description(
                modifier = Modifier.padding(top = 24.dp, start = 24.dp, end = 24.dp).width(316.dp)
            )
            )
            PromptShortcutModifier(
            PromptShortcutModifier(
                modifier =
                modifier =
@@ -94,51 +92,18 @@ fun ShortcutCustomizationDialog(
            ErrorMessageContainer(uiState.errorMessage)
            ErrorMessageContainer(uiState.errorMessage)
            DialogButtons(
            DialogButtons(
                onCancel,
                onCancel,
                    isConfirmButtonEnabled = uiState.pressedKeys.isNotEmpty(),
                isSetShortcutButtonEnabled = uiState.pressedKeys.isNotEmpty(),
                onConfirm = onConfirmSetShortcut,
                onConfirm = onConfirmSetShortcut,
                    confirmButtonText =
                        stringResource(
                            R.string.shortcut_helper_customize_dialog_set_shortcut_button_label
                        ),
            )
            )
        }
        }
    }
    }
        is ShortcutCustomizationUiState.DeleteShortcutDialog -> {
            Column(modifier) {
                Title(
                    title =
                        stringResource(
                            id = R.string.shortcut_customize_mode_remove_shortcut_dialog_title
                        )
                )
                Description(
                    text =
                        stringResource(
                            id = R.string.shortcut_customize_mode_remove_shortcut_description
                        )
                )
                DialogButtons(
                    onCancel = onCancel,
                    onConfirm = onConfirmDeleteShortcut,
                    confirmButtonText =
                        stringResource(
                            R.string.shortcut_helper_customize_dialog_remove_button_label
                        ),
                )
            }
        }
        else -> {
            /* No-Op */
        }
    }
}
}


@Composable
@Composable
fun DialogButtons(
fun DialogButtons(
    onCancel: () -> Unit,
    onCancel: () -> Unit,
    isConfirmButtonEnabled: Boolean = true,
    isSetShortcutButtonEnabled: Boolean,
    onConfirm: () -> Unit,
    onConfirm: () -> Unit,
    confirmButtonText: String,
) {
) {
    Row(
    Row(
        modifier =
        modifier =
@@ -161,8 +126,9 @@ fun DialogButtons(
            color = MaterialTheme.colorScheme.primary,
            color = MaterialTheme.colorScheme.primary,
            width = 116.dp,
            width = 116.dp,
            contentColor = MaterialTheme.colorScheme.onPrimary,
            contentColor = MaterialTheme.colorScheme.onPrimary,
            text = confirmButtonText,
            text =
            enabled = isConfirmButtonEnabled,
                stringResource(R.string.shortcut_helper_customize_dialog_set_shortcut_button_label),
            enabled = isSetShortcutButtonEnabled,
        )
        )
    }
    }
}
}
@@ -296,28 +262,23 @@ private fun ShortcutTextKey(key: ShortcutKey.Text) {
}
}


@Composable
@Composable
private fun Title(title: String) {
private fun Title(title: String, modifier: Modifier = Modifier) {
    Text(
    Text(
        text = title,
        text = title,
        style = MaterialTheme.typography.headlineSmall,
        style = MaterialTheme.typography.headlineSmall,
        fontSize = 24.sp,
        fontSize = 24.sp,
        modifier =
        modifier = modifier.wrapContentSize(Alignment.Center),
            Modifier.padding(horizontal = 24.dp).width(316.dp).wrapContentSize(Alignment.Center),
        color = MaterialTheme.colorScheme.onSurface,
        color = MaterialTheme.colorScheme.onSurface,
        lineHeight = 32.sp,
        lineHeight = 32.sp,
        fontWeight = FontWeight.W400,
    )
    )
}
}


@Composable
@Composable
private fun Description(text: String) {
private fun Description(modifier: Modifier = Modifier) {
    Text(
    Text(
        text = text,
        text = stringResource(id = R.string.shortcut_helper_customize_mode_sub_title),
        style = MaterialTheme.typography.bodyMedium,
        style = MaterialTheme.typography.bodyMedium,
        modifier =
        modifier = modifier.wrapContentSize(Alignment.Center),
            Modifier.padding(top = 24.dp, start = 24.dp, end = 24.dp)
                .width(316.dp)
                .wrapContentSize(Alignment.Center),
        color = MaterialTheme.colorScheme.onSurfaceVariant,
        color = MaterialTheme.colorScheme.onSurfaceVariant,
    )
    )
}
}
+13 −38
Original line number Original line Diff line number Diff line
@@ -111,6 +111,7 @@ import androidx.compose.ui.util.fastForEach
import androidx.compose.ui.util.fastForEachIndexed
import androidx.compose.ui.util.fastForEachIndexed
import com.android.compose.modifiers.thenIf
import com.android.compose.modifiers.thenIf
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import com.android.compose.ui.graphics.painter.rememberDrawablePainter
import com.android.systemui.keyboard.shortcut.shared.model.Shortcut as ShortcutModel
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCategoryType
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCommand
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCommand
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCustomizationRequestInfo
import com.android.systemui.keyboard.shortcut.shared.model.ShortcutCustomizationRequestInfo
@@ -121,7 +122,6 @@ import com.android.systemui.keyboard.shortcut.ui.model.IconSource
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCategoryUi
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutCategoryUi
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutsUiState
import com.android.systemui.keyboard.shortcut.ui.model.ShortcutsUiState
import com.android.systemui.res.R
import com.android.systemui.res.R
import com.android.systemui.keyboard.shortcut.shared.model.Shortcut as ShortcutModel
import kotlinx.coroutines.delay
import kotlinx.coroutines.delay


@Composable
@Composable
@@ -462,18 +462,14 @@ private fun EndSidePanel(
                searchQuery = searchQuery,
                searchQuery = searchQuery,
                subCategory = subcategory,
                subCategory = subcategory,
                isCustomizing = isCustomizing,
                isCustomizing = isCustomizing,
                onCustomizationRequested = { requestInfo ->
                onCustomizationRequested = { label, subCategoryLabel ->
                    when (requestInfo) {
                        is ShortcutCustomizationRequestInfo.Add ->
                    onCustomizationRequested(
                    onCustomizationRequested(
                                requestInfo.copy(categoryType = category.type)
                        ShortcutCustomizationRequestInfo.Add(
                            label = label,
                            subCategoryLabel = subCategoryLabel,
                            categoryType = category.type,
                        )
                        )

                        is ShortcutCustomizationRequestInfo.Delete ->
                            onCustomizationRequested(
                                requestInfo.copy(categoryType = category.type)
                    )
                    )
                    }
                },
                },
            )
            )
            Spacer(modifier = Modifier.height(8.dp))
            Spacer(modifier = Modifier.height(8.dp))
@@ -504,7 +500,7 @@ private fun SubCategoryContainerDualPane(
    searchQuery: String,
    searchQuery: String,
    subCategory: ShortcutSubCategory,
    subCategory: ShortcutSubCategory,
    isCustomizing: Boolean,
    isCustomizing: Boolean,
    onCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit,
    onCustomizationRequested: (String, String) -> Unit = { _: String, _: String -> },
) {
) {
    Surface(
    Surface(
        modifier = Modifier.fillMaxWidth(),
        modifier = Modifier.fillMaxWidth(),
@@ -526,19 +522,7 @@ private fun SubCategoryContainerDualPane(
                    searchQuery = searchQuery,
                    searchQuery = searchQuery,
                    shortcut = shortcut,
                    shortcut = shortcut,
                    isCustomizing = isCustomizing,
                    isCustomizing = isCustomizing,
                    onCustomizationRequested = { requestInfo ->
                    onCustomizationRequested = { onCustomizationRequested(it, subCategory.label) },
                        when (requestInfo) {
                            is ShortcutCustomizationRequestInfo.Add ->
                                onCustomizationRequested(
                                    requestInfo.copy(subCategoryLabel = subCategory.label)
                                )

                            is ShortcutCustomizationRequestInfo.Delete ->
                                onCustomizationRequested(
                                    requestInfo.copy(subCategoryLabel = subCategory.label)
                                )
                        }
                    },
                )
                )
            }
            }
        }
        }
@@ -560,7 +544,7 @@ private fun Shortcut(
    searchQuery: String,
    searchQuery: String,
    shortcut: ShortcutModel,
    shortcut: ShortcutModel,
    isCustomizing: Boolean = false,
    isCustomizing: Boolean = false,
    onCustomizationRequested: (ShortcutCustomizationRequestInfo) -> Unit = {},
    onCustomizationRequested: (String) -> Unit = {},
) {
) {
    val interactionSource = remember { MutableInteractionSource() }
    val interactionSource = remember { MutableInteractionSource() }
    val isFocused by interactionSource.collectIsFocusedAsState()
    val isFocused by interactionSource.collectIsFocusedAsState()
@@ -588,16 +572,7 @@ private fun Shortcut(
            modifier = Modifier.weight(.666f),
            modifier = Modifier.weight(.666f),
            shortcut = shortcut,
            shortcut = shortcut,
            isCustomizing = isCustomizing,
            isCustomizing = isCustomizing,
            onAddShortcutRequested = {
            onAddShortcutRequested = { onCustomizationRequested(shortcut.label) },
                onCustomizationRequested(
                    ShortcutCustomizationRequestInfo.Add(label = shortcut.label)
                )
            },
            onDeleteShortcutRequested = {
                onCustomizationRequested(
                    ShortcutCustomizationRequestInfo.Delete(label = shortcut.label)
                )
            },
        )
        )
    }
    }
}
}
Loading