diff options
Diffstat (limited to 'java/src')
10 files changed, 116 insertions, 125 deletions
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 0ee8d7174..68868f12e 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -325,6 +325,13 @@ public class Key { keyAttr, R.styleable.Keyboard_Key_keyIcon, KeyboardIconsSet.ICON_UNDEFINED)); Keyboard.setDefaultBounds(mIcon); + final int shiftedIconId = style.getInt(keyAttr, R.styleable.Keyboard_Key_keyIconShifted, + KeyboardIconsSet.ICON_UNDEFINED); + if (shiftedIconId != KeyboardIconsSet.ICON_UNDEFINED) { + final Drawable shiftedIcon = iconsSet.getIcon(shiftedIconId); + Keyboard.setDefaultBounds(shiftedIcon); + mKeyboard.addShiftedIcon(this, shiftedIcon); + } mHintLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyHintLabel); mLabel = style.getText(keyAttr, R.styleable.Keyboard_Key_keyLabel); @@ -342,12 +349,9 @@ public class Key { } else { mCode = Keyboard.CODE_DUMMY; } - - final Drawable shiftedIcon = iconsSet.getIcon(style.getInt( - keyAttr, R.styleable.Keyboard_Key_keyIconShifted, - KeyboardIconsSet.ICON_UNDEFINED)); - if (shiftedIcon != null) - mKeyboard.getShiftedIcons().put(this, shiftedIcon); + if (mCode == Keyboard.CODE_SHIFT) { + mKeyboard.addShiftKey(this); + } } finally { keyAttr.recycle(); } diff --git a/java/src/com/android/inputmethod/keyboard/Keyboard.java b/java/src/com/android/inputmethod/keyboard/Keyboard.java index 19847c5ec..8840c79da 100644 --- a/java/src/com/android/inputmethod/keyboard/Keyboard.java +++ b/java/src/com/android/inputmethod/keyboard/Keyboard.java @@ -34,7 +34,6 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; -import java.util.Map; /** * Loads an XML description of a keyboard and stores the attributes of the keys. A keyboard @@ -77,6 +76,8 @@ public class Keyboard { public static final int CODE_CLOSING_SQUARE_BRACKET = ']'; public static final int CODE_CLOSING_CURLY_BRACKET = '}'; public static final int CODE_CLOSING_ANGLE_BRACKET = '>'; + public static final int CODE_DIGIT0 = '0'; + public static final int CODE_PLUS = '+'; /** Special keys code. These should be aligned with values/keycodes.xml */ @@ -116,8 +117,8 @@ public class Keyboard { /** List of shift keys in this keyboard and its icons and state */ private final List<Key> mShiftKeys = new ArrayList<Key>(); private final HashMap<Key, Drawable> mShiftedIcons = new HashMap<Key, Drawable>(); - private final HashMap<Key, Drawable> mNormalShiftIcons = new HashMap<Key, Drawable>(); - private final HashSet<Key> mShiftLockEnabled = new HashSet<Key>(); + private final HashMap<Key, Drawable> mUnshiftedIcons = new HashMap<Key, Drawable>(); + private final HashSet<Key> mShiftLockKeys = new HashSet<Key>(); private final KeyboardShiftState mShiftState = new KeyboardShiftState(); /** Total height of the keyboard, including the padding and keys */ @@ -284,30 +285,35 @@ public class Keyboard { mMaxPopupColumn = column; } - public List<Key> getShiftKeys() { - return mShiftKeys; + public void addShiftKey(Key key) { + if (key == null) return; + mShiftKeys.add(key); + if (key.mSticky) { + mShiftLockKeys.add(key); + } } - public Map<Key, Drawable> getShiftedIcons() { - return mShiftedIcons; + public void addShiftedIcon(Key key, Drawable icon) { + if (key == null) return; + mUnshiftedIcons.put(key, key.getIcon()); + mShiftedIcons.put(key, icon); } - public void enableShiftLock() { - for (final Key key : getShiftKeys()) { - mShiftLockEnabled.add(key); - mNormalShiftIcons.put(key, key.getIcon()); - } - } - - public boolean isShiftLockEnabled(Key key) { - return mShiftLockEnabled.contains(key); + public boolean hasShiftLockKey() { + return !mShiftLockKeys.isEmpty(); } public boolean setShiftLocked(boolean newShiftLockState) { - final Map<Key, Drawable> shiftedIcons = getShiftedIcons(); - for (final Key key : getShiftKeys()) { + for (final Key key : mShiftLockKeys) { + // To represent "shift locked" state. The highlight is handled by background image that + // might be a StateListDrawable. key.setHighlightOn(newShiftLockState); - key.setIcon(newShiftLockState ? shiftedIcons.get(key) : mNormalShiftIcons.get(key)); + // To represent "shifted" state. The key might have a shifted icon. + if (newShiftLockState && mShiftedIcons.containsKey(key)) { + key.setIcon(mShiftedIcons.get(key)); + } else { + key.setIcon(mUnshiftedIcons.get(key)); + } } mShiftState.setShiftLocked(newShiftLockState); return true; @@ -318,12 +324,11 @@ public class Keyboard { } public boolean setShifted(boolean newShiftState) { - final Map<Key, Drawable> shiftedIcons = getShiftedIcons(); - for (final Key key : getShiftKeys()) { + for (final Key key : mShiftKeys) { if (!newShiftState && !mShiftState.isShiftLocked()) { - key.setIcon(mNormalShiftIcons.get(key)); + key.setIcon(mUnshiftedIcons.get(key)); } else if (newShiftState && !mShiftState.isShiftedOrShiftLocked()) { - key.setIcon(shiftedIcons.get(key)); + key.setIcon(mShiftedIcons.get(key)); } } return mShiftState.setShifted(newShiftState); diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 3f30165aa..c3f4d0aa2 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -58,7 +58,6 @@ public class KeyboardId { public final boolean mVoiceKeyEnabled; public final boolean mHasVoiceKey; public final int mImeAction; - public final boolean mEnableShiftLock; public final String mXmlName; public final EditorInfo mAttribute; @@ -67,8 +66,7 @@ public class KeyboardId { public KeyboardId(String xmlName, int xmlId, Locale locale, int orientation, int width, int mode, EditorInfo attribute, boolean hasSettingsKey, int f2KeyMode, - boolean clobberSettingsKey, boolean voiceKeyEnabled, boolean hasVoiceKey, - boolean enableShiftLock) { + boolean clobberSettingsKey, boolean voiceKeyEnabled, boolean hasVoiceKey) { final int inputType = (attribute != null) ? attribute.inputType : 0; final int imeOptions = (attribute != null) ? attribute.imeOptions : 0; this.mLocale = locale; @@ -91,7 +89,6 @@ public class KeyboardId { // {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION}. this.mImeAction = imeOptions & ( EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION); - this.mEnableShiftLock = enableShiftLock; this.mXmlName = xmlName; this.mAttribute = attribute; @@ -110,21 +107,19 @@ public class KeyboardId { voiceKeyEnabled, hasVoiceKey, mImeAction, - enableShiftLock, }); } public KeyboardId cloneAsMiniKeyboard() { return new KeyboardId("mini popup keyboard", MINI_KEYBOARD_ID_MARKER, mLocale, mOrientation, - mWidth, mMode, mAttribute, false, F2KEY_MODE_NONE, false, false, false, false); + mWidth, mMode, mAttribute, false, F2KEY_MODE_NONE, false, false, false); } public KeyboardId cloneWithNewGeometry(int orientation, int width) { if (mWidth == width) return this; return new KeyboardId(mXmlName, mXmlId, mLocale, orientation, width, mMode, mAttribute, - mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey, - mEnableShiftLock); + mHasSettingsKey, mF2KeyMode, mClobberSettingsKey, mVoiceKeyEnabled, mHasVoiceKey); } public int getXmlId() { @@ -160,7 +155,7 @@ public class KeyboardId { return other instanceof KeyboardId && equals((KeyboardId) other); } - boolean equals(KeyboardId other) { + private boolean equals(KeyboardId other) { return other.mLocale.equals(this.mLocale) && other.mOrientation == this.mOrientation && other.mWidth == this.mWidth @@ -173,8 +168,7 @@ public class KeyboardId { && other.mClobberSettingsKey == this.mClobberSettingsKey && other.mVoiceKeyEnabled == this.mVoiceKeyEnabled && other.mHasVoiceKey == this.mHasVoiceKey - && other.mImeAction == this.mImeAction - && other.mEnableShiftLock == this.mEnableShiftLock; + && other.mImeAction == this.mImeAction; } @Override @@ -184,7 +178,7 @@ public class KeyboardId { @Override public String toString() { - return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s%s]", + return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s%s]", mXmlName, mLocale, (mOrientation == 1 ? "port" : "land"), mWidth, @@ -196,8 +190,7 @@ public class KeyboardId { (mPasswordInput ? " passwordInput" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""), (mVoiceKeyEnabled ? " voiceKeyEnabled" : ""), - (mHasVoiceKey ? " hasVoiceKey" : ""), - (mEnableShiftLock ? " enableShiftLock" : "") + (mHasVoiceKey ? " hasVoiceKey" : "") ); } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 552a3cd30..0fcd8aeb9 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -161,24 +161,25 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } } + public void onHideWindow() { + mWindowWidth = 0; + mIsAutoCorrectionActive = false; + } + @SuppressWarnings("unused") public void onSizeChanged(int w, int h, int oldw, int oldh) { + // TODO: This hack should be removed when display metric returns a proper width. + // Until then, the behavior of KeyboardSwitcher is suboptimal on a device that has a + // vertical system navigation bar in landscape screen orientation, for instance. final int width = mInputMethodService.getWindow().getWindow().getDecorView().getWidth(); // If the window width hasn't fixed yet or keyboard doesn't exist, nothing to do with. if (width == 0 || mCurrentId == null) return; // The window width is fixed. mWindowWidth = width; - // If this is the first time the {@link KeyboardView} has been shown, no need to reload - // keyboard. - if (oldw == 0 && oldh == 0) - return; // Reload keyboard with new width. final int orientation = mInputMethodService.getResources().getConfiguration().orientation; final KeyboardId newId = mCurrentId.cloneWithNewGeometry(orientation, width); - // If the new keyboard is the same as the current one, no need to reload it. - if (newId.equals(mCurrentId)) - return; setKeyboard(getKeyboard(newId)); } @@ -204,11 +205,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha mSubtypeSwitcher.getInputLocale()); keyboard = new LatinKeyboard(mThemeContext, id, id.mWidth); - - if (id.mEnableShiftLock) { - keyboard.enableShiftLock(); - } - mKeyboardCache.put(id, new SoftReference<LatinKeyboard>(keyboard)); if (DEBUG_CACHE) Log.d(TAG, "keyboard cache size=" + mKeyboardCache.size() + ": " @@ -241,16 +237,13 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha final int mode = Utils.getKeyboardMode(attribute); final boolean hasVoiceKey = voiceKeyEnabled && (isSymbols != voiceKeyOnMain); final int xmlId; - final boolean enableShiftLock; switch (mode) { case KeyboardId.MODE_PHONE: xmlId = (isSymbols && isShift) ? R.xml.kbd_phone_shift : R.xml.kbd_phone; - enableShiftLock = true; break; case KeyboardId.MODE_NUMBER: xmlId = R.xml.kbd_number; - enableShiftLock = false; break; default: if (isSymbols) { @@ -258,7 +251,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha } else { xmlId = R.xml.kbd_qwerty; } - enableShiftLock = true; break; } @@ -275,7 +267,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha return new KeyboardId( res.getResourceEntryName(xmlId), xmlId, locale, orientation, mWindowWidth, mode, attribute, hasSettingsKey, f2KeyMode, clobberSettingsKey, voiceKeyEnabled, - hasVoiceKey, enableShiftLock); + hasVoiceKey); } public int getKeyboardMode() { @@ -571,7 +563,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha // Symbol keyboard may have an ALT key that has a caps lock style indicator (a.k.a. // sticky shift key). To show or dismiss the indicator, we need to call setShiftLocked() // that takes care of the current keyboard having such ALT key or not. - keyboard.setShiftLocked(hasStickyShiftKey(keyboard)); + keyboard.setShiftLocked(keyboard.hasShiftLockKey()); } else { keyboard = getKeyboard(mSymbolsKeyboardId); // Symbol keyboard has an ALT key that has a caps lock style indicator. To disable the @@ -581,14 +573,6 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha setKeyboard(keyboard); } - private static boolean hasStickyShiftKey(Keyboard keyboard) { - for (final Key shiftKey : keyboard.getShiftKeys()) { - if (shiftKey.mSticky) - return true; - } - return false; - } - public boolean isInMomentarySwitchState() { return mSwitchState == SWITCH_STATE_MOMENTARY_ALPHA_AND_SYMBOL || mSwitchState == SWITCH_STATE_MOMENTARY_SYMBOL_AND_MORE; diff --git a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java index c404a5dfb..b78fd94ea 100644 --- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java @@ -53,55 +53,55 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { @Override public void setKeyPreviewPopupEnabled(boolean previewEnabled, int delay) { - LatinKeyboard latinKeyboard = getLatinKeyboard(); - if (latinKeyboard != null - && (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard())) { - // Phone and number keyboard never shows popup preview (except language switch). - super.setKeyPreviewPopupEnabled(false, delay); - } else { - super.setKeyPreviewPopupEnabled(previewEnabled, delay); + final Keyboard keyboard = getKeyboard(); + if (keyboard instanceof LatinKeyboard) { + final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard; + if (latinKeyboard.isPhoneKeyboard() || latinKeyboard.isNumberKeyboard()) { + // Phone and number keyboard never shows popup preview. + super.setKeyPreviewPopupEnabled(false, delay); + return; + } } + super.setKeyPreviewPopupEnabled(previewEnabled, delay); } @Override public void setKeyboard(Keyboard newKeyboard) { super.setKeyboard(newKeyboard); // One-seventh of the keyboard width seems like a reasonable threshold - mJumpThresholdSquare = newKeyboard.getMinWidth() / 7; - mJumpThresholdSquare *= mJumpThresholdSquare; - } - - private LatinKeyboard getLatinKeyboard() { - Keyboard keyboard = getKeyboard(); - if (keyboard instanceof LatinKeyboard) { - return (LatinKeyboard)keyboard; - } else { - return null; - } + final int jumpThreshold = newKeyboard.getMinWidth() / 7; + mJumpThresholdSquare = jumpThreshold * jumpThreshold; } public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) { - final LatinKeyboard currentKeyboard = getLatinKeyboard(); + final Keyboard keyboard = getKeyboard(); // We should not set text fade factor to the keyboard which does not display the language on // its spacebar. - if (currentKeyboard != null && currentKeyboard == oldKeyboard) - currentKeyboard.setSpacebarTextFadeFactor(fadeFactor, this); + if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) { + ((LatinKeyboard)keyboard).setSpacebarTextFadeFactor(fadeFactor, this); + } } @Override protected boolean onLongPress(Key key, PointerTracker tracker) { - int primaryCode = key.mCode; + final int primaryCode = key.mCode; + final Keyboard keyboard = getKeyboard(); + if (keyboard instanceof LatinKeyboard) { + final LatinKeyboard latinKeyboard = (LatinKeyboard) keyboard; + if (primaryCode == Keyboard.CODE_DIGIT0 && latinKeyboard.isPhoneKeyboard()) { + tracker.onLongPressed(); + // Long pressing on 0 in phone number keypad gives you a '+'. + return invokeOnKey(Keyboard.CODE_PLUS); + } + if (primaryCode == Keyboard.CODE_SHIFT && latinKeyboard.isAlphaKeyboard()) { + tracker.onLongPressed(); + return invokeOnKey(Keyboard.CODE_CAPSLOCK); + } + } if (primaryCode == Keyboard.CODE_SETTINGS || primaryCode == Keyboard.CODE_SPACE) { tracker.onLongPressed(); // Both long pressing settings key and space key invoke IME switcher dialog. return invokeOnKey(Keyboard.CODE_SETTINGS_LONGPRESS); - } else if (primaryCode == '0' && getLatinKeyboard().isPhoneKeyboard()) { - tracker.onLongPressed(); - // Long pressing on 0 in phone number keypad gives you a '+'. - return invokeOnKey('+'); - } else if (primaryCode == Keyboard.CODE_SHIFT) { - tracker.onLongPressed(); - return invokeOnKey(Keyboard.CODE_CAPSLOCK); } else { return super.onLongPress(key, tracker); } @@ -194,7 +194,7 @@ public class LatinKeyboardView extends LatinKeyboardBaseView { @Override public boolean onTouchEvent(MotionEvent me) { - if (getLatinKeyboard() == null) return true; + if (getKeyboard() == null) return true; // If there was a sudden jump, return without processing the actual motion event. if (handleSuddenJump(me)) { diff --git a/java/src/com/android/inputmethod/keyboard/PointerTracker.java b/java/src/com/android/inputmethod/keyboard/PointerTracker.java index 6b6a4538f..b25754de4 100644 --- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java +++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java @@ -329,36 +329,28 @@ public class PointerTracker { return mKeyDetector.getKeyIndexAndNearbyCodes(x, y, null); } - public boolean isSpaceKey(int keyIndex) { - Key key = getKey(keyIndex); - return key != null && key.mCode == Keyboard.CODE_SPACE; - } - private void setReleasedKeyGraphics(int keyIndex) { mDrawingProxy.dismissKeyPreview(this); final Key key = getKey(keyIndex); - if (key != null) { + if (key != null && key.isEnabled()) { key.onReleased(); mDrawingProxy.invalidateKey(key); } } private void setPressedKeyGraphics(int keyIndex) { - if (isKeyPreviewRequired(keyIndex)) { - mDrawingProxy.showKeyPreview(keyIndex, this); - } final Key key = getKey(keyIndex); if (key != null && key.isEnabled()) { + if (isKeyPreviewRequired(key)) { + mDrawingProxy.showKeyPreview(keyIndex, this); + } key.onPressed(); mDrawingProxy.invalidateKey(key); } } // The modifier key, such as shift key, should not show its key preview. - private boolean isKeyPreviewRequired(int keyIndex) { - final Key key = getKey(keyIndex); - if (key == null || !key.isEnabled()) - return false; + private static boolean isKeyPreviewRequired(Key key) { final int code = key.mCode; if (isModifierCode(code) || code == Keyboard.CODE_DELETE || code == Keyboard.CODE_ENTER || code == Keyboard.CODE_SPACE) diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java index 8eae2bb42..6a83b3d99 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardParser.java @@ -338,8 +338,6 @@ public class KeyboardParser { Arrays.toString(key.mPopupCharacters))); checkEndTag(TAG_KEY, parser); keys.add(key); - if (key.mCode == Keyboard.CODE_SHIFT) - mKeyboard.getShiftKeys().add(key); endKey(key); } } diff --git a/java/src/com/android/inputmethod/latin/CandidateView.java b/java/src/com/android/inputmethod/latin/CandidateView.java index 4baf52e52..713f3abe2 100644 --- a/java/src/com/android/inputmethod/latin/CandidateView.java +++ b/java/src/com/android/inputmethod/latin/CandidateView.java @@ -323,8 +323,11 @@ public class CandidateView extends LinearLayout implements OnClickListener { word.setTag(i); word.setOnClickListener(this); mWords.add(word); + final View divider = inflater.inflate(R.layout.candidate_divider, null); + divider.setTag(i); + divider.setOnClickListener(this); + mDividers.add(divider); mInfos.add((TextView)inflater.inflate(R.layout.candidate_info, null)); - mDividers.add(inflater.inflate(R.layout.candidate_divider, null)); } mTouchToSave = findViewById(R.id.touch_to_save); @@ -476,6 +479,7 @@ public class CandidateView extends LinearLayout implements OnClickListener { final TextView word = mWords.get(pos); final TextPaint paint = word.getPaint(); + final View divider = mDividers.get(pos); // TODO: Reorder candidates in strip as appropriate. The center candidate should hold // the word when space is typed (valid typed word or auto corrected word). word.setTextColor(getCandidateTextColor(isAutoCorrect, @@ -505,7 +509,7 @@ public class CandidateView extends LinearLayout implements OnClickListener { word.setTextScaleX(scaleX); if (i != 0) { // Add divider if this isn't the left most suggestion in candidate strip. - mCandidatesStrip.addView(mDividers.get(i)); + mCandidatesStrip.addView(divider); } mCandidatesStrip.addView(word); if (params.mCanUseFixedWidthColumns) { @@ -534,7 +538,6 @@ public class CandidateView extends LinearLayout implements OnClickListener { } if (x != 0) { // Add divider if this isn't the left most suggestion in current row. - final View divider = mDividers.get(i); mCandidatesPane.addView(divider); FrameLayoutCompatUtils.placeViewAt( divider, x, y + (mCandidateStripHeight - params.mDividerHeight) / 2, diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index d9d421411..225c7c899 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -872,7 +872,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar @Override public void hideWindow() { LatinImeLogger.commit(); - mKeyboardSwitcher.onAutoCorrectionStateChanged(false); + mKeyboardSwitcher.onHideWindow(); if (TRACE) Debug.stopMethodTracing(); if (mOptionsDialog != null && mOptionsDialog.isShowing()) { @@ -917,7 +917,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar if (onEvaluateInputViewShown() && mCandidateViewContainer != null) { final boolean shouldShowCandidates = shown && (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true); - if (isExtractViewShown()) { + if (isFullscreenMode()) { // No need to have extra space to show the key preview. mCandidateViewContainer.setMinimumHeight(0); mCandidateViewContainer.setVisibility( @@ -2163,8 +2163,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } }; final AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setIcon(R.drawable.ic_dialog_keyboard) - .setNegativeButton(android.R.string.cancel, null) .setItems(items, listener) .setTitle(title); showOptionDialogInternal(builder.create()); @@ -2191,8 +2189,6 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar } }; final AlertDialog.Builder builder = new AlertDialog.Builder(this) - .setIcon(R.drawable.ic_dialog_keyboard) - .setNegativeButton(android.R.string.cancel, null) .setItems(items, listener) .setTitle(title); showOptionDialogInternal(builder.create()); diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 156510b40..ae938aea8 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -17,6 +17,7 @@ package com.android.inputmethod.latin.spellcheck; import android.service.textservice.SpellCheckerService; +import android.util.Log; import android.view.textservice.SuggestionsInfo; import android.view.textservice.TextInfo; @@ -24,11 +25,26 @@ import android.view.textservice.TextInfo; * Service for spell checking, using LatinIME's dictionaries and mechanisms. */ public class AndroidSpellCheckerService extends SpellCheckerService { + private static final String TAG = AndroidSpellCheckerService.class.getSimpleName(); + private static final boolean DBG = true; @Override public SuggestionsInfo getSuggestions(TextInfo textInfo, int suggestionsLimit, String locale) { // TODO: implement this - String[] candidates = new String[] {"candidate1", "candidate2", "candidate3"}; - return new SuggestionsInfo(0, candidates); + final String text = textInfo.getText(); + if (DBG) { + Log.w(TAG, "getSuggestions: " + text); + } + String[] candidates0 = new String[] {text, "candidate1", "candidate2", "candidate3"}; + String[] candidates1 = new String[] {text, "candidateA", "candidateB"}; + final int textLength = textInfo.getText().length() % 3; + if (textLength % 3 == 0) { + return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_LOOKS_TYPO + | SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY, candidates0); + } else if (textLength % 3 == 1) { + return new SuggestionsInfo(SuggestionsInfo.RESULT_ATTR_IN_THE_DICTIONARY, candidates1); + } else { + return new SuggestionsInfo(0, null); + } } } |