am 49cc3beb: resolved conflicts for merge of 137667ed to master

* commit '49cc3beb75e2916037a0f8ff2d2795f306918598':
  Ignore microphone and settings key while typing
main
Tadashi G. Takaoka 2011-11-18 09:15:36 -08:00 committed by Android Git Automerger
commit ea953fd555
3 changed files with 63 additions and 43 deletions

View File

@ -63,6 +63,7 @@
<integer name="config_long_press_space_key_timeout">@integer/config_long_press_key_timeout</integer> <integer name="config_long_press_space_key_timeout">@integer/config_long_press_key_timeout</integer>
<integer name="config_touch_noise_threshold_millis">40</integer> <integer name="config_touch_noise_threshold_millis">40</integer>
<integer name="config_double_spaces_turn_into_period_timeout">1100</integer> <integer name="config_double_spaces_turn_into_period_timeout">1100</integer>
<integer name="config_ignore_special_key_timeout">700</integer>
<dimen name="config_touch_noise_threshold_distance">2.0mm</dimen> <dimen name="config_touch_noise_threshold_distance">2.0mm</dimen>
<!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. --> <!-- This configuration is the index of the array {@link KeyboardSwitcher.KEYBOARD_THEMES}. -->
<string name="config_default_keyboard_theme_id" translatable="false">5</string> <string name="config_default_keyboard_theme_id" translatable="false">5</string>

View File

