Merge "Add language agnostic QWERTY subtype"

main
Tadashi G. Takaoka 2012-03-30 03:03:55 -07:00 committed by Android (Google) Code Review
commit 3224878351
15 changed files with 242 additions and 18 deletions

View File

@ -0,0 +1,139 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE
U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE
U+00E2: "â" LATIN SMALL LETTER A WITH CIRCUMFLEX
U+00E3: "ã" LATIN SMALL LETTER A WITH TILDE
U+00E4: "ä" LATIN SMALL LETTER A WITH DIAERESIS
U+00E5: "å" LATIN SMALL LETTER A WITH RING ABOVE
U+00E6: "æ" LATIN SMALL LETTER AE
U+0101: "ā" LATIN SMALL LETTER A WITH MACRON
U+0103: "ă" LATIN SMALL LETTER A WITH BREVE
U+0105: "ą" LATIN SMALL LETTER A WITH OGONEK
U+00AA: "ª" FEMININE ORDINAL INDICATOR -->
<string name="more_keys_for_a">&#x00E0;,&#x00E1;,&#x00E2;,&#x00E3;,&#x00E4;,&#x00E5;,&#x00E6;,&#x00E3;,&#x00E5;,&#x0101;,&#x0103;,&#x0105;,&#x00AA;</string>
<!-- U+00E8: "è" LATIN SMALL LETTER E WITH GRAVE
U+00E9: "é" LATIN SMALL LETTER E WITH ACUTE
U+00EA: "ê" LATIN SMALL LETTER E WITH CIRCUMFLEX
U+00EB: "ë" LATIN SMALL LETTER E WITH DIAERESIS
U+0113: "ē" LATIN SMALL LETTER E WITH MACRON
U+0115: "ĕ" LATIN SMALL LETTER E WITH BREVE
U+0117: "ė" LATIN SMALL LETTER E WITH DOT ABOVE
U+0119: "ę" LATIN SMALL LETTER E WITH OGONEK
U+011B: "ě" LATIN SMALL LETTER E WITH CARON -->
<string name="more_keys_for_e">&#x00E8;,&#x00E9;,&#x00EA;,&#x00EB;,&#x0113;,&#x0115;,&#x0117;,&#x0119;,&#x011B;</string>
<!-- U+00EC: "ì" LATIN SMALL LETTER I WITH GRAVE
U+00ED: "í" LATIN SMALL LETTER I WITH ACUTE
U+00EE: "î" LATIN SMALL LETTER I WITH CIRCUMFLEX
U+00EF: "ï" LATIN SMALL LETTER I WITH DIAERESIS
U+0129: "ĩ" LATIN SMALL LETTER I WITH TILDE
U+012B: "ī" LATIN SMALL LETTER I WITH MACRON
U+012D: "ĭ" LATIN SMALL LETTER I WITH BREVE
U+012F: "į" LATIN SMALL LETTER I WITH OGONEK
U+0131: "ı" LATIN SMALL LETTER DOTLESS I
U+0133: "ij" LATIN SMALL LIGATURE IJ -->
<string name="more_keys_for_i">&#x00EC;,&#x00ED;,&#x00EE;,&#x00EF;,&#x0129;,&#x012B;,&#x012D;,&#x012F;,&#x0131;,&#x0133;</string>
<!-- U+00F2: "ò" LATIN SMALL LETTER O WITH GRAVE
U+00F3: "ó" LATIN SMALL LETTER O WITH ACUTE
U+00F4: "ô" LATIN SMALL LETTER O WITH CIRCUMFLEX
U+00F5: "õ" LATIN SMALL LETTER O WITH TILDE
U+00F6: "ö" LATIN SMALL LETTER O WITH DIAERESIS
U+00F8: "ø" LATIN SMALL LETTER O WITH STROKE
U+014D: "ō" LATIN SMALL LETTER O WITH MACRON
U+014F: "ŏ" LATIN SMALL LETTER O WITH BREVE
U+0151: "ő" LATIN SMALL LETTER O WITH DOUBLE ACUTE
U+0153: "œ" LATIN SMALL LIGATURE OE
U+00BA: "º" MASCULINE ORDINAL INDICATOR -->
<string name="more_keys_for_o">&#x00F2;,&#x00F3;,&#x00F4;,&#x00F5;,&#x00F6;,&#x00F8;,&#x014D;,&#x014F;,&#x0151;,&#x0153;,&#x00BA;</string>
<!-- U+00F9: "ù" LATIN SMALL LETTER U WITH GRAVE
U+00FA: "ú" LATIN SMALL LETTER U WITH ACUTE
U+00FB: "û" LATIN SMALL LETTER U WITH CIRCUMFLEX
U+00FC: "ü" LATIN SMALL LETTER U WITH DIAERESIS
U+0169: "ũ" LATIN SMALL LETTER U WITH TILDE
U+016B: "ū" LATIN SMALL LETTER U WITH MACRON
U+016D: "ŭ" LATIN SMALL LETTER U WITH BREVE
U+016F: "ů" LATIN SMALL LETTER U WITH RING ABOVE
U+0171: "ű" LATIN SMALL LETTER U WITH DOUBLE ACUTE
U+0173: "ų" LATIN SMALL LETTER U WITH OGONEK -->
<string name="more_keys_for_u">&#x00F9;,&#x00FA;,&#x00FB;,&#x00FC;,&#x0169;,&#x016B;,&#x016D;,&#x016F;,&#x0171;,&#x0173;</string>
<!-- U+00DF: "ß" LATIN SMALL LETTER SHARP S
U+015B: "ś" LATIN SMALL LETTER S WITH ACUTE
U+015D: "ŝ" LATIN SMALL LETTER S WITH CIRCUMFLEX
U+015F: "ş" LATIN SMALL LETTER S WITH CEDILLA
U+0161: "š" LATIN SMALL LETTER S WITH CARON
U+017F: "ſ" LATIN SMALL LETTER LONG S -->
<string name="more_keys_for_s">&#x00DF;,&#x015B;,&#x015D;,&#x015F;,&#x0161;,&#x017F;</string>
<!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE
U+0144: "ń" LATIN SMALL LETTER N WITH ACUTE
U+0146: "ņ" LATIN SMALL LETTER N WITH CEDILLA
U+0148: "ň" LATIN SMALL LETTER N WITH CARON
U+0149: "ʼn" LATIN SMALL LETTER N PRECEDED BY APOSTROPHE
U+014B: "ŋ" LATIN SMALL LETTER ENG -->
<string name="more_keys_for_n">&#x00F1;,&#x0144;,&#x0146;,&#x0148;,&#x0149;,&#x014B;</string>
<!-- U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA
U+0107: "ć" LATIN SMALL LETTER C WITH ACUTE
U+0109: "ĉ" LATIN SMALL LETTER C WITH CIRCUMFLEX
U+010B: "ċ" LATIN SMALL LETTER C WITH DOT ABOVE
U+010D: "č" LATIN SMALL LETTER C WITH CARON -->
<string name="more_keys_for_c">&#x00E7;,&#x0107;,&#x0109;,&#x010B;,&#x010D;</string>
<!-- U+00FD: "ý" LATIN SMALL LETTER Y WITH ACUTE
U+0177: "ŷ" LATIN SMALL LETTER Y WITH CIRCUMFLEX
U+00FF: "ÿ" LATIN SMALL LETTER Y WITH DIAERESIS
U+0133: "ij" LATIN SMALL LIGATURE IJ -->
<string name="more_keys_for_y">&#x00FD;,&#x0177;,&#x00FF;,&#x0133;</string>
<!-- U+010F: "ď" LATIN SMALL LETTER D WITH CARON
U+0111: "đ" LATIN SMALL LETTER D WITH STROKE
U+00F0: "ð" LATIN SMALL LETTER ETH -->
<string name="more_keys_for_d">&#x010F;,&#x0111;,&#x00F0;</string>
<!-- U+0155: "ŕ" LATIN SMALL LETTER R WITH ACUTE
U+0157: "ŗ" LATIN SMALL LETTER R WITH CEDILLA
U+0159: "ř" LATIN SMALL LETTER R WITH CARON -->
<string name="more_keys_for_r">&#x0155;,&#x0157;,&#x0159;</string>
<!-- U+00FE: "þ" LATIN SMALL LETTER THORN
U+0163: "ţ" LATIN SMALL LETTER T WITH CEDILLA
U+0165: "ť" LATIN SMALL LETTER T WITH CARON
U+0167: "ŧ" LATIN SMALL LETTER T WITH STROKE -->
<string name="more_keys_for_t">&#x00FE;,&#x0163;,&#x0165;,&#x0167;</string>
<!-- U+017A: "ź" LATIN SMALL LETTER Z WITH ACUTE
U+017C: "ż" LATIN SMALL LETTER Z WITH DOT ABOVE
U+017E: "ž" LATIN SMALL LETTER Z WITH CARON -->
<string name="more_keys_for_z">&#x017A;,&#x017C;,&#x017E;</string>
<!-- U+0137: "ķ" LATIN SMALL LETTER K WITH CEDILLA
U+0138: "ĸ" LATIN SMALL LETTER KRA -->
<string name="more_keys_for_k">&#x0137;,&#x0138;</string>
<!-- U+013A: "ĺ" LATIN SMALL LETTER L WITH ACUTE
U+013C: "ļ" LATIN SMALL LETTER L WITH CEDILLA
U+013E: "ľ" LATIN SMALL LETTER L WITH CARON
U+0140: "ŀ" LATIN SMALL LETTER L WITH MIDDLE DOT
U+0142: "ł" LATIN SMALL LETTER L WITH STROKE -->
<string name="more_keys_for_l">&#x013A;,&#x013C;,&#x013E;,&#x0140;,&#x0142;</string>
<!-- U+011D: "ĝ" LATIN SMALL LETTER G WITH CIRCUMFLEX
U+011F: "ğ" LATIN SMALL LETTER G WITH BREVE
U+0121: "ġ" LATIN SMALL LETTER G WITH DOT ABOVE
U+0123: "ģ" LATIN SMALL LETTER G WITH CEDILLA -->
<string name="more_keys_for_g">&#x011D;,&#x011F;,&#x0121;,&#x0123;</string>
<!-- U+0125: "ĥ" LATIN SMALL LETTER H WITH CIRCUMFLEX -->
<string name="more_keys_for_h">&#x0125;</string>
<!-- U+0135: "ĵ" LATIN SMALL LETTER J WITH CIRCUMFLEX -->
<string name="more_keys_for_j">&#x0135;</string>
<!-- U+0175: "ŵ" LATIN SMALL LETTER W WITH CIRCUMFLEX -->
<string name="more_keys_for_w">&#x0175;</string>
</resources>

