am 169d76cc: Merge "Disable mic key on more keys when voice IME is disabled"

* commit '169d76cc5c4cfffd6b9aad05a1e59f974db4717d':
  Disable mic key on more keys when voice IME is disabled
main
Tadashi G. Takaoka 2013-11-27 07:51:48 -08:00 committed by Android Git Automerger
commit 6aa6dcffb7
12 changed files with 64 additions and 59 deletions

View File

@ -423,7 +423,7 @@
<attr name="navigatePrevious" format="boolean" /> <attr name="navigatePrevious" format="boolean" />
<attr name="passwordInput" format="boolean" /> <attr name="passwordInput" format="boolean" />
<attr name="clobberSettingsKey" format="boolean" /> <attr name="clobberSettingsKey" format="boolean" />
<attr name="shortcutKeyEnabled" format="boolean" /> <attr name="supportsSwitchingToShortcutIme" format="boolean" />
<attr name="hasShortcutKey" format="boolean" /> <attr name="hasShortcutKey" format="boolean" />
<attr name="languageSwitchKeyEnabled" format="boolean" /> <attr name="languageSwitchKeyEnabled" format="boolean" />
<attr name="isMultiLine" format="boolean" /> <attr name="isMultiLine" format="boolean" />

View File

@ -23,7 +23,7 @@
> >
<switch> <switch>
<case <case
latin:shortcutKeyEnabled="true" latin:supportsSwitchingToShortcutIme="true"
latin:clobberSettingsKey="false" latin:clobberSettingsKey="false"
> >
<Key <Key
@ -32,20 +32,20 @@
latin:moreKeys="!text/settings_as_more_key" /> latin:moreKeys="!text/settings_as_more_key" />
</case> </case>
<case <case
latin:shortcutKeyEnabled="true" latin:supportsSwitchingToShortcutIme="true"
latin:clobberSettingsKey="true" latin:clobberSettingsKey="true"
> >
<Key <Key
latin:keyStyle="shortcutKeyStyle" /> latin:keyStyle="shortcutKeyStyle" />
</case> </case>
<case <case
latin:shortcutKeyEnabled="false" latin:supportsSwitchingToShortcutIme="false"
latin:clobberSettingsKey="false" latin:clobberSettingsKey="false"
> >
<Key <Key
latin:keyStyle="settingsKeyStyle" /> latin:keyStyle="settingsKeyStyle" />
</case> </case>
<!-- shortcutKeyEnabled="false" clobberSettingsKey="true" --> <!-- supportsSwitchingToShortcutIme="false" clobberSettingsKey="true" -->
<default> <default>
<Spacer /> <Spacer />
</default> </default>

View File

@ -36,6 +36,16 @@
latin:keyLabel="\@" latin:keyLabel="\@"
latin:keyStyle="f1MoreKeysStyle" /> latin:keyStyle="f1MoreKeysStyle" />
</case> </case>
<case
latin:supportsSwitchingToShortcutIme="false"
>
<Key
latin:keyLabel="!text/keylabel_for_comma"
latin:keyLabelFlags="hasPopupHint"
latin:additionalMoreKeys="!text/more_keys_for_comma"
latin:keyStyle="f1MoreKeysStyle" />
</case>
<!-- latin:supportsSwitchingToShortcutIme="true" -->
<case <case
latin:hasShortcutKey="true" latin:hasShortcutKey="true"
> >

View File

@ -28,7 +28,7 @@
latin:keyWidth="11.538%p" /> latin:keyWidth="11.538%p" />
<switch> <switch>
<case <case
latin:shortcutKeyEnabled="true" latin:supportsSwitchingToShortcutIme="true"
> >
<Key <Key
latin:keyStyle="shortcutKeyStyle" latin:keyStyle="shortcutKeyStyle"

View File

@ -27,15 +27,6 @@
latin:backgroundType="functional" latin:backgroundType="functional"
latin:keyLabel="/" /> latin:keyLabel="/" />
<switch>
<case latin:hasShortcutKey="true" >
<Key latin:keyStyle="shortcutKeyStyle" />
</case>
<!-- latin:hasShortcutKey="false" -->
<default>
</default>
</switch>
<include latin:keyboardLayout="@xml/key_space_symbols" /> <include latin:keyboardLayout="@xml/key_space_symbols" />
<include latin:keyboardLayout="@xml/keys_comma_period" /> <include latin:keyboardLayout="@xml/keys_comma_period" />