@ -251,11 +251,36 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 3; private static final int MSG_FADEOUT_LANGUAGE_ON_SPACEBAR = 3;
private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 4; private static final int MSG_DISMISS_LANGUAGE_ON_SPACEBAR = 4;
private static final int MSG_SPACE_TYPED = 5; private static final int MSG_SPACE_TYPED = 5;
private static final int MSG_SET_BIGRAM_PREDICTIONS = 6; private static final int MSG_KEY_TYPED = 6;
private static final int MSG_PENDING_IMS_CALLBACK = 7; private static final int MSG_SET_BIGRAM_PREDICTIONS = 7;
private static final int MSG_PENDING_IMS_CALLBACK = 8;
private final int mDelayBeforeFadeoutLanguageOnSpacebar;
private final int mDelayUpdateSuggestions;
private final int mDelayUpdateShiftState;
private final int mDurationOfFadeoutLanguageOnSpacebar;
private final float mFinalFadeoutFactorOfLanguageOnSpacebar;
private final long mDoubleSpacesTurnIntoPeriodTimeout;
private final long mIgnoreSpecialKeyTimeout;
public UIHandler(LatinIME outerInstance) { public UIHandler(LatinIME outerInstance) {
super(outerInstance); super(outerInstance);
final Resources res = outerInstance.getResources();
mDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_delay_before_fadeout_language_on_spacebar);
mDelayUpdateSuggestions =
res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateShiftState =
res.getInteger(R.integer.config_delay_update_shift_state);
mDurationOfFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_duration_of_fadeout_language_on_spacebar);
mFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
mDoubleSpacesTurnIntoPeriodTimeout = res.getInteger(
R.integer.config_double_spaces_turn_into_period_timeout);
mIgnoreSpecialKeyTimeout = res.getInteger(
R.integer.config_ignore_special_key_timeout);
} }
@Override @Override
@ -280,17 +305,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR: case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
if (inputView != null) { if (inputView != null) {
inputView.setSpacebarTextFadeFactor( inputView.setSpacebarTextFadeFactor(
(1.0f + latinIme.mSettingsValues. (1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
mFinalFadeoutFactorOfLanguageOnSpacebar) / 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),
latinIme.mSettingsValues.mDurationOfFadeoutLanguageOnSpacebar); mDurationOfFadeoutLanguageOnSpacebar);
break; break;
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR: case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
if (inputView != null) { if (inputView != null) {
inputView.setSpacebarTextFadeFactor( inputView.setSpacebarTextFadeFactor(mFinalFadeoutFactorOfLanguageOnSpacebar,
latinIme.mSettingsValues.mFinalFadeoutFactorOfLanguageOnSpacebar,
(LatinKeyboard)msg.obj); (LatinKeyboard)msg.obj);
} }
break; break;
@ -299,8 +322,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void postUpdateSuggestions() { public void postUpdateSuggestions() {
removeMessages(MSG_UPDATE_SUGGESTIONS); removeMessages(MSG_UPDATE_SUGGESTIONS);
sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), sendMessageDelayed(obtainMessage(MSG_UPDATE_SUGGESTIONS), mDelayUpdateSuggestions);
getOuterInstance().mSettingsValues.mDelayUpdateSuggestions);
} }
public void cancelUpdateSuggestions() { public void cancelUpdateSuggestions() {
@ -313,8 +335,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void postUpdateShiftKeyState() { public void postUpdateShiftKeyState() {
removeMessages(MSG_UPDATE_SHIFT_STATE); removeMessages(MSG_UPDATE_SHIFT_STATE);
sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), sendMessageDelayed(obtainMessage(MSG_UPDATE_SHIFT_STATE), mDelayUpdateShiftState);
getOuterInstance().mSettingsValues.mDelayUpdateShiftState);
} }
public void cancelUpdateShiftState() { public void cancelUpdateShiftState() {
@ -323,8 +344,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
public void postUpdateBigramPredictions() { public void postUpdateBigramPredictions() {
removeMessages(MSG_SET_BIGRAM_PREDICTIONS); removeMessages(MSG_SET_BIGRAM_PREDICTIONS);
sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), sendMessageDelayed(obtainMessage(MSG_SET_BIGRAM_PREDICTIONS), mDelayUpdateSuggestions);
getOuterInstance().mSettingsValues.mDelayUpdateSuggestions);
} }
public void cancelUpdateBigramPredictions() { public void cancelUpdateBigramPredictions() {
@ -344,26 +364,24 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
final LatinKeyboard keyboard = latinIme.mKeyboardSwitcher.getLatinKeyboard(); final LatinKeyboard keyboard = latinIme.mKeyboardSwitcher.getLatinKeyboard();
// The language is always displayed when the delay is negative. // The language is always displayed when the delay is negative.
final boolean needsToDisplayLanguage = localeChanged final boolean needsToDisplayLanguage = localeChanged
|| latinIme.mSettingsValues.mDelayBeforeFadeoutLanguageOnSpacebar < 0; || mDelayBeforeFadeoutLanguageOnSpacebar < 0;
// The language is never displayed when the delay is zero. // The language is never displayed when the delay is zero.
if (latinIme.mSettingsValues.mDelayBeforeFadeoutLanguageOnSpacebar != 0) { if (mDelayBeforeFadeoutLanguageOnSpacebar != 0) {
inputView.setSpacebarTextFadeFactor(needsToDisplayLanguage ? 1.0f inputView.setSpacebarTextFadeFactor(needsToDisplayLanguage ? 1.0f
: latinIme.mSettingsValues.mFinalFadeoutFactorOfLanguageOnSpacebar, : mFinalFadeoutFactorOfLanguageOnSpacebar,
keyboard); keyboard);
} }
// The fadeout animation will start when the delay is positive. // The fadeout animation will start when the delay is positive.
if (localeChanged if (localeChanged && mDelayBeforeFadeoutLanguageOnSpacebar > 0) {
&& latinIme.mSettingsValues.mDelayBeforeFadeoutLanguageOnSpacebar > 0) {
sendMessageDelayed(obtainMessage(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR, keyboard), sendMessageDelayed(obtainMessage(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR, keyboard),
latinIme.mSettingsValues.mDelayBeforeFadeoutLanguageOnSpacebar); mDelayBeforeFadeoutLanguageOnSpacebar);
} }
} }
} }
public void startDoubleSpacesTimer() { public void startDoubleSpacesTimer() {
removeMessages(MSG_SPACE_TYPED); removeMessages(MSG_SPACE_TYPED);
sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED), sendMessageDelayed(obtainMessage(MSG_SPACE_TYPED), mDoubleSpacesTurnIntoPeriodTimeout);
getOuterInstance().mSettingsValues.mDoubleSpacesTurnIntoPeriodTimeout);
} }
public void cancelDoubleSpacesTimer() { public void cancelDoubleSpacesTimer() {
@ -374,6 +392,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
return hasMessages(MSG_SPACE_TYPED); return hasMessages(MSG_SPACE_TYPED);
} }
public void startKeyTypedTimer() {
removeMessages(MSG_KEY_TYPED);
sendMessageDelayed(obtainMessage(MSG_KEY_TYPED), mIgnoreSpecialKeyTimeout);
}
public boolean isIgnoringSpecialKey() {
return hasMessages(MSG_KEY_TYPED);
}
// Working variables for the following methods. // Working variables for the following methods.
private boolean mIsOrientationChanging; private boolean mIsOrientationChanging;
private boolean mPendingSuccesiveImsCallback; private boolean mPendingSuccesiveImsCallback;
@ -1276,12 +1303,12 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
// Implementation of {@link KeyboardActionListener}. // Implementation of {@link KeyboardActionListener}.
@Override @Override
public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) { public void onCodeInput(int primaryCode, int[] keyCodes, int x, int y) {
long when = SystemClock.uptimeMillis(); final long when = SystemClock.uptimeMillis();
if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) { if (primaryCode != Keyboard.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {
mDeleteCount = 0; mDeleteCount = 0;
} }
mLastKeyTime = when; mLastKeyTime = when;
KeyboardSwitcher switcher = mKeyboardSwitcher; final KeyboardSwitcher switcher = mKeyboardSwitcher;
final boolean distinctMultiTouch = switcher.hasDistinctMultitouch(); final boolean distinctMultiTouch = switcher.hasDistinctMultitouch();
// The space state depends only on the last character pressed and its own previous // The space state depends only on the last character pressed and its own previous
// state. Here, we revert the space state to neutral if the key is actually modifying // state. Here, we revert the space state to neutral if the key is actually modifying
@ -1295,6 +1322,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mHandler.cancelDoubleSpacesTimer(); mHandler.cancelDoubleSpacesTimer();
} }
boolean shouldStartKeyTypedTimer = true;
switch (primaryCode) { switch (primaryCode) {
case Keyboard.CODE_DELETE: case Keyboard.CODE_DELETE:
mSpaceState = SPACE_STATE_NONE; mSpaceState = SPACE_STATE_NONE;
@ -1319,14 +1347,20 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
} }
break; break;
case Keyboard.CODE_SETTINGS: case Keyboard.CODE_SETTINGS:
onSettingsKeyPressed(); if (!mHandler.isIgnoringSpecialKey()) {
onSettingsKeyPressed();
}
shouldStartKeyTypedTimer = false;
break; break;
case Keyboard.CODE_CAPSLOCK: case Keyboard.CODE_CAPSLOCK:
switcher.toggleCapsLock(); switcher.toggleCapsLock();
hapticAndAudioFeedback(primaryCode); hapticAndAudioFeedback(primaryCode);
break; break;
case Keyboard.CODE_SHORTCUT: case Keyboard.CODE_SHORTCUT:
mSubtypeSwitcher.switchToShortcutIME(); if (!mHandler.isIgnoringSpecialKey()) {
mSubtypeSwitcher.switchToShortcutIME();
}
shouldStartKeyTypedTimer = false;
break; break;
case Keyboard.CODE_TAB: case Keyboard.CODE_TAB:
handleTab(); handleTab();
@ -1352,6 +1386,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
switcher.onKey(primaryCode); switcher.onKey(primaryCode);
// Reset after any single keystroke // Reset after any single keystroke
mEnteredText = null; mEnteredText = null;
if (shouldStartKeyTypedTimer) {
mHandler.startKeyTypedTimer();
}
} }
@Override @Override

