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; 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.app.AlertDialog;
import android.content.ContentResolver; import android.content.ContentResolver;
import android.content.Context; import android.content.Context;
@ -63,6 +46,24 @@ import android.view.inputmethod.ExtractedTextRequest;
import android.view.inputmethod.InputConnection; import android.view.inputmethod.InputConnection;
import android.widget.TextView; 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.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -747,8 +748,9 @@ public class VoiceProxy implements VoiceInput.UiListener {
// keep showing the warning. // keep showing the warning.
if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) { if (mSubtypeSwitcher.isVoiceMode() && windowToken != null) {
// Close keyboard view if it is been shown. // Close keyboard view if it is been shown.
if (KeyboardSwitcher.getInstance().isInputViewShown()) final LatinKeyboardView keyboardView = KeyboardSwitcher.getInstance().getKeyboardView();
KeyboardSwitcher.getInstance().getKeyboardView().purgeKeyboardAndClosing(); if (keyboardView != null && keyboardView.isShown())
keyboardView.purgeKeyboardAndClosing();
startListening(false, windowToken); startListening(false, windowToken);
} }
// If we have no token, onAttachedToWindow will take care of showing dialog and start // 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); 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() { public Keyboard getKeyboard() {
if (mKeyboardView != null) { if (mKeyboardView != null) {
return mKeyboardView.getKeyboard(); return mKeyboardView.getKeyboard();

View File

@ -291,8 +291,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
latinIme.updateBigramPredictions(); latinIme.updateBigramPredictions();
break; break;
case MSG_VOICE_RESULTS: case MSG_VOICE_RESULTS:
final Keyboard keyboard = switcher.getKeyboard();
latinIme.mVoiceProxy.handleVoiceResults(latinIme.preferCapitalization() latinIme.mVoiceProxy.handleVoiceResults(latinIme.preferCapitalization()
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked())); || (keyboard != null && keyboard.isShiftedOrShiftLocked()));
break; break;
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
setSpacebarTextFadeFactor(inputView, setSpacebarTextFadeFactor(inputView,
@ -987,8 +988,10 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) { private void setSuggestionStripShownInternal(boolean shown, boolean needsInputViewShown) {
// TODO: Modify this if we support suggestions with hard keyboard // TODO: Modify this if we support suggestions with hard keyboard
if (onEvaluateInputViewShown() && mSuggestionsContainer != null) { if (onEvaluateInputViewShown() && mSuggestionsContainer != null) {
final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
final boolean inputViewShown = (keyboardView != null) ? keyboardView.isShown() : false;
final boolean shouldShowSuggestions = shown final boolean shouldShowSuggestions = shown
&& (needsInputViewShown ? mKeyboardSwitcher.isInputViewShown() : true); && (needsInputViewShown ? inputViewShown : true);
if (isFullscreenMode()) { if (isFullscreenMode()) {
mSuggestionsContainer.setVisibility( mSuggestionsContainer.setVisibility(
shouldShowSuggestions ? View.VISIBLE : View.GONE); shouldShowSuggestions ? View.VISIBLE : View.GONE);
@ -1020,7 +1023,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final int extraHeight = extractHeight + backingHeight + suggestionsHeight; final int extraHeight = extractHeight + backingHeight + suggestionsHeight;
int touchY = extraHeight; int touchY = extraHeight;
// Need to set touchable region only if input view is being shown // 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) { if (mSuggestionsContainer.getVisibility() == View.VISIBLE) {
touchY -= suggestionsHeight; touchY -= suggestionsHeight;
} }
@ -1081,9 +1085,11 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
case KeyEvent.KEYCODE_DPAD_UP: case KeyEvent.KEYCODE_DPAD_UP:
case KeyEvent.KEYCODE_DPAD_LEFT: case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_DPAD_RIGHT: case KeyEvent.KEYCODE_DPAD_RIGHT:
final LatinKeyboardView keyboardView = mKeyboardSwitcher.getKeyboardView();
final Keyboard keyboard = mKeyboardSwitcher.getKeyboard();
// Enable shift key and DPAD to do selections // Enable shift key and DPAD to do selections
if (mKeyboardSwitcher.isInputViewShown() if ((keyboardView != null && keyboardView.isShown())
&& mKeyboardSwitcher.isShiftedOrShiftLocked()) { && (keyboard != null && keyboard.isShiftedOrShiftLocked())) {
KeyEvent newEvent = new KeyEvent(event.getDownTime(), event.getEventTime(), KeyEvent newEvent = new KeyEvent(event.getDownTime(), event.getEventTime(),
event.getAction(), event.getKeyCode(), event.getRepeatCount(), event.getAction(), event.getKeyCode(), event.getRepeatCount(),
event.getDeviceId(), event.getScanCode(), event.getDeviceId(), event.getScanCode(),