View File

@ -412,7 +412,8 @@ public final class EmojiPalettesView extends LinearLayout implements OnTabChange
builder.setSubtype(SubtypeSwitcher.getInstance().getEmojiSubtype()); builder.setSubtype(SubtypeSwitcher.getInstance().getEmojiSubtype());
builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res), builder.setKeyboardGeometry(ResourceUtils.getDefaultKeyboardWidth(res),
mEmojiLayoutParams.mEmojiKeyboardHeight); mEmojiLayoutParams.mEmojiKeyboardHeight);
builder.setOptions(false /* voiceKeyEnabled */, false /* lanuageSwitchKeyEnabled */); builder.setOptions(false /* shortcutImeEnabled */, false /* showsVoiceInputKey */,
false /* languageSwitchKeyEnabled */);
mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context), mEmojiCategory = new EmojiCategory(PreferenceManager.getDefaultSharedPreferences(context),
context.getResources(), builder.build()); context.getResources(), builder.build());
mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context); mDeleteKeyOnTouchListener = new DeleteKeyOnTouchListener(context);

View File

@ -70,7 +70,7 @@ public final class KeyboardId {
public final int mElementId; public final int mElementId;
private final EditorInfo mEditorInfo; private final EditorInfo mEditorInfo;
public final boolean mClobberSettingsKey; public final boolean mClobberSettingsKey;
public final boolean mShortcutKeyEnabled; public final boolean mSupportsSwitchingToShortcutIme;
public final boolean mLanguageSwitchKeyEnabled; public final boolean mLanguageSwitchKeyEnabled;
public final String mCustomActionLabel; public final String mCustomActionLabel;
public final boolean mHasShortcutKey; public final boolean mHasShortcutKey;
@ -86,11 +86,11 @@ public final class KeyboardId {
mElementId = elementId; mElementId = elementId;
mEditorInfo = params.mEditorInfo; mEditorInfo = params.mEditorInfo;
mClobberSettingsKey = params.mNoSettingsKey; mClobberSettingsKey = params.mNoSettingsKey;
mShortcutKeyEnabled = params.mVoiceKeyEnabled; mSupportsSwitchingToShortcutIme = params.mSupportsSwitchingToShortcutIme;
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled; mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
mCustomActionLabel = (mEditorInfo.actionLabel != null) mCustomActionLabel = (mEditorInfo.actionLabel != null)
? mEditorInfo.actionLabel.toString() : null; ? mEditorInfo.actionLabel.toString() : null;
mHasShortcutKey = mShortcutKeyEnabled && isAlphabetKeyboard(elementId); mHasShortcutKey = mSupportsSwitchingToShortcutIme && params.mShowsVoiceInputKey;
mHashCode = computeHashCode(this); mHashCode = computeHashCode(this);
} }
@ -103,7 +103,8 @@ public final class KeyboardId {
id.mHeight, id.mHeight,
id.passwordInput(), id.passwordInput(),
id.mClobberSettingsKey, id.mClobberSettingsKey,
id.mShortcutKeyEnabled, id.mSupportsSwitchingToShortcutIme,
id.mHasShortcutKey,
id.mLanguageSwitchKeyEnabled, id.mLanguageSwitchKeyEnabled,
id.isMultiLine(), id.isMultiLine(),
id.imeAction(), id.imeAction(),
@ -123,7 +124,8 @@ public final class KeyboardId {
&& other.mHeight == mHeight && other.mHeight == mHeight
&& other.passwordInput() == passwordInput() && other.passwordInput() == passwordInput()
&& other.mClobberSettingsKey == mClobberSettingsKey && other.mClobberSettingsKey == mClobberSettingsKey
&& other.mShortcutKeyEnabled == mShortcutKeyEnabled && other.mSupportsSwitchingToShortcutIme == mSupportsSwitchingToShortcutIme
&& other.mHasShortcutKey == mHasShortcutKey
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled && other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
&& other.isMultiLine() == isMultiLine() && other.isMultiLine() == isMultiLine()
&& other.imeAction() == imeAction() && other.imeAction() == imeAction()
@ -182,12 +184,12 @@ public final class KeyboardId {
mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
mWidth, mHeight, mWidth, mHeight,
modeName(mMode), modeName(mMode),
imeAction(), actionName(imeAction()),
(navigateNext() ? " navigateNext" : ""), (navigateNext() ? " navigateNext" : ""),
(navigatePrevious() ? " navigatePrevious" : ""), (navigatePrevious() ? " navigatePrevious" : ""),
(mClobberSettingsKey ? " clobberSettingsKey" : ""), (mClobberSettingsKey ? " clobberSettingsKey" : ""),
(passwordInput() ? " passwordInput" : ""), (passwordInput() ? " passwordInput" : ""),
(mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""), (mSupportsSwitchingToShortcutIme ? " supportsSwitchingToShortcutIme" : ""),
(mHasShortcutKey ? " hasShortcutKey" : ""), (mHasShortcutKey ? " hasShortcutKey" : ""),
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""), (mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
(isMultiLine() ? " isMultiLine" : "") (isMultiLine() ? " isMultiLine" : "")

View File

@ -105,7 +105,10 @@ public final class KeyboardLayoutSet {
int mMode; int mMode;
EditorInfo mEditorInfo; EditorInfo mEditorInfo;
boolean mDisableTouchPositionCorrectionDataForTest; boolean mDisableTouchPositionCorrectionDataForTest;
boolean mVoiceKeyEnabled; boolean mIsPasswordField;
boolean mSupportsSwitchingToShortcutIme;
boolean mShowsVoiceInputKey;
boolean mNoMicrophoneKey;
boolean mNoSettingsKey; boolean mNoSettingsKey;
boolean mLanguageSwitchKeyEnabled; boolean mLanguageSwitchKeyEnabled;
InputMethodSubtype mSubtype; InputMethodSubtype mSubtype;
@ -218,16 +221,24 @@ public final class KeyboardLayoutSet {
private static final EditorInfo EMPTY_EDITOR_INFO = new EditorInfo(); private static final EditorInfo EMPTY_EDITOR_INFO = new EditorInfo();
public Builder(final Context context, final EditorInfo editorInfo) { public Builder(final Context context, final EditorInfo ei) {
mContext = context; mContext = context;
mPackageName = context.getPackageName(); mPackageName = context.getPackageName();
mResources = context.getResources(); mResources = context.getResources();
final Params params = mParams; final Params params = mParams;
final EditorInfo editorInfo = (ei != null) ? ei : EMPTY_EDITOR_INFO;
params.mMode = getKeyboardMode(editorInfo); params.mMode = getKeyboardMode(editorInfo);
params.mEditorInfo = (editorInfo != null) ? editorInfo : EMPTY_EDITOR_INFO; params.mEditorInfo = editorInfo;
params.mIsPasswordField = InputTypeUtils.isPasswordInputType(editorInfo.inputType);
@SuppressWarnings("deprecation")
final boolean deprecatedNoMicrophone = InputAttributes.inPrivateImeOptions(
null, NO_MICROPHONE_COMPAT, editorInfo);
params.mNoMicrophoneKey = InputAttributes.inPrivateImeOptions(
mPackageName, NO_MICROPHONE, editorInfo)
|| deprecatedNoMicrophone;
params.mNoSettingsKey = InputAttributes.inPrivateImeOptions( params.mNoSettingsKey = InputAttributes.inPrivateImeOptions(
mPackageName, NO_SETTINGS_KEY, params.mEditorInfo); mPackageName, NO_SETTINGS_KEY, editorInfo);
} }
public Builder setKeyboardGeometry(final int keyboardWidth, final int keyboardHeight) { public Builder setKeyboardGeometry(final int keyboardWidth, final int keyboardHeight) {
@ -258,15 +269,11 @@ public final class KeyboardLayoutSet {
return this; return this;
} }
public Builder setOptions(final boolean voiceKeyEnabled, public Builder setOptions(final boolean isShortcutImeEnabled,
final boolean languageSwitchKeyEnabled) { final boolean showsVoiceInputKey, final boolean languageSwitchKeyEnabled) {
@SuppressWarnings("deprecation") mParams.mSupportsSwitchingToShortcutIme =
final boolean deprecatedNoMicrophone = InputAttributes.inPrivateImeOptions( isShortcutImeEnabled && !mParams.mNoMicrophoneKey && !mParams.mIsPasswordField;
null, NO_MICROPHONE_COMPAT, mParams.mEditorInfo); mParams.mShowsVoiceInputKey = showsVoiceInputKey;
final boolean noMicrophone = InputAttributes.inPrivateImeOptions(
mPackageName, NO_MICROPHONE, mParams.mEditorInfo)
|| deprecatedNoMicrophone;
mParams.mVoiceKeyEnabled = voiceKeyEnabled && !noMicrophone;
mParams.mLanguageSwitchKeyEnabled = languageSwitchKeyEnabled; mParams.mLanguageSwitchKeyEnabled = languageSwitchKeyEnabled;
return this; return this;
} }
@ -362,9 +369,6 @@ public final class KeyboardLayoutSet {
} }
private static int getKeyboardMode(final EditorInfo editorInfo) { private static int getKeyboardMode(final EditorInfo editorInfo) {
if (editorInfo == null)
return KeyboardId.MODE_TEXT;
final int inputType = editorInfo.inputType; final int inputType = editorInfo.inputType;
final int variation = inputType & InputType.TYPE_MASK_VARIATION; final int variation = inputType & InputType.TYPE_MASK_VARIATION;

View File

@ -154,7 +154,8 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype()); builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
builder.setOptions( builder.setOptions(
settingsValues.isVoiceKeyEnabled(editorInfo), mSubtypeSwitcher.isShortcutImeEnabled(),
settingsValues.mShowsVoiceInputKey,
settingsValues.isLanguageSwitchKeyEnabled()); settingsValues.isLanguageSwitchKeyEnabled());
mKeyboardLayoutSet = builder.build(); mKeyboardLayoutSet = builder.build();
try { try {

View File

@ -649,8 +649,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
R.styleable.Keyboard_Case_passwordInput, id.passwordInput()); R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr, final boolean clobberSettingsKeyMatched = matchBoolean(caseAttr,
R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey); R.styleable.Keyboard_Case_clobberSettingsKey, id.mClobberSettingsKey);
final boolean shortcutKeyEnabledMatched = matchBoolean(caseAttr, final boolean supportsSwitchingToShortcutImeMatched = matchBoolean(caseAttr,
R.styleable.Keyboard_Case_shortcutKeyEnabled, id.mShortcutKeyEnabled); R.styleable.Keyboard_Case_supportsSwitchingToShortcutIme,
id.mSupportsSwitchingToShortcutIme);
final boolean hasShortcutKeyMatched = matchBoolean(caseAttr, final boolean hasShortcutKeyMatched = matchBoolean(caseAttr,
R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey); R.styleable.Keyboard_Case_hasShortcutKey, id.mHasShortcutKey);
final boolean languageSwitchKeyEnabledMatched = matchBoolean(caseAttr, final boolean languageSwitchKeyEnabledMatched = matchBoolean(caseAttr,
@ -669,7 +670,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
&& modeMatched && navigateNextMatched && navigatePreviousMatched && modeMatched && navigateNextMatched && navigatePreviousMatched
&& passwordInputMatched && clobberSettingsKeyMatched && passwordInputMatched && clobberSettingsKeyMatched
&& shortcutKeyEnabledMatched && hasShortcutKeyMatched && supportsSwitchingToShortcutImeMatched && hasShortcutKeyMatched
&& languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched && languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched
&& localeCodeMatched && languageCodeMatched && countryCodeMatched; && localeCodeMatched && languageCodeMatched && countryCodeMatched;
@ -691,8 +692,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
"clobberSettingsKey"), "clobberSettingsKey"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_passwordInput, booleanAttr(caseAttr, R.styleable.Keyboard_Case_passwordInput,
"passwordInput"), "passwordInput"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_shortcutKeyEnabled, booleanAttr(
"shortcutKeyEnabled"), caseAttr, R.styleable.Keyboard_Case_supportsSwitchingToShortcutIme,
"supportsSwitchingToShortcutIme"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_hasShortcutKey, booleanAttr(caseAttr, R.styleable.Keyboard_Case_hasShortcutKey,
"hasShortcutKey"), "hasShortcutKey"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_languageSwitchKeyEnabled, booleanAttr(caseAttr, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,

View File

@ -67,7 +67,7 @@ public final class SettingsValues {
public final boolean mVibrateOn; public final boolean mVibrateOn;
public final boolean mSoundOn; public final boolean mSoundOn;
public final boolean mKeyPreviewPopupOn; public final boolean mKeyPreviewPopupOn;
private final boolean mShowsVoiceInputKey; public final boolean mShowsVoiceInputKey;
public final boolean mIncludesOtherImesInLanguageSwitchList; public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsLanguageSwitchKey; public final boolean mShowsLanguageSwitchKey;
public final boolean mUseContactsDict; public final boolean mUseContactsDict;
@ -271,13 +271,6 @@ public final class SettingsValues {
return mInputAttributes.mShouldInsertSpacesAutomatically; return mInputAttributes.mShouldInsertSpacesAutomatically;
} }
public boolean isVoiceKeyEnabled(final EditorInfo editorInfo) {
final boolean shortcutImeEnabled = SubtypeSwitcher.getInstance().isShortcutImeEnabled();
final int inputType = (editorInfo != null) ? editorInfo.inputType : 0;
return shortcutImeEnabled && mShowsVoiceInputKey
&& !InputTypeUtils.isPasswordInputType(inputType);
}
public boolean isLanguageSwitchKeyEnabled() { public boolean isLanguageSwitchKeyEnabled() {
if (!mShowsLanguageSwitchKey) { if (!mShowsLanguageSwitchKey) {
return false; return false;

View File

@ -1357,8 +1357,9 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
private static final LogStatement LOGSTATEMENT_MAINKEYBOARDVIEW_SETKEYBOARD = private static final LogStatement LOGSTATEMENT_MAINKEYBOARDVIEW_SETKEYBOARD =
new LogStatement("MainKeyboardViewSetKeyboard", false, false, "elementId", "locale", new LogStatement("MainKeyboardViewSetKeyboard", false, false, "elementId", "locale",
"orientation", "width", "modeName", "action", "navigateNext", "orientation", "width", "modeName", "action", "navigateNext",
"navigatePrevious", "clobberSettingsKey", "passwordInput", "shortcutKeyEnabled", "navigatePrevious", "clobberSettingsKey", "passwordInput",
"hasShortcutKey", "languageSwitchKeyEnabled", "isMultiLine", "tw", "th", "supportsSwitchingToShortcutIme", "hasShortcutKey", "languageSwitchKeyEnabled",
"isMultiLine", "tw", "th",
"keys"); "keys");
public static void mainKeyboardView_setKeyboard(final Keyboard keyboard, public static void mainKeyboardView_setKeyboard(final Keyboard keyboard,
final int orientation) { final int orientation) {
@ -1371,7 +1372,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang
kid.mLocale + ":" + kid.mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), kid.mLocale + ":" + kid.mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
orientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(), orientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(),
kid.navigateNext(), kid.navigatePrevious(), kid.mClobberSettingsKey, kid.navigateNext(), kid.navigatePrevious(), kid.mClobberSettingsKey,
isPasswordView, kid.mShortcutKeyEnabled, kid.mHasShortcutKey, isPasswordView, kid.mSupportsSwitchingToShortcutIme, kid.mHasShortcutKey,
kid.mLanguageSwitchKeyEnabled, kid.isMultiLine(), keyboard.mOccupiedWidth, kid.mLanguageSwitchKeyEnabled, kid.isMultiLine(), keyboard.mOccupiedWidth,
keyboard.mOccupiedHeight, keyboard.getKeys()); keyboard.mOccupiedHeight, keyboard.getKeys());
} }