Fix auto correction spacebar LED
Change-Id: I4894d188d5612380cc9f8eec7cb72544e37fb2b0main
parent
5a39e527dd
commit
23d27fefcb
|
@ -38,7 +38,6 @@
|
||||||
<bool name="config_default_bigram_prediction">false</bool>
|
<bool name="config_default_bigram_prediction">false</bool>
|
||||||
<bool name="config_default_sound_enabled">false</bool>
|
<bool name="config_default_sound_enabled">false</bool>
|
||||||
<bool name="config_default_vibration_enabled">true</bool>
|
<bool name="config_default_vibration_enabled">true</bool>
|
||||||
<bool name="config_auto_correction_spacebar_led_enabled">false</bool>
|
|
||||||
<!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false -->
|
<!-- Showing mini keyboard, just above the touched point if true, aligned to the key if false -->
|
||||||
<bool name="config_show_mini_keyboard_at_touched_point">false</bool>
|
<bool name="config_show_mini_keyboard_at_touched_point">false</bool>
|
||||||
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
<!-- The language is never displayed if == 0, always displayed if < 0 -->
|
||||||
|
|
|
@ -32,8 +32,7 @@
|
||||||
<item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item>
|
<item name="maxMoreKeysColumn">@integer/config_max_more_keys_column</item>
|
||||||
</style>
|
</style>
|
||||||
<style name="LatinKeyboard">
|
<style name="LatinKeyboard">
|
||||||
<item name="autoCorrectionSpacebarLedEnabled">@bool/config_auto_correction_spacebar_led_enabled
|
<item name="autoCorrectionSpacebarLedEnabled">true</item>
|
||||||
</item>
|
|
||||||
<item name="spacebarTextColor">#FFC0C0C0</item>
|
<item name="spacebarTextColor">#FFC0C0C0</item>
|
||||||
<item name="spacebarTextShadowColor">#80000000</item>
|
<item name="spacebarTextShadowColor">#80000000</item>
|
||||||
</style>
|
</style>
|
||||||
|
@ -242,6 +241,7 @@
|
||||||
name="LatinKeyboard.IceCreamSandwich"
|
name="LatinKeyboard.IceCreamSandwich"
|
||||||
parent="LatinKeyboard"
|
parent="LatinKeyboard"
|
||||||
>
|
>
|
||||||
|
<item name="autoCorrectionSpacebarLedEnabled">false</item>
|
||||||
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
<item name="disabledShortcutIcon">@drawable/sym_keyboard_voice_off_holo</item>
|
||||||
</style>
|
</style>
|
||||||
<style
|
<style
|
||||||
|
|
|
@ -166,18 +166,29 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
|
SettingsValues.getKeyPreviewPopupDismissDelay(mPrefs, mResources));
|
||||||
final boolean localeChanged = (oldKeyboard == null)
|
final boolean localeChanged = (oldKeyboard == null)
|
||||||
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
|
|| !keyboard.mId.mLocale.equals(oldKeyboard.mId.mLocale);
|
||||||
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
|
if (keyboard instanceof LatinKeyboard) {
|
||||||
|
final LatinKeyboard latinKeyboard = (LatinKeyboard)keyboard;
|
||||||
|
latinKeyboard.updateAutoCorrectionState(mIsAutoCorrectionActive);
|
||||||
|
// If the cached keyboard had been switched to another keyboard while the language was
|
||||||
|
// displayed on its spacebar, it might have had arbitrary text fade factor. In such
|
||||||
|
// case, we should reset the text fade factor. It is also applicable to shortcut key.
|
||||||
|
latinKeyboard.updateSpacebarLanguage(0.0f,
|
||||||
|
Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
|
||||||
|
mSubtypeSwitcher.needsToDisplayLanguage(latinKeyboard.mId.mLocale));
|
||||||
|
latinKeyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady());
|
||||||
|
}
|
||||||
updateShiftState();
|
updateShiftState();
|
||||||
|
mInputMethodService.mHandler.startDisplayLanguageOnSpacebar(localeChanged);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Move this method to KeyboardSet.
|
// TODO: Move this method to KeyboardSet.
|
||||||
private LatinKeyboard getKeyboard(KeyboardId id) {
|
private LatinKeyboard getKeyboard(Context context, KeyboardId id) {
|
||||||
final SoftReference<LatinKeyboard> ref = mKeyboardCache.get(id);
|
final SoftReference<LatinKeyboard> ref = mKeyboardCache.get(id);
|
||||||
LatinKeyboard keyboard = (ref == null) ? null : ref.get();
|
LatinKeyboard keyboard = (ref == null) ? null : ref.get();
|
||||||
if (keyboard == null) {
|
if (keyboard == null) {
|
||||||
final Locale savedLocale = LocaleUtils.setSystemLocale(mResources, id.mLocale);
|
final Locale savedLocale = LocaleUtils.setSystemLocale(mResources, id.mLocale);
|
||||||
try {
|
try {
|
||||||
final LatinKeyboard.Builder builder = new LatinKeyboard.Builder(mThemeContext);
|
final LatinKeyboard.Builder builder = new LatinKeyboard.Builder(context);
|
||||||
builder.load(id);
|
builder.load(id);
|
||||||
builder.setTouchPositionCorrectionEnabled(
|
builder.setTouchPositionCorrectionEnabled(
|
||||||
mSubtypeSwitcher.currentSubtypeContainsExtraValueKey(
|
mSubtypeSwitcher.currentSubtypeContainsExtraValueKey(
|
||||||
|
@ -198,14 +209,8 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
+ " theme=" + themeName(keyboard.mThemeId));
|
+ " theme=" + themeName(keyboard.mThemeId));
|
||||||
}
|
}
|
||||||
|
|
||||||
keyboard.onAutoCorrectionStateChanged(mIsAutoCorrectionActive);
|
|
||||||
keyboard.setShiftLocked(false);
|
keyboard.setShiftLocked(false);
|
||||||
keyboard.setShifted(false);
|
keyboard.setShifted(false);
|
||||||
// If the cached keyboard had been switched to another keyboard while the language was
|
|
||||||
// displayed on its spacebar, it might have had arbitrary text fade factor. In such case,
|
|
||||||
// we should reset the text fade factor. It is also applicable to shortcut key.
|
|
||||||
keyboard.setSpacebarTextFadeFactor(0.0f, null);
|
|
||||||
keyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady(), null);
|
|
||||||
return keyboard;
|
return keyboard;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -338,19 +343,19 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsKeyboard() {
|
public void setSymbolsKeyboard() {
|
||||||
setKeyboard(getKeyboard(mKeyboardSet.mSymbolsId));
|
setKeyboard(getKeyboard(mThemeContext, mKeyboardSet.mSymbolsId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setAlphabetKeyboard() {
|
public void setAlphabetKeyboard() {
|
||||||
setKeyboard(getKeyboard(mKeyboardSet.mAlphabetId));
|
setKeyboard(getKeyboard(mThemeContext, mKeyboardSet.mAlphabetId));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Implements {@link KeyboardState.SwitchActions}.
|
// Implements {@link KeyboardState.SwitchActions}.
|
||||||
@Override
|
@Override
|
||||||
public void setSymbolsShiftedKeyboard() {
|
public void setSymbolsShiftedKeyboard() {
|
||||||
final Keyboard keyboard = getKeyboard(mKeyboardSet.mSymbolsShiftedId);
|
final Keyboard keyboard = getKeyboard(mThemeContext, mKeyboardSet.mSymbolsShiftedId);
|
||||||
setKeyboard(keyboard);
|
setKeyboard(keyboard);
|
||||||
// TODO: Remove this logic once we introduce initial keyboard shift state attribute.
|
// TODO: Remove this logic once we introduce initial keyboard shift state attribute.
|
||||||
// Symbol shift keyboard may have a shift key that has a caps lock style indicator (a.k.a.
|
// Symbol shift keyboard may have a shift key that has a caps lock style indicator (a.k.a.
|
||||||
|
@ -451,12 +456,22 @@ public class KeyboardSwitcher implements KeyboardState.SwitchActions,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void onNetworkStateChanged() {
|
||||||
|
final LatinKeyboard keyboard = getLatinKeyboard();
|
||||||
|
if (keyboard == null) return;
|
||||||
|
final Key updatedKey = keyboard.updateShortcutKey(
|
||||||
|
SubtypeSwitcher.getInstance().isShortcutImeReady());
|
||||||
|
if (updatedKey != null && mKeyboardView != null) {
|
||||||
|
mKeyboardView.invalidateKey(updatedKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
|
public void onAutoCorrectionStateChanged(boolean isAutoCorrection) {
|
||||||
if (mIsAutoCorrectionActive != isAutoCorrection) {
|
if (mIsAutoCorrectionActive != isAutoCorrection) {
|
||||||
mIsAutoCorrectionActive = isAutoCorrection;
|
mIsAutoCorrectionActive = isAutoCorrection;
|
||||||
final LatinKeyboard keyboard = getLatinKeyboard();
|
final LatinKeyboard keyboard = getLatinKeyboard();
|
||||||
if (keyboard != null && keyboard.needsAutoCorrectionSpacebarLed()) {
|
if (keyboard != null && keyboard.needsAutoCorrectionSpacebarLed()) {
|
||||||
final Key invalidatedKey = keyboard.onAutoCorrectionStateChanged(isAutoCorrection);
|
final Key invalidatedKey = keyboard.updateAutoCorrectionState(isAutoCorrection);
|
||||||
final LatinKeyboardView keyboardView = getKeyboardView();
|
final LatinKeyboardView keyboardView = getKeyboardView();
|
||||||
if (keyboardView != null)
|
if (keyboardView != null)
|
||||||
keyboardView.invalidateKey(invalidatedKey);
|
keyboardView.invalidateKey(invalidatedKey);
|
||||||
|
|
|
@ -31,11 +31,9 @@ import android.graphics.drawable.BitmapDrawable;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
import com.android.inputmethod.keyboard.internal.KeyboardBuilder;
|
||||||
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
import com.android.inputmethod.keyboard.internal.KeyboardParams;
|
||||||
import com.android.inputmethod.latin.R;
|
import com.android.inputmethod.latin.R;
|
||||||
import com.android.inputmethod.latin.SubtypeSwitcher;
|
|
||||||
import com.android.inputmethod.latin.Utils;
|
import com.android.inputmethod.latin.Utils;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -48,7 +46,6 @@ public class LatinKeyboard extends Keyboard {
|
||||||
|
|
||||||
private final Resources mRes;
|
private final Resources mRes;
|
||||||
private final Theme mTheme;
|
private final Theme mTheme;
|
||||||
private final SubtypeSwitcher mSubtypeSwitcher = SubtypeSwitcher.getInstance();
|
|
||||||
|
|
||||||
/* Space key and its icons, drawables and colors. */
|
/* Space key and its icons, drawables and colors. */
|
||||||
private final Key mSpaceKey;
|
private final Key mSpaceKey;
|
||||||
|
@ -57,11 +54,15 @@ public class LatinKeyboard extends Keyboard {
|
||||||
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
private final Drawable mAutoCorrectionSpacebarLedIcon;
|
||||||
private final int mSpacebarTextColor;
|
private final int mSpacebarTextColor;
|
||||||
private final int mSpacebarTextShadowColor;
|
private final int mSpacebarTextShadowColor;
|
||||||
private float mSpacebarTextFadeFactor = 0.0f;
|
|
||||||
private final HashMap<Integer, BitmapDrawable> mSpaceDrawableCache =
|
private final HashMap<Integer, BitmapDrawable> mSpaceDrawableCache =
|
||||||
new HashMap<Integer, BitmapDrawable>();
|
new HashMap<Integer, BitmapDrawable>();
|
||||||
private final boolean mIsSpacebarTriggeringPopupByLongPress;
|
private final boolean mIsSpacebarTriggeringPopupByLongPress;
|
||||||
|
|
||||||
|
private boolean mAutoCorrectionSpacebarLedOn;
|
||||||
|
private boolean mMultipleEnabledIMEsOrSubtypes;
|
||||||
|
private boolean mNeedsToDisplayLanguage;
|
||||||
|
private float mSpacebarTextFadeFactor = 0.0f;
|
||||||
|
|
||||||
/* Shortcut key and its icons if available */
|
/* Shortcut key and its icons if available */
|
||||||
private final Key mShortcutKey;
|
private final Key mShortcutKey;
|
||||||
private final Drawable mEnabledShortcutIcon;
|
private final Drawable mEnabledShortcutIcon;
|
||||||
|
@ -140,11 +141,13 @@ public class LatinKeyboard extends Keyboard {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpacebarTextFadeFactor(float fadeFactor, KeyboardView view) {
|
public Key updateSpacebarLanguage(float fadeFactor, boolean multipleEnabledIMEsOrSubtypes,
|
||||||
|
boolean needsToDisplayLanguage) {
|
||||||
mSpacebarTextFadeFactor = fadeFactor;
|
mSpacebarTextFadeFactor = fadeFactor;
|
||||||
updateSpacebarForLocale(false);
|
mMultipleEnabledIMEsOrSubtypes = multipleEnabledIMEsOrSubtypes;
|
||||||
if (view != null)
|
mNeedsToDisplayLanguage = needsToDisplayLanguage;
|
||||||
view.invalidateKey(mSpaceKey);
|
updateSpacebarIcon();
|
||||||
|
return mSpaceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static int getSpacebarTextColor(int color, float fadeFactor) {
|
private static int getSpacebarTextColor(int color, float fadeFactor) {
|
||||||
|
@ -153,13 +156,12 @@ public class LatinKeyboard extends Keyboard {
|
||||||
return newColor;
|
return newColor;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateShortcutKey(boolean available, KeyboardView view) {
|
public Key updateShortcutKey(boolean available) {
|
||||||
if (mShortcutKey == null)
|
if (mShortcutKey == null)
|
||||||
return;
|
return null;
|
||||||
mShortcutKey.setEnabled(available);
|
mShortcutKey.setEnabled(available);
|
||||||
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
|
mShortcutKey.setIcon(available ? mEnabledShortcutIcon : mDisabledShortcutIcon);
|
||||||
if (view != null)
|
return mShortcutKey;
|
||||||
view.invalidateKey(mShortcutKey);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean needsAutoCorrectionSpacebarLed() {
|
public boolean needsAutoCorrectionSpacebarLed() {
|
||||||
|
@ -169,8 +171,9 @@ public class LatinKeyboard extends Keyboard {
|
||||||
/**
|
/**
|
||||||
* @return a key which should be invalidated.
|
* @return a key which should be invalidated.
|
||||||
*/
|
*/
|
||||||
public Key onAutoCorrectionStateChanged(boolean isAutoCorrection) {
|
public Key updateAutoCorrectionState(boolean isAutoCorrection) {
|
||||||
updateSpacebarForLocale(isAutoCorrection);
|
mAutoCorrectionSpacebarLedOn = isAutoCorrection;
|
||||||
|
updateSpacebarIcon();
|
||||||
return mSpaceKey;
|
return mSpaceKey;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -183,19 +186,15 @@ public class LatinKeyboard extends Keyboard {
|
||||||
return label;
|
return label;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateSpacebarForLocale(boolean isAutoCorrection) {
|
private void updateSpacebarIcon() {
|
||||||
if (mSpaceKey == null) return;
|
if (mSpaceKey == null) return;
|
||||||
final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
|
|
||||||
if (imm == null) return;
|
|
||||||
// The "..." popup hint for triggering something by a long-pressing the spacebar
|
|
||||||
final boolean shouldShowInputMethodPicker = mIsSpacebarTriggeringPopupByLongPress
|
final boolean shouldShowInputMethodPicker = mIsSpacebarTriggeringPopupByLongPress
|
||||||
&& Utils.hasMultipleEnabledIMEsOrSubtypes(imm, true /* include aux subtypes */);
|
&& mMultipleEnabledIMEsOrSubtypes;
|
||||||
mSpaceKey.setNeedsSpecialPopupHint(shouldShowInputMethodPicker);
|
mSpaceKey.setNeedsSpecialPopupHint(shouldShowInputMethodPicker);
|
||||||
// If application locales are explicitly selected.
|
if (mNeedsToDisplayLanguage) {
|
||||||
if (mSubtypeSwitcher.needsToDisplayLanguage(mId.mLocale)) {
|
mSpaceKey.setIcon(getSpaceDrawable(mId.mLocale));
|
||||||
mSpaceKey.setIcon(getSpaceDrawable(mId.mLocale, isAutoCorrection));
|
} else if (mAutoCorrectionSpacebarLedOn) {
|
||||||
} else if (isAutoCorrection) {
|
mSpaceKey.setIcon(getSpaceDrawable(null));
|
||||||
mSpaceKey.setIcon(getSpaceDrawable(null, true));
|
|
||||||
} else {
|
} else {
|
||||||
mSpaceKey.setIcon(mSpaceIcon);
|
mSpaceKey.setIcon(mSpaceIcon);
|
||||||
}
|
}
|
||||||
|
@ -245,15 +244,15 @@ public class LatinKeyboard extends Keyboard {
|
||||||
return language;
|
return language;
|
||||||
}
|
}
|
||||||
|
|
||||||
private BitmapDrawable getSpaceDrawable(Locale locale, boolean isAutoCorrection) {
|
private BitmapDrawable getSpaceDrawable(Locale locale) {
|
||||||
final Integer hashCode = Arrays.hashCode(
|
final Integer hashCode = Arrays.hashCode(
|
||||||
new Object[] { locale, isAutoCorrection, mSpacebarTextFadeFactor });
|
new Object[] { locale, mAutoCorrectionSpacebarLedOn, mSpacebarTextFadeFactor });
|
||||||
final BitmapDrawable cached = mSpaceDrawableCache.get(hashCode);
|
final BitmapDrawable cached = mSpaceDrawableCache.get(hashCode);
|
||||||
if (cached != null) {
|
if (cached != null) {
|
||||||
return cached;
|
return cached;
|
||||||
}
|
}
|
||||||
final BitmapDrawable drawable = new BitmapDrawable(mRes, drawSpacebar(
|
final BitmapDrawable drawable = new BitmapDrawable(mRes, drawSpacebar(
|
||||||
locale, isAutoCorrection, mSpacebarTextFadeFactor));
|
locale, mAutoCorrectionSpacebarLedOn, mSpacebarTextFadeFactor));
|
||||||
mSpaceDrawableCache.put(hashCode, drawable);
|
mSpaceDrawableCache.put(hashCode, drawable);
|
||||||
return drawable;
|
return drawable;
|
||||||
}
|
}
|
||||||
|
|
|
@ -374,15 +374,6 @@ public class LatinKeyboardView extends KeyboardView implements PointerTracker.Ke
|
||||||
return miniKeyboardView;
|
return miniKeyboardView;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSpacebarTextFadeFactor(float fadeFactor, LatinKeyboard oldKeyboard) {
|
|
||||||
final Keyboard keyboard = getKeyboard();
|
|
||||||
// We should not set text fade factor to the keyboard which does not display the language on
|
|
||||||
// its spacebar.
|
|
||||||
if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
|
|
||||||
((LatinKeyboard)keyboard).setSpacebarTextFadeFactor(fadeFactor, this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Called when a key is long pressed. By default this will open mini keyboard associated
|
* Called when a key is long pressed. By default this will open mini keyboard associated
|
||||||
* with this key.
|
* with this key.
|
||||||
|
|
|
@ -297,19 +297,15 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
|
|| (switcher.isAlphabetMode() && switcher.isShiftedOrShiftLocked()));
|
||||||
break;
|
break;
|
||||||
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
|
case MSG_FADEOUT_LANGUAGE_ON_SPACEBAR:
|
||||||
if (inputView != null) {
|
setSpacebarTextFadeFactor(inputView,
|
||||||
inputView.setSpacebarTextFadeFactor(
|
(1.0f + mFinalFadeoutFactorOfLanguageOnSpacebar) / 2,
|
||||||
(1.0f + 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),
|
||||||
mDurationOfFadeoutLanguageOnSpacebar);
|
mDurationOfFadeoutLanguageOnSpacebar);
|
||||||
break;
|
break;
|
||||||
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
|
case MSG_DISMISS_LANGUAGE_ON_SPACEBAR:
|
||||||
if (inputView != null) {
|
setSpacebarTextFadeFactor(inputView, mFinalFadeoutFactorOfLanguageOnSpacebar,
|
||||||
inputView.setSpacebarTextFadeFactor(mFinalFadeoutFactorOfLanguageOnSpacebar,
|
(LatinKeyboard)msg.obj);
|
||||||
(LatinKeyboard)msg.obj);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -349,6 +345,19 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
sendMessage(obtainMessage(MSG_VOICE_RESULTS));
|
sendMessage(obtainMessage(MSG_VOICE_RESULTS));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void setSpacebarTextFadeFactor(LatinKeyboardView inputView,
|
||||||
|
float fadeFactor, LatinKeyboard oldKeyboard) {
|
||||||
|
if (inputView == null) return;
|
||||||
|
final Keyboard keyboard = inputView.getKeyboard();
|
||||||
|
if (keyboard instanceof LatinKeyboard && keyboard == oldKeyboard) {
|
||||||
|
final Key updatedKey = ((LatinKeyboard)keyboard).updateSpacebarLanguage(
|
||||||
|
fadeFactor,
|
||||||
|
Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */),
|
||||||
|
SubtypeSwitcher.getInstance().needsToDisplayLanguage(keyboard.mId.mLocale));
|
||||||
|
inputView.invalidateKey(updatedKey);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void startDisplayLanguageOnSpacebar(boolean localeChanged) {
|
public void startDisplayLanguageOnSpacebar(boolean localeChanged) {
|
||||||
final LatinIME latinIme = getOuterInstance();
|
final LatinIME latinIme = getOuterInstance();
|
||||||
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
|
removeMessages(MSG_FADEOUT_LANGUAGE_ON_SPACEBAR);
|
||||||
|
@ -361,9 +370,9 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
|| 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 (mDelayBeforeFadeoutLanguageOnSpacebar != 0) {
|
if (mDelayBeforeFadeoutLanguageOnSpacebar != 0) {
|
||||||
inputView.setSpacebarTextFadeFactor(needsToDisplayLanguage ? 1.0f
|
setSpacebarTextFadeFactor(inputView,
|
||||||
: mFinalFadeoutFactorOfLanguageOnSpacebar,
|
needsToDisplayLanguage ? 1.0f : 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 && mDelayBeforeFadeoutLanguageOnSpacebar > 0) {
|
if (localeChanged && mDelayBeforeFadeoutLanguageOnSpacebar > 0) {
|
||||||
|
@ -1229,7 +1238,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (isShowingOptionDialog()) return;
|
if (isShowingOptionDialog()) return;
|
||||||
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
|
if (InputMethodServiceCompatWrapper.CAN_HANDLE_ON_CURRENT_INPUT_METHOD_SUBTYPE_CHANGED) {
|
||||||
showSubtypeSelectorAndSettings();
|
showSubtypeSelectorAndSettings();
|
||||||
} else if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, false /* exclude aux subtypes */)) {
|
} else if (Utils.hasMultipleEnabledIMEsOrSubtypes(false /* exclude aux subtypes */)) {
|
||||||
showOptionsMenu();
|
showOptionsMenu();
|
||||||
} else {
|
} else {
|
||||||
launchSettings();
|
launchSettings();
|
||||||
|
@ -1245,7 +1254,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
|
||||||
if (isShowingOptionDialog()) return false;
|
if (isShowingOptionDialog()) return false;
|
||||||
switch (requestCode) {
|
switch (requestCode) {
|
||||||
case CODE_SHOW_INPUT_METHOD_PICKER:
|
case CODE_SHOW_INPUT_METHOD_PICKER:
|
||||||
if (Utils.hasMultipleEnabledIMEsOrSubtypes(mImm, true /* include aux subtypes */)) {
|
if (Utils.hasMultipleEnabledIMEsOrSubtypes(true /* include aux subtypes */)) {
|
||||||
mImm.showInputMethodPicker();
|
mImm.showInputMethodPicker();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,6 @@ import com.android.inputmethod.compat.InputMethodManagerCompatWrapper;
|
||||||
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
|
import com.android.inputmethod.compat.InputMethodSubtypeCompatWrapper;
|
||||||
import com.android.inputmethod.deprecated.VoiceProxy;
|
import com.android.inputmethod.deprecated.VoiceProxy;
|
||||||
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
import com.android.inputmethod.keyboard.KeyboardSwitcher;
|
||||||
import com.android.inputmethod.keyboard.LatinKeyboard;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
@ -421,11 +420,7 @@ public class SubtypeSwitcher {
|
||||||
ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
|
ConnectivityManager.EXTRA_NO_CONNECTIVITY, false);
|
||||||
mIsNetworkConnected = !noConnection;
|
mIsNetworkConnected = !noConnection;
|
||||||
|
|
||||||
final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance();
|
KeyboardSwitcher.getInstance().onNetworkStateChanged();
|
||||||
final LatinKeyboard keyboard = switcher.getLatinKeyboard();
|
|
||||||
if (keyboard != null) {
|
|
||||||
keyboard.updateShortcutKey(isShortcutImeReady(), switcher.getKeyboardView());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////
|
//////////////////////////////////
|
||||||
|
|
|
@ -118,8 +118,9 @@ public class Utils {
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasMultipleEnabledIMEsOrSubtypes(
|
public static boolean hasMultipleEnabledIMEsOrSubtypes(
|
||||||
final InputMethodManagerCompatWrapper imm,
|
|
||||||
final boolean shouldIncludeAuxiliarySubtypes) {
|
final boolean shouldIncludeAuxiliarySubtypes) {
|
||||||
|
final InputMethodManagerCompatWrapper imm = InputMethodManagerCompatWrapper.getInstance();
|
||||||
|
if (imm == null) return false;
|
||||||
final List<InputMethodInfoCompatWrapper> enabledImis = imm.getEnabledInputMethodList();
|
final List<InputMethodInfoCompatWrapper> enabledImis = imm.getEnabledInputMethodList();
|
||||||
|
|
||||||
// Number of the filtered IMEs
|
// Number of the filtered IMEs
|
||||||
|
|
Loading…
Reference in New Issue