aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java8
-rw-r--r--java/src/com/android/inputmethod/latin/PunctuationSuggestions.java4
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java24
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java5
-rw-r--r--native/jni/src/utils/char_utils.cpp7
-rw-r--r--tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java24
-rw-r--r--tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java12
7 files changed, 48 insertions, 36 deletions
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 719656b07..2be84591a 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1171,9 +1171,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
SuggestedWords.getFromApplicationSpecifiedCompletions(
applicationSpecifiedCompletions);
final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords,
- null /* rawSuggestions */, false /* typedWordValid */, false /* willAutoCorrect */,
+ null /* rawSuggestions */,
+ null /* typedWord */,
+ false /* typedWordValid */,
+ false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */);
+ SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
// When in fullscreen mode, show completions generated by the application forcibly
setSuggestedWords(suggestedWords);
}
diff --git a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
index a65304cd0..555bbc7d4 100644
--- a/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/PunctuationSuggestions.java
@@ -33,10 +33,12 @@ public final class PunctuationSuggestions extends SuggestedWords {
private PunctuationSuggestions(final ArrayList<SuggestedWordInfo> punctuationsList) {
super(punctuationsList,
null /* rawSuggestions */,
+ null /* typedWord */,
false /* typedWordValid */,
false /* hasAutoCorrectionCandidate */,
false /* isObsoleteSuggestions */,
- INPUT_STYLE_NONE /* inputStyle */);
+ INPUT_STYLE_NONE /* inputStyle */,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
}
/**
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index bddeac495..02b2d56e7 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -50,8 +50,9 @@ public class SuggestedWords {
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST = new ArrayList<>(0);
@Nonnull
private static final SuggestedWords EMPTY = new SuggestedWords(
- EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, false /* typedWordValid */,
- false /* willAutoCorrect */, false /* isObsoleteSuggestions */, INPUT_STYLE_NONE);
+ EMPTY_WORD_INFO_LIST, null /* rawSuggestions */, null /* typedWord */,
+ false /* typedWordValid */, false /* willAutoCorrect */,
+ false /* isObsoleteSuggestions */, INPUT_STYLE_NONE, NOT_A_SEQUENCE_NUMBER);
public final String mTypedWord;
public final boolean mTypedWordValid;
@@ -69,19 +70,6 @@ public class SuggestedWords {
public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
final ArrayList<SuggestedWordInfo> rawSuggestions,
- final boolean typedWordValid,
- final boolean willAutoCorrect,
- final boolean isObsoleteSuggestions,
- final int inputStyle) {
- this(suggestedWordInfoList, rawSuggestions,
- (suggestedWordInfoList.isEmpty() || isPrediction(inputStyle)) ? null
- : suggestedWordInfoList.get(INDEX_OF_TYPED_WORD).mWord,
- typedWordValid, willAutoCorrect,
- isObsoleteSuggestions, inputStyle, NOT_A_SEQUENCE_NUMBER);
- }
-
- public SuggestedWords(final ArrayList<SuggestedWordInfo> suggestedWordInfoList,
- final ArrayList<SuggestedWordInfo> rawSuggestions,
final String typedWord,
final boolean typedWordValid,
final boolean willAutoCorrect,
@@ -423,8 +411,10 @@ public class SuggestedWords {
info.mSourceDict, SuggestedWordInfo.NOT_AN_INDEX,
SuggestedWordInfo.NOT_A_CONFIDENCE));
}
- return new SuggestedWords(newSuggestions, null /* rawSuggestions */, mTypedWordValid,
- mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH);
+ return new SuggestedWords(newSuggestions, null /* rawSuggestions */,
+ newSuggestions.isEmpty() ? null : newSuggestions.get(0).mWord /* typedWord */,
+ mTypedWordValid, mWillAutoCorrect, mIsObsoleteSuggestions, INPUT_STYLE_TAIL_BATCH,
+ NOT_A_SEQUENCE_NUMBER);
}
/**
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index c034055ab..e6d69a92f 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -1884,8 +1884,9 @@ public final class InputLogic {
final ArrayList<SuggestedWords.SuggestedWordInfo> typedWordAndPreviousSuggestions =
SuggestedWords.getTypedWordAndPreviousSuggestions(typedWord, oldSuggestedWords);
return new SuggestedWords(typedWordAndPreviousSuggestions, null /* rawSuggestions */,
- false /* typedWordValid */, false /* hasAutoCorrectionCandidate */,
- true /* isObsoleteSuggestions */, oldSuggestedWords.mInputStyle);
+ typedWord, false /* typedWordValid */, false /* hasAutoCorrectionCandidate */,
+ true /* isObsoleteSuggestions */, oldSuggestedWords.mInputStyle,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
}
/**
diff --git a/native/jni/src/utils/char_utils.cpp b/native/jni/src/utils/char_utils.cpp
index 3bb9055b2..a43e6dd62 100644
--- a/native/jni/src/utils/char_utils.cpp
+++ b/native/jni/src/utils/char_utils.cpp
@@ -1117,7 +1117,9 @@ static int compare_pair_capital(const void *a, const void *b) {
// TODO: Check if it's really acceptable to consider ΓΈ a diacritical variant of o
/* U+0100 */ 0x0041, 0x0061, 0x0041, 0x0061, 0x0041, 0x0061, 0x0043, 0x0063,
/* U+0108 */ 0x0043, 0x0063, 0x0043, 0x0063, 0x0043, 0x0063, 0x0044, 0x0064,
- /* U+0110 */ 0x0110, 0x0111, 0x0045, 0x0065, 0x0045, 0x0065, 0x0045, 0x0065,
+ /* U+0110 */ 0x0046, 0x0064, 0x0045, 0x0065, 0x0045, 0x0065, 0x0045, 0x0065,
+ // U+0110: Manually changed from 0110 to 0046
+ // U+0111: Manually changed from 0111 to 0064
/* U+0118 */ 0x0045, 0x0065, 0x0045, 0x0065, 0x0047, 0x0067, 0x0047, 0x0067,
/* U+0120 */ 0x0047, 0x0067, 0x0047, 0x0067, 0x0048, 0x0068, 0x0126, 0x0127,
/* U+0128 */ 0x0049, 0x0069, 0x0049, 0x0069, 0x0049, 0x0069, 0x0049, 0x0069,
@@ -1135,6 +1137,9 @@ static int compare_pair_capital(const void *a, const void *b) {
/* U+0170 */ 0x0055, 0x0075, 0x0055, 0x0075, 0x0057, 0x0077, 0x0059, 0x0079,
/* U+0178 */ 0x0059, 0x005A, 0x007A, 0x005A, 0x007A, 0x005A, 0x007A, 0x0073,
/* U+0180 */ 0x0180, 0x0181, 0x0182, 0x0183, 0x0184, 0x0185, 0x0186, 0x0187,
+ // TODO: A lot of letters are their own base code points, but for
+ // some (e.g. U+0180) it doesn't seem right. Ideally each code point should
+ // be checked individually with all languages it's used in.
/* U+0188 */ 0x0188, 0x0189, 0x018A, 0x018B, 0x018C, 0x018D, 0x018E, 0x018F,
/* U+0190 */ 0x0190, 0x0191, 0x0192, 0x0193, 0x0194, 0x0195, 0x0196, 0x0197,
/* U+0198 */ 0x0198, 0x0199, 0x019A, 0x019B, 0x019C, 0x019D, 0x019E, 0x019F,
diff --git a/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java b/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
index 1c320db1c..7bbf965f9 100644
--- a/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
+++ b/tests/src/com/android/inputmethod/compat/SuggestionSpanUtilsTest.java
@@ -102,11 +102,11 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
}
public void testGetTextWithSuggestionSpan() {
- final SuggestedWordInfo predicition1 =
+ final SuggestedWordInfo prediction1 =
createWordInfo("Quality", SuggestedWordInfo.KIND_PREDICTION);
- final SuggestedWordInfo predicition2 =
+ final SuggestedWordInfo prediction2 =
createWordInfo("Speed", SuggestedWordInfo.KIND_PREDICTION);
- final SuggestedWordInfo predicition3 =
+ final SuggestedWordInfo prediction3 =
createWordInfo("Price", SuggestedWordInfo.KIND_PREDICTION);
final SuggestedWordInfo typed =
@@ -122,13 +122,15 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
// is specified.
{
final SuggestedWords predictedWords = new SuggestedWords(
- new ArrayList<>(Arrays.asList(predicition1, predicition2, predicition3)),
+ new ArrayList<>(Arrays.asList(prediction1, prediction2, prediction3)),
null /* rawSuggestions */,
+ null /* typedWord */,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_PREDICTION);
- final String PICKED_WORD = predicition2.mWord;
+ SuggestedWords.INPUT_STYLE_PREDICTION,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
+ final String PICKED_WORD = prediction2.mWord;
assertNotSuggestionSpan(
PICKED_WORD,
SuggestionSpanUtils.getTextWithSuggestionSpan(getContext(), PICKED_WORD,
@@ -137,17 +139,19 @@ public class SuggestionSpanUtilsTest extends AndroidTestCase {
final ArrayList<SuggestedWordInfo> suggestedWordList = new ArrayList<>();
suggestedWordList.add(typed);
- suggestedWordList.add(predicition1);
- suggestedWordList.add(predicition2);
- suggestedWordList.add(predicition3);
+ suggestedWordList.add(prediction1);
+ suggestedWordList.add(prediction2);
+ suggestedWordList.add(prediction3);
suggestedWordList.addAll(Arrays.asList(corrections));
final SuggestedWords typedAndCollectedWords = new SuggestedWords(
suggestedWordList,
null /* rawSuggestions */,
+ null /* typedWord */,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_TYPING);
+ SuggestedWords.INPUT_STYLE_TYPING,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
for (final SuggestedWordInfo pickedWord : suggestedWordList) {
final String PICKED_WORD = pickedWord.mWord;
diff --git a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
index 90db75e39..7a7edf031 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestedWordsTests.java
@@ -99,10 +99,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
// Make sure getTypedWordInfoOrNull() returns non-null object.
final SuggestedWords wordsWithTypedWord = new SuggestedWords(
list, null /* rawSuggestions */,
+ TYPED_WORD,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_NONE);
+ SuggestedWords.INPUT_STYLE_NONE,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
final SuggestedWordInfo typedWord = wordsWithTypedWord.getTypedWordInfoOrNull();
assertNotNull(typedWord);
assertEquals(TYPED_WORD, typedWord.mWord);
@@ -111,10 +113,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
list.remove(0);
final SuggestedWords wordsWithoutTypedWord = new SuggestedWords(
list, null /* rawSuggestions */,
+ null /* typedWord */,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_NONE);
+ SuggestedWords.INPUT_STYLE_NONE,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
assertNull(wordsWithoutTypedWord.getTypedWordInfoOrNull());
// Make sure getTypedWordInfoOrNull() returns null.
@@ -122,10 +126,12 @@ public class SuggestedWordsTests extends AndroidTestCase {
final SuggestedWords emptySuggestedWords = new SuggestedWords(
new ArrayList<SuggestedWordInfo>(), null /* rawSuggestions */,
+ null /* typedWord */,
false /* typedWordValid */,
false /* willAutoCorrect */,
false /* isObsoleteSuggestions */,
- SuggestedWords.INPUT_STYLE_NONE);
+ SuggestedWords.INPUT_STYLE_NONE,
+ SuggestedWords.NOT_A_SEQUENCE_NUMBER);
assertNull(emptySuggestedWords.getTypedWordInfoOrNull());
assertNull(SuggestedWords.getEmptyInstance().getTypedWordInfoOrNull());