am aab33aac: Merge "Cleanup redundant methods of KeyboardSwitcher"

* commit 'aab33aac0a3f4755e6a533dea1025b450507e116':
  Cleanup redundant methods of KeyboardSwitcher
main
Tadashi G. Takaoka 2012-01-31 01:34:44 -08:00 committed by Android Git Automerger
commit 0f33b17d4f
3 changed files with 32 additions and 41 deletions

View File

@ -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.ExtractedTextRequest;
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 @@ public class VoiceProxy implements VoiceInput.UiListener {
// 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

View File

@ -179,23 +179,6 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
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();

View File

@ -291,8 +291,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
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 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
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 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
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 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
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(),