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

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

Merge "updated dialog title to include title + description for A11y" into main

parents f45b3d84 779a56f0
Loading
Loading
Loading
Loading
+22 −11
Original line number Diff line number Diff line
@@ -108,20 +108,31 @@ constructor(

    private fun setDialogProperties(dialog: SystemUIDialog, uiState: ShortcutCustomizationUiState) {
        dialog.setOnDismissListener { viewModel.onDialogDismissed() }
        dialog.setTitle(
            resources.getString(
        dialog.setTitle("${getDialogTitle(uiState)}. ${getDialogDescription(uiState)}")
        // By default, apps cannot intercept action key. The system always handles it. This
        // flag is needed to enable customisation dialog window to intercept action key
        dialog.window?.addPrivateFlags(PRIVATE_FLAG_ALLOW_ACTION_KEY_EVENTS)
    }

    private fun getDialogTitle(uiState: ShortcutCustomizationUiState): String {
        return when (uiState) {
            is AddShortcutDialog -> uiState.shortcutLabel
            is DeleteShortcutDialog ->
                resources.getString(R.string.shortcut_customize_mode_remove_shortcut_dialog_title)
            else ->
                resources.getString(R.string.shortcut_customize_mode_reset_shortcut_dialog_title)
        }
    }

    private fun getDialogDescription(uiState: ShortcutCustomizationUiState): String {
        return resources.getString(
            when (uiState) {
                    is AddShortcutDialog ->
                        R.string.shortcut_customize_mode_add_shortcut_description
                is AddShortcutDialog -> R.string.shortcut_customize_mode_add_shortcut_description
                is DeleteShortcutDialog ->
                    R.string.shortcut_customize_mode_remove_shortcut_description
                else -> R.string.shortcut_customize_mode_reset_shortcut_description
            }
        )
        )
        // By default, apps cannot intercept action key. The system always handles it. This
        // flag is needed to enable customisation dialog window to intercept action key
        dialog.window?.addPrivateFlags(PRIVATE_FLAG_ALLOW_ACTION_KEY_EVENTS)
    }

    @AssistedFactory