aboutsummaryrefslogtreecommitdiffstats
path: root/java/src
diff options
context:
space:
mode:
Diffstat (limited to 'java/src')
-rw-r--r--java/src/com/android/inputmethod/keyboard/Key.java15
-rw-r--r--java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java2
-rw-r--r--java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java119
3 files changed, 76 insertions, 60 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 06d248e3a..c4d5e857d 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -102,8 +102,12 @@ public class Key {
* {@link Keyboard#EDGE_TOP} and {@link Keyboard#EDGE_BOTTOM}.
*/
private int mEdgeFlags;
- /** Whether this is a functional key which has different key top than normal key */
- public final boolean mFunctional;
+
+ /** Background type that represents different key background visual than normal one. */
+ public final int mBackgroundType;
+ public static final int BACKGROUND_TYPE_NORMAL = 0;
+ public static final int BACKGROUND_TYPE_FUNCTIONAL = 1;
+
/** Whether this key repeats itself when held down */
public final boolean mRepeatable;
@@ -225,7 +229,7 @@ public class Key {
mEdgeFlags = edgeFlags;
mHintLabel = hintLabel;
mLabelOption = 0;
- mFunctional = false;
+ mBackgroundType = BACKGROUND_TYPE_NORMAL;
mSticky = false;
mRepeatable = false;
mMoreKeys = null;
@@ -325,8 +329,9 @@ public class Key {
mMaxMoreKeysColumn = style.getInt(keyboardAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn,
params.mMaxMiniKeyboardColumn);
+ mBackgroundType = style.getInt(
+ keyAttr, R.styleable.Keyboard_Key_backgroundType, BACKGROUND_TYPE_NORMAL);
mRepeatable = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable, false);
- mFunctional = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional, false);
mSticky = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky, false);
mEnabled = style.getBoolean(keyAttr, R.styleable.Keyboard_Key_enabled, true);
mEdgeFlags = 0;
@@ -540,7 +545,7 @@ public class Key {
*/
public int[] getCurrentDrawableState() {
final boolean pressed = mPressed;
- if (!mSticky && mFunctional) {
+ if (!mSticky && mBackgroundType == BACKGROUND_TYPE_FUNCTIONAL) {
if (pressed) {
return KEY_STATE_FUNCTIONAL_PRESSED;
} else {
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
index 6d78e8533..9800f245a 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyStyles.java
@@ -172,7 +172,7 @@ public class KeyStyles {
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconPreview);
readInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted);
readInt(keyAttr, R.styleable.Keyboard_Key_maxMoreKeysColumn);
- readBoolean(keyAttr, R.styleable.Keyboard_Key_isFunctional);
+ readInt(keyAttr, R.styleable.Keyboard_Key_backgroundType);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isSticky);
readBoolean(keyAttr, R.styleable.Keyboard_Key_isRepeatable);
readBoolean(keyAttr, R.styleable.Keyboard_Key_enabled);
diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
index dfa0abf1b..bf2e90dca 100644
--- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
+++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java
@@ -327,67 +327,78 @@ public class AndroidSpellCheckerService extends SpellCheckerService {
@Override
public SuggestionsInfo onGetSuggestions(final TextInfo textInfo,
final int suggestionsLimit) {
- final String text = textInfo.getText();
-
- if (shouldFilterOut(text)) return EMPTY_SUGGESTIONS_INFO;
-
- final SuggestionsGatherer suggestionsGatherer =
- new SuggestionsGatherer(suggestionsLimit);
- final WordComposer composer = new WordComposer();
- final int length = text.length();
- for (int i = 0; i < length; ++i) {
- final int character = text.codePointAt(i);
- final int proximityIndex = SpellCheckerProximityInfo.getIndexOf(character);
- final int[] proximities;
- if (-1 == proximityIndex) {
- proximities = new int[] { character };
- } else {
- proximities = Arrays.copyOfRange(SpellCheckerProximityInfo.PROXIMITY,
- proximityIndex, proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
- }
- composer.add(character, proximities,
- WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
- }
-
- final int capitalizeType = getCapitalizationType(text);
- boolean isInDict = true;
try {
- final DictAndProximity dictInfo = mDictionaryPool.take();
- dictInfo.mDictionary.getWords(composer, suggestionsGatherer,
- dictInfo.mProximityInfo);
- isInDict = dictInfo.mDictionary.isValidWord(text);
- if (!isInDict && CAPITALIZE_NONE != capitalizeType) {
- // We want to test the word again if it's all caps or first caps only.
- // If it's fully down, we already tested it, if it's mixed case, we don't
- // want to test a lowercase version of it.
- isInDict = dictInfo.mDictionary.isValidWord(text.toLowerCase(mLocale));
+ final String text = textInfo.getText();
+
+ if (shouldFilterOut(text)) return EMPTY_SUGGESTIONS_INFO;
+
+ final SuggestionsGatherer suggestionsGatherer =
+ new SuggestionsGatherer(suggestionsLimit);
+ final WordComposer composer = new WordComposer();
+ final int length = text.length();
+ for (int i = 0; i < length; ++i) {
+ final int character = text.codePointAt(i);
+ final int proximityIndex = SpellCheckerProximityInfo.getIndexOf(character);
+ final int[] proximities;
+ if (-1 == proximityIndex) {
+ proximities = new int[] { character };
+ } else {
+ proximities = Arrays.copyOfRange(SpellCheckerProximityInfo.PROXIMITY,
+ proximityIndex,
+ proximityIndex + SpellCheckerProximityInfo.ROW_SIZE);
+ }
+ composer.add(character, proximities,
+ WordComposer.NOT_A_COORDINATE, WordComposer.NOT_A_COORDINATE);
}
- if (!mDictionaryPool.offer(dictInfo)) {
- Log.e(TAG, "Can't re-insert a dictionary into its pool");
+
+ final int capitalizeType = getCapitalizationType(text);
+ boolean isInDict = true;
+ try {
+ final DictAndProximity dictInfo = mDictionaryPool.take();
+ dictInfo.mDictionary.getWords(composer, suggestionsGatherer,
+ dictInfo.mProximityInfo);
+ isInDict = dictInfo.mDictionary.isValidWord(text);
+ if (!isInDict && CAPITALIZE_NONE != capitalizeType) {
+ // We want to test the word again if it's all caps or first caps only.
+ // If it's fully down, we already tested it, if it's mixed case, we don't
+ // want to test a lowercase version of it.
+ isInDict = dictInfo.mDictionary.isValidWord(text.toLowerCase(mLocale));
+ }
+ if (!mDictionaryPool.offer(dictInfo)) {
+ Log.e(TAG, "Can't re-insert a dictionary into its pool");
+ }
+ } catch (InterruptedException e) {
+ // I don't think this can happen.
+ return EMPTY_SUGGESTIONS_INFO;
}
- } catch (InterruptedException e) {
- // I don't think this can happen.
- return EMPTY_SUGGESTIONS_INFO;
- }
- final SuggestionsGatherer.Result result = suggestionsGatherer.getResults(text,
- mService.mTypoThreshold, capitalizeType, mLocale);
+ final SuggestionsGatherer.Result result = suggestionsGatherer.getResults(text,
+ mService.mTypoThreshold, capitalizeType, mLocale);
+
+ if (DBG) {
+ Log.i(TAG, "Spell checking results for " + text + " with suggestion limit "
+ + suggestionsLimit);
+ Log.i(TAG, "IsInDict = " + result.mLooksLikeTypo);
+ Log.i(TAG, "LooksLikeTypo = " + result.mLooksLikeTypo);
+ for (String suggestion : result.mSuggestions) {
+ Log.i(TAG, suggestion);
+ }
+ }
- if (DBG) {
- Log.i(TAG, "Spell checking results for " + text + " with suggestion limit "
- + suggestionsLimit);
- Log.i(TAG, "IsInDict = " + result.mLooksLikeTypo);
- Log.i(TAG, "LooksLikeTypo = " + result.mLooksLikeTypo);
- for (String suggestion : result.mSuggestions) {
- Log.i(TAG, suggestion);
+ final int flags =
+ (isInDict ? SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY : 0)
+ | (result.mLooksLikeTypo
+ ? SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO : 0);
+ return new SuggestionsInfo(flags, result.mSuggestions);
+ } catch (RuntimeException e) {
+ // Don't kill the keyboard if there is a bug in the spell checker
+ if (DBG) {
+ throw e;
+ } else {
+ Log.e(TAG, "Exception while spellcheking: " + e);
+ return EMPTY_SUGGESTIONS_INFO;
}
}
-
- final int flags =
- (isInDict ? SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY : 0)
- | (result.mLooksLikeTypo
- ? SuggestionsInfo.RESULT_ATTR_LOOKS_LIKE_TYPO : 0);
- return new SuggestionsInfo(flags, result.mSuggestions);
}
}
}