View File

@ -403,6 +403,11 @@
<attr name="parentStyle" format="string" />
</declare-styleable>
<declare-styleable name="KeyboardSet">
<!-- Disable shortcut key. Shortcut key is enabled by default. -->
<attr name="disableShortcutKey" format="boolean" />
</declare-styleable>
<declare-styleable name="KeyboardSet_Element">
<!-- This should be aligned with KeyboardId.ELEMENT_* -->
<attr name="elementName" format="enum">

View File

@ -35,6 +35,9 @@
<string name="more_keys_for_l"></string>
<string name="more_keys_for_g"></string>
<string name="more_keys_for_v"></string>
<string name="more_keys_for_h"></string>
<string name="more_keys_for_j"></string>
<string name="more_keys_for_w"></string>
<string name="keylabel_for_nordic_row1_11"></string>
<string name="keylabel_for_nordic_row2_10"></string>
<string name="keylabel_for_nordic_row2_11"></string>

View File

@ -156,18 +156,22 @@
<string-array name="subtype_locale_exception_keys">
<item>en_US</item>
<item>en_GB</item>
<item>de_ZZ</item>
<item>de_QY</item>
<item>zz_QY</item>
</string-array>
<string-array name="subtype_locale_exception_values">
<item>English (US)</item>
<item>English (UK)</item>
<item>Deutsch (QWERTY)</item>
<item>@string/subtype_generic_qwerty</item>
<item>@string/subtype_qwerty</item>
</string-array>
<!-- Generic subtype label -->
<string name="subtype_generic">%s</string>
<!-- Description for generic QWERTY keyboard subtype -->
<string name="subtype_generic_qwerty">%s (QWERTY)</string>
<!-- Description for language agnostic QWERTY keyboard subtype -->
<string name="subtype_qwerty">QWERTY</string>
<!-- dictionary pack package name /settings activity (for shared prefs and settings) -->
<string name="dictionary_pack_package_name">com.google.android.inputmethod.latin.dictionarypack</string>

