From 2d603fff64499098927a6a615baafa78a1ff3999 Mon Sep 17 00:00:00 2001 From: "Tadashi G. Takaoka" Date: Tue, 13 Dec 2011 22:53:54 +0900 Subject: [PATCH] Remove EditorInfo from KeyboardId Change-Id: I70919ff30622afa1d8c29ca45589fa617f2c1f0e --- .../inputmethod/keyboard/KeyboardId.java | 77 +++++++++++-------- .../keyboard/internal/KeyboardBuilder.java | 6 +- .../inputmethod/latin/SuggestTestsBase.java | 3 +- 3 files changed, 49 insertions(+), 37 deletions(-) diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index db5d8a84c..3b3ff0709 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -63,46 +63,39 @@ public class KeyboardId { // TODO: Remove this field. private final int mXmlId; public final int mElementState; - public final boolean mNavigateAction; - public final boolean mPasswordInput; + private final int mInputType; + private final int mImeOptions; private final boolean mSettingsKeyEnabled; public final boolean mClobberSettingsKey; public final boolean mShortcutKeyEnabled; public final boolean mHasShortcutKey; - public final int mImeAction; - - // TODO: Remove this field. - private final EditorInfo mEditorInfo; private final int mHashCode; public KeyboardId(int xmlId, int elementState, Locale locale, int orientation, int width, int mode, EditorInfo editorInfo, boolean settingsKeyEnabled, boolean clobberSettingsKey, boolean shortcutKeyEnabled, boolean hasShortcutKey) { - final int inputType = (editorInfo != null) ? editorInfo.inputType : 0; - final int imeOptions = (editorInfo != null) ? editorInfo.imeOptions : 0; - this.mElementState = elementState; + this(xmlId, elementState, locale, orientation, width, mode, + (editorInfo != null ? editorInfo.inputType : 0), + (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.mOrientation = orientation; this.mWidth = width; this.mMode = mode; this.mXmlId = xmlId; - // Note: Turn off checking navigation flag to show TAB key for now. - this.mNavigateAction = InputTypeCompatUtils.isWebInputType(inputType); -// || EditorInfoCompatUtils.hasFlagNavigateNext(imeOptions) -// || EditorInfoCompatUtils.hasFlagNavigatePrevious(imeOptions); - this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType) - || InputTypeCompatUtils.isVisiblePasswordInputType(inputType); + this.mElementState = elementState; + this.mInputType = inputType; + this.mImeOptions = imeOptions; this.mSettingsKeyEnabled = settingsKeyEnabled; this.mClobberSettingsKey = clobberSettingsKey; this.mShortcutKeyEnabled = shortcutKeyEnabled; 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); } @@ -114,14 +107,14 @@ public class KeyboardId { id.mMode, id.mWidth, id.mXmlId, - id.mNavigateAction, - id.mPasswordInput, + id.navigateAction(), + id.passwordInput(), id.mSettingsKeyEnabled, id.mClobberSettingsKey, id.mShortcutKeyEnabled, id.mHasShortcutKey, - id.mImeAction, - id.mLocale, + id.imeAction(), + id.mLocale }); } @@ -133,19 +126,19 @@ public class KeyboardId { && other.mMode == this.mMode && other.mWidth == this.mWidth && other.mXmlId == this.mXmlId - && other.mNavigateAction == this.mNavigateAction - && other.mPasswordInput == this.mPasswordInput + && other.navigateAction() == this.navigateAction() + && other.passwordInput() == this.passwordInput() && other.mSettingsKeyEnabled == this.mSettingsKeyEnabled && other.mClobberSettingsKey == this.mClobberSettingsKey && other.mShortcutKeyEnabled == this.mShortcutKeyEnabled && other.mHasShortcutKey == this.mHasShortcutKey - && other.mImeAction == this.mImeAction + && other.imeAction() == this.imeAction() && other.mLocale.equals(this.mLocale); } public KeyboardId cloneWithNewXml(int xmlId) { return new KeyboardId(xmlId, mElementState, mLocale, mOrientation, mWidth, mMode, - mEditorInfo, false, false, false, false); + mInputType, mImeOptions, false, false, false, false); } // Remove this method. @@ -169,6 +162,26 @@ public class KeyboardId { 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() { return mSettingsKeyEnabled && !mClobberSettingsKey; } @@ -205,11 +218,11 @@ public class KeyboardId { mLocale, (mOrientation == 1 ? "port" : "land"), mWidth, modeName(mMode), - EditorInfoCompatUtils.imeOptionsName(mImeAction), + EditorInfoCompatUtils.imeOptionsName(imeAction()), f2KeyModeName(f2KeyMode()), (mClobberSettingsKey ? " clobberSettingsKey" : ""), - (mNavigateAction ? " navigateAction" : ""), - (mPasswordInput ? " passwordInput" : ""), + (navigateAction() ? " navigateAction" : ""), + (passwordInput() ? " passwordInput" : ""), (hasSettingsKey() ? " hasSettingsKey" : ""), (mShortcutKeyEnabled ? " shortcutKeyEnabled" : ""), (mHasShortcutKey ? " hasShortcutKey" : "") diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java index 31785ff75..66a9d049b 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java @@ -609,9 +609,9 @@ public class KeyboardBuilder { final boolean modeMatched = matchTypedValue(a, R.styleable.Keyboard_Case_mode, id.mMode, KeyboardId.modeName(id.mMode)); final boolean navigateActionMatched = matchBoolean(a, - R.styleable.Keyboard_Case_navigateAction, id.mNavigateAction); + R.styleable.Keyboard_Case_navigateAction, id.navigateAction()); final boolean passwordInputMatched = matchBoolean(a, - R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput); + R.styleable.Keyboard_Case_passwordInput, id.passwordInput()); final boolean hasSettingsKeyMatched = matchBoolean(a, R.styleable.Keyboard_Case_hasSettingsKey, id.hasSettingsKey()); final boolean f2KeyModeMatched = matchInteger(a, @@ -627,7 +627,7 @@ public class KeyboardBuilder { // {@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. final boolean imeActionMatched = matchInteger(a, - R.styleable.Keyboard_Case_imeAction, id.mImeAction); + R.styleable.Keyboard_Case_imeAction, id.imeAction()); final boolean localeCodeMatched = matchString(a, R.styleable.Keyboard_Case_localeCode, id.mLocale.toString()); final boolean languageCodeMatched = matchString(a, diff --git a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java index 406c97f71..7b4c6a904 100644 --- a/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java +++ b/tests/src/com/android/inputmethod/latin/SuggestTestsBase.java @@ -21,7 +21,6 @@ import android.content.res.Configuration; import android.test.AndroidTestCase; import android.text.TextUtils; import android.util.DisplayMetrics; -import android.view.inputmethod.EditorInfo; 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, 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) {