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

Commit b5d17e52 authored by satok's avatar satok
Browse files

Add logOnSeparator

This is a supplement for  I9abb8141f23100d

Change-Id: I529d2a78f4fe630611db4cba830d933370c8c34f
parent 50cce07f
Loading
Loading
Loading
Loading
+11 −12
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import com.android.inputmethod.keyboard.KeyboardSwitcher;
import com.android.inputmethod.keyboard.KeyboardView;
import com.android.inputmethod.keyboard.LatinKeyboard;
import com.android.inputmethod.keyboard.LatinKeyboardView;
import com.android.inputmethod.latin.Utils.RingCharBuffer;

import android.app.AlertDialog;
import android.content.BroadcastReceiver;
@@ -1174,10 +1173,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            if (primaryCode != Keyboard.CODE_ENTER) {
                mJustAddedAutoSpace = false;
            }
            RingCharBuffer.getInstance().push((char)primaryCode, x, y);
            LatinImeLogger.logOnInputChar();
            if (isWordSeparator(primaryCode)) {
                handleSeparator(primaryCode);
                handleSeparator(primaryCode, x, y);
            } else {
                handleCharacter(primaryCode, keyCodes, x, y);
            }
@@ -1357,10 +1354,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        }
        switcher.updateShiftState();
        if (LatinIME.PERF_DEBUG) measureCps();
        TextEntryState.typedCharacter((char) code, isWordSeparator(code));
        TextEntryState.typedCharacter((char) code, isWordSeparator(code), x, y);
    }

    private void handleSeparator(int primaryCode) {
    private void handleSeparator(int primaryCode, int x, int y) {
        mVoiceProxy.handleSeparator();

        // Should dismiss the "Touch again to save" message when handling separator
@@ -1381,7 +1378,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            // in Italian dov' should not be expanded to dove' because the elision
            // requires the last vowel to be removed.
            if (mAutoCorrectOn && primaryCode != '\'') {
                pickedDefault = pickDefaultSuggestion();
                pickedDefault = pickDefaultSuggestion(primaryCode);
                // Picked the suggestion by the space key.  We consider this
                // as "added an auto space".
                if (primaryCode == Keyboard.CODE_SPACE) {
@@ -1403,7 +1400,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            reswapPeriodAndSpace();
        }

        TextEntryState.typedCharacter((char) primaryCode, true);
        TextEntryState.typedCharacter((char) primaryCode, true, x, y);
        if (TextEntryState.isPunctuationAfterAccepted() && primaryCode != Keyboard.CODE_ENTER) {
            swapPunctuationAndSpace();
        } else if (isSuggestionsRequested() && primaryCode == Keyboard.CODE_SPACE) {
@@ -1592,14 +1589,14 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
        setCandidatesViewShown(isCandidateStripVisible());
    }

    private boolean pickDefaultSuggestion() {
    private boolean pickDefaultSuggestion(int separatorCode) {
        // Complete any pending candidate query first
        if (mHandler.hasPendingUpdateSuggestions()) {
            mHandler.cancelUpdateSuggestions();
            updateSuggestions();
        }
        if (mBestWord != null && mBestWord.length() > 0) {
            TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord);
            TextEntryState.acceptedDefault(mWord.getTypedWord(), mBestWord, separatorCode);
            mJustAccepted = true;
            pickSuggestion(mBestWord);
            // Add the word to the auto dictionary if it's not a known word
@@ -1688,7 +1685,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
            // Fool the state watcher so that a subsequent backspace will not do a revert, unless
            // we just did a correction, in which case we need to stay in
            // TextEntryState.State.PICKED_SUGGESTION state.
            TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true);
            TextEntryState.typedCharacter((char) Keyboard.CODE_SPACE, true,
                    WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
            setPunctuationSuggestions();
        } else if (!showingAddToDictionaryHint) {
            // If we're not showing the "Touch again to save", then show corrections again.
@@ -1895,7 +1893,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
                ic.commitText(mComposing, 1);
                TextEntryState.acceptedTyped(mComposing);
                ic.commitText(punctuation, 1);
                TextEntryState.typedCharacter(punctuation.charAt(0), true);
                TextEntryState.typedCharacter(punctuation.charAt(0), true,
                        WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
                // Clear composing text
                mComposing.setLength(0);
            } else {
+5 −2
Original line number Diff line number Diff line
@@ -45,10 +45,10 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
            String before, String after, int position, List<CharSequence> suggestions) {
   }

    public static void logOnAutoSuggestion(String before, String after) {
    public static void logOnAutoCorrection(String before, String after, int separatorCode) {
    }

    public static void logOnAutoSuggestionCanceled() {
    public static void logOnAutoCorrectionCancelled() {
    }

    public static void logOnDelete() {
@@ -57,6 +57,9 @@ public class LatinImeLogger implements SharedPreferences.OnSharedPreferenceChang
    public static void logOnInputChar() {
    }

    public static void logOnInputSeparator() {
    }

    public static void logOnException(String metaData, Throwable e) {
    }

+14 −4
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.inputmethod.latin;

import com.android.inputmethod.latin.Utils.RingCharBuffer;

import android.util.Log;

public class TextEntryState {
@@ -43,10 +45,12 @@ public class TextEntryState {
        sState = newState;
    }

    public static void acceptedDefault(CharSequence typedWord, CharSequence actualWord) {
    public static void acceptedDefault(CharSequence typedWord, CharSequence actualWord,
            int separatorCode) {
        if (typedWord == null) return;
        setState(ACCEPTED_DEFAULT);
        LatinImeLogger.logOnAutoSuggestion(typedWord.toString(), actualWord.toString());
        LatinImeLogger.logOnAutoCorrection(
                typedWord.toString(), actualWord.toString(), separatorCode);
        if (DEBUG)
            displayState("acceptedDefault", "typedWord", typedWord, "actualWord", actualWord);
    }
@@ -95,7 +99,7 @@ public class TextEntryState {
        if (DEBUG) displayState("onAbortRecorrection");
    }

    public static void typedCharacter(char c, boolean isSeparator) {
    public static void typedCharacter(char c, boolean isSeparator, int x, int y) {
        final boolean isSpace = (c == ' ');
        switch (sState) {
        case IN_WORD:
@@ -149,13 +153,19 @@ public class TextEntryState {
            setState(START);
            break;
        }
        RingCharBuffer.getInstance().push(c, x, y);
        if (isSeparator) {
            LatinImeLogger.logOnInputSeparator();
        } else {
            LatinImeLogger.logOnInputChar();
        }
        if (DEBUG) displayState("typedCharacter", "char", c, "isSeparator", isSeparator);
    }
    
    public static void backspace() {
        if (sState == ACCEPTED_DEFAULT) {
            setState(UNDO_COMMIT);
            LatinImeLogger.logOnAutoSuggestionCanceled();
            LatinImeLogger.logOnAutoCorrectionCancelled();
        } else if (sState == UNDO_COMMIT) {
            setState(IN_WORD);
        }
+12 −5
Original line number Diff line number Diff line
@@ -209,11 +209,11 @@ public class Utils {
                return mCharBuf[mEnd];
            }
        }
        public char getLastChar() {
            if (mLength < 1) {
        public char getBackwardNthChar(int n) {
            if (mLength <= n || n < 0) {
                return PLACEHOLDER_DELIMITER_CHAR;
            } else {
                return mCharBuf[normalize(mEnd - 1)];
                return mCharBuf[normalize(mEnd - n - 1)];
            }
        }
        public int getPreviousX(char c, int back) {
@@ -234,9 +234,16 @@ public class Utils {
                return mYBuf[index];
            }
        }
        public String getLastString() {
        public String getLastWord(int ignoreCharCount) {
            StringBuilder sb = new StringBuilder();
            for (int i = 0; i < mLength; ++i) {
            int i = ignoreCharCount;
            for (; i < mLength; ++i) {
                char c = mCharBuf[normalize(mEnd - 1 - i)];
                if (!((LatinIME)mContext).isWordSeparator(c)) {
                    break;
                }
            }
            for (; i < mLength; ++i) {
                char c = mCharBuf[normalize(mEnd - 1 - i)];
                if (!((LatinIME)mContext).isWordSeparator(c)) {
                    sb.append(c);