aboutsummaryrefslogtreecommitdiffstats
path: root/java/src/com/android/inputmethod/latin
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/com/android/inputmethod/latin')
-rw-r--r--java/src/com/android/inputmethod/latin/ExpandableDictionary.java2
-rw-r--r--java/src/com/android/inputmethod/latin/LatinIME.java37
-rw-r--r--java/src/com/android/inputmethod/latin/SubtypeSwitcher.java7
-rw-r--r--java/src/com/android/inputmethod/latin/SuggestionsView.java169
-rw-r--r--java/src/com/android/inputmethod/latin/UserDictionary.java3
-rw-r--r--java/src/com/android/inputmethod/latin/Utils.java15
-rw-r--r--java/src/com/android/inputmethod/latin/WordComposer.java83
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java12
8 files changed, 175 insertions, 153 deletions
diff --git a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
index cad69bb0e..7eec8e2ca 100644
--- a/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
+++ b/java/src/com/android/inputmethod/latin/ExpandableDictionary.java
@@ -51,6 +51,7 @@ public class ExpandableDictionary extends Dictionary {
private Object mUpdatingLock = new Object();
private static class Node {
+ Node() {}
char mCode;
int mFrequency;
boolean mTerminal;
@@ -547,6 +548,7 @@ public class ExpandableDictionary extends Dictionary {
}
private class LoadDictionaryTask extends Thread {
+ LoadDictionaryTask() {}
@Override
public void run() {
loadDictionaryAsync();
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 943361c73..20c87ad13 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -297,19 +297,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
break;
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
- if (inputView != null) {
- inputView.setSpacebarTextFadeFactor(
- (1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
- (LatinKeyboard)msg.obj);
- }
+ setSpacebarTextFadeFactor(inputView,
+ (1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
+ (LatinKeyboard)msg.obj);
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
mDurationOfFadeoutLanguageOnSpacebar);
break;
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
- if (inputView != null) {
- inputView.setSpacebarTextFadeFactor(mFinalFadeoutFactorOfLanguageOnSpacebar,
- (LatinKeyboard)msg.obj);
- }
+ setSpacebarTextFadeFactor(inputView, mFinalFadeoutFactorOfLanguageOnSpacebar,
+ (LatinKeyboard)msg.obj);
break;
}
}
@@ -349,6 +345,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
sendMessage(obtainMessage(MSG_VOICE_RESULTS));
}
+ private static void setSpacebarTextFadeFactor(LatinKeyboardView inputView,
+ float fadeFactor, LatinKeyboard oldKeyboard) {
+ if (inputView == null) return;
+ final Keyboard keyboard = inputView.getKeyboard();
+ if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
+ final Key updatedKey = ((LatinKeyboard)keyboard).updateSpacebarLanguage(
+ fadeFactor,
+ Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
+ SubtypeSwitcher.getInstance().needsToDisplayLanguage(keyboard.mId.mLocale));
+ inputView.invalidateKey(updatedKey);
+ }
+ }
+
public void startDisplayLanguageOnSpacebar(boolean localeChanged) {
final LatinIME latinIme = getOuterInstance();
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
@@ -361,9 +370,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|| mDelayBeforeFadeoutLanguageOnSpacebar < 0;
// The language is never displayed when the delay is zero.
if (mDelayBeforeFadeoutLanguageOnSpacebar != 0) {
- inputView.setSpacebarTextFadeFactor(needsToDisplayLanguage ? 1.0f
- : mFinalFadeoutFactorOfLanguageOnSpacebar,
- keyboard);
+ setSpacebarTextFadeFactor(inputView,
+ needsToDisplayLanguage ? 1.0f : mFinalFadeoutFactorOfLanguageOnSpacebar,
+ keyboard);
}
// The fadeout animation will start when the delay is positive.
if (localeChanged && mDelayBeforeFadeoutLanguageOnSpacebar > 0) {
@@ -1229,7 +1238,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (isShowingOptionDialog()) return;
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
showSubtypeSelectorAndSettings();
- } else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, false /* exclude aux subtypes */)) {
+ } else if (Utils.hasMultipleEnabledIMEsOrSubtypes(false /* exclude aux subtypes */)) {
showOptionsMenu();
} else {
launchSettings();
@@ -1245,7 +1254,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
if (isShowingOptionDialog()) return false;
switch (requestCode) {
case CODE_SHOW_INPUT_METHOD_PICKER:
- if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, true /* include aux subtypes */)) {
+ if (Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
mImm.showInputMethodPicker();
return true;
}
diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
index 8a4862094..42111822d 100644
--- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
+++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java
@@ -35,7 +35,6 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
import com.android.inputmethod.deprecated.VoiceProxy;
import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.keyboard.LatinKeyboard;
import java.util.ArrayList;
import java.util.Arrays;
@@ -421,11 +420,7 @@ public class SubtypeSwitcher {
ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
mIsNetworkConnected = !noConnection;
- final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance();
- final LatinKeyboard keyboard = switcher.getLatinKeyboard();
- if (keyboard != null) {
- keyboard.updateShortcutKey(isShortcutImeReady(), switcher.getKeyboardView());
- }
+ KeyboardSwitcher.getInstance().onNetworkStateChanged();
}
//////////////////////////////////
diff --git a/java/src/com/android/inputmethod/latin/SuggestionsView.java b/java/src/com/android/inputmethod/latin/SuggestionsView.java
index 883bb57f0..47c790093 100644
--- a/java/src/com/android/inputmethod/latin/SuggestionsView.java
+++ b/java/src/com/android/inputmethod/latin/SuggestionsView.java
@@ -461,6 +461,91 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
setLayoutWeight(
hintView, 1.0f - mCenterSuggestionWeight, ViewGroup.LayoutParams.MATCH_PARENT);
}
+
+ private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
+ if (DBG && pos < suggestions.size()) {
+ final SuggestedWordInfo wordInfo = suggestions.getInfo(pos);
+ if (wordInfo != null) {
+ final CharSequence debugInfo = wordInfo.getDebugString();
+ if (!TextUtils.isEmpty(debugInfo)) {
+ return debugInfo;
+ }
+ }
+ }
+ return null;
+ }
+
+ private static void setLayoutWeight(View v, float weight, int height) {
+ final ViewGroup.LayoutParams lp = v.getLayoutParams();
+ if (lp instanceof LinearLayout.LayoutParams) {
+ final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
+ llp.weight = weight;
+ llp.width = 0;
+ llp.height = height;
+ }
+ }
+
+ private static float getTextScaleX(CharSequence text, int maxWidth, TextPaint paint) {
+ paint.setTextScaleX(1.0f);
+ final int width = getTextWidth(text, paint);
+ if (width <= maxWidth) {
+ return 1.0f;
+ }
+ return maxWidth / (float)width;
+ }
+
+ private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
+ TextPaint paint) {
+ if (text == null) return null;
+ paint.setTextScaleX(1.0f);
+ final int width = getTextWidth(text, paint);
+ if (width <= maxWidth) {
+ return text;
+ }
+ final float scaleX = maxWidth / (float)width;
+ if (scaleX >= MIN_TEXT_XSCALE) {
+ paint.setTextScaleX(scaleX);
+ return text;
+ }
+
+ // Note that TextUtils.ellipsize() use text-x-scale as 1.0 if ellipsize is needed. To
+ // get squeezed and ellipsized text, passes enlarged width (maxWidth / MIN_TEXT_XSCALE).
+ final CharSequence ellipsized = TextUtils.ellipsize(
+ text, paint, maxWidth / MIN_TEXT_XSCALE, TextUtils.TruncateAt.MIDDLE);
+ paint.setTextScaleX(MIN_TEXT_XSCALE);
+ return ellipsized;
+ }
+
+ private static int getTextWidth(CharSequence text, TextPaint paint) {
+ if (TextUtils.isEmpty(text)) return 0;
+ final Typeface savedTypeface = paint.getTypeface();
+ paint.setTypeface(getTextTypeface(text));
+ final int len = text.length();
+ final float[] widths = new float[len];
+ final int count = paint.getTextWidths(text, 0, len, widths);
+ int width = 0;
+ for (int i = 0; i < count; i++) {
+ width += Math.round(widths[i] + 0.5f);
+ }
+ paint.setTypeface(savedTypeface);
+ return width;
+ }
+
+ private static Typeface getTextTypeface(CharSequence text) {
+ if (!(text instanceof SpannableString))
+ return Typeface.DEFAULT;
+
+ final SpannableString ss = (SpannableString)text;
+ final StyleSpan[] styles = ss.getSpans(0, text.length(), StyleSpan.class);
+ if (styles.length == 0)
+ return Typeface.DEFAULT;
+
+ switch (styles[0].getStyle()) {
+ case Typeface.BOLD: return Typeface.DEFAULT_BOLD;
+ // TODO: BOLD_ITALIC, ITALIC case?
+ default: return Typeface.DEFAULT;
+ }
+ }
}
/**
@@ -547,90 +632,6 @@ public class SuggestionsView extends RelativeLayout implements OnClickListener,
mParams.layout(mSuggestions, mSuggestionsStrip, this, getWidth());
}
- private static CharSequence getDebugInfo(SuggestedWords suggestions, int pos) {
- if (DBG && pos < suggestions.size()) {
- final SuggestedWordInfo wordInfo = suggestions.getInfo(pos);
- if (wordInfo != null) {
- final CharSequence debugInfo = wordInfo.getDebugString();
- if (!TextUtils.isEmpty(debugInfo)) {
- return debugInfo;
- }
- }
- }
- return null;
- }
-
- private static void setLayoutWeight(View v, float weight, int height) {
- final ViewGroup.LayoutParams lp = v.getLayoutParams();
- if (lp instanceof LinearLayout.LayoutParams) {
- final LinearLayout.LayoutParams llp = (LinearLayout.LayoutParams)lp;
- llp.weight = weight;
- llp.width = 0;
- llp.height = height;
- }
- }
-
- private static float getTextScaleX(CharSequence text, int maxWidth, TextPaint paint) {
- paint.setTextScaleX(1.0f);
- final int width = getTextWidth(text, paint);
- if (width <= maxWidth) {
- return 1.0f;
- }
- return maxWidth / (float)width;
- }
-
- private static CharSequence getEllipsizedText(CharSequence text, int maxWidth,
- TextPaint paint) {
- if (text == null) return null;
- paint.setTextScaleX(1.0f);
- final int width = getTextWidth(text, paint);
- if (width <= maxWidth) {
- return text;
- }
- final float scaleX = maxWidth / (float)width;
- if (scaleX >= MIN_TEXT_XSCALE) {
- paint.setTextScaleX(scaleX);
- return text;
- }
-
- // Note that TextUtils.ellipsize() use text-x-scale as 1.0 if ellipsize is needed. To get
- // squeezed and ellipsized text, passes enlarged width (maxWidth / MIN_TEXT_XSCALE).
- final CharSequence ellipsized = TextUtils.ellipsize(
- text, paint, maxWidth / MIN_TEXT_XSCALE, TextUtils.TruncateAt.MIDDLE);
- paint.setTextScaleX(MIN_TEXT_XSCALE);
- return ellipsized;
- }
-
- private static int getTextWidth(CharSequence text, TextPaint paint) {
- if (TextUtils.isEmpty(text)) return 0;
- final Typeface savedTypeface = paint.getTypeface();
- paint.setTypeface(getTextTypeface(text));
- final int len = text.length();
- final float[] widths = new float[len];
- final int count = paint.getTextWidths(text, 0, len, widths);
- int width = 0;
- for (int i = 0; i < count; i++) {
- width += Math.round(widths[i] + 0.5f);
- }
- paint.setTypeface(savedTypeface);
- return width;
- }
-
- private static Typeface getTextTypeface(CharSequence text) {
- if (!(text instanceof SpannableString))
- return Typeface.DEFAULT;
-
- final SpannableString ss = (SpannableString)text;
- final StyleSpan[] styles = ss.getSpans(0, text.length(), StyleSpan.class);
- if (styles.length == 0)
- return Typeface.DEFAULT;
-
- switch (styles[0].getStyle()) {
- case Typeface.BOLD: return Typeface.DEFAULT_BOLD;
- // TODO: BOLD_ITALIC, ITALIC case?
- default: return Typeface.DEFAULT;
- }
- }
public boolean isShowingAddToDictionaryHint() {
return mSuggestionsStrip.getChildCount() > 0
diff --git a/java/src/com/android/inputmethod/latin/UserDictionary.java b/java/src/com/android/inputmethod/latin/UserDictionary.java
index 8c28324d8..6d6296e10 100644
--- a/java/src/com/android/inputmethod/latin/UserDictionary.java
+++ b/java/src/com/android/inputmethod/latin/UserDictionary.java
@@ -18,13 +18,10 @@ package com.android.inputmethod.latin;
import android.content.ContentProviderClient;
import android.content.ContentResolver;
-import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.database.ContentObserver;
import android.database.Cursor;
-import android.net.Uri;
-import android.os.RemoteException;
import android.provider.UserDictionary.Words;
import android.text.TextUtils;
diff --git a/java/src/com/android/inputmethod/latin/Utils.java b/java/src/com/android/inputmethod/latin/Utils.java
index 64f4d058b..bfa51897e 100644
--- a/java/src/com/android/inputmethod/latin/Utils.java
+++ b/java/src/com/android/inputmethod/latin/Utils.java
@@ -118,8 +118,9 @@ public class Utils {
}
public static boolean hasMultipleEnabledIMEsOrSubtypes(
- final InputMethodManagerCompatWrapper imm,
final boolean shouldIncludeAuxiliarySubtypes) {
+ final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
+ if (imm == null) return false;
final List<InputMethodInfoCompatWrapper> enabledImis = imm.getEnabledInputMethodList();
// Number of the filtered IMEs
@@ -543,13 +544,13 @@ public class Utils {
final String currentDateTimeString =
new SimpleDateFormat("yyyyMMdd-HHmmssZ").format(date);
if (mFile == null) {
- Log.w(TAG, "No internal log file found.");
+ Log.w(USABILITY_TAG, "No internal log file found.");
return;
}
if (mIms.checkCallingOrSelfPermission(
android.Manifest.permission.WRITE_EXTERNAL_STORAGE)
!= PackageManager.PERMISSION_GRANTED) {
- Log.w(TAG, "Doesn't have the permission WRITE_EXTERNAL_STORAGE");
+ Log.w(USABILITY_TAG, "Doesn't have the permission WRITE_EXTERNAL_STORAGE");
return;
}
mWriter.flush();
@@ -563,20 +564,20 @@ public class Utils {
src.close();
dest.close();
} catch (FileNotFoundException e1) {
- Log.w(TAG, e1);
+ Log.w(USABILITY_TAG, e1);
return;
} catch (IOException e2) {
- Log.w(TAG, e2);
+ Log.w(USABILITY_TAG, e2);
return;
}
if (destFile == null || !destFile.exists()) {
- Log.w(TAG, "Dest file doesn't exist.");
+ Log.w(USABILITY_TAG, "Dest file doesn't exist.");
return;
}
final Intent intent = new Intent(Intent.ACTION_SEND);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
if (LatinImeLogger.sDBG) {
- Log.d(TAG, "Destination file URI is " + destFile.toURI());
+ Log.d(USABILITY_TAG, "Destination file URI is " + destFile.toURI());
}
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://" + destPath));
diff --git a/java/src/com/android/inputmethod/latin/WordComposer.java b/java/src/com/android/inputmethod/latin/WordComposer.java
index 8bbcff758..60a9685bc 100644
--- a/java/src/com/android/inputmethod/latin/WordComposer.java
+++ b/java/src/com/android/inputmethod/latin/WordComposer.java
@@ -32,15 +32,40 @@ public class WordComposer {
public static final int NOT_A_CODE = KeyDetector.NOT_A_CODE;
public static final int NOT_A_COORDINATE = -1;
- /**
- * The list of unicode values for each keystroke (including surrounding keys)
- */
- private ArrayList<int[]> mCodes;
-
- private int[] mXCoordinates;
- private int[] mYCoordinates;
+ // Storage for all the info about the current input.
+ private static class CharacterStore {
+ /**
+ * The list of unicode values for each keystroke (including surrounding keys)
+ */
+ ArrayList<int[]> mCodes;
+ int[] mXCoordinates;
+ int[] mYCoordinates;
+ StringBuilder mTypedWord;
+ CharacterStore() {
+ final int N = BinaryDictionary.MAX_WORD_LENGTH;
+ mCodes = new ArrayList<int[]>(N);
+ mTypedWord = new StringBuilder(N);
+ mXCoordinates = new int[N];
+ mYCoordinates = new int[N];
+ }
+ CharacterStore(final CharacterStore that) {
+ mCodes = new ArrayList<int[]>(that.mCodes);
+ mTypedWord = new StringBuilder(that.mTypedWord);
+ mXCoordinates = Arrays.copyOf(that.mXCoordinates, that.mXCoordinates.length);
+ mYCoordinates = Arrays.copyOf(that.mYCoordinates, that.mYCoordinates.length);
+ }
+ void reset() {
+ // For better performance than creating a new character store.
+ mCodes.clear();
+ mTypedWord.setLength(0);
+ }
+ }
- private StringBuilder mTypedWord;
+ // The currently typing word.
+ // NOTE: this is not reset as soon as the word is committed because it may be needed again
+ // to resume suggestion if backspaced. TODO: separate cleanly what is actually being
+ // composed and what is kept for possible resuming.
+ private CharacterStore mCurrentWord;
// An auto-correction for this word out of the dictionary.
private CharSequence mAutoCorrection;
@@ -56,11 +81,7 @@ public class WordComposer {
private boolean mIsFirstCharCapitalized;
public WordComposer() {
- final int N = BinaryDictionary.MAX_WORD_LENGTH;
- mCodes = new ArrayList<int[]>(N);
- mTypedWord = new StringBuilder(N);
- mXCoordinates = new int[N];
- mYCoordinates = new int[N];
+ mCurrentWord = new CharacterStore();
mTrailingSingleQuotesCount = 0;
mAutoCorrection = null;
}
@@ -70,10 +91,7 @@ public class WordComposer {
}
public void init(WordComposer source) {
- mCodes = new ArrayList<int[]>(source.mCodes);
- mTypedWord = new StringBuilder(source.mTypedWord);
- mXCoordinates = Arrays.copyOf(source.mXCoordinates, source.mXCoordinates.length);
- mYCoordinates = Arrays.copyOf(source.mYCoordinates, source.mYCoordinates.length);
+ mCurrentWord = new CharacterStore(source.mCurrentWord);
mCapsCount = source.mCapsCount;
mIsFirstCharCapitalized = source.mIsFirstCharCapitalized;
mAutoCapitalized = source.mAutoCapitalized;
@@ -85,8 +103,7 @@ public class WordComposer {
* Clear out the keys registered so far.
*/
public void reset() {
- mCodes.clear();
- mTypedWord.setLength(0);
+ mCurrentWord.reset();
mCapsCount = 0;
mIsFirstCharCapitalized = false;
mTrailingSingleQuotesCount = 0;
@@ -98,7 +115,7 @@ public class WordComposer {
* @return the number of keystrokes
*/
public final int size() {
- return mTypedWord.length();
+ return mCurrentWord.mTypedWord.length();
}
/**
@@ -107,15 +124,15 @@ public class WordComposer {
* @return the unicode for the pressed and surrounding keys
*/
public int[] getCodesAt(int index) {
- return mCodes.get(index);
+ return mCurrentWord.mCodes.get(index);
}
public int[] getXCoordinates() {
- return mXCoordinates;
+ return mCurrentWord.mXCoordinates;
}
public int[] getYCoordinates() {
- return mYCoordinates;
+ return mCurrentWord.mYCoordinates;
}
private static boolean isFirstCharCapitalized(int index, int codePoint, boolean previous) {
@@ -130,12 +147,12 @@ public class WordComposer {
*/
public void add(int primaryCode, int[] codes, int x, int y) {
final int newIndex = size();
- mTypedWord.append((char) primaryCode);
+ mCurrentWord.mTypedWord.append((char) primaryCode);
correctPrimaryJuxtapos(primaryCode, codes);
- mCodes.add(codes);
+ mCurrentWord.mCodes.add(codes);
if (newIndex < BinaryDictionary.MAX_WORD_LENGTH) {
- mXCoordinates[newIndex] = x;
- mYCoordinates[newIndex] = y;
+ mCurrentWord.mXCoordinates[newIndex] = x;
+ mCurrentWord.mYCoordinates[newIndex] = y;
}
mIsFirstCharCapitalized = isFirstCharCapitalized(
newIndex, primaryCode, mIsFirstCharCapitalized);
@@ -215,9 +232,9 @@ public class WordComposer {
final int size = size();
if (size > 0) {
final int lastPos = size - 1;
- char lastChar = mTypedWord.charAt(lastPos);
- mCodes.remove(lastPos);
- mTypedWord.deleteCharAt(lastPos);
+ char lastChar = mCurrentWord.mTypedWord.charAt(lastPos);
+ mCurrentWord.mCodes.remove(lastPos);
+ mCurrentWord.mTypedWord.deleteCharAt(lastPos);
if (Character.isUpperCase(lastChar)) mCapsCount--;
}
if (size() == 0) {
@@ -226,8 +243,8 @@ public class WordComposer {
if (mTrailingSingleQuotesCount > 0) {
--mTrailingSingleQuotesCount;
} else {
- for (int i = mTypedWord.length() - 1; i >= 0; --i) {
- if (Keyboard.CODE_SINGLE_QUOTE != mTypedWord.codePointAt(i)) break;
+ for (int i = mCurrentWord.mTypedWord.length() - 1; i >= 0; --i) {
+ if (Keyboard.CODE_SINGLE_QUOTE != mCurrentWord.mTypedWord.codePointAt(i)) break;
++mTrailingSingleQuotesCount;
}
}
@@ -239,7 +256,7 @@ public class WordComposer {
* @return the word that was typed so far. Never returns null.
*/
public String getTypedWord() {
- return mTypedWord.toString();
+ return mCurrentWord.mTypedWord.toString();
}
/**
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
index 9a2bebfdf..2bc2cfdf6 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/SpellCheckerProximityInfo.java
@@ -43,7 +43,7 @@ public class SpellCheckerProximityInfo {
return result;
}
- static class Latin {
+ private static class Latin {
// This is a map from the code point to the index in the PROXIMITY array.
// At the time the native code to read the binary dictionary needs the proximity info be
// passed as a flat array spaced by MAX_PROXIMITY_CHARS_SIZE columns, one for each input
@@ -62,7 +62,7 @@ public class SpellCheckerProximityInfo {
// to spell check has been entered with one of the keyboards above. Also, specifically
// to English, many spelling errors consist of the last vowel of the word being wrong
// because in English vowels tend to merge with each other in pronunciation.
- final private static int[] PROXIMITY = {
+ final static int[] PROXIMITY = {
'q', 'w', 's', 'a', 'z', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
'w', 'q', 'a', 's', 'd', 'e', 'x', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
'e', 'w', 's', 'd', 'f', 'r', 'a', 'i', 'o', 'u', NUL, NUL, NUL, NUL, NUL, NUL,
@@ -101,14 +101,14 @@ public class SpellCheckerProximityInfo {
static {
buildProximityIndices(PROXIMITY, INDICES);
}
- private static int getIndexOf(int characterCode) {
+ static int getIndexOf(int characterCode) {
return computeIndex(characterCode, INDICES);
}
}
- static class Cyrillic {
+ private static class Cyrillic {
final private static TreeMap<Integer, Integer> INDICES = new TreeMap<Integer, Integer>();
- final private static int[] PROXIMITY = {
+ final static int[] PROXIMITY = {
// TODO: This table is solely based on the keyboard layout. Consult with Russian
// speakers on commonly misspelled words/letters.
'ะน', 'ั†', 'ั„', 'ั‹', NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL, NUL,
@@ -150,7 +150,7 @@ public class SpellCheckerProximityInfo {
static {
buildProximityIndices(PROXIMITY, INDICES);
}
- private static int getIndexOf(int characterCode) {
+ static int getIndexOf(int characterCode) {
return computeIndex(characterCode, INDICES);
}
}