Merge "Refactor to suppress null worning"
diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java
index b8d04e0..79c7ce0 100644
--- a/java/src/com/android/inputmethod/keyboard/Key.java
+++ b/java/src/com/android/inputmethod/keyboard/Key.java
@@ -558,11 +558,8 @@
     }
 
     public Drawable getIcon(KeyboardIconsSet iconSet) {
-        return iconSet.getIconDrawable(mIconId);
-    }
-
-    public Drawable getDisabledIcon(KeyboardIconsSet iconSet) {
-        return iconSet.getIconDrawable(mDisabledIconId);
+        final int iconId = mEnabled ? mIconId : mDisabledIconId;
+        return iconSet.getIconDrawable(iconId);
     }
 
     public Drawable getPreviewIcon(KeyboardIconsSet iconSet) {
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 59fa66d..edc4efd 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -1114,12 +1114,12 @@
     // and the composingStateManager about it.
     private void resetEntireInputState() {
         resetComposingState(true /* alsoResetLastComposedWord */);
+        mComposingStateManager.onFinishComposingText();
         updateSuggestions();
         final InputConnection ic = getCurrentInputConnection();
         if (ic != null) {
             ic.finishComposingText();
         }
-        mComposingStateManager.onFinishComposingText();
         mVoiceProxy.setVoiceInputHighlighted(false);
     }
 
@@ -1536,8 +1536,8 @@
                 // it entirely and resume suggestions on the previous word, we'd like to still
                 // have touch coordinates for it.
                 resetComposingState(false /* alsoResetLastComposedWord */);
-                clearSuggestions();
                 mComposingStateManager.onFinishComposingText();
+                clearSuggestions();
             }
         }
         if (isComposingWord) {
@@ -1897,12 +1897,11 @@
                 mSuggestionsView.clear();
             }
             mKeyboardSwitcher.updateShiftState();
+            resetComposingState(true /* alsoResetLastComposedWord */);
             final InputConnection ic = getCurrentInputConnection();
             if (ic != null) {
-                ic.beginBatchEdit();
                 final CompletionInfo completionInfo = mApplicationSpecifiedCompletions[index];
                 ic.commitCompletion(completionInfo);
-                ic.endBatchEdit();
             }
             return;
         }