aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/latin/Suggest.java6
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestedWords.java3
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java21
-rw-r--r--java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java5
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java10
-rw-r--r--java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java5
-rw-r--r--java/src/com/android/inputmethod/latin/utils/StringUtils.java7
7 files changed, 20 insertions, 37 deletions
diff --git a/java/src/com/android/inputmethod/latin/Suggest.java b/java/src/com/android/inputmethod/latin/Suggest.java
index fc85c1388..439c8562e 100644
--- a/java/src/com/android/inputmethod/latin/Suggest.java
+++ b/java/src/com/android/inputmethod/latin/Suggest.java
@@ -50,8 +50,6 @@ public final class Suggest {
// Close to -2**31
private static final int SUPPRESS_SUGGEST_THRESHOLD = -2000000000;
- public static final int MAX_SUGGESTIONS = 18;
-
private static final boolean DBG = LatinImeLogger.sDBG;
public final DictionaryFacilitatorForSuggest mDictionaryFacilitator;
@@ -109,7 +107,7 @@ public final class Suggest {
final OnGetSuggestedWordsCallback callback) {
final int trailingSingleQuotesCount = wordComposer.trailingSingleQuotesCount();
final BoundedTreeSet suggestionsSet = new BoundedTreeSet(sSuggestedWordInfoComparator,
- MAX_SUGGESTIONS);
+ SuggestedWords.MAX_SUGGESTIONS);
final String typedWord = wordComposer.getTypedWord();
final String consideredWord = trailingSingleQuotesCount > 0
@@ -226,7 +224,7 @@ public final class Suggest {
final int sessionId, final int sequenceNumber,
final OnGetSuggestedWordsCallback callback) {
final BoundedTreeSet suggestionsSet = new BoundedTreeSet(sSuggestedWordInfoComparator,
- MAX_SUGGESTIONS);
+ SuggestedWords.MAX_SUGGESTIONS);
mDictionaryFacilitator.getSuggestions(wordComposer, prevWordForBigram, proximityInfo,
blockOffensiveWords, additionalFeaturesOptions, sessionId, suggestionsSet);
for (SuggestedWordInfo wordInfo : suggestionsSet) {
diff --git a/java/src/com/android/inputmethod/latin/SuggestedWords.java b/java/src/com/android/inputmethod/latin/SuggestedWords.java
index f9de89c80..bb34b7ba9 100644
--- a/java/src/com/android/inputmethod/latin/SuggestedWords.java
+++ b/java/src/com/android/inputmethod/latin/SuggestedWords.java
@@ -31,6 +31,9 @@ public final class SuggestedWords {
public static final int INDEX_OF_AUTO_CORRECTION = 1;
public static final int NOT_A_SEQUENCE_NUMBER = -1;
+ // The maximum number of suggestions available.
+ public static final int MAX_SUGGESTIONS = 18;
+
private static final ArrayList<SuggestedWordInfo> EMPTY_WORD_INFO_LIST =
CollectionUtils.newArrayList(0);
public static final SuggestedWords EMPTY = new SuggestedWords(
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 6cd84016e..125976932 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -16,9 +16,6 @@
package com.android.inputmethod.latin;
-import com.android.inputmethod.annotations.UsedForTesting;
-import com.android.inputmethod.keyboard.Key;
-import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.utils.CoordinateUtils;
import com.android.inputmethod.latin.utils.StringUtils;
@@ -276,24 +273,6 @@ public final class WordComposer {
}
/**
- * Add a dummy key by retrieving reasonable coordinates
- */
- // TODO: make this private or remove it entirely. Right now it's used in the tests
- @UsedForTesting
- public void addKeyInfo(final int codePoint, final Keyboard keyboard) {
- final int x, y;
- final Key key;
- if (keyboard != null && (key = keyboard.getKey(codePoint)) != null) {
- x = key.getX() + key.getWidth() / 2;
- y = key.getY() + key.getHeight() / 2;
- } else {
- x = Constants.NOT_A_COORDINATE;
- y = Constants.NOT_A_COORDINATE;
- }
- add(codePoint, x, y);
- }
-
- /**
* Set the currently composing word to the one passed as an argument.
* This will register NOT_A_COORDINATE for X and Ys, and use the passed keyboard for proximity.
* @param codePoints the code points to set as the composing word.
diff --git a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
index f2687e58e..6e9bdc34a 100644
--- a/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
+++ b/java/src/com/android/inputmethod/latin/inputlogic/InputLogic.java
@@ -46,7 +46,6 @@ import com.android.inputmethod.latin.define.ProductionFlag;
import com.android.inputmethod.latin.settings.Settings;
import com.android.inputmethod.latin.settings.SettingsValues;
import com.android.inputmethod.latin.settings.SpacingAndPunctuations;
-import com.android.inputmethod.latin.suggestions.SuggestionStripView;
import com.android.inputmethod.latin.utils.AsyncResultHolder;
import com.android.inputmethod.latin.utils.CollectionUtils;
import com.android.inputmethod.latin.utils.InputTypeUtils;
@@ -1064,7 +1063,7 @@ public final class InputLogic {
final String typedWord = range.mWord.toString();
if (includeResumedWordInSuggestions) {
suggestions.add(new SuggestedWordInfo(typedWord,
- SuggestionStripView.MAX_SUGGESTIONS + 1,
+ SuggestedWords.MAX_SUGGESTIONS + 1,
SuggestedWordInfo.KIND_TYPED, Dictionary.DICTIONARY_USER_TYPED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE /* autoCommitFirstWordConfidence */));
@@ -1076,7 +1075,7 @@ public final class InputLogic {
++i;
if (!TextUtils.equals(s, typedWord)) {
suggestions.add(new SuggestedWordInfo(s,
- SuggestionStripView.MAX_SUGGESTIONS - i,
+ SuggestedWords.MAX_SUGGESTIONS - i,
SuggestedWordInfo.KIND_RESUMED, Dictionary.DICTIONARY_RESUMED,
SuggestedWordInfo.NOT_AN_INDEX /* indexOfTouchPointOfSecondWord */,
SuggestedWordInfo.NOT_A_CONFIDENCE
diff --git a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
index 52012c846..b96175f02 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/MoreSuggestions.java
@@ -47,10 +47,10 @@ public final class MoreSuggestions extends Keyboard {
}
private static final class MoreSuggestionsParam extends KeyboardParams {
- private final int[] mWidths = new int[SuggestionStripView.MAX_SUGGESTIONS];
- private final int[] mRowNumbers = new int[SuggestionStripView.MAX_SUGGESTIONS];
- private final int[] mColumnOrders = new int[SuggestionStripView.MAX_SUGGESTIONS];
- private final int[] mNumColumnsInRow = new int[SuggestionStripView.MAX_SUGGESTIONS];
+ private final int[] mWidths = new int[SuggestedWords.MAX_SUGGESTIONS];
+ private final int[] mRowNumbers = new int[SuggestedWords.MAX_SUGGESTIONS];
+ private final int[] mColumnOrders = new int[SuggestedWords.MAX_SUGGESTIONS];
+ private final int[] mNumColumnsInRow = new int[SuggestedWords.MAX_SUGGESTIONS];
private static final int MAX_COLUMNS_IN_ROW = 3;
private int mNumRows;
public Drawable mDivider;
@@ -72,7 +72,7 @@ public final class MoreSuggestions extends Keyboard {
int row = 0;
int index = fromIndex;
int rowStartIndex = fromIndex;
- final int size = Math.min(suggestedWords.size(), SuggestionStripView.MAX_SUGGESTIONS);
+ final int size = Math.min(suggestedWords.size(), SuggestedWords.MAX_SUGGESTIONS);
while (index < size) {
final String word = suggestedWords.getWord(index);
// TODO: Should take care of text x-scaling.
diff --git a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
index 073148a50..88b57f93b 100644
--- a/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
+++ b/java/src/com/android/inputmethod/latin/suggestions/SuggestionStripView.java
@@ -53,9 +53,6 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
public void pickSuggestionManually(int index, SuggestedWordInfo word);
}
- // The maximum number of suggestions available. See {@link Suggest#mPrefMaxSuggestions}.
- public static final int MAX_SUGGESTIONS = 18;
-
static final boolean DBG = LatinImeLogger.sDBG;
private final ViewGroup mSuggestionsStrip;
@@ -91,7 +88,7 @@ public final class SuggestionStripView extends RelativeLayout implements OnClick
inflater.inflate(R.layout.suggestions_strip, this);
mSuggestionsStrip = (ViewGroup)findViewById(R.id.suggestions_strip);
- for (int pos = 0; pos < MAX_SUGGESTIONS; pos++) {
+ for (int pos = 0; pos < SuggestedWords.MAX_SUGGESTIONS; pos++) {
final TextView word = (TextView)inflater.inflate(R.layout.suggestion_word, null);
word.setOnClickListener(this);
word.setOnLongClickListener(this);
diff --git a/java/src/com/android/inputmethod/latin/utils/StringUtils.java b/java/src/com/android/inputmethod/latin/utils/StringUtils.java
index 8fc245d9b..6f15b11bf 100644
--- a/java/src/com/android/inputmethod/latin/utils/StringUtils.java
+++ b/java/src/com/android/inputmethod/latin/utils/StringUtils.java
@@ -174,6 +174,13 @@ public final class StringUtils {
return toCodePointArray(string, 0, string.length());
}
+ /**
+ * Converts a range of a string to an array of code points.
+ * @param string the source string.
+ * @param startIndex the start index inside the string in java chars, inclusive.
+ * @param endIndex the end index inside the string in java chars, exclusive.
+ * @return a new array of code points. At most endIndex - startIndex, but possibly less.
+ */
public static int[] toCodePointArray(final String string,
final int startIndex, final int endIndex) {
final int length = string.length();