diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index 390f72bfaceef65fe2a39512af85a8fee5d0980e..828ad6d5380482ec129f73635cc776ee86a987c9 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -457,6 +457,8 @@ language among those that use the Latin alphabet. This keyboard is laid out in t disposition that offers additional keys, but smaller keys compared to other common dispositions for mobile devices. [CHAR LIMIT=25] --> <string name="subtype_no_language_pcqwerty">Alphabet (PC)</string> + <!-- Description for Emoji keyboard subtype [CHAR LIMIT=25] --> + <string name="subtype_emoji">Emoji</string> <!-- Title of the preference settings for custom input styles (language and keyboard layout pairs) [CHAR LIMIT=35]--> <string name="custom_input_styles_title">Custom input styles</string> diff --git a/java/res/xml/method.xml b/java/res/xml/method.xml index 2c3ac57edb7b09bd18fa29bc906636bc75b9f238..689b270a810c83357e241a374e7986c6bd4fa245 100644 --- a/java/res/xml/method.xml +++ b/java/res/xml/method.xml @@ -80,6 +80,7 @@ vi: Vietnamese/qwerty zu: Zulu/qwerty zz: QWERTY/qwerty + (zz: Emoji/emoji) --> <!-- TODO: use <lang>_keyboard icon instead of a common keyboard icon. --> <!-- Note: SupportTouchPositionCorrection extra value is obsolete and maintained for backward @@ -510,4 +511,15 @@ android:imeSubtypeMode="keyboard" android:imeSubtypeExtraValue="KeyboardLayoutSet=qwerty,AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable" /> + <!-- Emoji subtype has to be an addtional subtype added at boot time because ICS doesn't + support Emoji. --> + <!-- + <subtype android:icon="@drawable/ic_subtype_keyboard" + android:label="@string/subtype_emoji" + android:subtypeId="0xc14d88b2" + android:imeSubtypeLocale="zz" + android:imeSubtypeMode="keyboard" + android:imeSubtypeExtraValue="KeyboardLayoutSet=emoji" + /> + --> </input-method> diff --git a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java index be03d4ae5623f8deaa2608e85337b12b417889e5..0889f22caf2d6d91ce0492e9d26a6e21c50856ca 100644 --- a/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java +++ b/java/src/com/android/inputmethod/latin/SubtypeSwitcher.java @@ -53,12 +53,22 @@ public final class SubtypeSwitcher { private InputMethodInfo mShortcutInputMethodInfo; private InputMethodSubtype mShortcutSubtype; private InputMethodSubtype mNoLanguageSubtype; + private InputMethodSubtype mEmojiSubtype; private boolean mIsNetworkConnected; // Dummy no language QWERTY subtype. See {@link R.xml.method}. private static final InputMethodSubtype DUMMY_NO_LANGUAGE_SUBTYPE = new InputMethodSubtype( - R.string.subtype_no_language_qwerty, R.drawable.ic_subtype_keyboard, "zz", "keyboard", - "KeyboardLayoutSet=qwerty,AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable", + R.string.subtype_no_language_qwerty, R.drawable.ic_subtype_keyboard, + SubtypeLocaleUtils.NO_LANGUAGE, "keyboard", + "KeyboardLayoutSet=" + SubtypeLocaleUtils.QWERTY + + ",AsciiCapable,EnabledWhenDefaultIsNotAsciiCapable", + false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */); + // Caveat: We probably should remove this when we add an Emoji subtype in {@link R.xml.method}. + // Dummy Emoji subtype. See {@link R.xml.method}. + private static final InputMethodSubtype DUMMY_EMOJI_SUBTYPE = new InputMethodSubtype( + R.string.subtype_emoji, R.drawable.ic_subtype_keyboard, + SubtypeLocaleUtils.NO_LANGUAGE, "keyboard", + "KeyboardLayoutSet=" + SubtypeLocaleUtils.EMOJI, false /* isAuxiliary */, false /* overridesImplicitlyEnabledSubtype */); static final class NeedsToDisplayLanguage { @@ -271,4 +281,17 @@ public final class SubtypeSwitcher { + DUMMY_NO_LANGUAGE_SUBTYPE); return DUMMY_NO_LANGUAGE_SUBTYPE; } + + public InputMethodSubtype getEmojiSubtype() { + if (mEmojiSubtype == null) { + mEmojiSubtype = mRichImm.findSubtypeByLocaleAndKeyboardLayoutSet( + SubtypeLocaleUtils.NO_LANGUAGE, SubtypeLocaleUtils.EMOJI); + } + if (mEmojiSubtype != null) { + return mEmojiSubtype; + } + Log.w(TAG, "Can't find Emoji subtype"); + Log.w(TAG, "No input method subtype found; return dummy subtype: " + DUMMY_EMOJI_SUBTYPE); + return DUMMY_EMOJI_SUBTYPE; + } } diff --git a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java index 16728092d61966127e4d97fcc6c10255df0cc2f3..102a41b4edf6e1e9ea35070e2d5fd5aa90fd11bc 100644 --- a/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/SubtypeLocaleUtils.java @@ -40,6 +40,7 @@ public final class SubtypeLocaleUtils { // Special language code to represent "no language". public static final String NO_LANGUAGE = "zz"; public static final String QWERTY = "qwerty"; + public static final String EMOJI = "emoji"; public static final int UNKNOWN_KEYBOARD_LAYOUT = R.string.subtype_generic; private static boolean sInitialized = false;