View File

@ -0,0 +1,43 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2012, The Android Open Source Project
**
** Licensed under the Apache License, Version 2.0 (the "License");
** you may not use this file except in compliance with the License.
** You may obtain a copy of the License at
**
** http://www.apache.org/licenses/LICENSE-2.0
**
** Unless required by applicable law or agreed to in writing, software
** distributed under the License is distributed on an "AS IS" BASIS,
** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
** See the License for the specific language governing permissions and
** limitations under the License.
*/
-->
<KeyboardSet
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
latin:disableShortcutKey="true" >
<Element
latin:elementName="alphabet"
latin:elementKeyboard="@xml/kbd_qwerty"
latin:enableProximityCharsCorrection="true" />
<Element
latin:elementName="symbols"
latin:elementKeyboard="@xml/kbd_symbols" />
<Element
latin:elementName="symbolsShifted"
latin:elementKeyboard="@xml/kbd_symbols_shift" />
<Element
latin:elementName="phone"
latin:elementKeyboard="@xml/kbd_phone" />
<Element
latin:elementName="phoneSymbols"
latin:elementKeyboard="@xml/kbd_phone_symbols" />
<Element
latin:elementName="number"
latin:elementKeyboard="@xml/kbd_number" />
</KeyboardSet>

View File

@ -27,7 +27,7 @@
cs: Czech/qwertz
da: Danish/nordic
de: German/qwertz
de_ZZ: German (QWERTY)/qwerty
de_QY: German (QWERTY)/qwerty
el: Greek/greek
en_US: English United States/qwerty
en_GB: English Great Britain/qwerty
@ -63,6 +63,7 @@
tr: Turkish/qwerty
uk: Ukrainian/east_slavic
vi: Vietnamese/qwerty
zz_QY: QWERTY/qwerty
-->
<!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. -->
<!-- If IME doesn't have an applicable subtype, the first subtype will be used as a default
@ -74,7 +75,7 @@
android:label="@string/subtype_en_US"
android:imeSubtypeLocale="en_US"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable"
android:imeSubtypeExtraValue="TrySuppressingImeSwitcher,AsciiCapable"
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_en_GB"
@ -119,7 +120,7 @@
android:label="@string/subtype_generic_qwerty"
android:imeSubtypeLocale="de"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,KeyboardLocale=de_ZZ"
android:imeSubtypeExtraValue="AsciiCapable,KeyboardLocale=de_QY"
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_generic"
@ -310,4 +311,10 @@
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable"
/>
<subtype android:icon="@drawable/ic_subtype_keyboard"
android:label="@string/subtype_qwerty"
android:imeSubtypeLocale="zz_QY"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable"
/>
</input-method>

