Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -833,6 +833,11 @@ sealed class ActionData : Comparable<ActionData> {
override val id = ActionId.SHOW_KEYBOARD_PICKER
}

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

@Serializable
data object CopyText : ActionData() {
override val id = ActionId.TEXT_COPY
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,7 @@ object ActionDataEntityMapper {
ActionId.SHOW_KEYBOARD -> ActionData.ShowKeyboard
ActionId.HIDE_KEYBOARD -> ActionData.HideKeyboard
ActionId.SHOW_KEYBOARD_PICKER -> ActionData.ShowKeyboardPicker
ActionId.PERFORM_IME_ACTION -> ActionData.PerformImeAction
ActionId.TEXT_CUT -> ActionData.CutText
ActionId.TEXT_COPY -> ActionData.CopyText
ActionId.TEXT_PASTE -> ActionData.PasteText
Expand Down Expand Up @@ -1322,6 +1323,7 @@ object ActionDataEntityMapper {
ActionId.SHOW_KEYBOARD to "show_keyboard",
ActionId.HIDE_KEYBOARD to "hide_keyboard",
ActionId.SHOW_KEYBOARD_PICKER to "show_keyboard_picker",
ActionId.PERFORM_IME_ACTION to "perform_ime_action",
ActionId.TEXT_CUT to "text_cut",
ActionId.TEXT_COPY to "text_copy",
ActionId.TEXT_PASTE to "text_paste",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ enum class ActionId {
SHOW_KEYBOARD,
HIDE_KEYBOARD,
SHOW_KEYBOARD_PICKER,
PERFORM_IME_ACTION,

SWITCH_KEYBOARD,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ class ActionUiHelper(
ActionData.SelectWordAtCursor -> getString(R.string.action_select_word_at_cursor)
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)
ActionData.ShowPowerMenu -> getString(R.string.action_show_power_menu)

ActionData.StatusBar.Collapse -> getString(R.string.action_collapse_status_bar)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,7 @@ object ActionUtils {
ActionId.HIDE_KEYBOARD -> ActionCategory.KEYBOARD
ActionId.SHOW_KEYBOARD_PICKER -> ActionCategory.KEYBOARD
ActionId.SELECT_WORD_AT_CURSOR -> ActionCategory.KEYBOARD
ActionId.PERFORM_IME_ACTION -> ActionCategory.KEYBOARD
ActionId.SWITCH_KEYBOARD -> ActionCategory.KEYBOARD
ActionId.LOCK_DEVICE -> ActionCategory.INTERFACE
ActionId.POWER_ON_OFF_DEVICE -> ActionCategory.INTERFACE
Expand Down Expand Up @@ -424,6 +425,8 @@ object ActionUtils {

ActionId.SELECT_WORD_AT_CURSOR -> R.string.action_select_word_at_cursor

ActionId.PERFORM_IME_ACTION -> R.string.action_perform_ime_action

ActionId.SWITCH_KEYBOARD -> R.string.action_switch_keyboard

ActionId.TOGGLE_AIRPLANE_MODE -> R.string.action_toggle_airplane_mode
Expand Down Expand Up @@ -599,6 +602,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.PERFORM_IME_ACTION -> null
ActionId.SWITCH_KEYBOARD -> R.drawable.ic_outline_keyboard_24
ActionId.TOGGLE_AIRPLANE_MODE -> R.drawable.ic_outline_airplanemode_active_24
ActionId.ENABLE_AIRPLANE_MODE -> R.drawable.ic_outline_airplanemode_active_24
Expand Down Expand Up @@ -677,6 +681,8 @@ object ActionUtils {
ActionId.SELECT_WORD_AT_CURSOR,
-> Build.VERSION_CODES.JELLY_BEAN_MR2

ActionId.PERFORM_IME_ACTION -> Build.VERSION_CODES.TIRAMISU

ActionId.SHOW_POWER_MENU -> Build.VERSION_CODES.LOLLIPOP

ActionId.DEVICE_CONTROLS -> Build.VERSION_CODES.S
Expand Down Expand Up @@ -1029,6 +1035,7 @@ object ActionUtils {
ActionId.TEXT_COPY -> Icons.Rounded.ContentCopy
ActionId.TEXT_PASTE -> Icons.Rounded.ContentPaste
ActionId.SELECT_WORD_AT_CURSOR -> KeyMapperIcons.MatchWord
ActionId.PERFORM_IME_ACTION -> Icons.Outlined.Keyboard
ActionId.SWITCH_KEYBOARD -> Icons.Outlined.Keyboard
ActionId.TOGGLE_AIRPLANE_MODE -> Icons.Outlined.AirplanemodeActive
ActionId.ENABLE_AIRPLANE_MODE -> Icons.Outlined.AirplanemodeActive
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1066,6 +1066,8 @@ class CreateActionDelegate(

ActionId.SHOW_KEYBOARD_PICKER -> return ActionData.ShowKeyboardPicker

ActionId.PERFORM_IME_ACTION -> return ActionData.PerformImeAction

ActionId.TEXT_CUT -> return ActionData.CutText

ActionId.TEXT_COPY -> return ActionData.CopyText
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -764,6 +764,15 @@ class PerformActionsUseCaseImpl @AssistedInject constructor(
result = inputMethodAdapter.showImePicker(fromForeground = false)
}

is ActionData.PerformImeAction -> {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
service.performImeAction()
result = Success(Unit)
} else {
result = SdkVersionTooLow(minSdk = Build.VERSION_CODES.TIRAMISU)
}
}

is ActionData.CutText -> {
result = service.performActionOnNode({ it.isFocused }) {
AccessibilityNodeAction(AccessibilityNodeInfo.ACTION_CUT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -569,4 +569,8 @@ abstract class BaseAccessibilityService :
null,
)
}

override fun performImeAction() {
inputMethod?.currentInputConnection?.performEditorAction(EditorInfo.IME_ACTION_UNSPECIFIED)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,7 @@ interface IAccessibilityService : SwitchImeInterface {

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
fun injectText(text: String)

@RequiresApi(Build.VERSION_CODES.TIRAMISU)
fun performImeAction()
}
2 changes: 2 additions & 0 deletions base/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1074,6 +1074,8 @@

<string name="action_show_keyboard_picker">Show keyboard picker</string>

<string name="action_perform_ime_action">Perform IME action</string>

<string name="action_switch_keyboard">Switch keyboard</string>
<string name="action_switch_keyboard_formatted">Switch to %s</string>

Expand Down
Loading