am ebec5e13: Merge "Add Hinglish (hi_ZZ) subtype"

* commit 'ebec5e13383e4810b07e0cdbe10022e3ddb9c0d3':
  Add Hinglish (hi_ZZ) subtype
main
Tadashi G. Takaoka 2014-08-21 10:30:04 +00:00 committed by Android Git Automerger
commit 462db77683
11 changed files with 159 additions and 5 deletions

View File

@ -37,6 +37,12 @@
<item>en_US</item>
<item>en_GB</item>
<item>es_US</item>
<item>hi_ZZ</item>
</string-array>
<!-- Subtype locale whose name should be displayed in Locale.ROOT. -->
<string-array name="subtype_locale_displayed_in_root_locale">
<item>hi_ZZ</item>
</string-array>
<!-- Generic subtype label -->

View File

@ -184,6 +184,8 @@
<!-- Description for Spanish (US) keyboard subtype [CHAR LIMIT=25]
(US) should be an abbreviation of United States to fit in the CHAR LIMIT. -->
<string name="subtype_es_US">Spanish (US)</string>
<!-- Description for Hinglish (https://en.wikipedia.org/wiki/Hinglish) keyboard subtype [CHAR LIMIT=25] -->
<string name="subtype_hi_ZZ">Hinglish</string>
<!-- Description for English (UK) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25]
(UK) should be an abbreviation of United Kingdom to fit in the CHAR LIMIT.
This should be identical to subtype_en_GB aside from the trailing (%s). -->
@ -196,6 +198,9 @@
(US) should be an abbreviation of United Statesn to fit in the CHAR LIMIT.
This should be identical to subtype_es_US aside from the trailing (%s). -->
<string name="subtype_with_layout_es_US">Spanish (US) (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string>
<!-- Description for Hinglish (https://en.wikipedia.org/wiki/Hinglish) keyboard subtype with explicit keyboard layout [CHAR LIMIT=25]
This should be identical to subtype_hi_ZZ aside from the trailing (%s). -->
<string name="subtype_with_layout_hi_ZZ">Hinglish (<xliff:g id="KEYBOARD_LAYOUT" example="QWERTY">%s</xliff:g>)</string>
<!-- Description for "LANGUAGE_NAME" (Traditional) keyboard subtype [CHAR LIMIT=25]
(Traditional) can be an abbreviation to fit in the CHAR LIMIT. -->
<string name="subtype_generic_traditional"><xliff:g id="LANGUAGE_NAME" example="Nepali">%s</xliff:g> (Traditional)</string>

View File

@ -80,6 +80,7 @@
</case>
<!-- fa: Persian (Rial and Afgahni)
hi: Hindi (Indian Rupee)
hi_ZZ: Hinglish (Indian Rupee)
iw: Hebrew (New Sheqel)
lo: Lao (Kip)
mn: Mongolian (Tugrik)

View File

@ -52,6 +52,7 @@
gl_ES: Galician (Spain)/spanish
hi: Hindi/hindi
hi: Hindi/hindi_compact
(hi_ZZ: Hinglish/qwerty) # This is a preliminary keyboard layout.
hr: Croatian/qwertz
hu: Hungarian/qwertz
hy_AM: Armenian (Armenia) Phonetic/armenian_phonetic
@ -354,6 +355,16 @@
android:imeSubtypeExtraValue="KeyboardLayoutSet=hindi_compact,EmojiCapable"
android:isAsciiCapable="false"
/>
<!-- TODO: This Hinglish keyboard is a preliminary layout.
This isn't based on the final specification. -->
<subtype android:icon="@drawable/ic_ime_switcher_dark"
android:label="@string/subtype_hi_ZZ"
android:subtypeId="0x352eb37c"
android:imeSubtypeLocale="hi_ZZ"
android:imeSubtypeMode="keyboard"
android:imeSubtypeExtraValue="AsciiCapable,KeyboardLayoutSet=qwerty,EmojiCapable"
android:isAsciiCapable="true"
/>
<subtype android:icon="@drawable/ic_ime_switcher_dark"
android:label="@string/subtype_generic"
android:subtypeId="0x35b7526a"

View File

@ -94,7 +94,7 @@ public final class KeyboardTextsTable {
/* 8:22 */ "morekeys_n",
/* 9:22 */ "single_quotes",
/* 10:20 */ "morekeys_s",
/* 11:17 */ "keyspec_currency",
/* 11:18 */ "keyspec_currency",
/* 12:14 */ "morekeys_y",
/* 13:13 */ "morekeys_d",
/* 14:12 */ "morekeys_z",
@ -1874,6 +1874,15 @@ public final class KeyboardTextsTable {
/* additional_morekeys_symbols_0 */ "0",
};
/* Locale hi_ZZ: Hindi (ZZ) */
private static final String[] TEXTS_hi_ZZ = {
/* morekeys_a ~ */
null, null, null, null, null, null, null, null, null, null, null,
/* ~ morekeys_s */
// U+20B9: "₹" INDIAN RUPEE SIGN
/* keyspec_currency */ "\u20B9",
};
/* Locale hr: Croatian */
private static final String[] TEXTS_hr = {
/* morekeys_a ~ */
@ -3957,6 +3966,7 @@ public final class KeyboardTextsTable {
"fr" , TEXTS_fr, /* 13/ 62 French */
"gl_ES" , TEXTS_gl_ES, /* 7/ 9 Gallegan (Spain) */
"hi" , TEXTS_hi, /* 23/ 53 Hindi */
"hi_ZZ" , TEXTS_hi_ZZ, /* 1/ 12 Hindi (ZZ) */
"hr" , TEXTS_hr, /* 9/ 20 Croatian */
"hu" , TEXTS_hu, /* 9/ 20 Hungarian */
"hy_AM" , TEXTS_hy_AM, /* 9/126 Armenian (Armenia) */

View File

@ -30,6 +30,7 @@ import com.android.inputmethod.latin.R;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Locale;
public final class SubtypeLocaleUtils {
@ -52,6 +53,8 @@ public final class SubtypeLocaleUtils {
private static final HashMap<String, String> sKeyboardLayoutToDisplayNameMap = new HashMap<>();
// Keyboard layout to subtype name resource id map.
private static final HashMap<String, Integer> sKeyboardLayoutToNameIdsMap = new HashMap<>();
// Exceptional locale whose name should be displayed in Locale.ROOT.
static final HashSet<String> sExceptionalLocaleDisplayedInRootLocale = new HashSet<>();
// Exceptional locale to subtype name resource id map.
private static final HashMap<String, Integer> sExceptionalLocaleToNameIdsMap = new HashMap<>();
// Exceptional locale to subtype name with layout resource id map.
@ -106,6 +109,12 @@ public final class SubtypeLocaleUtils {
sKeyboardLayoutToNameIdsMap.put(key, noLanguageResId);
}
final String[] excetionalLocaleInRootLocale = res.getStringArray(
R.array.subtype_locale_displayed_in_root_locale);
for (int i = 0; i < excetionalLocaleInRootLocale.length; i++) {
sExceptionalLocaleDisplayedInRootLocale.add(excetionalLocaleInRootLocale[i]);
}
final String[] exceptionalLocales = res.getStringArray(
R.array.subtype_locale_exception_keys);
for (int i = 0; i < exceptionalLocales.length; i++) {
@ -157,6 +166,9 @@ public final class SubtypeLocaleUtils {
if (NO_LANGUAGE.equals(localeString)) {
return sResources.getConfiguration().locale;
}
if (sExceptionalLocaleDisplayedInRootLocale.contains(localeString)) {
return Locale.ROOT;
}
return LocaleUtils.constructLocaleFromString(localeString);
}
@ -171,9 +183,15 @@ public final class SubtypeLocaleUtils {
}
public static String getSubtypeLanguageDisplayName(final String localeString) {
final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
final Locale displayLocale = getDisplayLocaleOfSubtypeLocale(localeString);
return getSubtypeLocaleDisplayNameInternal(locale.getLanguage(), displayLocale);
final String languageString;
if (sExceptionalLocaleDisplayedInRootLocale.contains(localeString)) {
languageString = localeString;
} else {
final Locale locale = LocaleUtils.constructLocaleFromString(localeString);
languageString = locale.getLanguage();
}
return getSubtypeLocaleDisplayNameInternal(languageString, displayLocale);
}
private static String getSubtypeLocaleDisplayNameInternal(final String localeString,

View File

@ -25,8 +25,8 @@ import java.util.ArrayList;
@SmallTest
public class KeyboardLayoutSetSubtypesCountTests extends KeyboardLayoutSetTestsBase {
private static final int NUMBER_OF_SUBTYPES = 77;
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 45;
private static final int NUMBER_OF_SUBTYPES = 78;
private static final int NUMBER_OF_ASCII_CAPABLE_SUBTYPES = 46;
private static final int NUMBER_OF_PREDEFINED_ADDITIONAL_SUBTYPES = 2;
@Override

View File

@ -0,0 +1,56 @@
/*
* Copyright (C) 2014 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.
*/
package com.android.inputmethod.keyboard.layout.tests;
import android.test.suitebuilder.annotation.SmallTest;
import com.android.inputmethod.keyboard.layout.LayoutBase;
import com.android.inputmethod.keyboard.layout.LayoutBase.LayoutCustomizer;
import com.android.inputmethod.keyboard.layout.Qwerty;
import com.android.inputmethod.keyboard.layout.Symbols;
import com.android.inputmethod.keyboard.layout.SymbolsShifted;
import com.android.inputmethod.keyboard.layout.expected.ExpectedKey;
import java.util.Locale;
/*
* hi_ZZ: Hinglish/qwerty
*/
@SmallTest
public final class TestsHinglish extends LayoutTestsBase {
private static final Locale LOCALE = new Locale("hi", "ZZ");
private static final LayoutBase LAYOUT = new Qwerty(new HinglishCustomizer(LOCALE));
@Override
LayoutBase getLayout() { return LAYOUT; }
private static class HinglishCustomizer extends LayoutCustomizer {
public HinglishCustomizer(final Locale locale) { super(locale); }
@Override
public ExpectedKey getCurrencyKey() { return CURRENCY_RUPEE; }
@Override
public ExpectedKey[] getOtherCurrencyKeys() {
return SymbolsShifted.CURRENCIES_OTHER_GENERIC;
}
// U+20B9: "₹" INDIAN RUPEE SIGN
private static final ExpectedKey CURRENCY_RUPEE = key("\u20B9",
Symbols.CURRENCY_GENERIC_MORE_KEYS);
}
}

View File

@ -44,6 +44,7 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
InputMethodSubtype FR_CH;
InputMethodSubtype DE;
InputMethodSubtype DE_CH;
InputMethodSubtype HI_ZZ;
InputMethodSubtype ZZ;
InputMethodSubtype DE_QWERTY;
InputMethodSubtype FR_QWERTZ;
@ -85,6 +86,8 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
Locale.GERMAN.toString(), "qwertz");
DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss");
HI_ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"hi_ZZ", "qwerty");
ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
@ -122,6 +125,12 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
for (final InputMethodSubtype subtype : mSubtypesList) {
final String subtypeName = SubtypeLocaleUtils
.getSubtypeDisplayNameInSystemLocale(subtype);
if (SubtypeLocaleUtils.sExceptionalLocaleDisplayedInRootLocale.contains(
subtype.getLocale())) {
// Skip test because the language part of this locale string doesn't represent
// the locale to be displayed on the spacebar (for example hi_ZZ and Hinglish).
continue;
}
final String spacebarText = SpacebarLanguageUtils.getMiddleDisplayName(subtype);
if (SubtypeLocaleUtils.isNoLanguage(subtype)) {
assertEquals(subtypeName,
@ -147,6 +156,7 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
// fr_CH swiss F Français Français (Suisse)
// de qwertz F Deutsch Deutsch
// de_CH swiss F Deutsch Deutsch (Schweiz)
// hi_ZZ qwerty F Hinglish Hinglish
// zz qwerty F QWERTY QWERTY
// fr qwertz T Français Français
// de qwerty T Deutsch Deutsch
@ -172,6 +182,8 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
SpacebarLanguageUtils.getFullDisplayName(DE));
assertEquals("de_CH", "Deutsch (Schweiz)",
SpacebarLanguageUtils.getFullDisplayName(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SpacebarLanguageUtils.getFullDisplayName(HI_ZZ));
assertEquals("zz", "QWERTY",
SpacebarLanguageUtils.getFullDisplayName(ZZ));
@ -191,6 +203,8 @@ public class SpacebarLanguageUtilsTests extends AndroidTestCase {
SpacebarLanguageUtils.getMiddleDisplayName(DE));
assertEquals("de_CH", "Deutsch",
SpacebarLanguageUtils.getMiddleDisplayName(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SpacebarLanguageUtils.getMiddleDisplayName(HI_ZZ));
assertEquals("zz", "QWERTY",
SpacebarLanguageUtils.getMiddleDisplayName(ZZ));
return null;

View File

@ -44,6 +44,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
InputMethodSubtype FR_CH;
InputMethodSubtype DE;
InputMethodSubtype DE_CH;
InputMethodSubtype HI_ZZ;
InputMethodSubtype ZZ;
InputMethodSubtype DE_QWERTY;
InputMethodSubtype FR_QWERTZ;
@ -85,6 +86,8 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
Locale.GERMAN.toString(), "qwertz");
DE_CH = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"de_CH", "swiss");
HI_ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
"hi_ZZ", "qwerty");
ZZ = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet(
SubtypeLocaleUtils.NO_LANGUAGE, "qwerty");
DE_QWERTY = AdditionalSubtypeUtils.createAsciiEmojiCapableAdditionalSubtype(
@ -128,6 +131,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
assertEquals("fr_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(FR_CH));
assertEquals("de", "qwertz", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE));
assertEquals("de_CH", "swiss", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_CH));
assertEquals("hi_ZZ", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(HI_ZZ));
assertEquals("zz", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(ZZ));
assertEquals("de qwerty", "qwerty", SubtypeLocaleUtils.getKeyboardLayoutSetName(DE_QWERTY));
@ -154,6 +158,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// fr_CH swiss F French (Switzerland)
// de qwertz F German
// de_CH swiss F German (Switzerland)
// hi_ZZ qwerty F Hinglish
// zz qwerty F Alphabet (QWERTY)
// fr qwertz T French (QWERTZ)
// de qwerty T German (QWERTY)
@ -182,6 +187,8 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("de_CH", "German (Switzerland)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_ZZ));
assertEquals("zz", "Alphabet (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
return null;
@ -226,6 +233,7 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
// fr_CH swiss F Français (Suisse)
// de qwertz F Allemand
// de_CH swiss F Allemand (Suisse)
// hi_ZZ qwerty F Hinglish
// zz qwerty F Alphabet latin (QWERTY)
// fr qwertz T Français (QWERTZ)
// de qwerty T Allemand (QWERTY)
@ -254,6 +262,8 @@ public class SubtypeLocaleUtilsTests extends AndroidTestCase {
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE));
assertEquals("de_CH", "Allemand (Suisse)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(DE_CH));
assertEquals("hi_ZZ", "Hinglish",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(HI_ZZ));
assertEquals("zz", "Alphabet latin (QWERTY)",
SubtypeLocaleUtils.getSubtypeDisplayNameInSystemLocale(ZZ));
return null;

View File

@ -0,0 +1,23 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
/*
**
** Copyright 2014, 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+20B9: "₹" INDIAN RUPEE SIGN -->
<string name="keyspec_currency">&#x20B9;</string>
</resources>