@@ -463,8 +463,6 @@ public void onLongPress(Keyboard.Key popupKey) {
463
463
} else if (popupKey .codes [0 ] == CustomKeyboard .KEYCODE_SHIFT ) {
464
464
mIsLongPress = !mIsCapsLock ;
465
465
466
- } else if (popupKey .codes [0 ] == Keyboard .KEYCODE_DELETE ) {
467
- handleBackspace (true );
468
466
}
469
467
}
470
468
@@ -489,7 +487,7 @@ public void onKey(int primaryCode, int[] keyCodes, boolean hasPopup) {
489
487
handleShift (!mKeyboardView .isShifted ());
490
488
break ;
491
489
case Keyboard .KEYCODE_DELETE :
492
- handleBackspace (false );
490
+ handleBackspace ();
493
491
break ;
494
492
case Keyboard .KEYCODE_DONE :
495
493
handleDone ();
@@ -645,7 +643,7 @@ private void handleShift(boolean isShifted) {
645
643
mKeyboardView .setShifted (shifted || mIsCapsLock );
646
644
}
647
645
648
- private void handleBackspace (final boolean isLongPress ) {
646
+ private void handleBackspace () {
649
647
final InputConnection connection = mInputConnection ;
650
648
if (mComposingText .length () > 0 ) {
651
649
CharSequence selectedText = mInputConnection .getSelectedText (0 );
@@ -668,25 +666,18 @@ private void handleBackspace(final boolean isLongPress) {
668
666
return ;
669
667
}
670
668
671
- if (isLongPress ) {
672
- CharSequence currentText = connection .getExtractedText (new ExtractedTextRequest (), 0 ).text ;
673
- CharSequence beforeCursorText = connection .getTextBeforeCursor (currentText .length (), 0 );
674
- CharSequence afterCursorText = connection .getTextAfterCursor (currentText .length (), 0 );
675
- connection .deleteSurroundingText (beforeCursorText .length (), afterCursorText .length ());
676
- } else {
677
- if (mCurrentKeyboard .usesTextOverride ()) {
678
- String beforeText = getTextBeforeCursor (connection );
679
- String newBeforeText = mCurrentKeyboard .overrideBackspace (beforeText );
680
- if (newBeforeText != null ) {
681
- // Replace whole before text
682
- connection .deleteSurroundingText (beforeText .length (), 0 );
683
- connection .commitText (newBeforeText , 1 );
684
- return ;
685
- }
669
+ if (mCurrentKeyboard .usesTextOverride ()) {
670
+ String beforeText = getTextBeforeCursor (connection );
671
+ String newBeforeText = mCurrentKeyboard .overrideBackspace (beforeText );
672
+ if (newBeforeText != null ) {
673
+ // Replace whole before text
674
+ connection .deleteSurroundingText (beforeText .length (), 0 );
675
+ connection .commitText (newBeforeText , 1 );
676
+ return ;
686
677
}
687
- // Remove the character before the cursor.
688
- connection .deleteSurroundingText (1 , 0 );
689
678
}
679
+ // Remove the character before the cursor.
680
+ connection .deleteSurroundingText (1 , 0 );
690
681
});
691
682
}
692
683
@@ -1030,7 +1021,7 @@ public boolean dispatchKeyEvent(final KeyEvent event) {
1030
1021
1031
1022
switch (keyCode ) {
1032
1023
case KeyEvent .KEYCODE_DEL :
1033
- handleBackspace (event . isLongPress () );
1024
+ handleBackspace ();
1034
1025
return true ;
1035
1026
case KeyEvent .KEYCODE_ENTER :
1036
1027
case KeyEvent .KEYCODE_NUMPAD_ENTER :
0 commit comments