Remove unused supportsSwitchingToShortcutIme attribute

Change-Id: I51c5247ac925a158facb79057f704b763b903552
This commit is contained in:
Tadashi G. Takaoka 2014-06-06 01:41:42 +09:00
parent b7206b6bca
commit 3ca65c8fd5
11 changed files with 49 additions and 51 deletions

View file

@ -437,7 +437,6 @@
<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="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

@ -70,7 +70,6 @@ public final class KeyboardId {
public final int mElementId; public final int mElementId;
public final EditorInfo mEditorInfo; public final EditorInfo mEditorInfo;
public final boolean mClobberSettingsKey; public final boolean mClobberSettingsKey;
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 +85,10 @@ public final class KeyboardId {
mElementId = elementId; mElementId = elementId;
mEditorInfo = params.mEditorInfo; mEditorInfo = params.mEditorInfo;
mClobberSettingsKey = params.mNoSettingsKey; mClobberSettingsKey = params.mNoSettingsKey;
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 = mSupportsSwitchingToShortcutIme && params.mShowsVoiceInputKey; mHasShortcutKey = params.mVoiceInputKeyEnabled;
mHashCode = computeHashCode(this); mHashCode = computeHashCode(this);
} }
@ -103,7 +101,6 @@ public final class KeyboardId {
id.mHeight, id.mHeight,
id.passwordInput(), id.passwordInput(),
id.mClobberSettingsKey, id.mClobberSettingsKey,
id.mSupportsSwitchingToShortcutIme,
id.mHasShortcutKey, id.mHasShortcutKey,
id.mLanguageSwitchKeyEnabled, id.mLanguageSwitchKeyEnabled,
id.isMultiLine(), id.isMultiLine(),
@ -124,7 +121,6 @@ public final class KeyboardId {
&& other.mHeight == mHeight && other.mHeight == mHeight
&& other.passwordInput() == passwordInput() && other.passwordInput() == passwordInput()
&& other.mClobberSettingsKey == mClobberSettingsKey && other.mClobberSettingsKey == mClobberSettingsKey
&& other.mSupportsSwitchingToShortcutIme == mSupportsSwitchingToShortcutIme
&& other.mHasShortcutKey == mHasShortcutKey && other.mHasShortcutKey == mHasShortcutKey
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled && other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
&& other.isMultiLine() == isMultiLine() && other.isMultiLine() == isMultiLine()
@ -179,7 +175,7 @@ public final class KeyboardId {
@Override @Override
public String toString() { public String toString() {
return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s%s]", return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s%s%s%s%s%s%s%s]",
elementIdToName(mElementId), elementIdToName(mElementId),
mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET),
mWidth, mHeight, mWidth, mHeight,
@ -189,7 +185,6 @@ public final class KeyboardId {
(navigatePrevious() ? " navigatePrevious" : ""), (navigatePrevious() ? " navigatePrevious" : ""),
(mClobberSettingsKey ? " clobberSettingsKey" : ""), (mClobberSettingsKey ? " clobberSettingsKey" : ""),
(passwordInput() ? " passwordInput" : ""), (passwordInput() ? " passwordInput" : ""),
(mSupportsSwitchingToShortcutIme ? " supportsSwitchingToShortcutIme" : ""),
(mHasShortcutKey ? " hasShortcutKey" : ""), (mHasShortcutKey ? " hasShortcutKey" : ""),
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""), (mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
(isMultiLine() ? " isMultiLine" : "") (isMultiLine() ? " isMultiLine" : "")

View file

@ -17,8 +17,6 @@
package com.android.inputmethod.keyboard; package com.android.inputmethod.keyboard;
import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII; import static com.android.inputmethod.latin.Constants.ImeOption.FORCE_ASCII;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY; import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY;
import android.content.Context; import android.content.Context;
@ -102,12 +100,11 @@ public final class KeyboardLayoutSet {
public static final class Params { public static final class Params {
String mKeyboardLayoutSetName; String mKeyboardLayoutSetName;
int mMode; int mMode;
EditorInfo mEditorInfo;
boolean mDisableTouchPositionCorrectionDataForTest; boolean mDisableTouchPositionCorrectionDataForTest;
// TODO: Use {@link InputAttributes} instead of these variables.
EditorInfo mEditorInfo;
boolean mIsPasswordField; boolean mIsPasswordField;
boolean mSupportsSwitchingToShortcutIme; boolean mVoiceInputKeyEnabled;
boolean mShowsVoiceInputKey;
boolean mNoMicrophoneKey;
boolean mNoSettingsKey; boolean mNoSettingsKey;
boolean mLanguageSwitchKeyEnabled; boolean mLanguageSwitchKeyEnabled;
InputMethodSubtype mSubtype; InputMethodSubtype mSubtype;
@ -228,14 +225,9 @@ public final class KeyboardLayoutSet {
final EditorInfo editorInfo = (ei != null) ? ei : EMPTY_EDITOR_INFO; final EditorInfo editorInfo = (ei != null) ? ei : EMPTY_EDITOR_INFO;
params.mMode = getKeyboardMode(editorInfo); params.mMode = getKeyboardMode(editorInfo);
// TODO: Consolidate those with {@link InputAttributes}.
params.mEditorInfo = editorInfo; params.mEditorInfo = editorInfo;
params.mIsPasswordField = InputTypeUtils.isPasswordInputType(editorInfo.inputType); 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, editorInfo); mPackageName, NO_SETTINGS_KEY, editorInfo);
} }
@ -248,6 +240,7 @@ public final class KeyboardLayoutSet {
public Builder setSubtype(final InputMethodSubtype subtype) { public Builder setSubtype(final InputMethodSubtype subtype) {
final boolean asciiCapable = InputMethodSubtypeCompatUtils.isAsciiCapable(subtype); final boolean asciiCapable = InputMethodSubtypeCompatUtils.isAsciiCapable(subtype);
// TODO: Consolidate with {@link InputAttributes}.
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions( final boolean deprecatedForceAscii = InputAttributes.inPrivateImeOptions(
mPackageName, FORCE_ASCII, mParams.mEditorInfo); mPackageName, FORCE_ASCII, mParams.mEditorInfo);
@ -268,12 +261,13 @@ public final class KeyboardLayoutSet {
return this; return this;
} }
public Builder setOptions(final boolean isShortcutImeEnabled, public Builder setVoiceInputKeyEnabled(final boolean enabled) {
final boolean showsVoiceInputKey, final boolean languageSwitchKeyEnabled) { mParams.mVoiceInputKeyEnabled = enabled;
mParams.mSupportsSwitchingToShortcutIme = return this;
isShortcutImeEnabled && !mParams.mNoMicrophoneKey && !mParams.mIsPasswordField; }
mParams.mShowsVoiceInputKey = showsVoiceInputKey;
mParams.mLanguageSwitchKeyEnabled = languageSwitchKeyEnabled; public Builder setLanguageSwitchKeyEnabled(final boolean enabled) {
mParams.mLanguageSwitchKeyEnabled = enabled;
return this; return this;
} }

View file

@ -115,10 +115,10 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setKeyboardGeometry(keyboardWidth, keyboardHeight);
builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype()); builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype());
builder.setOptions( builder.setVoiceInputKeyEnabled(mSubtypeSwitcher.isShortcutImeEnabled()
mSubtypeSwitcher.isShortcutImeEnabled(), && settingsValues.mShowsVoiceInputKey
settingsValues.mShowsVoiceInputKey, && !settingsValues.mInputAttributes.hasNoMicrophoneKeyOption());
mLatinIME.shouldShowLanguageSwitchKey()); builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
mKeyboardLayoutSet = builder.build(); mKeyboardLayoutSet = builder.build();
mCurrentSettingsValues = settingsValues; mCurrentSettingsValues = settingsValues;
try { try {

View file

@ -115,8 +115,6 @@ 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 /* shortcutImeEnabled */, false /* showsVoiceInputKey */,
false /* languageSwitchKeyEnabled */);
final KeyboardLayoutSet layoutSet = builder.build(); final KeyboardLayoutSet layoutSet = builder.build();
final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs, final TypedArray emojiPalettesViewAttr = context.obtainStyledAttributes(attrs,
R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView); R.styleable.EmojiPalettesView, defStyle, R.style.EmojiPalettesView);

View file

@ -652,9 +652,6 @@ 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 supportsSwitchingToShortcutImeMatched = matchBoolean(caseAttr,
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,
@ -674,14 +671,13 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
&& modeMatched && navigateNextMatched && navigatePreviousMatched && modeMatched && navigateNextMatched && navigatePreviousMatched
&& passwordInputMatched && clobberSettingsKeyMatched && passwordInputMatched && clobberSettingsKeyMatched && hasShortcutKeyMatched
&& supportsSwitchingToShortcutImeMatched && hasShortcutKeyMatched
&& languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched && languageSwitchKeyEnabledMatched && isMultiLineMatched && imeActionMatched
&& isIconDefinedMatched && localeCodeMatched && languageCodeMatched && isIconDefinedMatched && localeCodeMatched && languageCodeMatched
&& countryCodeMatched; && countryCodeMatched;
if (DEBUG) { if (DEBUG) {
startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE, startTag("<%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s%s>%s", TAG_CASE,
textAttr(caseAttr.getString( textAttr(caseAttr.getString(
R.styleable.Keyboard_Case_keyboardLayoutSet), "keyboardLayoutSet"), R.styleable.Keyboard_Case_keyboardLayoutSet), "keyboardLayoutSet"),
textAttr(caseAttr.getString( textAttr(caseAttr.getString(
@ -698,9 +694,6 @@ 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_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

@ -16,6 +16,9 @@
package com.android.inputmethod.latin; package com.android.inputmethod.latin;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE;
import static com.android.inputmethod.latin.Constants.ImeOption.NO_MICROPHONE_COMPAT;
import android.text.InputType; import android.text.InputType;
import android.util.Log; import android.util.Log;
import android.view.inputmethod.EditorInfo; import android.view.inputmethod.EditorInfo;
@ -39,8 +42,13 @@ public final class InputAttributes {
final public boolean mApplicationSpecifiedCompletionOn; final public boolean mApplicationSpecifiedCompletionOn;
final public boolean mShouldInsertSpacesAutomatically; final public boolean mShouldInsertSpacesAutomatically;
final private int mInputType; final private int mInputType;
final private EditorInfo mEditorInfo;
final private String mPackageNameForPrivateImeOptions;
public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode) { public InputAttributes(final EditorInfo editorInfo, final boolean isFullscreenMode,
final String packageNameForPrivateImeOptions) {
mEditorInfo = editorInfo;
mPackageNameForPrivateImeOptions = packageNameForPrivateImeOptions;
mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null; mTargetApplicationPackageName = null != editorInfo ? editorInfo.packageName : null;
final int inputType = null != editorInfo ? editorInfo.inputType : 0; final int inputType = null != editorInfo ? editorInfo.inputType : 0;
final int inputClass = inputType & InputType.TYPE_MASK_CLASS; final int inputClass = inputType & InputType.TYPE_MASK_CLASS;
@ -111,6 +119,15 @@ public final class InputAttributes {
return editorInfo.inputType == mInputType; return editorInfo.inputType == mInputType;
} }
public boolean hasNoMicrophoneKeyOption() {
@SuppressWarnings("deprecation")
final boolean deprecatedNoMicrophone = InputAttributes.inPrivateImeOptions(
null, NO_MICROPHONE_COMPAT, mEditorInfo);
final boolean noMicrophone = InputAttributes.inPrivateImeOptions(
mPackageNameForPrivateImeOptions, NO_MICROPHONE, mEditorInfo);
return noMicrophone || deprecatedNoMicrophone;
}
@SuppressWarnings("unused") @SuppressWarnings("unused")
private void dumpFlags(final int inputType) { private void dumpFlags(final int inputType) {
final int inputClass = inputType & InputType.TYPE_MASK_CLASS; final int inputClass = inputType & InputType.TYPE_MASK_CLASS;

View file

@ -522,7 +522,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen
void loadSettings() { void loadSettings() {
final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale(); final Locale locale = mSubtypeSwitcher.getCurrentSubtypeLocale();
final EditorInfo editorInfo = getCurrentInputEditorInfo(); final EditorInfo editorInfo = getCurrentInputEditorInfo();
final InputAttributes inputAttributes = new InputAttributes(editorInfo, isFullscreenMode()); final InputAttributes inputAttributes = new InputAttributes(
editorInfo, isFullscreenMode(), getPackageName());
mSettings.loadSettings(this, locale, inputAttributes); mSettings.loadSettings(this, locale, inputAttributes);
final SettingsValues currentSettingsValues = mSettings.getCurrent(); final SettingsValues currentSettingsValues = mSettings.getCurrent();
AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(currentSettingsValues); AudioAndHapticFeedbackManager.getInstance().onSettingsChanged(currentSettingsValues);

View file

@ -109,7 +109,8 @@ public final class SettingsValues {
// Store the input attributes // Store the input attributes
if (null == inputAttributes) { if (null == inputAttributes) {
mInputAttributes = new InputAttributes(null, false /* isFullscreenMode */); mInputAttributes = new InputAttributes(
null, false /* isFullscreenMode */, context.getPackageName());
} else { } else {
mInputAttributes = inputAttributes; mInputAttributes = inputAttributes;
} }

View file

@ -114,13 +114,13 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
final EditorInfo editorInfo) { final EditorInfo editorInfo) {
return createKeyboardLayoutSet(subtype, editorInfo, false /* isShortcutImeEnabled */, return createKeyboardLayoutSet(subtype, editorInfo, false /* voiceInputKeyEnabled */,
false /* showsVoiceInputKey */, false /* isLanguageSwitchKeyEnabled */); false /* languageSwitchKeyEnabled */);
} }
protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype, protected final KeyboardLayoutSet createKeyboardLayoutSet(final InputMethodSubtype subtype,
final EditorInfo editorInfo, final boolean isShortcutImeEnabled, final EditorInfo editorInfo, final boolean voiceInputKeyEnabled,
final boolean showsVoiceInputKey, final boolean isLanguageSwitchKeyEnabled) { final boolean languageSwitchKeyEnabled) {
final Context context = mThemeContext; final Context context = mThemeContext;
final Resources res = context.getResources(); final Resources res = context.getResources();
final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res);
@ -128,7 +128,8 @@ public abstract class KeyboardLayoutSetTestsBase extends AndroidTestCase {
final Builder builder = new Builder(context, editorInfo); final Builder builder = new Builder(context, editorInfo);
builder.setKeyboardGeometry(keyboardWidth, keyboardHeight) builder.setKeyboardGeometry(keyboardWidth, keyboardHeight)
.setSubtype(subtype) .setSubtype(subtype)
.setOptions(isShortcutImeEnabled, showsVoiceInputKey, isLanguageSwitchKeyEnabled); .setVoiceInputKeyEnabled(voiceInputKeyEnabled)
.setLanguageSwitchKeyEnabled(languageSwitchKeyEnabled);
return builder.build(); return builder.build();
} }
} }

View file

@ -54,8 +54,7 @@ abstract class LayoutTestsBase extends KeyboardLayoutSetTestsBase {
+ (isPhone() ? "phone" : "tablet"); + (isPhone() ? "phone" : "tablet");
// TODO: Test with language switch key enabled and disabled. // TODO: Test with language switch key enabled and disabled.
mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */, mKeyboardLayoutSet = createKeyboardLayoutSet(mSubtype, null /* editorInfo */,
true /* isShortcutImeEnabled */, true /* showsVoiceInputKey */, true /* voiceInputKeyEnabled */, true /* languageSwitchKeyEnabled */);
true /* isLanguageSwitchKeyEnabled */);
} }
@Override @Override