Remove web mode and add webInput boolean

Bug: 4490948
Change-Id: I6fe23c9ab4918eab6806cc621c4d6821c2e1baf9
Cherry-Pick: I4cd1af0b
main
Tadashi G. Takaoka 2011-05-27 21:41:13 +09:00
parent 144e97f154
commit 9e2d810dc5
8 changed files with 50 additions and 23 deletions

View File

@ -184,9 +184,10 @@
<enum name="url" value="1" /> <enum name="url" value="1" />
<enum name="email" value="2" /> <enum name="email" value="2" />
<enum name="im" value="3" /> <enum name="im" value="3" />
<enum name="web" value="4" /> <enum name="phone" value="4" />
<enum name="phone" value="5" /> <enum name="number" value="5" />
</attr> </attr>
<attr name="webInput" format="boolean" />
<attr name="passwordInput" format="boolean" /> <attr name="passwordInput" format="boolean" />
<attr name="hasSettingsKey" format="string" /> <attr name="hasSettingsKey" format="string" />
<attr name="voiceKeyEnabled" format="string" /> <attr name="voiceKeyEnabled" format="string" />

View File

@ -46,7 +46,7 @@
</case> </case>
<!-- latin:hasVoiceKey="false" --> <!-- latin:hasVoiceKey="false" -->
<case <case
latin:mode="web" latin:webInput="true"
> >
<Key <Key
latin:keyLabel="." latin:keyLabel="."

View File

@ -40,7 +40,7 @@
latin:keyWidth="40%p" /> latin:keyWidth="40%p" />
<switch> <switch>
<case <case
latin:mode="web" latin:webInput="true"
> >
<Key <Key
latin:keyHintIcon="@drawable/hint_popup" latin:keyHintIcon="@drawable/hint_popup"
@ -90,7 +90,7 @@
latin:keyWidth="30%p" /> latin:keyWidth="30%p" />
<switch> <switch>
<case <case
latin:mode="web" latin:webInput="true"
> >
<Key <Key
latin:keyHintIcon="@drawable/hint_popup" latin:keyHintIcon="@drawable/hint_popup"

View File

