aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/res/values-is/donottranslate-more-keys.xml73
-rw-r--r--java/res/xml-is/keyboard_set.xml42
-rw-r--r--java/res/xml/method.xml7
-rw-r--r--java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java32
-rw-r--r--java/src/com/android/inputmethod/latin/BinaryDictionary.java10
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableDictionary.java8
-rw-r--r--java/src/com/android/inputmethod/latin/LastComposedWord.java8
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java4
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java52
9 files changed, 186 insertions, 50 deletions
diff --git a/java/res/values-is/donottranslate-more-keys.xml b/java/res/values-is/donottranslate-more-keys.xml
new file mode 100644
index 000000000..2c3fa1e2e
--- /dev/null
+++ b/java/res/values-is/donottranslate-more-keys.xml
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
+ <!-- U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
+ U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
+ U+00E6: "æ" LATIN SMALL LETTER AE
+ U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE
+ U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
+ U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
+ U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
+ U+0101: "ā" LATIN SMALL LETTER A WITH MACRON -->
+ <string name="more_keys_for_a">&#x00E1;,&#x00E4;,&#x00E6;,&#x00E5;,&#x00E0;,&#x00E2;,&#x00E3;,&#x0101;</string>
+ <!-- U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE
+ U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS
+ U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE
+ U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX
+ U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK
+ U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE
+ U+0113: "ē" LATIN SMALL LETTER E WITH MACRON -->
+ <string name="more_keys_for_e">&#x00E9;,&#x00EB;,&#x00E8;,&#x00EA;,&#x0119;,&#x0117;,&#x0113;</string>
+ <!-- U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE
+ U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS
+ U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX
+ U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE
+ U+012F: "į" LATIN SMALL LETTER I WITH OGONEK
+ U+012B: "ī" LATIN SMALL LETTER I WITH MACRON -->
+ <string name="more_keys_for_i">&#x00ED;,&#x00EF;,&#x00EE;,&#x00EC;,&#x012F;,&#x012B;</string>
+ <!-- U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE
+ U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
+ U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX
+ U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE
+ U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE
+ U+0153: "œ" LATIN SMALL LIGATURE OE
+ U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE
+ U+014D: "ō" LATIN SMALL LETTER O WITH MACRON -->
+ <string name="more_keys_for_o">&#x00F3;,&#x00F6;,&#x00F4;,&#x00F2;,&#x00F5;,&#x0153;,&#x00F8;,&#x014D;</string>
+ <!-- U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE
+ U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS
+ U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX
+ U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE
+ U+016B: "ū" LATIN SMALL LETTER U WITH MACRON -->
+ <string name="more_keys_for_u">&#x00FA;,&#x00FC;,&#x00FB;,&#x00F9;,&#x016B;</string>
+ <!-- U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE
+ U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS -->
+ <string name="more_keys_for_y">&#x00FD;,&#x00FF;</string>
+ <!-- U+00F0: "ð" LATIN SMALL LETTER ETH -->
+ <string name="more_keys_for_d">&#x00F0;</string>
+ <!-- U+00FE: "þ" LATIN SMALL LETTER THORN -->
+ <string name="more_keys_for_t">&#x00FE;</string>
+ <!-- U+00F0: "ð" LATIN SMALL LETTER ETH -->
+ <string name="keylabel_for_scandinavia_row1_11">&#x00F0;</string>
+ <!-- U+00E6: "æ" LATIN SMALL LETTER AE -->
+ <string name="keylabel_for_scandinavia_row2_10">&#x00E6;</string>
+ <!-- U+00FE: "þ" LATIN SMALL LETTER THORN -->
+ <string name="keylabel_for_scandinavia_row2_11">&#x00FE;</string>
+</resources>
diff --git a/java/res/xml-is/keyboard_set.xml b/java/res/xml-is/keyboard_set.xml
new file mode 100644
index 000000000..077bc6b27
--- /dev/null
+++ b/java/res/xml-is/keyboard_set.xml
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 2012, The Android Open Source Project
+**
+** Licensed under the Apache License, Version 2.0 (the "License");
+** you may not use this file except in compliance with the License.
+** You may obtain a copy of the License at
+**
+** http://www.apache.org/licenses/LICENSE-2.0
+**
+** Unless required by applicable law or agreed to in writing, software
+** distributed under the License is distributed on an "AS IS" BASIS,
+** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+** See the License for the specific language governing permissions and
+** limitations under the License.
+*/
+-->
+
+<KeyboardSet
+ xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
+ latin:keyboardLocale="is">
+ <Element
+ latin:elementName="alphabet"
+ latin:elementKeyboard="@xml/kbd_nordic" />
+ <Element
+ latin:elementName="symbols"
+ latin:elementKeyboard="@xml/kbd_symbols" />
+ <Element
+ latin:elementName="symbolsShifted"
+ latin:elementKeyboard="@xml/kbd_symbols_shift" />
+ <Element
+ latin:elementName="phone"
+ latin:elementKeyboard="@xml/kbd_phone" />
+ <Element
+ latin:elementName="phoneSymbols"
+ latin:elementKeyboard="@xml/kbd_phone_symbols" />
+ <Element
+ latin:elementName="number"
+ latin:elementKeyboard="@xml/kbd_number" />
+</KeyboardSet>
diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml
index 544f3fd64..1cdd68ad9 100644
--- a/java/res/xml/method.xml
+++ b/java/res/xml/method.xml
@@ -41,6 +41,7 @@
hi: Hindi/hindi
hr: Croatian/qwertz
hu: Hungarian/qwertz
+ is: Icelandic/qwerty
it: Italian/qwerty
iw: Hebrew/hebrew
ka: Georgian/georgian
@@ -191,6 +192,12 @@
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
+ android:imeSubtypeLocale="is"
+ android:imeSubtypeMode="keyboard"
+ android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection"
+ />
+ <subtype android:icon="@drawable/ic_subtype_keyboard"
+ android:label="@string/subtype_generic"
android:imeSubtypeLocale="it"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,SupportTouchPositionCorrection"
diff --git a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
index e82d91411..a9e48404a 100644
--- a/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
+++ b/java/src/com/android/inputmethod/compat/SuggestionSpanUtils.java
@@ -48,21 +48,30 @@ public class SuggestionSpanUtils {
Context.class, Locale.class, String[].class, int.class, Class.class };
private static final Constructor<?> CONSTRUCTOR_SuggestionSpan = CompatUtils
.getConstructor(CLASS_SuggestionSpan, INPUT_TYPE_SuggestionSpan);
- public static final Field FIELD_FLAG_AUTO_CORRECTION
- = CompatUtils.getField(CLASS_SuggestionSpan, "FLAG_AUTO_CORRECTION");
+ public static final Field FIELD_FLAG_EASY_CORRECT =
+ CompatUtils.getField(CLASS_SuggestionSpan, "FLAG_EASY_CORRECT");
+ public static final Field FIELD_FLAG_MISSPELLED =
+ CompatUtils.getField(CLASS_SuggestionSpan, "FLAG_MISSPELLED");
+ public static final Field FIELD_FLAG_AUTO_CORRECTION =
+ CompatUtils.getField(CLASS_SuggestionSpan, "FLAG_AUTO_CORRECTION");
public static final Field FIELD_SUGGESTIONS_MAX_SIZE
= CompatUtils.getField(CLASS_SuggestionSpan, "SUGGESTIONS_MAX_SIZE");
+ public static final Integer OBJ_FLAG_EASY_CORRECT = (Integer) CompatUtils
+ .getFieldValue(null, null, FIELD_FLAG_EASY_CORRECT);
+ public static final Integer OBJ_FLAG_MISSPELLED = (Integer) CompatUtils
+ .getFieldValue(null, null, FIELD_FLAG_MISSPELLED);
public static final Integer OBJ_FLAG_AUTO_CORRECTION = (Integer) CompatUtils
- .getFieldValue(null, null, FIELD_FLAG_AUTO_CORRECTION);;
+ .getFieldValue(null, null, FIELD_FLAG_AUTO_CORRECTION);
public static final Integer OBJ_SUGGESTIONS_MAX_SIZE = (Integer) CompatUtils
- .getFieldValue(null, null, FIELD_SUGGESTIONS_MAX_SIZE);;
+ .getFieldValue(null, null, FIELD_SUGGESTIONS_MAX_SIZE);
static {
SUGGESTION_SPAN_IS_SUPPORTED =
CLASS_SuggestionSpan != null && CONSTRUCTOR_SuggestionSpan != null;
if (LatinImeLogger.sDBG) {
if (SUGGESTION_SPAN_IS_SUPPORTED
- && (OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTIONS_MAX_SIZE == null)) {
+ && (OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTIONS_MAX_SIZE == null
+ || OBJ_FLAG_MISSPELLED == null || OBJ_FLAG_EASY_CORRECT == null)) {
throw new RuntimeException("Field is accidentially null.");
}
}
@@ -71,7 +80,8 @@ public class SuggestionSpanUtils {
public static CharSequence getTextWithAutoCorrectionIndicatorUnderline(
Context context, CharSequence text) {
if (TextUtils.isEmpty(text) || CONSTRUCTOR_SuggestionSpan == null
- || OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTIONS_MAX_SIZE == null) {
+ || OBJ_FLAG_AUTO_CORRECTION == null || OBJ_SUGGESTIONS_MAX_SIZE == null
+ || OBJ_FLAG_MISSPELLED == null || OBJ_FLAG_EASY_CORRECT == null) {
return text;
}
final Spannable spannable = text instanceof Spannable
@@ -104,6 +114,7 @@ public class SuggestionSpanUtils {
spannable = new SpannableString(pickedWord);
}
final ArrayList<String> suggestionsList = new ArrayList<String>();
+ boolean sameAsTyped = false;
for (int i = 0; i < suggestedWords.size(); ++i) {
if (suggestionsList.size() >= OBJ_SUGGESTIONS_MAX_SIZE) {
break;
@@ -111,11 +122,18 @@ public class SuggestionSpanUtils {
final CharSequence word = suggestedWords.getWord(i);
if (!TextUtils.equals(pickedWord, word)) {
suggestionsList.add(word.toString());
+ } else if (i == 0) {
+ sameAsTyped = true;
}
}
+ // TODO: Share the implementation for checking typed word validity between the IME
+ // and the spell checker.
+ final int flag = (sameAsTyped && !suggestedWords.mTypedWordValid)
+ ? ((int)OBJ_FLAG_EASY_CORRECT | (int)OBJ_FLAG_MISSPELLED)
+ : 0;
final Object[] args =
- { context, null, suggestionsList.toArray(new String[suggestionsList.size()]), 0,
+ { context, null, suggestionsList.toArray(new String[suggestionsList.size()]), flag,
(Class<?>) SuggestionSpanPickedNotificationReceiver.class };
final Object ss = CompatUtils.newInstance(CONSTRUCTOR_SuggestionSpan, args);
if (ss == null) {
diff --git a/java/src/com/android/inputmethod/latin/BinaryDictionary.java b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
index a9df1ce12..9909638d4 100644
--- a/java/src/com/android/inputmethod/latin/BinaryDictionary.java
+++ b/java/src/com/android/inputmethod/latin/BinaryDictionary.java
@@ -144,9 +144,7 @@ public class BinaryDictionary extends Dictionary {
int codesSize = codes.size();
Arrays.fill(mInputCodes, -1);
if (codesSize > 0) {
- int[] alternatives = codes.getCodesAt(0);
- System.arraycopy(alternatives, 0, mInputCodes, 0,
- Math.min(alternatives.length, MAX_PROXIMITY_CHARS_SIZE));
+ mInputCodes[0] = codes.getCodeAt(0);
}
int count = getBigramsNative(mNativeDict, chars, chars.length, mInputCodes, codesSize,
@@ -205,11 +203,7 @@ public class BinaryDictionary extends Dictionary {
Arrays.fill(mInputCodes, WordComposer.NOT_A_CODE);
for (int i = 0; i < codesSize; i++) {
- final int[] alternatives = codes.getCodesAt(i);
- if (alternatives == null || alternatives.length < 1) {
- continue;
- }
- mInputCodes[i] = alternatives[0];
+ mInputCodes[i] = codes.getCodeAt(i);
}
Arrays.fill(outputChars, (char) 0);
Arrays.fill(scores, 0);
diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
index 8e8adc1c2..f8de029bd 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
@@ -210,7 +210,11 @@ public class ExpandableDictionary extends Dictionary {
if (mCodes.length < mInputLength) mCodes = new int[mInputLength][];
// Cache the codes so that we don't have to lookup an array list
for (int i = 0; i < mInputLength; i++) {
- mCodes[i] = codes.getCodesAt(i);
+ // TODO: Calculate proximity info here.
+ if (mCodes[i] == null || mCodes[i].length < 1) {
+ mCodes[i] = new int[1];
+ }
+ mCodes[i][0] = codes.getCodeAt(i);
}
mMaxDepth = mInputLength * 3;
getWordsRec(mRoots, codes, mWordBuilder, 0, false, 1, 0, -1, callback);
@@ -319,7 +323,7 @@ public class ExpandableDictionary extends Dictionary {
}
} else {
// Don't use alternatives if we're looking for missing characters
- final int alternativesSize = skipPos >= 0? 1 : currentChars.length;
+ final int alternativesSize = skipPos >= 0 ? 1 : currentChars.length;
for (int j = 0; j < alternativesSize; j++) {
final int addedAttenuation = (j > 0 ? 1 : 2);
final int currentChar = currentChars[j];
diff --git a/java/src/com/android/inputmethod/latin/LastComposedWord.java b/java/src/com/android/inputmethod/latin/LastComposedWord.java
index bc0792434..af0ef4b37 100644
--- a/java/src/com/android/inputmethod/latin/LastComposedWord.java
+++ b/java/src/com/android/inputmethod/latin/LastComposedWord.java
@@ -18,8 +18,6 @@ package com.android.inputmethod.latin;
import android.text.TextUtils;
-import java.util.ArrayList;
-
/**
* This class encapsulates data about a word previously composed, but that has been
* committed already. This is used for resuming suggestion, and cancel auto-correction.
@@ -42,7 +40,7 @@ public class LastComposedWord {
public static final int NOT_A_SEPARATOR = -1;
- public final ArrayList<int[]> mCodes;
+ public final int[] mPrimaryKeyCodes;
public final int[] mXCoordinates;
public final int[] mYCoordinates;
public final String mTypedWord;
@@ -56,10 +54,10 @@ public class LastComposedWord {
// Warning: this is using the passed objects as is and fully expects them to be
// immutable. Do not fiddle with their contents after you passed them to this constructor.
- public LastComposedWord(final ArrayList<int[]> codes, final int[] xCoordinates,
+ public LastComposedWord(final int[] primaryKeyCodes, final int[] xCoordinates,
final int[] yCoordinates, final String typedWord, final String committedWord,
final int separatorCode) {
- mCodes = codes;
+ mPrimaryKeyCodes = primaryKeyCodes;
mXCoordinates = xCoordinates;
mYCoordinates = yCoordinates;
mTypedWord = typedWord;
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index be64c2fd8..0485c881b 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -31,9 +31,7 @@ import android.os.Process;
import android.text.TextUtils;
import android.text.format.DateUtils;
import android.util.Log;
-import android.view.MotionEvent;
-import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.latin.SuggestedWords.SuggestedWordInfo;
import java.io.BufferedReader;
@@ -112,7 +110,6 @@ public class Utils {
/* package */ static final int BUFSIZE = 20;
private InputMethodService mContext;
private boolean mEnabled = false;
- private boolean mUsabilityStudy = false;
private int mEnd = 0;
/* package */ int mLength = 0;
private char[] mCharBuf = new char[BUFSIZE];
@@ -129,7 +126,6 @@ public class Utils {
boolean usabilityStudy) {
sRingCharBuffer.mContext = context;
sRingCharBuffer.mEnabled = enabled || usabilityStudy;
- sRingCharBuffer.mUsabilityStudy = usabilityStudy;
UsabilityStudyLogUtils.getInstance().init(context);
return sRingCharBuffer;
}
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index cabf68099..29a7e4816 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -21,7 +21,6 @@ import com.android.inputmethod.keyboard.KeyDetector;
import com.android.inputmethod.keyboard.Keyboard;
import com.android.inputmethod.keyboard.KeyboardActionListener;
-import java.util.ArrayList;
import java.util.Arrays;
/**
@@ -32,9 +31,9 @@ public class WordComposer {
public static final int NOT_A_CODE = KeyDetector.NOT_A_CODE;
public static final int NOT_A_COORDINATE = -1;
- final static int N = BinaryDictionary.MAX_WORD_LENGTH;
+ private static final int N = BinaryDictionary.MAX_WORD_LENGTH;
- private ArrayList<int[]> mCodes;
+ private int[] mPrimaryKeyCodes;
private int[] mXCoordinates;
private int[] mYCoordinates;
private StringBuilder mTypedWord;
@@ -44,6 +43,7 @@ public class WordComposer {
private int mCapsCount;
private boolean mAutoCapitalized;
private int mTrailingSingleQuotesCount;
+ private int mCodePointSize;
/**
* Whether the user chose to capitalize the first char of the word.
@@ -51,12 +51,13 @@ public class WordComposer {
private boolean mIsFirstCharCapitalized;
public WordComposer() {
- mCodes = new ArrayList<int[]>(N);
+ mPrimaryKeyCodes = new int[N];
mTypedWord = new StringBuilder(N);
mXCoordinates = new int[N];
mYCoordinates = new int[N];
mAutoCorrection = null;
mTrailingSingleQuotesCount = 0;
+ refreshSize();
}
public WordComposer(WordComposer source) {
@@ -64,7 +65,7 @@ public class WordComposer {
}
public void init(WordComposer source) {
- mCodes = new ArrayList<int[]>(source.mCodes);
+ mPrimaryKeyCodes = Arrays.copyOf(source.mPrimaryKeyCodes, source.mPrimaryKeyCodes.length);
mTypedWord = new StringBuilder(source.mTypedWord);
mXCoordinates = Arrays.copyOf(source.mXCoordinates, source.mXCoordinates.length);
mYCoordinates = Arrays.copyOf(source.mYCoordinates, source.mYCoordinates.length);
@@ -72,18 +73,23 @@ public class WordComposer {
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
mTrailingSingleQuotesCount = source.mTrailingSingleQuotesCount;
+ refreshSize();
}
/**
* Clear out the keys registered so far.
*/
public void reset() {
- mCodes.clear();
mTypedWord.setLength(0);
mAutoCorrection = null;
mCapsCount = 0;
mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0;
+ refreshSize();
+ }
+
+ public final void refreshSize() {
+ mCodePointSize = mTypedWord.codePointCount(0, mTypedWord.length());
}
/**
@@ -91,20 +97,15 @@ public class WordComposer {
* @return the number of keystrokes
*/
public final int size() {
- return mCodes.size();
+ return mCodePointSize;
}
public final boolean isComposingWord() {
- return mCodes.size() > 0;
+ return size() > 0;
}
- /**
- * Returns the codes at a particular position in the word.
- * @param index the position in the word
- * @return the unicode for the pressed and surrounding keys
- */
- public int[] getCodesAt(int index) {
- return mCodes.get(index);
+ public int getCodeAt(int index) {
+ return mPrimaryKeyCodes[index];
}
public int[] getXCoordinates() {
@@ -149,9 +150,10 @@ public class WordComposer {
* @param codes the array of unicode values
*/
private void add(int primaryCode, int[] codes, int keyX, int keyY) {
- final int newIndex = mCodes.size();
+ final int newIndex = size();
mTypedWord.appendCodePoint(primaryCode);
- mCodes.add(codes);
+ refreshSize();
+ mPrimaryKeyCodes[newIndex] = codes[0];
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
mXCoordinates[newIndex] = keyX;
mYCoordinates[newIndex] = keyY;
@@ -201,9 +203,8 @@ public class WordComposer {
* Delete the last keystroke as a result of hitting backspace.
*/
public void deleteLast() {
- final int size = mCodes.size();
+ final int size = size();
if (size > 0) {
- mCodes.remove(size - 1);
// Note: mTypedWord.length() and mCodes.length differ when there are surrogate pairs
final int stringBuilderLength = mTypedWord.length();
if (stringBuilderLength < size) {
@@ -217,9 +218,10 @@ public class WordComposer {
mTypedWord.deleteCharAt(stringBuilderLength - 1);
}
if (Character.isUpperCase(lastChar)) mCapsCount--;
+ refreshSize();
}
// We may have deleted the last one.
- if (0 == mCodes.size()) {
+ if (0 == size()) {
mIsFirstCharCapitalized = false;
}
if (mTrailingSingleQuotesCount > 0) {
@@ -307,29 +309,31 @@ public class WordComposer {
// Note: currently, we come here whenever we commit a word. If it's a MANUAL_PICK
// or a DECIDED_WORD we may cancel the commit later; otherwise, we should deactivate
// the last composed word to ensure this does not happen.
- final ArrayList<int[]> codes = mCodes;
+ final int[] primaryKeyCodes = mPrimaryKeyCodes;
final int[] xCoordinates = mXCoordinates;
final int[] yCoordinates = mYCoordinates;
- mCodes = new ArrayList<int[]>(N);
+ mPrimaryKeyCodes = new int[N];
mXCoordinates = new int[N];
mYCoordinates = new int[N];
- final LastComposedWord lastComposedWord = new LastComposedWord(codes,
+ final LastComposedWord lastComposedWord = new LastComposedWord(primaryKeyCodes,
xCoordinates, yCoordinates, mTypedWord.toString(), committedWord, separatorCode);
if (type != LastComposedWord.COMMIT_TYPE_DECIDED_WORD
&& type != LastComposedWord.COMMIT_TYPE_MANUAL_PICK) {
lastComposedWord.deactivate();
}
mTypedWord.setLength(0);
+ refreshSize();
mAutoCorrection = null;
return lastComposedWord;
}
public void resumeSuggestionOnLastComposedWord(final LastComposedWord lastComposedWord) {
- mCodes = lastComposedWord.mCodes;
+ mPrimaryKeyCodes = lastComposedWord.mPrimaryKeyCodes;
mXCoordinates = lastComposedWord.mXCoordinates;
mYCoordinates = lastComposedWord.mYCoordinates;
mTypedWord.setLength(0);
mTypedWord.append(lastComposedWord.mTypedWord);
+ refreshSize();
mAutoCorrection = null; // This will be filled by the next call to updateSuggestion.
}
}