Skip to content

Commit 9a3e71a

Browse files
author
if-can
committed
fix: edit action interceptor not working
1 parent 7e635f7 commit 9a3e71a

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed

app/src/main/java/com/osfans/trime/ime/core/TrimeInputMethodService.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -849,7 +849,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
849849
etr.token = 0
850850
val et = ic.getExtractedText(etr, 0)
851851
if (et != null) {
852-
if (et.selectionEnd - et.selectionStart > 0) return ic.performContextMenuAction(android.R.id.cut)
852+
if (et.selectionStart != et.selectionEnd) return ic.performContextMenuAction(android.R.id.cut)
853853
}
854854
}
855855
Timber.w("hookKeyboard cut fail")
@@ -863,7 +863,7 @@ open class TrimeInputMethodService : LifecycleInputMethodService() {
863863
etr.token = 0
864864
val et = ic.getExtractedText(etr, 0)
865865
if (et != null) {
866-
if (et.selectionEnd - et.selectionStart > 0) return ic.performContextMenuAction(android.R.id.copy)
866+
if (et.selectionStart != et.selectionEnd) return ic.performContextMenuAction(android.R.id.copy)
867867
}
868868
}
869869
Timber.w("hookKeyboard copy fail")

app/src/main/java/com/osfans/trime/ime/keyboard/CommonKeyboardActionListener.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -291,15 +291,15 @@ class CommonKeyboardActionListener(
291291
?: Rime.getRimeKeycodeByName(Keycode.keyNameOf(keyEventCode))
292292
val modifiers = KeyModifiers.fromMetaState(metaState).modifiers
293293
service.postRimeJob {
294+
if (service.hookKeyboard(keyEventCode, metaState)) {
295+
Timber.d("handleKey: hook")
296+
return@postRimeJob
297+
}
294298
if (processKey(value, modifiers)) {
295299
shouldReleaseKey = true
296300
Timber.d("handleKey: processKey")
297301
return@postRimeJob
298302
}
299-
if (service.hookKeyboard(keyEventCode, metaState)) {
300-
Timber.d("handleKey: hook")
301-
return@postRimeJob
302-
}
303303
if (AppUtils.launchKeyCategory(service, keyEventCode)) {
304304
Timber.d("handleKey: openCategory")
305305
return@postRimeJob

0 commit comments

Comments
 (0)