Remove EditorInfo from KeyboardId

Change-Id: I70919ff30622afa1d8c29ca45589fa617f2c1f0e
main
Tadashi G. Takaoka 2011-12-13 22:53:54 +09:00
parent 014b755f8a
commit 2d603fff64
3 changed files with 49 additions and 37 deletions

View File

@ -63,46 +63,39 @@ public class KeyboardId {
// TODO: Remove this field. // TODO: Remove this field.
private final int mXmlId; private final int mXmlId;
public final int mElementState; public final int mElementState;
public final boolean mNavigateAction; private final int mInputType;
public final boolean mPasswordInput; private final int mImeOptions;
private final boolean mSettingsKeyEnabled; private final boolean mSettingsKeyEnabled;
public final boolean mClobberSettingsKey; public final boolean mClobberSettingsKey;
public final boolean mShortcutKeyEnabled; public final boolean mShortcutKeyEnabled;
public final boolean mHasShortcutKey; public final boolean mHasShortcutKey;
public final int mImeAction;
// TODO: Remove this field.
private final EditorInfo mEditorInfo;
private final int mHashCode; private final int mHashCode;
public KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width, public KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width,
int mode, EditorInfo editorInfo, boolean settingsKeyEnabled, int mode, EditorInfo editorInfo, boolean settingsKeyEnabled,
boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) { boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) {
final int inputType = (editorInfo != null) ? editorInfo.inputType : 0; this(xmlId, elementState, locale, orientation, width, mode,
final int imeOptions = (editorInfo != null) ? editorInfo.imeOptions : 0; (editorInfo != null ? editorInfo.inputType : 0),
this.mElementState = elementState; (editorInfo != null ? editorInfo.imeOptions : 0),
settingsKeyEnabled, clobberSettingsKey, shortcutKeyEnabled, hasShortcutKey);
}
private KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width,
int mode, int inputType, int imeOptions, boolean settingsKeyEnabled,
boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) {
this.mLocale = locale; this.mLocale = locale;
this.mOrientation = orientation; this.mOrientation = orientation;
this.mWidth = width; this.mWidth = width;
this.mMode = mode; this.mMode = mode;
this.mXmlId = xmlId; this.mXmlId = xmlId;
// Note: Turn off checking navigation flag to show TAB key for now. this.mElementState = elementState;
this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType); this.mInputType = inputType;
// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions) this.mImeOptions = imeOptions;
// || EditorInfoCompatUtils.hasFlagNavigatePrevious(imeOptions);
this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType);
this.mSettingsKeyEnabled = settingsKeyEnabled; this.mSettingsKeyEnabled = settingsKeyEnabled;
this.mClobberSettingsKey = clobberSettingsKey; this.mClobberSettingsKey = clobberSettingsKey;
this.mShortcutKeyEnabled = shortcutKeyEnabled; this.mShortcutKeyEnabled = shortcutKeyEnabled;
this.mHasShortcutKey = hasShortcutKey; this.mHasShortcutKey = hasShortcutKey;
// We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
// {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION}.
this.mImeAction = imeOptions & (
EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
this.mEditorInfo = editorInfo;
this.mHashCode = hashCode(this); this.mHashCode = hashCode(this);
} }
@ -114,14 +107,14 @@ public class KeyboardId {
id.mMode, id.mMode,
id.mWidth, id.mWidth,
id.mXmlId, id.mXmlId,
id.mNavigateAction, id.navigateAction(),
id.mPasswordInput, id.passwordInput(),
id.mSettingsKeyEnabled, id.mSettingsKeyEnabled,
id.mClobberSettingsKey, id.mClobberSettingsKey,
id.mShortcutKeyEnabled, id.mShortcutKeyEnabled,
id.mHasShortcutKey, id.mHasShortcutKey,
id.mImeAction, id.imeAction(),
id.mLocale, id.mLocale
}); });
} }
@ -133,19 +126,19 @@ public class KeyboardId {
&& other.mMode == this.mMode && other.mMode == this.mMode
&& other.mWidth == this.mWidth && other.mWidth == this.mWidth
&& other.mXmlId == this.mXmlId && other.mXmlId == this.mXmlId
&& other.mNavigateAction == this.mNavigateAction && other.navigateAction() == this.navigateAction()
&& other.mPasswordInput == this.mPasswordInput && other.passwordInput() == this.passwordInput()
&& other.mSettingsKeyEnabled == this.mSettingsKeyEnabled && other.mSettingsKeyEnabled == this.mSettingsKeyEnabled
&& other.mClobberSettingsKey == this.mClobberSettingsKey && other.mClobberSettingsKey == this.mClobberSettingsKey
&& other.mShortcutKeyEnabled == this.mShortcutKeyEnabled && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled
&& other.mHasShortcutKey == this.mHasShortcutKey && other.mHasShortcutKey == this.mHasShortcutKey
&& other.mImeAction == this.mImeAction && other.imeAction() == this.imeAction()
&& other.mLocale.equals(this.mLocale); && other.mLocale.equals(this.mLocale);
} }
public KeyboardId cloneWithNewXml(int xmlId) { public KeyboardId cloneWithNewXml(int xmlId) {
return new KeyboardId(xmlId, mElementState, mLocale, mOrientation, mWidth, mMode, return new KeyboardId(xmlId, mElementState, mLocale, mOrientation, mWidth, mMode,
mEditorInfo, false, false, false, false); mInputType, mImeOptions, false, false, false, false);
} }
// Remove this method. // Remove this method.
@ -169,6 +162,26 @@ public class KeyboardId {
return mElementState == ELEMENT_PHONE_SHIFT; return mElementState == ELEMENT_PHONE_SHIFT;
} }
public boolean navigateAction() {
// Note: Turn off checking navigation flag to show TAB key for now.
boolean navigateAction = InputTypeCompatUtils.isWebInputType(mInputType);
// || EditorInfoCompatUtils.hasFlagNavigateNext(mImeOptions)
// || EditorInfoCompatUtils.hasFlagNavigatePrevious(mImeOptions);
return navigateAction;
}
public boolean passwordInput() {
return InputTypeCompatUtils.isPasswordInputType(mInputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(mInputType);
}
public int imeAction() {
// We are interested only in {@link EditorInfo#IME_MASK_ACTION} enum value and
// {@link EditorInfo#IME_FLAG_NO_ENTER_ACTION}.
return mImeOptions & (
EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION);
}
public boolean hasSettingsKey() { public boolean hasSettingsKey() {
return mSettingsKeyEnabled && !mClobberSettingsKey; return mSettingsKeyEnabled && !mClobberSettingsKey;
} }
@ -205,11 +218,11 @@ public class KeyboardId {
mLocale, mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth, (mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode), modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction), EditorInfoCompatUtils.imeOptionsName(imeAction()),
f2KeyModeName(f2KeyMode()), f2KeyModeName(f2KeyMode()),
(mClobberSettingsKey ? " clobberSettingsKey" : ""), (mClobberSettingsKey ? " clobberSettingsKey" : ""),
(mNavigateAction ? " navigateAction" : ""), (navigateAction() ? " navigateAction" : ""),
(mPasswordInput ? " passwordInput" : ""), (passwordInput() ? " passwordInput" : ""),
(hasSettingsKey() ? " hasSettingsKey" : ""), (hasSettingsKey() ? " hasSettingsKey" : ""),
(mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""), (mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""),
(mHasShortcutKey ? " hasShortcutKey" : "") (mHasShortcutKey ? " hasShortcutKey" : "")

View File

@ -609,9 +609,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean modeMatched = matchTypedValue(a, final boolean modeMatched = matchTypedValue(a,
R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode)); R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode));
final boolean navigateActionMatched = matchBoolean(a, final boolean navigateActionMatched = matchBoolean(a,
R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction); R.styleable.Keyboard_Case_navigateAction, id.navigateAction());
final boolean passwordInputMatched = matchBoolean(a, final boolean passwordInputMatched = matchBoolean(a,
R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput); R.styleable.Keyboard_Case_passwordInput, id.passwordInput());
final boolean hasSettingsKeyMatched = matchBoolean(a, final boolean hasSettingsKeyMatched = matchBoolean(a,
R.styleable.Keyboard_Case_hasSettingsKey, id.hasSettingsKey()); R.styleable.Keyboard_Case_hasSettingsKey, id.hasSettingsKey());
final boolean f2KeyModeMatched = matchInteger(a, final boolean f2KeyModeMatched = matchInteger(a,
@ -627,7 +627,7 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
// {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching // {@link android.view.inputmethod.EditorInfo#IME_FLAG_NO_ENTER_ACTION}. So matching
// this attribute with id.mImeOptions as integer value is enough for our purpose. // this attribute with id.mImeOptions as integer value is enough for our purpose.
final boolean imeActionMatched = matchInteger(a, final boolean imeActionMatched = matchInteger(a,
R.styleable.Keyboard_Case_imeAction, id.mImeAction); R.styleable.Keyboard_Case_imeAction, id.imeAction());
final boolean localeCodeMatched = matchString(a, final boolean localeCodeMatched = matchString(a,
R.styleable.Keyboard_Case_localeCode, id.mLocale.toString()); R.styleable.Keyboard_Case_localeCode, id.mLocale.toString());
final boolean languageCodeMatched = matchString(a, final boolean languageCodeMatched = matchString(a,

View File

@ -21,7 +21,6 @@ import android.content.res.Configuration;
import android.test.AndroidTestCase; import android.test.AndroidTestCase;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.view.inputmethod.EditorInfo;
import com.android.inputmethod.keyboard.KeyboardId; import com.android.inputmethod.keyboard.KeyboardId;
@ -52,7 +51,7 @@ public class SuggestTestsBase extends AndroidTestCase {
} }
return new KeyboardId(com.android.inputmethod.latin.R.xml.kbd_qwerty, return new KeyboardId(com.android.inputmethod.latin.R.xml.kbd_qwerty,
KeyboardId.ELEMENT_ALPHABET, locale, orientation, width, KeyboardId.MODE_TEXT, KeyboardId.ELEMENT_ALPHABET, locale, orientation, width, KeyboardId.MODE_TEXT,
new EditorInfo(), false, false, false, false); null, false, false, false, false);
} }
protected InputStream openTestRawResource(int resIdInTest) { protected InputStream openTestRawResource(int resIdInTest) {