Skip to content

Commit c551df4

Browse files
authored
Merge pull request #30 (hopefully fix #29)
Replace keyDownUp for DEL/SEARCH
2 parents a1a1db0 + f814607 commit c551df4

5 files changed

Lines changed: 19 additions & 7 deletions

File tree

app/src/main/java/jp/deadend/noname/skk/AbbrevKeyboardView.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class AbbrevKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
8181
// repeatable
8282
Keyboard.KEYCODE_DELETE -> {
8383
if (!isCapsLocked) isShifted = false
84-
if (!mService.handleBackspace()) mService.keyDownUp(KeyEvent.KEYCODE_DEL)
84+
if (!mService.handleBackspace()) mService.pressDel()
8585
}
8686
// codes[0] 以外
8787
Keyboard.KEYCODE_CAPSLOCK -> {

app/src/main/java/jp/deadend/noname/skk/FlickJPKeyboardView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,7 @@ class FlickJPKeyboardView(context: Context, attrs: AttributeSet?) : KeyboardView
843843
override fun onLongPress(key: Keyboard.Key): Boolean {
844844
val code = key.codes[0]
845845
if (code == KEYCODE_FLICK_JP_ENTER) {
846-
mService.keyDownUp(KeyEvent.KEYCODE_SEARCH)
846+
mService.pressSearch()
847847
return true
848848
}
849849

@@ -911,7 +911,7 @@ class FlickJPKeyboardView(context: Context, attrs: AttributeSet?) : KeyboardView
911911
when (primaryCode) {
912912
// repeatable
913913
Keyboard.KEYCODE_DELETE -> if (!mService.handleBackspace()) {
914-
mService.keyDownUp(KeyEvent.KEYCODE_DEL)
914+
mService.pressDel()
915915
}
916916

917917
KEYCODE_FLICK_JP_LEFT -> if (!mArrowFlicked && !mService.handleDpad(KeyEvent.KEYCODE_DPAD_LEFT)) {

app/src/main/java/jp/deadend/noname/skk/GodanKeyboardView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ class GodanKeyboardView(context: Context, attrs: AttributeSet?) : KeyboardView(c
556556
override fun onLongPress(key: Keyboard.Key): Boolean {
557557
val code = key.codes[0]
558558
if (code == KEYCODE_GODAN_ENTER) {
559-
mService.keyDownUp(KeyEvent.KEYCODE_SEARCH)
559+
mService.pressSearch()
560560
return true
561561
}
562562

@@ -625,7 +625,7 @@ class GodanKeyboardView(context: Context, attrs: AttributeSet?) : KeyboardView(c
625625
// repeatable
626626
Keyboard.KEYCODE_DELETE -> if (!mService.handleBackspace()) {
627627
if (!isCapsLocked) isShifted = false
628-
mService.keyDownUp(KeyEvent.KEYCODE_DEL)
628+
mService.pressDel()
629629
}
630630

631631
KEYCODE_GODAN_LEFT -> if (!mArrowFlicked && !mService.handleDpad(KeyEvent.KEYCODE_DPAD_LEFT)) {

app/src/main/java/jp/deadend/noname/skk/QwertyKeyboardView.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
4646

4747
override fun onLongPress(key: Keyboard.Key): Boolean {
4848
if (key.codes[0] == KEYCODE_QWERTY_ENTER) {
49-
mService.keyDownUp(KeyEvent.KEYCODE_SEARCH)
49+
mService.pressSearch()
5050
return true
5151
}
5252

@@ -120,7 +120,7 @@ class QwertyKeyboardView : KeyboardView, KeyboardView.OnKeyboardActionListener {
120120
// repeatable
121121
Keyboard.KEYCODE_DELETE -> {
122122
if (!isCapsLocked) isShifted = false
123-
if (!mService.handleBackspace()) mService.keyDownUp(KeyEvent.KEYCODE_DEL)
123+
if (!mService.handleBackspace()) mService.pressDel()
124124
}
125125
// codes[0] 以外
126126
Keyboard.KEYCODE_CAPSLOCK -> {

app/src/main/java/jp/deadend/noname/skk/SKKService.kt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,6 +1096,18 @@ class SKKService : InputMethodService() {
10961096
updateSuggestionsASCII()
10971097
}
10981098

1099+
fun pressDel() {
1100+
val ic = currentInputConnection ?: return
1101+
ic.deleteSurroundingText(1, 0)
1102+
updateSuggestionsASCII()
1103+
}
1104+
1105+
fun pressSearch() {
1106+
val ic = currentInputConnection ?: return
1107+
ic.performEditorAction(EditorInfo.IME_ACTION_SEARCH)
1108+
updateSuggestionsASCII()
1109+
}
1110+
10991111
fun pressEnter() {
11001112
val ic = currentInputConnection ?: return
11011113
val editorInfo = currentInputEditorInfo

0 commit comments

Comments
 (0)