View File

@ -35,9 +35,11 @@
latin:keyLabel="g"
latin:moreKeys="@string/more_keys_for_g" />
<Key
latin:keyLabel="h" />
latin:keyLabel="h"
latin:moreKeys="@string/more_keys_for_h" />
<Key
latin:keyLabel="j" />
latin:keyLabel="j"
latin:moreKeys="@string/more_keys_for_j" />
<Key
latin:keyLabel="k"
latin:moreKeys="@string/more_keys_for_k" />

View File

@ -22,7 +22,8 @@
xmlns:latin="http://schemas.android.com/apk/res/com.android.inputmethod.latin"
>
<Key
latin:keyLabel="w" />
latin:keyLabel="w"
latin:moreKeys="@string/more_keys_for_w" />
<Key
latin:keyLabel="x" />
<Key

View File

@ -28,7 +28,8 @@
<Key
latin:keyLabel="w"
latin:keyHintLabel="2"
latin:additionalMoreKeys="2" />
latin:additionalMoreKeys="2"
latin:moreKeys="@string/more_keys_for_w" />
<Key
latin:keyLabel="e"
latin:keyHintLabel="3"

View File

@ -36,9 +36,11 @@
latin:keyLabel="g"
latin:moreKeys="@string/more_keys_for_g" />
<Key
latin:keyLabel="h" />
latin:keyLabel="h"
latin:moreKeys="@string/more_keys_for_h" />
<Key
latin:keyLabel="j" />
latin:keyLabel="j"
latin:moreKeys="@string/more_keys_for_j" />
<Key
latin:keyLabel="k"
latin:moreKeys="@string/more_keys_for_k" />

