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

Commit 40edd14c authored by Kurt Partridge's avatar Kurt Partridge Committed by Android (Google) Code Review
Browse files

Merge "add logPoint for manual correction (inc touch pos)"

parents 9c2a96aa 9bfb6202
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -1817,7 +1817,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
    }

    @Override
    public void pickSuggestionManually(final int index, final CharSequence suggestion) {
    public void pickSuggestionManually(final int index, final CharSequence suggestion,
            int x, int y) {
        final SuggestedWords suggestedWords = mSuggestionsView.getSuggestions();

        if (SPACE_STATE_PHANTOM == mSpaceState && suggestion.length() > 0) {
@@ -1840,6 +1841,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
            if (ic != null) {
                final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index];
                ic.commitCompletion(completionInfo);
                if (ProductionFlag.IS_EXPERIMENTAL) {
                    ResearchLogger.latinIME_pickApplicationSpecifiedCompletion(index,
                            completionInfo.getText(), x, y);
                }
            }
            return;
        }
@@ -1850,6 +1855,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
            // So, LatinImeLogger logs "" as a user's input.
            LatinImeLogger.logOnManualSuggestion("", suggestion.toString(), index, suggestedWords);
            // Rely on onCodeInput to do the complicated swapping/stripping logic consistently.
            if (ProductionFlag.IS_EXPERIMENTAL) {
                ResearchLogger.latinIME_punctuationSuggestion(index, suggestion, x, y);
            }
            final int primaryCode = suggestion.charAt(0);
            onCodeInput(primaryCode,
                    KeyboardActionListener.SUGGESTION_STRIP_COORDINATE,
@@ -1858,8 +1866,12 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
        }
        // We need to log before we commit, because the word composer will store away the user
        // typed word.
        LatinImeLogger.logOnManualSuggestion(mWordComposer.getTypedWord().toString(),
        final String replacedWord = mWordComposer.getTypedWord().toString();
        LatinImeLogger.logOnManualSuggestion(replacedWord,
                suggestion.toString(), index, suggestedWords);
        if (ProductionFlag.IS_EXPERIMENTAL) {
            ResearchLogger.latinIME_pickSuggestionManually(replacedWord, index, suggestion, x, y);
        }
        mExpectingUpdateSelection = true;
        commitChosenWord(suggestion, LastComposedWord.COMMIT_TYPE_MANUAL_PICK,
                LastComposedWord.NOT_A_SEPARATOR);
+28 −0
Original line number Diff line number Diff line
@@ -375,6 +375,10 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
        private static final boolean SUDDENJUMPINGTOUCHEVENTHANDLER_ONTOUCHEVENT_ENABLED
                = DEFAULT_ENABLED;
        private static final boolean SUGGESTIONSVIEW_SETSUGGESTIONS_ENABLED = DEFAULT_ENABLED;
        private static final boolean LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED
                = DEFAULT_ENABLED;
        private static final boolean LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED = DEFAULT_ENABLED;
        private static final boolean LATINIME_PICKSUGGESTIONMANUALLY_ENABLED = DEFAULT_ENABLED;
    }

    public static void logUnstructured(String logGroup, final String details) {
@@ -633,6 +637,30 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
        }
    }

    public static void latinIME_pickApplicationSpecifiedCompletion(final int index,
            final CharSequence text, int x, int y) {
        if (UnsLogGroup.LATINIME_PICKAPPLICATIONSPECIFIEDCOMPLETION_ENABLED) {
            final String s = String.valueOf(index) + '\t' + text + '\t' + x + '\t' + y;
            logUnstructured("latinIME_pickApplicationSpecifiedCompletion", s);
        }
    }

    public static void latinIME_pickSuggestionManually(final String replacedWord,
            final int index, CharSequence suggestion, int x, int y) {
        if (UnsLogGroup.LATINIME_PICKSUGGESTIONMANUALLY_ENABLED) {
            final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y;
            logUnstructured("latinIME_pickSuggestionManually", s);
        }
    }

    public static void latinIME_punctuationSuggestion(final int index,
            final CharSequence suggestion, int x, int y) {
        if (UnsLogGroup.LATINIME_PICKPUNCTUATIONSUGGESTION_ENABLED) {
            final String s = String.valueOf(index) + '\t' + suggestion + '\t' + x + '\t' + y;
            logUnstructured("latinIME_pickPunctuationSuggestion", s);
        }
    }

    public static void latinIME_switchToKeyboardView() {
        if (UnsLogGroup.LATINIME_SWITCHTOKEYBOARDVIEW_ENABLED) {
            final String s = "Switch to keyboard view.";
+5 −3
Original line number Diff line number Diff line
@@ -72,7 +72,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
        OnLongClickListener {
    public interface Listener {
        public boolean addWordToDictionary(String word);
        public void pickSuggestionManually(int index, CharSequence word);
        public void pickSuggestionManually(int index, CharSequence word, int x, int y);
    }

    // The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
@@ -717,7 +717,9 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
        public boolean onCustomRequest(int requestCode) {
            final int index = requestCode;
            final CharSequence word = mSuggestedWords.getWord(index);
            mListener.pickSuggestionManually(index, word);
            // TODO: change caller path so coordinates are passed through here
            mListener.pickSuggestionManually(index, word, NOT_A_TOUCH_COORDINATE,
                    NOT_A_TOUCH_COORDINATE);
            dismissMoreSuggestions();
            return true;
        }
@@ -867,7 +869,7 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
            return;

        final CharSequence word = mSuggestedWords.getWord(index);
        mListener.pickSuggestionManually(index, word);
        mListener.pickSuggestionManually(index, word, mLastX, mLastY);
    }

    @Override
+10 −10
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD_TO_TYPE = "this";
        final String EXPECTED_RESULT = "this";
        type(WORD_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
        pickSuggestionManually(0, WORD_TO_TYPE);
        mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
        type(Keyboard.CODE_DELETE);
        assertEquals("press suggestion then backspace", EXPECTED_RESULT,
@@ -44,7 +44,7 @@ public class InputLogicTests extends InputTestsBase {
        type(WORD_TO_TYPE);
        // Choose the auto-correction, which is always in position 0. For "tgis", the
        // auto-correction should be "this".
        mLatinIME.pickSuggestionManually(0, WORD_TO_PICK);
        pickSuggestionManually(0, WORD_TO_PICK);
        mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
        assertEquals("pick typed word over auto-correction then backspace", WORD_TO_PICK,
                mTextView.getText().toString());
@@ -59,7 +59,7 @@ public class InputLogicTests extends InputTestsBase {
        type(WORD_TO_TYPE);
        // Choose the typed word, which should be in position 1 (because position 0 should
        // be occupied by the "this" auto-correction, as checked by testAutoCorrect())
        mLatinIME.pickSuggestionManually(1, WORD_TO_TYPE);
        pickSuggestionManually(1, WORD_TO_TYPE);
        mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
        assertEquals("pick typed word over auto-correction then backspace", WORD_TO_TYPE,
                mTextView.getText().toString());
@@ -75,7 +75,7 @@ public class InputLogicTests extends InputTestsBase {
        type(WORD_TO_TYPE);
        // Choose the second suggestion, which should be in position 2 and should be "thus"
        // when "tgis is typed.
        mLatinIME.pickSuggestionManually(2, WORD_TO_PICK);
        pickSuggestionManually(2, WORD_TO_PICK);
        mLatinIME.onUpdateSelection(0, 0, WORD_TO_TYPE.length(), WORD_TO_TYPE.length(), -1, -1);
        assertEquals("pick different suggestion then backspace", WORD_TO_PICK,
                mTextView.getText().toString());
@@ -171,7 +171,7 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD_TO_TYPE = "this";
        final String EXPECTED_RESULT = WORD_TO_TYPE;
        type(WORD_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD_TO_TYPE);
        pickSuggestionManually(0, WORD_TO_TYPE);
        assertEquals("no space after manual pick", EXPECTED_RESULT,
                mTextView.getText().toString());
    }
@@ -181,7 +181,7 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD2_TO_TYPE = "is";
        final String EXPECTED_RESULT = "this is";
        type(WORD1_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
        pickSuggestionManually(0, WORD1_TO_TYPE);
        type(WORD2_TO_TYPE);
        assertEquals("manual pick then type", EXPECTED_RESULT, mTextView.getText().toString());
    }
@@ -191,7 +191,7 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD2_TO_TYPE = "!";
        final String EXPECTED_RESULT = "this!";
        type(WORD1_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
        pickSuggestionManually(0, WORD1_TO_TYPE);
        type(WORD2_TO_TYPE);
        assertEquals("manual pick then separator", EXPECTED_RESULT, mTextView.getText().toString());
    }
@@ -201,7 +201,7 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD2_TO_TYPE = " is";
        final String EXPECTED_RESULT = "this is";
        type(WORD1_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
        pickSuggestionManually(0, WORD1_TO_TYPE);
        type(WORD2_TO_TYPE);
        assertEquals("manual pick then space then type", EXPECTED_RESULT,
                mTextView.getText().toString());
@@ -212,11 +212,11 @@ public class InputLogicTests extends InputTestsBase {
        final String WORD2_TO_PICK = "is";
        final String EXPECTED_RESULT = "this is";
        type(WORD1_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
        pickSuggestionManually(0, WORD1_TO_TYPE);
        // Here we fake picking a word through bigram prediction. This test is taking
        // advantage of the fact that Latin IME blindly trusts the caller of #pickSuggestionManually
        // to actually pass the right string.
        mLatinIME.pickSuggestionManually(1, WORD2_TO_PICK);
        pickSuggestionManually(1, WORD2_TO_PICK);
        assertEquals("manual pick then manual pick", EXPECTED_RESULT,
                mTextView.getText().toString());
    }
+3 −3
Original line number Diff line number Diff line
@@ -33,7 +33,7 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
        final String EXPECTED_RESULT = "test !";
        changeLanguage("fr");
        type(WORD1_TO_TYPE);
        mLatinIME.pickSuggestionManually(0, WORD1_TO_TYPE);
        pickSuggestionManually(0, WORD1_TO_TYPE);
        type(WORD2_TO_TYPE);
        assertEquals("manual pick then separator for French", EXPECTED_RESULT,
                mTextView.getText().toString());
@@ -49,8 +49,8 @@ public class InputLogicTestsNonEnglish extends InputTestsBase {
        runMessages();
        assertTrue("type word then type space should display punctuation strip",
                mLatinIME.isShowingPunctuationList());
        mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
        mLatinIME.pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
        pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
        pickSuggestionManually(0, PUNCTUATION_FROM_STRIP);
        assertEquals("type word then type space then punctuation from strip twice for French",
                EXPECTED_RESULT, mTextView.getText().toString());
    }
Loading