Hide shortcut key when the shortcut IME is not enabled

Bug: 3398726
Change-Id: I5e1bfc1fec9047c1c4e4f29fbf79f0fdf9356ffb
This commit is contained in:
Tadashi G. Takaoka 2011-03-02 21:34:11 -08:00
parent 424f6ec2bc
commit 4503e2ea98
4 changed files with 32 additions and 13 deletions

View file

@ -447,7 +447,8 @@ public class KeyboardParser {
textAttr(KeyboardId.modeName(
a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"),
textAttr(KeyboardId.colorSchemeName(
a.getInt(R.styleable.KeyboardView_colorScheme, -1)), "colorSchemeName"),
viewAttr.getInt(
R.styleable.KeyboardView_colorScheme, -1)), "colorSchemeName"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"),

View file

@ -194,7 +194,7 @@ public class KeyboardSwitcher implements SharedPreferences.OnSharedPreferenceCha
// 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.isShortcutAvailable(), null);
keyboard.updateShortcutKey(mSubtypeSwitcher.isShortcutImeReady(), null);
return keyboard;
}

View file

@ -547,7 +547,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
// Most such things we decide below in initializeInputAttributesAndGetMode, but we need to
// know now whether this is a password text field, because we need to know now whether we
// want to enable the voice button.
mVoiceConnector.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType)
final VoiceIMEConnector voiceIme = mVoiceConnector;
voiceIme.resetVoiceStates(Utils.isPasswordInputType(attribute.inputType)
|| Utils.isVisiblePasswordInputType(attribute.inputType));
initializeInputAttributes(attribute);
@ -562,8 +563,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
loadSettings(attribute);
if (mSubtypeSwitcher.isKeyboardMode()) {
switcher.loadKeyboard(attribute,
mVoiceConnector.isVoiceButtonEnabled(),
mVoiceConnector.isVoiceButtonOnPrimary());
mSubtypeSwitcher.isShortcutImeEnabled() && voiceIme.isVoiceButtonEnabled(),
voiceIme.isVoiceButtonOnPrimary());
switcher.updateShiftState();
}
@ -583,7 +584,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
checkRecorrectionOnStart();
inputView.setForeground(true);
mVoiceConnector.onStartInputView(inputView.getWindowToken());
voiceIme.onStartInputView(inputView.getWindowToken());
if (TRACE) Debug.startMethodTracing("/data/trace/latinime");
}
@ -1930,7 +1931,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
}
// Reload keyboard because the current language has been changed.
mKeyboardSwitcher.loadKeyboard(getCurrentInputEditorInfo(),
mVoiceConnector.isVoiceButtonEnabled(), mVoiceConnector.isVoiceButtonOnPrimary());
mSubtypeSwitcher.isShortcutImeEnabled() && mVoiceConnector.isVoiceButtonEnabled(),
mVoiceConnector.isVoiceButtonOnPrimary());
initSuggest();
mKeyboardSwitcher.updateShiftState();
}

View file

@ -46,7 +46,7 @@ import java.util.Map;
public class SubtypeSwitcher {
private static boolean DBG = LatinImeLogger.sDBG;
private static final String TAG = "SubtypeSwitcher";
private static final String TAG = SubtypeSwitcher.class.getSimpleName();
private static final char LOCALE_SEPARATER = '_';
private static final String KEYBOARD_MODE = "keyboard";
@ -221,7 +221,7 @@ public class SubtypeSwitcher {
newMode = newSubtype.getMode();
}
if (DBG) {
Log.w(TAG, "Update subtype to:" + newLocale + "," + newSubtype.getMode()
Log.w(TAG, "Update subtype to:" + newLocale + "," + newMode
+ ", from: " + mInputLocaleStr + ", " + oldMode);
}
boolean languageChanged = false;
@ -355,11 +355,27 @@ public class SubtypeSwitcher {
return false;
}
public boolean isShortcutAvailable() {
public boolean isShortcutImeEnabled() {
if (mShortcutInputMethodInfo == null)
return false;
if (mShortcutSubtype != null && contains(mShortcutSubtype.getExtraValue().split(","),
SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY)) {
if (mShortcutSubtype == null)
return true;
final boolean allowsImplicitlySelectedSubtypes = true;
for (final InputMethodSubtype enabledSubtype : mImm.getEnabledInputMethodSubtypeList(
mShortcutInputMethodInfo, allowsImplicitlySelectedSubtypes)) {
if (enabledSubtype.equals(mShortcutSubtype))
return true;
}
return false;
}
public boolean isShortcutImeReady() {
if (mShortcutInputMethodInfo == null)
return false;
if (mShortcutSubtype == null)
return true;
if (contains(mShortcutSubtype.getExtraValue().split(","),
SUBTYPE_EXTRAVALUE_REQUIRE_NETWORK_CONNECTIVITY)) {
return mIsNetworkConnected;
}
return true;
@ -373,7 +389,7 @@ public class SubtypeSwitcher {
final KeyboardSwitcher switcher = KeyboardSwitcher.getInstance();
final LatinKeyboard keyboard = switcher.getLatinKeyboard();
if (keyboard != null) {
keyboard.updateShortcutKey(isShortcutAvailable(), switcher.getInputView());
keyboard.updateShortcutKey(isShortcutImeReady(), switcher.getInputView());
}
}