am e02cf109: am d5a6b910: Purge keyboard only when voice input will be invoked

* commit 'e02cf109644ab5ed8d6e3503e1a3bba4657dc60e':
  Purge keyboard only when voice input will be invoked
main
Tadashi G. Takaoka 2011-01-18 08:49:34 -08:00 committed by Android Git Automerger
commit 886d800efd
4 changed files with 18 additions and 12 deletions

View File

@ -161,9 +161,10 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
final Keyboard oldKeyboard = mInputView.getKeyboard(); final Keyboard oldKeyboard = mInputView.getKeyboard();
loadKeyboardInternal(mode, imeOptions, voiceKeyEnabled, voiceButtonOnPrimary, false); loadKeyboardInternal(mode, imeOptions, voiceKeyEnabled, voiceButtonOnPrimary, false);
final Keyboard newKeyboard = mInputView.getKeyboard(); final Keyboard newKeyboard = mInputView.getKeyboard();
if (newKeyboard.isAlphaKeyboard() && (oldKeyboard == null if (newKeyboard.isAlphaKeyboard()) {
|| !newKeyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale))) { final boolean localeChanged = (oldKeyboard == null)
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(); || !newKeyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
} }
} catch (RuntimeException e) { } catch (RuntimeException e) {
Log.w(TAG, e); Log.w(TAG, e);

View File

@ -1404,11 +1404,15 @@ public class KeyboardView extends View implements PointerTracker.UIProxy {
dismissPopupKeyboard(); dismissPopupKeyboard();
mBuffer = null; mBuffer = null;
mCanvas = null; mCanvas = null;
mKeyboard = null;
mMiniKeyboardCache.clear(); mMiniKeyboardCache.clear();
requestLayout(); requestLayout();
} }
public void purgeKeyboardAndClosing() {
mKeyboard = null;
closing();
}
@Override @Override
public void onDetachedFromWindow() { public void onDetachedFromWindow() {
super.onDetachedFromWindow(); super.onDetachedFromWindow();

View File

@ -154,7 +154,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
private boolean mConfigSwipeDownDismissKeyboardEnabled; private boolean mConfigSwipeDownDismissKeyboardEnabled;
private int mConfigDelayBeforeFadeoutLanguageOnSpacebar; private int mConfigDelayBeforeFadeoutLanguageOnSpacebar;
private int mConfigDurationOfFadeoutLanguageOnSpacebar; private int mConfigDurationOfFadeoutLanguageOnSpacebar;
private float mConfigFinalFadeoutFactorOfLanugageOnSpacebar; private float mConfigFinalFadeoutFactorOfLanguageOnSpacebar;
private int mCorrectionMode; private int mCorrectionMode;
private int mCommittedLength; private int mCommittedLength;
@ -269,7 +269,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
if (inputView != null) if (inputView != null)
inputView.setSpacebarTextFadeFactor( inputView.setSpacebarTextFadeFactor(
(1.0f + mConfigFinalFadeoutFactorOfLanugageOnSpacebar) / 2, (1.0f + mConfigFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
(LatinKeyboard)msg.obj); (LatinKeyboard)msg.obj);
sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj), sendMessageDelayed(obtainMessage(MSG_DISMISS_LANGUAGE_ON_SPACEBAR, msg.obj),
mConfigDurationOfFadeoutLanguageOnSpacebar); mConfigDurationOfFadeoutLanguageOnSpacebar);
@ -277,7 +277,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR: case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
if (inputView != null) if (inputView != null)
inputView.setSpacebarTextFadeFactor( inputView.setSpacebarTextFadeFactor(
mConfigFinalFadeoutFactorOfLanugageOnSpacebar, (LatinKeyboard)msg.obj); mConfigFinalFadeoutFactorOfLanguageOnSpacebar, (LatinKeyboard)msg.obj);
break; break;
} }
} }
@ -318,7 +318,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
sendMessage(obtainMessage(MSG_VOICE_RESULTS)); sendMessage(obtainMessage(MSG_VOICE_RESULTS));
} }
public void startDisplayLanguageOnSpacebar() { public void startDisplayLanguageOnSpacebar(boolean localeChanged) {
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR); removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR); removeMessages(MSG_DISMISS_LANGUAGE_ON_SPACEBAR);
final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView(); final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
@ -326,9 +326,10 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
final LatinKeyboard keyboard = inputView.getLatinKeyboard(); final LatinKeyboard keyboard = inputView.getLatinKeyboard();
// The language is never displayed when the delay is zero. // The language is never displayed when the delay is zero.
if (mConfigDelayBeforeFadeoutLanguageOnSpacebar != 0) if (mConfigDelayBeforeFadeoutLanguageOnSpacebar != 0)
inputView.setSpacebarTextFadeFactor(1.0f, keyboard); inputView.setSpacebarTextFadeFactor(localeChanged ? 1.0f
: mConfigFinalFadeoutFactorOfLanguageOnSpacebar, keyboard);
// The language is always displayed when the delay is negative. // The language is always displayed when the delay is negative.
if (mConfigDelayBeforeFadeoutLanguageOnSpacebar > 0) { if (localeChanged && mConfigDelayBeforeFadeoutLanguageOnSpacebar > 0) {
sendMessageDelayed(obtainMessage(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR, keyboard), sendMessageDelayed(obtainMessage(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR, keyboard),
mConfigDelayBeforeFadeoutLanguageOnSpacebar); mConfigDelayBeforeFadeoutLanguageOnSpacebar);
} }
@ -360,7 +361,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
R.integer.config_delay_before_fadeout_language_on_spacebar); R.integer.config_delay_before_fadeout_language_on_spacebar);
mConfigDurationOfFadeoutLanguageOnSpacebar = res.getInteger( mConfigDurationOfFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_duration_of_fadeout_language_on_spacebar); R.integer.config_duration_of_fadeout_language_on_spacebar);
mConfigFinalFadeoutFactorOfLanugageOnSpacebar = res.getInteger( mConfigFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f; R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
Utils.GCUtils.getInstance().reset(); Utils.GCUtils.getInstance().reset();

View File

@ -631,7 +631,7 @@ public class VoiceIMEConnector implements VoiceInput.UiListener {
if (mSubtypeSwitcher.isVoiceMode() && token != null) { if (mSubtypeSwitcher.isVoiceMode() && token != null) {
// Close keyboard view if it is been shown. // Close keyboard view if it is been shown.
if (KeyboardSwitcher.getInstance().isInputViewShown()) if (KeyboardSwitcher.getInstance().isInputViewShown())
KeyboardSwitcher.getInstance().getInputView().closing(); KeyboardSwitcher.getInstance().getInputView().purgeKeyboardAndClosing();
startListening(false, token, false); startListening(false, token, false);
} }
// 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