Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e255d5c0 authored by Ken Wakasa's avatar Ken Wakasa Committed by Android (Google) Code Review
Browse files

Merge "handleBackspace should always send KEYCODE_DEL for InputType.TYPE_NULL"...

Merge "handleBackspace should always send KEYCODE_DEL for InputType.TYPE_NULL" into jb-ub-latinimegoogle-bayo
parents db4f3730 87cd3912
Loading
Loading
Loading
Loading
+20 −29
Original line number Diff line number Diff line
@@ -2163,26 +2163,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
                // later (typically, in a subsequent press on backspace).
                mLastSelectionEnd = mLastSelectionStart;
                mConnection.deleteSurroundingText(numCharsDeleted, 0);
                if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
                    ResearchLogger.latinIME_handleBackspace(numCharsDeleted,
                            false /* shouldUncommitLogUnit */);
                }
            } else {
                // There is no selection, just delete one character.
                if (NOT_A_CURSOR_POSITION == mLastSelectionEnd) {
                    // This should never happen.
                    Log.e(TAG, "Backspace when we don't know the selection position");
                }
                final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
                if (codePointBeforeCursor == Constants.NOT_A_CODE) {
                    // Nothing to delete before the cursor. We have to revert the deletion states
                    // that were updated at the beginning of this method.
                    mDeleteCount--;
                    mExpectingUpdateSelection = false;
                    return;
                }
                final int lengthToDelete =
                        Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
                if (mAppWorkAroundsUtils.isBeforeJellyBean() ||
                        currentSettings.mInputAttributes.isTypeNull()) {
                    // There are two possible reasons to send a key event: either the field has
@@ -2193,13 +2179,21 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
                    // applications are relying on this behavior so we continue to support it for
                    // older apps, so we retain this behavior if the app has target SDK < JellyBean.
                    sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
                } else {
                    mConnection.deleteSurroundingText(lengthToDelete, 0);
                    if (mDeleteCount > DELETE_ACCELERATE_AT) {
                        sendDownUpKeyEvent(KeyEvent.KEYCODE_DEL);
                    }
                if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
                    ResearchLogger.latinIME_handleBackspace(lengthToDelete,
                            true /* shouldUncommitLogUnit */);
                } else {
                    final int codePointBeforeCursor = mConnection.getCodePointBeforeCursor();
                    if (codePointBeforeCursor == Constants.NOT_A_CODE) {
                        // Nothing to delete before the cursor. We have to revert the deletion
                        // states that were updated at the beginning of this method.
                        mDeleteCount--;
                        mExpectingUpdateSelection = false;
                        return;
                    }
                    final int lengthToDelete =
                            Character.isSupplementaryCodePoint(codePointBeforeCursor) ? 2 : 1;
                    mConnection.deleteSurroundingText(lengthToDelete, 0);
                    if (mDeleteCount > DELETE_ACCELERATE_AT) {
                        final int codePointBeforeCursorToDeleteAgain =
                                mConnection.getCodePointBeforeCursor();
@@ -2207,9 +2201,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
                            final int lengthToDeleteAgain = Character.isSupplementaryCodePoint(
                                   codePointBeforeCursorToDeleteAgain) ? 2 : 1;
                            mConnection.deleteSurroundingText(lengthToDeleteAgain, 0);
                        if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {
                            ResearchLogger.latinIME_handleBackspace(lengthToDeleteAgain,
                                    true /* shouldUncommitLogUnit */);
                        }
                    }
                }