Merge "Modified the test spell checker"
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index 0ee8d71..68868f1 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -325,6 +325,13 @@
                     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 @@
             } 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 19847c5..8840c79 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.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 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 @@
     /** 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 @@
         mMaxPopupColumn = column;
     }
 
-    public List<Key> getShiftKeys() {
-        return mShiftKeys;
-    }
-
-    public Map<Key, Drawable> getShiftedIcons() {
-        return mShiftedIcons;
-    }
-
-    public void enableShiftLock() {
-        for (final Key key : getShiftKeys()) {
-            mShiftLockEnabled.add(key);
-            mNormalShiftIcons.put(key, key.getIcon());
+    public void addShiftKey(Key key) {
+        if (key == null) return;
+        mShiftKeys.add(key);
+        if (key.mSticky) {
+            mShiftLockKeys.add(key);
         }
     }
 
-    public boolean isShiftLockEnabled(Key key) {
-        return mShiftLockEnabled.contains(key);
+    public void addShiftedIcon(Key key, Drawable icon) {
+        if (key == null) return;
+        mUnshiftedIcons.put(key, key.getIcon());
+        mShiftedIcons.put(key, icon);
+    }
+
+    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 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 3f30165..c3f4d0a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -58,7 +58,6 @@
     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 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 @@
         // {@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 @@
                 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 @@
         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 @@
             && 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 @@
 
     @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 @@
                 (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 552a3cd..0fcd8ae 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -161,24 +161,25 @@
         }
     }
 
+    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 @@
                     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 @@
         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 @@
             } else {
                 xmlId = R.xml.kbd_qwerty;
             }
-            enableShiftLock = true;
             break;
         }
 
@@ -275,7 +267,7 @@
         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 @@
             // 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 @@
         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 c404a5d..b78fd94 100644
--- a/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
+++ b/java/src/com/android/inputmethod/keyboard/LatinKeyboardView.java
@@ -53,55 +53,55 @@
 
     @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 @@
 
     @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 6b6a453..b25754d 100644
--- a/java/src/com/android/inputmethod/keyboard/PointerTracker.java
+++ b/java/src/com/android/inputmethod/keyboard/PointerTracker.java
@@ -329,36 +329,28 @@
         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 8eae2bb..6a83b3d 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 @@
                     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 4baf52e..713f3ab 100644
--- a/java/src/com/android/inputmethod/latin/CandidateView.java
+++ b/java/src/com/android/inputmethod/latin/CandidateView.java
@@ -323,8 +323,11 @@
             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 @@
 
             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 @@
                 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 @@
                 }
                 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 d9d4214..225c7c8 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -872,7 +872,7 @@
     @Override
     public void hideWindow() {
         LatinImeLogger.commit();
-        mKeyboardSwitcher.onAutoCorrectionStateChanged(false);
+        mKeyboardSwitcher.onHideWindow();
 
         if (TRACE) Debug.stopMethodTracing();
         if (mOptionsDialog != null && mOptionsDialog.isShowing()) {
@@ -917,7 +917,7 @@
         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 @@
             }
         };
         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 @@
             }
         };
         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/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
index 8aadee4..7d61d00 100644
--- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
+++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java
@@ -42,7 +42,7 @@
         return new KeyboardId(locale.toString() + " keyboard",
                 com.android.inputmethod.latin.R.xml.kbd_qwerty, locale,
                 Configuration.ORIENTATION_LANDSCAPE, displayWidth, KeyboardId.MODE_TEXT,
-                new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false, false);
+                new EditorInfo(), false, KeyboardId.F2KEY_MODE_NONE, false, false, false);
     }
 
     protected InputStream openTestRawResource(int resIdInTest) {