Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

## Added

- #2067 add action to select all text in the focused field.
- #2045 add action to input on-screen keyboard enter/send button.
- #2106 disable the keyboard auto-switching setting when manually switching the keyboard in the Key Mapper homescreen menu.
- #1029 add action to show a toast message.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -858,6 +858,11 @@ sealed class ActionData : Comparable<ActionData> {
override val id = ActionId.SELECT_WORD_AT_CURSOR
}

@Serializable
data object SelectAllText : ActionData() {
override val id = ActionId.SELECT_ALL_TEXT
}

@Serializable
data object VoiceAssistant : ActionData() {
override val id = ActionId.OPEN_VOICE_ASSISTANT
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,8 @@ object ActionDataEntityMapper {

ActionId.SELECT_WORD_AT_CURSOR -> ActionData.SelectWordAtCursor

ActionId.SELECT_ALL_TEXT -> ActionData.SelectAllText

ActionId.TOGGLE_AIRPLANE_MODE -> ActionData.AirplaneMode.Toggle

ActionId.ENABLE_AIRPLANE_MODE -> ActionData.AirplaneMode.Enable
Expand Down Expand Up @@ -1478,6 +1480,7 @@ object ActionDataEntityMapper {
ActionId.TEXT_COPY to "text_copy",
ActionId.TEXT_PASTE to "text_paste",
ActionId.SELECT_WORD_AT_CURSOR to "select_word_at_cursor",
ActionId.SELECT_ALL_TEXT to "select_all_text",

ActionId.SWITCH_KEYBOARD to "switch_keyboard",

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ enum class ActionId {
TEXT_PASTE,
MOVE_CURSOR,
SELECT_WORD_AT_CURSOR,
SELECT_ALL_TEXT,
TOGGLE_KEYBOARD,
SHOW_KEYBOARD,
HIDE_KEYBOARD,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ class ActionUiHelper(
ActionData.Screenshot -> getString(R.string.action_screenshot)
ActionData.SecureLock -> getString(R.string.action_secure_lock_device)
ActionData.SelectWordAtCursor -> getString(R.string.action_select_word_at_cursor)
ActionData.SelectAllText -> getString(R.string.action_select_all_text)
ActionData.ShowKeyboard -> getString(R.string.action_show_keyboard)
ActionData.ShowKeyboardPicker -> getString(R.string.action_show_keyboard_picker)
ActionData.PerformImeAction -> getString(R.string.action_perform_ime_action)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ import androidx.compose.material.icons.outlined.PowerSettingsNew
import androidx.compose.material.icons.outlined.Replay30
import androidx.compose.material.icons.outlined.ScreenLockRotation
import androidx.compose.material.icons.outlined.ScreenRotation
import androidx.compose.material.icons.outlined.SelectAll
import androidx.compose.material.icons.outlined.Settings
import androidx.compose.material.icons.outlined.SignalCellular4Bar
import androidx.compose.material.icons.outlined.SignalCellularOff
Expand Down Expand Up @@ -225,6 +226,7 @@ object ActionUtils {
ActionId.HIDE_KEYBOARD -> ActionCategory.KEYBOARD
ActionId.SHOW_KEYBOARD_PICKER -> ActionCategory.KEYBOARD
ActionId.SELECT_WORD_AT_CURSOR -> ActionCategory.KEYBOARD
ActionId.SELECT_ALL_TEXT -> ActionCategory.KEYBOARD
ActionId.PERFORM_IME_ACTION -> ActionCategory.KEYBOARD
ActionId.SWITCH_KEYBOARD -> ActionCategory.KEYBOARD
ActionId.LOCK_DEVICE -> ActionCategory.INTERFACE
Expand Down Expand Up @@ -426,6 +428,8 @@ object ActionUtils {

ActionId.SELECT_WORD_AT_CURSOR -> R.string.action_select_word_at_cursor

ActionId.SELECT_ALL_TEXT -> R.string.action_select_all_text

ActionId.PERFORM_IME_ACTION -> R.string.action_perform_ime_action

ActionId.SWITCH_KEYBOARD -> R.string.action_switch_keyboard
Expand Down Expand Up @@ -604,6 +608,7 @@ object ActionUtils {
ActionId.TEXT_COPY -> R.drawable.ic_content_copy
ActionId.TEXT_PASTE -> R.drawable.ic_content_paste
ActionId.SELECT_WORD_AT_CURSOR -> null
ActionId.SELECT_ALL_TEXT -> null
ActionId.PERFORM_IME_ACTION -> null
ActionId.SWITCH_KEYBOARD -> R.drawable.ic_outline_keyboard_24
ActionId.TOGGLE_AIRPLANE_MODE -> R.drawable.ic_outline_airplanemode_active_24
Expand Down Expand Up @@ -682,6 +687,7 @@ object ActionUtils {
ActionId.TEXT_COPY,
ActionId.TEXT_PASTE,
ActionId.SELECT_WORD_AT_CURSOR,
ActionId.SELECT_ALL_TEXT,
-> Build.VERSION_CODES.JELLY_BEAN_MR2

ActionId.PERFORM_IME_ACTION -> Build.VERSION_CODES.TIRAMISU
Expand Down Expand Up @@ -1038,6 +1044,7 @@ object ActionUtils {
ActionId.TEXT_COPY -> Icons.Rounded.ContentCopy
ActionId.TEXT_PASTE -> Icons.Rounded.ContentPaste
ActionId.SELECT_WORD_AT_CURSOR -> KeyMapperIcons.MatchWord
ActionId.SELECT_ALL_TEXT -> Icons.Outlined.SelectAll
ActionId.PERFORM_IME_ACTION -> Icons.Outlined.Keyboard
ActionId.SWITCH_KEYBOARD -> Icons.Outlined.Keyboard
ActionId.TOGGLE_AIRPLANE_MODE -> Icons.Outlined.AirplanemodeActive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,8 @@ class CreateActionDelegate(

ActionId.SELECT_WORD_AT_CURSOR -> return ActionData.SelectWordAtCursor

ActionId.SELECT_ALL_TEXT -> return ActionData.SelectAllText

ActionId.TOGGLE_AIRPLANE_MODE -> return ActionData.AirplaneMode.Toggle

ActionId.ENABLE_AIRPLANE_MODE -> return ActionData.AirplaneMode.Enable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -820,6 +820,23 @@ class PerformActionsUseCaseImpl @AssistedInject constructor(
}
}

is ActionData.SelectAllText -> {
result = service.performActionOnNode({ it.isFocused }) { node ->
val text = node.text?.toString().orEmpty()
if (text.isEmpty()) return@performActionOnNode null

val extras = mapOf(
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT to 0,
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT to text.length,
)

AccessibilityNodeAction(
AccessibilityNodeInfo.ACTION_SET_SELECTION,
extras,
)
}
}

is ActionData.AirplaneMode.Toggle -> {
result = if (airplaneModeAdapter.isEnabled()) {
airplaneModeAdapter.disable()
Expand Down
1 change: 1 addition & 0 deletions base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1098,6 +1098,7 @@
<string name="action_text_copy">Copy</string>
<string name="action_text_paste">Paste</string>
<string name="action_select_word_at_cursor">Select word at cursor</string>
<string name="action_select_all_text">Select all text</string>

<string name="action_open_settings">Open settings</string>
<string name="action_show_power_menu">Show power menu</string>
Expand Down
Loading