View File

@ -28,7 +28,8 @@
<Key
latin:keyLabel="w"
latin:keyHintLabel="2"
latin:additionalMoreKeys="2" />
latin:additionalMoreKeys="2"
latin:moreKeys="@string/more_keys_for_w" />
<Key
latin:keyLabel="e"
latin:keyHintLabel="3"

View File

@ -98,6 +98,7 @@ public class KeyboardSet {
int mMode;
EditorInfo mEditorInfo;
boolean mTouchPositionCorrectionEnabled;
boolean mDisableShortcutKey;
boolean mVoiceKeyEnabled;
boolean mVoiceKeyOnMain;
boolean mNoSettingsKey;
@ -200,11 +201,11 @@ public class KeyboardSet {
final Params params = mParams;
final boolean isSymbols = (keyboardSetElementId == KeyboardId.ELEMENT_SYMBOLS
|| keyboardSetElementId == KeyboardId.ELEMENT_SYMBOLS_SHIFTED);
final boolean hasShortcutKey = params.mVoiceKeyEnabled
&& (isSymbols != params.mVoiceKeyOnMain);
final boolean voiceKeyEnabled = params.mVoiceKeyEnabled && !params.mDisableShortcutKey;
final boolean hasShortcutKey = voiceKeyEnabled && (isSymbols != params.mVoiceKeyOnMain);
return new KeyboardId(keyboardSetElementId, params.mLocale, params.mOrientation,
params.mWidth, params.mMode, params.mEditorInfo, params.mNoSettingsKey,
params.mVoiceKeyEnabled, hasShortcutKey, params.mLanguageSwitchKeyEnabled);
voiceKeyEnabled, hasShortcutKey, params.mLanguageSwitchKeyEnabled);
}
public static class Builder {
@ -293,6 +294,11 @@ public class KeyboardSet {
if (event == XmlPullParser.START_TAG) {
final String tag = parser.getName();
if (TAG_KEYBOARD_SET.equals(tag)) {
final TypedArray a = mResources.obtainAttributes(
Xml.asAttributeSet(parser), R.styleable.KeyboardSet);
mParams.mDisableShortcutKey = a.getBoolean(
R.styleable.KeyboardSet_disableShortcutKey, false);
a.recycle();
parseKeyboardSetContent(parser);
} else {
throw new XmlParseUtils.IllegalStartTag(parser, TAG_KEYBOARD_SET);

View File

@ -36,10 +36,16 @@ public class SubtypeLocale {
}
public static String getFullDisplayName(Locale locale) {
String localeCode = locale.toString();
final String localeCode = locale.toString();
for (int index = 0; index < sExceptionKeys.length; index++) {
if (sExceptionKeys[index].equals(localeCode))
return sExceptionValues[index];
if (sExceptionKeys[index].equals(localeCode)) {
final String value = sExceptionValues[index];
if (value.indexOf("%s") >= 0) {
final String languageName = locale.getDisplayLanguage(locale);
return String.format(value, languageName);
}
return value;
}
}
return locale.getDisplayName(locale);
}

View File

@ -62,6 +62,10 @@ public class SubtypeLocaleTests extends AndroidTestCase {
int failedCount = 0;
for (final InputMethodSubtype subtype : mKeyboardSubtypes) {
final Locale locale = LocaleUtils.constructLocaleFromString(subtype.getLocale());
if (locale.getLanguage().equals("zz")) {
// This is special language name for language agnostic usage.
continue;
}
final String subtypeLocaleString =
subtype.containsExtraValueKey(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LOCALE)
? subtype.getExtraValueOf(LatinIME.SUBTYPE_EXTRA_VALUE_KEYBOARD_LOCALE)