View File

@ -102,13 +102,7 @@ public class Settings extends InputMethodSettingsActivity
public static class Values { public static class Values {
// From resources: // From resources:
public final int mDelayBeforeFadeoutLanguageOnSpacebar;
public final int mDelayUpdateSuggestions;
public final int mDelayUpdateOldSuggestions; public final int mDelayUpdateOldSuggestions;
public final int mDelayUpdateShiftState;
public final int mDurationOfFadeoutLanguageOnSpacebar;
public final float mFinalFadeoutFactorOfLanguageOnSpacebar;
public final long mDoubleSpacesTurnIntoPeriodTimeout;
public final String mWordSeparators; public final String mWordSeparators;
public final String mMagicSpaceStrippers; public final String mMagicSpaceStrippers;
public final String mMagicSpaceSwappers; public final String mMagicSpaceSwappers;
@ -148,20 +142,8 @@ public class Settings extends InputMethodSettingsActivity
} }
// Get the resources // Get the resources
mDelayBeforeFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_delay_before_fadeout_language_on_spacebar);
mDelayUpdateSuggestions =
res.getInteger(R.integer.config_delay_update_suggestions);
mDelayUpdateOldSuggestions = res.getInteger( mDelayUpdateOldSuggestions = res.getInteger(
R.integer.config_delay_update_old_suggestions); R.integer.config_delay_update_old_suggestions);
mDelayUpdateShiftState =
res.getInteger(R.integer.config_delay_update_shift_state);
mDurationOfFadeoutLanguageOnSpacebar = res.getInteger(
R.integer.config_duration_of_fadeout_language_on_spacebar);
mFinalFadeoutFactorOfLanguageOnSpacebar = res.getInteger(
R.integer.config_final_fadeout_percentage_of_language_on_spacebar) / 100.0f;
mDoubleSpacesTurnIntoPeriodTimeout = res.getInteger(
R.integer.config_double_spaces_turn_into_period_timeout);
mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols); mMagicSpaceStrippers = res.getString(R.string.magic_space_stripping_symbols);
mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols); mMagicSpaceSwappers = res.getString(R.string.magic_space_swapping_symbols);
String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers String wordSeparators = mMagicSpaceStrippers + mMagicSpaceSwappers