Cleanup redundant methods of KeyboardSwitcher

Change-Id: I2ebeb8852177f6c6e30578d0bb3f372f488dc6c1
diff --git a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
index a013ebc..f632b0e 100644
--- a/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
+++ b/java/src/com/android/inputmethod/deprecated/VoiceProxy.java
@@ -16,23 +16,6 @@
 
 package com.android.inputmethod.deprecated;
 
-import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
-import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
-import com.android.inputmethod.compat.SharedPreferencesCompat;
-import com.android.inputmethod.deprecated.voice.FieldContext;
-import com.android.inputmethod.deprecated.voice.Hints;
-import com.android.inputmethod.deprecated.voice.SettingsUtil;
-import com.android.inputmethod.deprecated.voice.VoiceInput;
-import com.android.inputmethod.keyboard.KeyboardSwitcher;
-import com.android.inputmethod.latin.EditingUtils;
-import com.android.inputmethod.latin.LatinIME;
-import com.android.inputmethod.latin.LatinIME.UIHandler;
-import com.android.inputmethod.latin.LatinImeLogger;
-import com.android.inputmethod.latin.R;
-import com.android.inputmethod.latin.SubtypeSwitcher;
-import com.android.inputmethod.latin.SuggestedWords;
-import com.android.inputmethod.latin.Utils;
-
 import android.app.AlertDialog;
 import android.content.ContentResolver;
 import android.content.Context;
@@ -63,6 +46,24 @@
 import android.view.inputmethod.InputConnection;
 import android.widget.TextView;
 
+import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
+import com.android.inputmethod.compat.InputMethodServiceCompatWrapper;
+import com.android.inputmethod.compat.SharedPreferencesCompat;
+import com.android.inputmethod.deprecated.voice.FieldContext;
+import com.android.inputmethod.deprecated.voice.Hints;
+import com.android.inputmethod.deprecated.voice.SettingsUtil;
+import com.android.inputmethod.deprecated.voice.VoiceInput;
+import com.android.inputmethod.keyboard.KeyboardSwitcher;
+import com.android.inputmethod.keyboard.LatinKeyboardView;
+import com.android.inputmethod.latin.EditingUtils;
+import com.android.inputmethod.latin.LatinIME;
+import com.android.inputmethod.latin.LatinIME.UIHandler;
+import com.android.inputmethod.latin.LatinImeLogger;
+import com.android.inputmethod.latin.R;
+import com.android.inputmethod.latin.SubtypeSwitcher;
+import com.android.inputmethod.latin.SuggestedWords;
+import com.android.inputmethod.latin.Utils;
+
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.List;
@@ -747,8 +748,9 @@
         // keep showing the warning.
         if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) {
             // Close keyboard view if it is been shown.
-            if (KeyboardSwitcher.getInstance().isInputViewShown())
-                KeyboardSwitcher.getInstance().getKeyboardView().purgeKeyboardAndClosing();
+            final LatinKeyboardView keyboardView = KeyboardSwitcher.getInstance().getKeyboardView();
+            if (keyboardView != null && keyboardView.isShown())
+                keyboardView.purgeKeyboardAndClosing();
             startListening(false, windowToken);
         }
         // If we have no token, onAttachedToWindow will take care of showing dialog and start
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 17ad45d..40bbc20 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -179,23 +179,6 @@
         mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
     }
 
-    // TODO: Remove this method.
-    public boolean isAlphabetMode() {
-        final Keyboard keyboard = getKeyboard();
-        return keyboard != null && keyboard.mId.isAlphabetKeyboard();
-    }
-
-    // TODO: Remove this method.
-    public boolean isInputViewShown() {
-        return mCurrentInputView != null && mCurrentInputView.isShown();
-    }
-
-    // TODO: Remove this method.
-    public boolean isShiftedOrShiftLocked() {
-        final Keyboard keyboard = getKeyboard();
-        return keyboard != null && keyboard.isShiftedOrShiftLocked();
-    }
-
     public Keyboard getKeyboard() {
         if (mKeyboardView != null) {
             return mKeyboardView.getKeyboard();
diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java
index 0d6395d..1e71714 100644
--- a/java/src/com/android/inputmethod/latin/LatinIME.java
+++ b/java/src/com/android/inputmethod/latin/LatinIME.java
@@ -291,8 +291,9 @@
                 latinIme.updateBigramPredictions();
                 break;
             case MSG_VOICE_RESULTS:
+                final Keyboard keyboard = switcher.getKeyboard();
                 latinIme.mVoiceProxy.handleVoiceResults(latinIme.preferCapitalization()
-                        || (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
+                        || (keyboard != null && keyboard.isShiftedOrShiftLocked()));
                 break;
             case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
                 setSpacebarTextFadeFactor(inputView,
@@ -987,8 +988,10 @@
     private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
         // TODO: Modify this if we support suggestions with hard keyboard
         if (onEvaluateInputViewShown() && mSuggestionsContainer != null) {
+            final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
+            final boolean inputViewShown = (keyboardView != null) ? keyboardView.isShown() : false;
             final boolean shouldShowSuggestions = shown
-                    && (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true);
+                    && (needsInputViewShown ? inputViewShown : true);
             if (isFullscreenMode()) {
                 mSuggestionsContainer.setVisibility(
                         shouldShowSuggestions ? View.VISIBLE : View.GONE);
@@ -1020,7 +1023,8 @@
         final int extraHeight = extractHeight + backingHeight + suggestionsHeight;
         int touchY = extraHeight;
         // Need to set touchable region only if input view is being shown
-        if (mKeyboardSwitcher.isInputViewShown()) {
+        final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
+        if (keyboardView != null && keyboardView.isShown()) {
             if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
                 touchY -= suggestionsHeight;
             }
@@ -1081,9 +1085,11 @@
         case KeyEvent.KEYCODE_DPAD_UP:
         case KeyEvent.KEYCODE_DPAD_LEFT:
         case KeyEvent.KEYCODE_DPAD_RIGHT:
+            final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
+            final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
             // Enable shift key and DPAD to do selections
-            if (mKeyboardSwitcher.isInputViewShown()
-                    && mKeyboardSwitcher.isShiftedOrShiftLocked()) {
+            if ((keyboardView != null && keyboardView.isShown())
+                    && (keyboard != null && keyboard.isShiftedOrShiftLocked())) {
                 KeyEvent newEvent = new KeyEvent(event.getDownTime(), event.getEventTime(),
                         event.getAction(), event.getKeyCode(), event.getRepeatCount(),
                         event.getDeviceId(), event.getScanCode(),