@ -37,6 +37,7 @@ public class InputTypeCompatUtils {
(Integer) CompatUtils.getFieldValue(null, null, (Integer) CompatUtils.getFieldValue(null, null,
FIELD_InputType_TYPE_NUMBER_VARIATION_PASSWORD); FIELD_InputType_TYPE_NUMBER_VARIATION_PASSWORD);
private static final int WEB_TEXT_PASSWORD_INPUT_TYPE; private static final int WEB_TEXT_PASSWORD_INPUT_TYPE;
private static final int WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE;
private static final int NUMBER_PASSWORD_INPUT_TYPE; private static final int NUMBER_PASSWORD_INPUT_TYPE;
private static final int TEXT_PASSWORD_INPUT_TYPE = private static final int TEXT_PASSWORD_INPUT_TYPE =
InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
@ -48,6 +49,11 @@ public class InputTypeCompatUtils {
OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD != null OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD != null
? InputType.TYPE_CLASS_TEXT | OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD ? InputType.TYPE_CLASS_TEXT | OBJ_InputType_TYPE_TEXT_VARIATION_WEB_PASSWORD
: 0; : 0;
WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE =
OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS != null
? InputType.TYPE_CLASS_TEXT
| OBJ_InputType_TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS
: 0;
NUMBER_PASSWORD_INPUT_TYPE = NUMBER_PASSWORD_INPUT_TYPE =
OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD != null OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD != null
? InputType.TYPE_CLASS_NUMBER | OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD ? InputType.TYPE_CLASS_NUMBER | OBJ_InputType_TYPE_NUMBER_VARIATION_PASSWORD
@ -59,6 +65,11 @@ public class InputTypeCompatUtils {
&& inputType == WEB_TEXT_PASSWORD_INPUT_TYPE; && inputType == WEB_TEXT_PASSWORD_INPUT_TYPE;
} }
private static boolean isWebEmailAddressInputType(int inputType) {
return WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE != 0
&& inputType == WEB_TEXT_EMAIL_ADDRESS_INPUT_TYPE;
}
private static boolean isNumberPasswordInputType(int inputType) { private static boolean isNumberPasswordInputType(int inputType) {
return NUMBER_PASSWORD_INPUT_TYPE != 0 return NUMBER_PASSWORD_INPUT_TYPE != 0
&& inputType == NUMBER_PASSWORD_INPUT_TYPE; && inputType == NUMBER_PASSWORD_INPUT_TYPE;
@ -78,6 +89,14 @@ public class InputTypeCompatUtils {
|| isWebEmailAddressVariation(variation); || isWebEmailAddressVariation(variation);
} }
public static boolean isWebInputType(int inputType) {
final int maskedInputType =
inputType & (InputType.TYPE_MASK_CLASS | InputType.TYPE_MASK_VARIATION);
return maskedInputType == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT
|| isWebPasswordInputType(maskedInputType)
|| isWebEmailAddressInputType(maskedInputType);
}
// Please refer to TextView.isPasswordInputType // Please refer to TextView.isPasswordInputType
public static boolean isPasswordInputType(int inputType) { public static boolean isPasswordInputType(int inputType) {
final int maskedInputType = final int maskedInputType =

View File

@ -34,9 +34,8 @@ public class KeyboardId {
public static final int MODE_URL = 1; public static final int MODE_URL = 1;
public static final int MODE_EMAIL = 2; public static final int MODE_EMAIL = 2;
public static final int MODE_IM = 3; public static final int MODE_IM = 3;
public static final int MODE_WEB = 4; public static final int MODE_PHONE = 4;
public static final int MODE_PHONE = 5; public static final int MODE_NUMBER = 5;
public static final int MODE_NUMBER = 6;
public final Locale mLocale; public final Locale mLocale;
public final int mOrientation; public final int mOrientation;
@ -44,6 +43,7 @@ public class KeyboardId {
public final int mMode; public final int mMode;
public final int mXmlId; public final int mXmlId;
public final int mColorScheme; public final int mColorScheme;
public final boolean mWebInput;
public final boolean mPasswordInput; public final boolean mPasswordInput;
public final boolean mHasSettingsKey; public final boolean mHasSettingsKey;
public final boolean mVoiceKeyEnabled; public final boolean mVoiceKeyEnabled;
@ -67,6 +67,7 @@ public class KeyboardId {
this.mMode = mode; this.mMode = mode;
this.mXmlId = xmlId; this.mXmlId = xmlId;
this.mColorScheme = colorScheme; this.mColorScheme = colorScheme;
this.mWebInput = InputTypeCompatUtils.isWebInputType(inputType);
this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType) this.mPasswordInput = InputTypeCompatUtils.isPasswordInputType(inputType)
|| InputTypeCompatUtils.isVisiblePasswordInputType(inputType); || InputTypeCompatUtils.isVisiblePasswordInputType(inputType);
this.mHasSettingsKey = hasSettingsKey; this.mHasSettingsKey = hasSettingsKey;
@ -88,6 +89,7 @@ public class KeyboardId {
mode, mode,
xmlId, xmlId,
colorScheme, colorScheme,
mWebInput,
mPasswordInput, mPasswordInput,
hasSettingsKey, hasSettingsKey,
voiceKeyEnabled, voiceKeyEnabled,
@ -141,6 +143,7 @@ public class KeyboardId {
&& other.mMode == this.mMode && other.mMode == this.mMode
&& other.mXmlId == this.mXmlId && other.mXmlId == this.mXmlId
&& other.mColorScheme == this.mColorScheme && other.mColorScheme == this.mColorScheme
&& other.mWebInput == this.mWebInput
&& other.mPasswordInput == this.mPasswordInput && other.mPasswordInput == this.mPasswordInput
&& other.mHasSettingsKey == this.mHasSettingsKey && other.mHasSettingsKey == this.mHasSettingsKey
&& other.mVoiceKeyEnabled == this.mVoiceKeyEnabled && other.mVoiceKeyEnabled == this.mVoiceKeyEnabled
@ -156,18 +159,19 @@ public class KeyboardId {
@Override @Override
public String toString() { public String toString() {
return String.format("[%s.xml %s %s%d %s %s %s%s%s%s%s%s]", return String.format("[%s.xml %s %s%d %s %s %s %s%s%s%s%s%s]",
mXmlName, mXmlName,
mLocale, mLocale,
(mOrientation == 1 ? "port" : "land"), mWidth, (mOrientation == 1 ? "port" : "land"), mWidth,
modeName(mMode), modeName(mMode),
EditorInfoCompatUtils.imeOptionsName(mImeAction), EditorInfoCompatUtils.imeOptionsName(mImeAction),
colorSchemeName(mColorScheme),
(mWebInput ? " webInput" : ""),
(mPasswordInput ? " passwordInput" : ""), (mPasswordInput ? " passwordInput" : ""),
(mHasSettingsKey ? " hasSettingsKey" : ""), (mHasSettingsKey ? " hasSettingsKey" : ""),
(mVoiceKeyEnabled ? " voiceKeyEnabled" : ""), (mVoiceKeyEnabled ? " voiceKeyEnabled" : ""),
(mHasVoiceKey ? " hasVoiceKey" : ""), (mHasVoiceKey ? " hasVoiceKey" : ""),
(mEnableShiftLock ? " enableShiftLock" : ""), (mEnableShiftLock ? " enableShiftLock" : "")
colorSchemeName(mColorScheme)
); );
} }
@ -177,7 +181,6 @@ public class KeyboardId {
case MODE_URL: return "url"; case MODE_URL: return "url";
case MODE_EMAIL: return "email"; case MODE_EMAIL: return "email";
case MODE_IM: return "im"; case MODE_IM: return "im";
case MODE_WEB: return "web";
case MODE_PHONE: return "phone"; case MODE_PHONE: return "phone";
case MODE_NUMBER: return "number"; case MODE_NUMBER: return "number";
} }

View File

@ -456,6 +456,8 @@ public class KeyboardParser {
try { try {
final boolean modeMatched = matchInteger(a, final boolean modeMatched = matchInteger(a,
R.styleable.Keyboard_Case_mode, id.mMode); R.styleable.Keyboard_Case_mode, id.mMode);
final boolean webInputMatched = matchBoolean(a,
R.styleable.Keyboard_Case_webInput, id.mWebInput);
final boolean passwordInputMatched = matchBoolean(a, final boolean passwordInputMatched = matchBoolean(a,
R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput); R.styleable.Keyboard_Case_passwordInput, id.mPasswordInput);
final boolean settingsKeyMatched = matchBoolean(a, final boolean settingsKeyMatched = matchBoolean(a,
@ -476,16 +478,18 @@ public class KeyboardParser {
R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage()); R.styleable.Keyboard_Case_languageCode, id.mLocale.getLanguage());
final boolean countryCodeMatched = matchString(a, final boolean countryCodeMatched = matchString(a,
R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry()); R.styleable.Keyboard_Case_countryCode, id.mLocale.getCountry());
final boolean selected = modeMatched && passwordInputMatched && settingsKeyMatched final boolean selected = modeMatched && webInputMatched && passwordInputMatched
&& voiceEnabledMatched && voiceKeyMatched && colorSchemeMatched && settingsKeyMatched && voiceEnabledMatched && voiceKeyMatched
&& imeActionMatched && languageCodeMatched && countryCodeMatched; && colorSchemeMatched && imeActionMatched && languageCodeMatched
&& countryCodeMatched;
if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE, if (DEBUG) Log.d(TAG, String.format("<%s%s%s%s%s%s%s%s%s%s%s> %s", TAG_CASE,
textAttr(KeyboardId.modeName( textAttr(KeyboardId.modeName(
a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"), a.getInt(R.styleable.Keyboard_Case_mode, -1)), "mode"),
textAttr(KeyboardId.colorSchemeName( textAttr(KeyboardId.colorSchemeName(
viewAttr.getInt( viewAttr.getInt(
R.styleable.KeyboardView_colorScheme, -1)), "colorSchemeName"), R.styleable.KeyboardView_colorScheme, -1)), "colorSchemeName"),
booleanAttr(a, R.styleable.Keyboard_Case_webInput, "webInput"),
booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"), booleanAttr(a, R.styleable.Keyboard_Case_passwordInput, "passwordInput"),
booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"), booleanAttr(a, R.styleable.Keyboard_Case_hasSettingsKey, "hasSettingsKey"),
booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"), booleanAttr(a, R.styleable.Keyboard_Case_voiceKeyEnabled, "voiceKeyEnabled"),

View File

@ -81,7 +81,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
private static final String TAG = LatinIME.class.getSimpleName(); private static final String TAG = LatinIME.class.getSimpleName();
private static final boolean PERF_DEBUG = false; private static final boolean PERF_DEBUG = false;
private static final boolean TRACE = false; private static final boolean TRACE = false;
private static boolean DEBUG = LatinImeLogger.sDBG; private static boolean DEBUG;
/** /**
* The private IME option used to indicate that no microphone should be * The private IME option used to indicate that no microphone should be
@ -357,6 +357,7 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
mSubtypeSwitcher = SubtypeSwitcher.getInstance(); mSubtypeSwitcher = SubtypeSwitcher.getInstance();
mKeyboardSwitcher = KeyboardSwitcher.getInstance(); mKeyboardSwitcher = KeyboardSwitcher.getInstance();
mRecorrection = Recorrection.getInstance(); mRecorrection = Recorrection.getInstance();
DEBUG = LatinImeLogger.sDBG;
loadSettings(); loadSettings();
@ -506,7 +507,8 @@ public class LatinIME extends InputMethodServiceCompatWrapper implements Keyboar
LatinKeyboardView inputView = switcher.getKeyboardView(); LatinKeyboardView inputView = switcher.getKeyboardView();
if (DEBUG) { if (DEBUG) {
Log.d(TAG, "onStartInputView: " + inputView); Log.d(TAG, "onStartInputView: inputType=" + ((attribute == null) ? "none"
: String.format("0x%08x", attribute.inputType)));
} }
// In landscape mode, this method gets called without the input view being created. // In landscape mode, this method gets called without the input view being created.
if (inputView == null) { if (inputView == null) {

View File

@ -538,8 +538,6 @@ public class Utils {
return KeyboardId.MODE_IM; return KeyboardId.MODE_IM;
} else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) { } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
return KeyboardId.MODE_TEXT; return KeyboardId.MODE_TEXT;
} else if (variation == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT) {
return KeyboardId.MODE_WEB;
} else { } else {
return KeyboardId.MODE_TEXT; return KeyboardId.MODE_TEXT;
} }