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

Commit 482cb781 authored by Josh's avatar Josh
Browse files

Minor UI Changes

+ UI Component showing selected key combination will now be focused by
  default
+ Set shortcut button will be enabled when user presses some
  keyCombination since we cannot yet validate key combination without
attempting to set shortcut

Test: Manual, open add shortcut dialog and ensure the changes above are
in effect.
Flag: com.android.systemui.keyboard_shortcut_helper_shortcut_customizer
Bug: 373638584

Change-Id: I79008ba1d1155e4a80772b4695c77849e5973a7f
parent 75e4420c
Loading
Loading
Loading
Loading
+11 −4
Original line number Diff line number Diff line
@@ -40,10 +40,13 @@ import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.getValue
import androidx.compose.runtime.remember
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.input.key.KeyEvent
import androidx.compose.ui.input.key.onKeyEvent
@@ -86,13 +89,13 @@ fun AssignNewShortcutDialog(
                pressedKeys = uiState.pressedKeys,
            )
            KeyCombinationAlreadyInUseErrorMessage(uiState.shouldShowErrorMessage)
            DialogButtons(onCancel, isValidKeyCombination = uiState.isValidKeyCombination)
            DialogButtons(onCancel, isSetShortcutButtonEnabled = uiState.pressedKeys.isNotEmpty())
        }
    }
}

@Composable
fun DialogButtons(onCancel: () -> Unit, isValidKeyCombination: Boolean) {
fun DialogButtons(onCancel: () -> Unit, isSetShortcutButtonEnabled: Boolean) {
    Row(
        modifier =
            Modifier.padding(top = 24.dp, start = 24.dp, end = 24.dp)
@@ -116,7 +119,7 @@ fun DialogButtons(onCancel: () -> Unit, isValidKeyCombination: Boolean) {
            contentColor = MaterialTheme.colorScheme.onPrimary,
            text =
                stringResource(R.string.shortcut_helper_customize_dialog_set_shortcut_button_label),
            enabled = isValidKeyCombination,
            enabled = isSetShortcutButtonEnabled,
        )
    }
}
@@ -150,6 +153,9 @@ fun SelectedKeyCombinationContainer(
        if (!isFocused) MaterialTheme.colorScheme.outline
        else if (shouldShowErrorMessage) MaterialTheme.colorScheme.error
        else MaterialTheme.colorScheme.primary
    val focusRequester = remember { FocusRequester() }

    LaunchedEffect(Unit) { focusRequester.requestFocus() }

    ClickableShortcutSurface(
        onClick = {},
@@ -159,7 +165,8 @@ fun SelectedKeyCombinationContainer(
            Modifier.padding(all = 16.dp)
                .sizeIn(minWidth = 332.dp, minHeight = 56.dp)
                .border(width = 2.dp, color = outlineColor, shape = RoundedCornerShape(50.dp))
                .onKeyEvent { onKeyPress(it) },
                .onKeyEvent { onKeyPress(it) }
                .focusRequester(focusRequester),
        interactionSource = interactionSource,
    ) {
        Row(
+0 −1
Original line number Diff line number Diff line
@@ -22,7 +22,6 @@ sealed interface ShortcutCustomizationUiState {
    data class AddShortcutDialog(
        val shortcutLabel: String,
        val shouldShowErrorMessage: Boolean,
        val isValidKeyCombination: Boolean,
        val defaultCustomShortcutModifierKey: ShortcutKey.Icon.ResIdIcon,
        val isDialogShowing: Boolean,
        val pressedKeys: List<ShortcutKey> = emptyList(),
+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ constructor(private val shortcutCustomizationInteractor: ShortcutCustomizationIn
                    ShortcutCustomizationUiState.AddShortcutDialog(
                        shortcutLabel = requestInfo.label,
                        shouldShowErrorMessage = false,
                        isValidKeyCombination = false,
                        defaultCustomShortcutModifierKey =
                            shortcutCustomizationInteractor.getDefaultCustomShortcutModifierKey(),
                        isDialogShowing = false,
+0 −1
Original line number Diff line number Diff line
@@ -223,7 +223,6 @@ class ShortcutCustomizationViewModelTest : SysuiTestCase() {
        ShortcutCustomizationUiState.AddShortcutDialog(
            shortcutLabel = "Standard shortcut",
            shouldShowErrorMessage = false,
            isValidKeyCombination = false,
            defaultCustomShortcutModifierKey =
                ShortcutKey.Icon.ResIdIcon(R.drawable.ic_ksh_key_meta),
            isDialogShowing = false,