diff options
Diffstat (limited to 'java')
42 files changed, 311 insertions, 230 deletions
diff --git a/java/res/drawable-hdpi/ic_emoji_dark.png b/java/res/drawable-hdpi/ic_emoji_dark.png Binary files differnew file mode 100644 index 000000000..a9f18cde0 --- /dev/null +++ b/java/res/drawable-hdpi/ic_emoji_dark.png diff --git a/java/res/drawable-hdpi/ic_emoji_light.png b/java/res/drawable-hdpi/ic_emoji_light.png Binary files differnew file mode 100644 index 000000000..2e3638bf3 --- /dev/null +++ b/java/res/drawable-hdpi/ic_emoji_light.png diff --git a/java/res/drawable-mdpi/ic_emoji_dark.png b/java/res/drawable-mdpi/ic_emoji_dark.png Binary files differnew file mode 100644 index 000000000..d0047a437 --- /dev/null +++ b/java/res/drawable-mdpi/ic_emoji_dark.png diff --git a/java/res/drawable-mdpi/ic_emoji_light.png b/java/res/drawable-mdpi/ic_emoji_light.png Binary files differnew file mode 100644 index 000000000..a3195041a --- /dev/null +++ b/java/res/drawable-mdpi/ic_emoji_light.png diff --git a/java/res/drawable-xhdpi/ic_emoji_dark.png b/java/res/drawable-xhdpi/ic_emoji_dark.png Binary files differnew file mode 100644 index 000000000..22daec22e --- /dev/null +++ b/java/res/drawable-xhdpi/ic_emoji_dark.png diff --git a/java/res/drawable-xhdpi/ic_emoji_light.png b/java/res/drawable-xhdpi/ic_emoji_light.png Binary files differnew file mode 100644 index 000000000..21bc9090d --- /dev/null +++ b/java/res/drawable-xhdpi/ic_emoji_light.png diff --git a/java/res/layout/input_view.xml b/java/res/layout/input_view.xml index 136e18cd5..1ffb8a32a 100644 --- a/java/res/layout/input_view.xml +++ b/java/res/layout/input_view.xml @@ -30,34 +30,17 @@ android:layout_width="match_parent" android:layout_height="0dp" /> - <!-- On tablets, the suggestions strip is centered with horizontal paddings on both sides - because width of the landscape mode is too long for the suggestions strip. This - LinearLayout is required to hold the paddings. --> - <LinearLayout - android:id="@+id/suggestions_container" - android:orientation="horizontal" + <!-- To ensure that key preview popup is correctly placed when the current system locale is + one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> + <com.android.inputmethod.latin.suggestions.SuggestionStripView + android:id="@+id/suggestion_strip_view" + android:layoutDirection="ltr" android:layout_width="match_parent" - android:layout_height="wrap_content" - > - <View - android:layout_width="@dimen/suggestions_strip_padding" - android:layout_height="@dimen/suggestions_strip_height" - style="?attr/suggestionsStripBackgroundStyle" /> - <!-- To ensure that key preview popup is correctly placed when the current system locale is - one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> - <com.android.inputmethod.latin.suggestions.SuggestionStripView - android:id="@+id/suggestion_strip_view" - android:layoutDirection="ltr" - android:layout_weight="1.0" - android:layout_width="0dp" - android:layout_height="@dimen/suggestions_strip_height" - android:gravity="center_vertical" - style="?attr/suggestionStripViewStyle" /> - <View - android:layout_width="@dimen/suggestions_strip_padding" - android:layout_height="@dimen/suggestions_strip_height" - style="?attr/suggestionsStripBackgroundStyle" /> - </LinearLayout> + android:layout_height="@dimen/suggestions_strip_height" + android:gravity="center_vertical" + android:paddingRight="@dimen/suggestions_strip_padding" + android:paddingLeft="@dimen/suggestions_strip_padding" + style="?attr/suggestionStripViewStyle" /> <!-- To ensure that key preview popup is correctly placed when the current system locale is one of RTL locales, layoutDirection="ltr" is needed in the SDK version 17+. --> diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml index c31831747..eef9116da 100644 --- a/java/res/values/attrs.xml +++ b/java/res/values/attrs.xml @@ -28,7 +28,6 @@ <attr name="moreKeysKeyboardViewStyle" format="reference" /> <attr name="moreKeysKeyboardPanelStyle" format="reference" /> <!-- Suggestions strip style --> - <attr name="suggestionsStripBackgroundStyle" format="reference" /> <attr name="suggestionStripViewStyle" format="reference" /> <attr name="moreSuggestionsViewStyle" format="reference" /> <attr name="suggestionBackgroundStyle" format="reference" /> @@ -217,6 +216,7 @@ <attr name="iconLanguageSwitchKey" format="reference" /> <attr name="iconZwnjKey" format="reference" /> <attr name="iconZwjKey" format="reference" /> + <attr name="iconEmojiKey" format="reference" /> </declare-styleable> <declare-styleable name="Keyboard_Key"> diff --git a/java/res/values/keyboard-icons-black.xml b/java/res/values/keyboard-icons-black.xml index e9c5733b5..c1b1b6573 100644 --- a/java/res/values/keyboard-icons-black.xml +++ b/java/res/values/keyboard-icons-black.xml @@ -39,5 +39,6 @@ <!-- TODO: Needs dedicated black theme ZWNJ and ZWJ icons --> <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> + <item name="iconEmojiKey">@drawable/ic_emoji_light</item> </style> </resources> diff --git a/java/res/values/keyboard-icons-ics.xml b/java/res/values/keyboard-icons-ics.xml index 8eba196de..5ada27ae8 100644 --- a/java/res/values/keyboard-icons-ics.xml +++ b/java/res/values/keyboard-icons-ics.xml @@ -36,5 +36,6 @@ <item name="iconLanguageSwitchKey">@drawable/sym_keyboard_language_switch</item> <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> + <item name="iconEmojiKey">@drawable/ic_emoji_light</item> </style> </resources> diff --git a/java/res/values/keyboard-icons-white.xml b/java/res/values/keyboard-icons-white.xml index e52099867..7c6de42fa 100644 --- a/java/res/values/keyboard-icons-white.xml +++ b/java/res/values/keyboard-icons-white.xml @@ -35,5 +35,6 @@ <!-- TODO: Needs dedicated black theme ZWNJ and ZWJ icons --> <item name="iconZwnjKey">@drawable/sym_keyboard_zwnj_holo</item> <item name="iconZwjKey">@drawable/sym_keyboard_zwj_holo</item> + <item name="iconEmojiKey">@drawable/ic_emoji_dark</item> </style> </resources> diff --git a/java/res/values/strings.xml b/java/res/values/strings.xml index f572904f0..1eff2f9c3 100644 --- a/java/res/values/strings.xml +++ b/java/res/values/strings.xml @@ -380,20 +380,83 @@ This should be identical to subtype_serbian_latin aside from the trailing (%s). <string name="subtype_with_layout_sr-Latn">Serbian (Latin) (<xliff:g id="layout">%s</xliff:g>)</string> --> - <!-- Description for language agnostic keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language">No language</string> - <!-- Description for language agnostic QWERTY keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_qwerty">No language (QWERTY)</string> - <!-- Description for language agnostic QWERTZ keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_qwertz">No language (QWERTZ)</string> - <!-- Description for language agnostic AZERTY keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_azerty">No language (AZERTY)</string> - <!-- Description for language agnostic Dvorak keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_dvorak">No language (Dvorak)</string> - <!-- Description for language agnostic Colemak keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_colemak">No language (Colemak)</string> - <!-- Description for language agnostic PC QWERTY keyboard subtype [CHAR LIMIT=25] --> - <string name="subtype_no_language_pcqwerty">No language (PC)</string> + <!-- This string is displayed in a language list that allows to choose a language for +suggestions in a software keyboard. This setting won't give suggestions in any particular +language, hence "No language". +As for the "alphabet" mention, it refers specifically to the Latin alphabet, as opposed to +Cyrillic, Arabic, Hebrew or other scripts. This keyboard offers no suggestions, but it will +be a QWERTY, or AZERTY, or any other disposition that only offers Latin characters, so +you wouldn't be able to type, say, Arabic on it. Please translate it in a way that "alphabet" +would be understood to mean specifically the Latin alphabet, rather than any other +alphabet. [CHAR LIMIT=25] --> + <string name="subtype_no_language">No language (Alphabet)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the QWERTY +disposition rather than other common dispositions for Latin languages. [CHAR LIMIT=25] --> + <string name="subtype_no_language_qwerty">Alphabet (QWERTY)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the QWERTZ +disposition rather than other common dispositions for Latin languages. [CHAR LIMIT=25] --> + <string name="subtype_no_language_qwertz">Alphabet (QWERTZ)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the AZERTY +disposition rather than other common dispositions for Latin languages. [CHAR LIMIT=25] --> + <string name="subtype_no_language_azerty">Alphabet (AZERTY)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the Dvorak +disposition rather than other common dispositions for Latin languages. [CHAR LIMIT=25] --> + <string name="subtype_no_language_dvorak">Alphabet (Dvorak)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the Colemak +disposition rather than other common dispositions for Latin languages. [CHAR LIMIT=25] --> + <string name="subtype_no_language_colemak">Alphabet (Colemak)</string> + <!-- This string is displayed in the description for a keyboard type. It refers specifically to +the Latin alphabet, as opposed to Cyrillic, Arabic, Hebrew or other scripts. +When the device is configured to use a language using a script other than the Latin alphabet, the +user still needs a keyboard that can input Latin characters for passwords or login names for +example, and a way to switch to this Latin alphabet keyboard. This string is the description for +this keyboard, so users of other scripts should understand when they read this that it represents a +keyboard that is meant for them to be able to enter Latin characters as opposed to the script they +are used to. This keyboard does not provide a dictionary, and it is not tied to any specific +language among those that use the Latin alphabet. This keyboard is laid out in the QWERTY PC +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> <!-- 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/values/styles.xml b/java/res/values/styles.xml index 8b6c29e59..37c6a9553 100644 --- a/java/res/values/styles.xml +++ b/java/res/values/styles.xml @@ -145,13 +145,10 @@ <style name="MoreKeysKeyboardPanelStyle"> <item name="android:background">@drawable/keyboard_popup_panel_background</item> </style> - <style name="SuggestionsStripBackgroundStyle"> - <item name="android:background">@drawable/keyboard_suggest_strip</item> - </style> <style name="SuggestionStripViewStyle" - parent="SuggestionsStripBackgroundStyle" > + <item name="android:background">@drawable/keyboard_suggest_strip</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="colorValidTypedWord">@color/highlight_color_default</item> <item name="colorTypedWord">@color/typed_word_color_default</item> @@ -380,13 +377,10 @@ <style name="MoreKeysKeyboardPanelStyle.IceCreamSandwich"> <item name="android:background">@drawable/keyboard_popup_panel_background_holo</item> </style> - <style name="SuggestionsStripBackgroundStyle.IceCreamSandwich"> - <item name="android:background">@drawable/keyboard_suggest_strip_holo</item> - </style> <style name="SuggestionStripViewStyle.IceCreamSandwich" - parent="SuggestionsStripBackgroundStyle.IceCreamSandwich" > + <item name="android:background">@drawable/keyboard_suggest_strip_holo</item> <item name="suggestionStripOption">autoCorrectBold|validTypedWordBold</item> <item name="colorValidTypedWord">@color/highlight_color_ics</item> <item name="colorTypedWord">@color/highlight_color_ics</item> diff --git a/java/res/values/themes-basic-highcontrast.xml b/java/res/values/themes-basic-highcontrast.xml index 48df0a1b6..e81d47386 100644 --- a/java/res/values/themes-basic-highcontrast.xml +++ b/java/res/values/themes-basic-highcontrast.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-basic.xml b/java/res/values/themes-basic.xml index 88a0c5d8d..c44f0f614 100644 --- a/java/res/values/themes-basic.xml +++ b/java/res/values/themes-basic.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-gingerbread.xml b/java/res/values/themes-gingerbread.xml index 51f680a7a..129afdf5b 100644 --- a/java/res/values/themes-gingerbread.xml +++ b/java/res/values/themes-gingerbread.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Gingerbread</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Gingerbread</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-ics.xml b/java/res/values/themes-ics.xml index d9c59a180..1264831f3 100644 --- a/java/res/values/themes-ics.xml +++ b/java/res/values/themes-ics.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.IceCreamSandwich</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.IceCreamSandwich</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle.IceCreamSandwich</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle.IceCreamSandwich</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle.IceCreamSandwich</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle.IceCreamSandwich</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle.IceCreamSandwich</item> diff --git a/java/res/values/themes-stone-bold.xml b/java/res/values/themes-stone-bold.xml index 6ace9d673..196f3ef9f 100644 --- a/java/res/values/themes-stone-bold.xml +++ b/java/res/values/themes-stone-bold.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/values/themes-stone.xml b/java/res/values/themes-stone.xml index 3c3826b1a..d0d35c28d 100644 --- a/java/res/values/themes-stone.xml +++ b/java/res/values/themes-stone.xml @@ -22,7 +22,6 @@ <item name="moreKeysKeyboardStyle">@style/MoreKeysKeyboard.Stone</item> <item name="moreKeysKeyboardViewStyle">@style/MoreKeysKeyboardView.Stone</item> <item name="moreKeysKeyboardPanelStyle">@style/MoreKeysKeyboardPanelStyle</item> - <item name="suggestionsStripBackgroundStyle">@style/SuggestionsStripBackgroundStyle</item> <item name="suggestionStripViewStyle">@style/SuggestionStripViewStyle</item> <item name="moreSuggestionsViewStyle">@style/MoreSuggestionsViewStyle</item> <item name="suggestionBackgroundStyle">@style/SuggestionBackgroundStyle</item> diff --git a/java/res/xml-sw600dp/key_styles_common.xml b/java/res/xml-sw600dp/key_styles_common.xml index a2d2fd827..f407ba346 100644 --- a/java/res/xml-sw600dp/key_styles_common.xml +++ b/java/res/xml-sw600dp/key_styles_common.xml @@ -120,6 +120,11 @@ latin:keyActionFlags="noKeyPreview|altCodeWhileTyping|enableLongPress" latin:altCode="!code/key_space" /> <key-style + latin:styleName="emojiKeyStyle" + latin:code="!code/key_emoji" + latin:keyIcon="!icon/emoji_key" + latin:keyActionFlags="noKeyPreview" /> + <key-style latin:styleName="settingsKeyStyle" latin:code="!code/key_settings" latin:keyIcon="!icon/settings_key" diff --git a/java/res/xml-sw600dp/rows_10_10_7_symbols.xml b/java/res/xml-sw600dp/rows_10_10_7_symbols.xml index 44c967c04..0e4710c37 100644 --- a/java/res/xml-sw600dp/rows_10_10_7_symbols.xml +++ b/java/res/xml-sw600dp/rows_10_10_7_symbols.xml @@ -43,7 +43,7 @@ latin:keyStyle="enterKeyStyle" latin:keyWidth="fillRight" /> </Row> - <Row + <Row latin:keyWidth="9.0%p" > <Key diff --git a/java/res/xml-sw768dp/key_styles_common.xml b/java/res/xml-sw768dp/key_styles_common.xml index e69bc3020..7c0a82a71 100644 --- a/java/res/xml-sw768dp/key_styles_common.xml +++ b/java/res/xml-sw768dp/key_styles_common.xml @@ -110,6 +110,11 @@ latin:keyActionFlags="noKeyPreview|altCodeWhileTyping|enableLongPress" latin:altCode="!code/key_space" /> <key-style + latin:styleName="emojiKeyStyle" + latin:code="!code/key_emoji" + latin:keyIcon="!icon/emoji_key" + latin:keyActionFlags="noKeyPreview" /> + <key-style latin:styleName="settingsKeyStyle" latin:code="!code/key_settings" latin:keyIcon="!icon/settings_key" diff --git a/java/res/xml/key_styles_common.xml b/java/res/xml/key_styles_common.xml index 6590d0a4c..355455e3b 100644 --- a/java/res/xml/key_styles_common.xml +++ b/java/res/xml/key_styles_common.xml @@ -126,6 +126,11 @@ latin:keyActionFlags="noKeyPreview|altCodeWhileTyping|enableLongPress" latin:altCode="!code/key_space" /> <key-style + latin:styleName="emojiKeyStyle" + latin:code="!code/key_emoji" + latin:keyIcon="!icon/emoji_key" + latin:keyActionFlags="noKeyPreview" /> + <key-style latin:styleName="tabKeyStyle" latin:code="!code/key_tab" latin:keyIcon="!icon/tab_key" diff --git a/java/src/com/android/inputmethod/keyboard/Key.java b/java/src/com/android/inputmethod/keyboard/Key.java index 09f1145e9..61805286d 100644 --- a/java/src/com/android/inputmethod/keyboard/Key.java +++ b/java/src/com/android/inputmethod/keyboard/Key.java @@ -306,8 +306,15 @@ public class Key implements Comparable<Key> { } mActionFlags = actionFlags; + final int code = KeySpecParser.parseCode(style.getString(keyAttr, + R.styleable.Keyboard_Key_code), params.mCodesSet, CODE_UNSPECIFIED); if ((mLabelFlags & LABEL_FLAGS_FROM_CUSTOM_ACTION_LABEL) != 0) { mLabel = params.mId.mCustomActionLabel; + } else if (code >= Character.MIN_SUPPLEMENTARY_CODE_POINT) { + // This is a workaround to have a key that has a supplementary code point in its label. + // Because we can put a string in resource neither as a XML entity of a supplementary + // code point nor as a surrogate pair. + mLabel = new StringBuilder().appendCodePoint(code).toString(); } else { mLabel = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyLabel), needsToUpperCase, locale); @@ -320,8 +327,6 @@ public class Key implements Comparable<Key> { } String outputText = KeySpecParser.toUpperCaseOfStringForLocale(style.getString(keyAttr, R.styleable.Keyboard_Key_keyOutputText), needsToUpperCase, locale); - final int code = KeySpecParser.parseCode(style.getString(keyAttr, - R.styleable.Keyboard_Key_code), params.mCodesSet, CODE_UNSPECIFIED); // Choose the first letter of the label as primary code if not specified. if (code == CODE_UNSPECIFIED && TextUtils.isEmpty(outputText) && !TextUtils.isEmpty(mLabel)) { diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java index 8864b7603..1dc3c6a4c 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java @@ -18,7 +18,6 @@ package com.android.inputmethod.keyboard; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.KEYBOARD_LAYOUT_SET; -import android.content.res.Configuration; import android.text.InputType; import android.text.TextUtils; import android.view.inputmethod.EditorInfo; @@ -58,8 +57,6 @@ public final class KeyboardId { public final InputMethodSubtype mSubtype; public final Locale mLocale; - // TODO: Remove this member. It is used only for logging purpose. - public final int mOrientation; public final int mWidth; public final int mHeight; public final int mMode; @@ -77,7 +74,6 @@ public final class KeyboardId { public KeyboardId(final int elementId, final KeyboardLayoutSet.Params params) { mSubtype = params.mSubtype; mLocale = SubtypeLocaleUtils.getSubtypeLocale(mSubtype); - mOrientation = params.mOrientation; mWidth = params.mKeyboardWidth; mHeight = params.mKeyboardHeight; mMode = params.mMode; @@ -101,7 +97,6 @@ public final class KeyboardId { private static int computeHashCode(final KeyboardId id) { return Arrays.hashCode(new Object[] { - id.mOrientation, id.mElementId, id.mMode, id.mWidth, @@ -123,8 +118,7 @@ public final class KeyboardId { private boolean equals(final KeyboardId other) { if (other == this) return true; - return other.mOrientation == mOrientation - && other.mElementId == mElementId + return other.mElementId == mElementId && other.mMode == mMode && other.mWidth == mWidth && other.mHeight == mHeight @@ -185,13 +179,10 @@ public final class KeyboardId { @Override public String toString() { - final String orientation = (mOrientation == Configuration.ORIENTATION_PORTRAIT) - ? "port" : "land"; - return String.format(Locale.ROOT, "[%s %s:%s %s:%dx%d %s %s %s%s%s%s%s%s%s%s%s]", + return String.format(Locale.ROOT, "[%s %s:%s %dx%d %s %s %s%s%s%s%s%s%s%s%s]", elementIdToName(mElementId), - mLocale, - mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), - orientation, mWidth, mHeight, + mLocale, mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), + mWidth, mHeight, modeName(mMode), imeAction(), (navigateNext() ? "navigateNext" : ""), diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java index e15310721..e97f29452 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java @@ -23,20 +23,16 @@ import static com.android.inputmethod.latin.Constants.ImeOption.NO_SETTINGS_KEY; import static com.android.inputmethod.latin.Constants.Subtype.ExtraValue.ASCII_CAPABLE; import android.content.Context; -import android.content.res.Configuration; import android.content.res.Resources; import android.content.res.TypedArray; import android.content.res.XmlResourceParser; import android.text.InputType; -import android.text.TextUtils; -import android.util.DisplayMetrics; import android.util.Log; import android.util.SparseArray; import android.util.Xml; import android.view.inputmethod.EditorInfo; import android.view.inputmethod.InputMethodSubtype; -import com.android.inputmethod.annotations.UsedForTesting; import com.android.inputmethod.compat.EditorInfoCompatUtils; import com.android.inputmethod.keyboard.internal.KeyboardBuilder; import com.android.inputmethod.keyboard.internal.KeyboardParams; @@ -45,10 +41,8 @@ import com.android.inputmethod.latin.InputAttributes; import com.android.inputmethod.latin.LatinImeLogger; import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SubtypeSwitcher; -import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.InputTypeUtils; -import com.android.inputmethod.latin.utils.ResourceUtils; import com.android.inputmethod.latin.utils.SubtypeLocaleUtils; import com.android.inputmethod.latin.utils.XmlParseUtils; @@ -74,8 +68,6 @@ public final class KeyboardLayoutSet { private static final String TAG_ELEMENT = "Element"; private static final String KEYBOARD_LAYOUT_SET_RESOURCE_PREFIX = "keyboard_layout_set_"; - private static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480; - private static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 800; private final Context mContext; private final Params mParams; @@ -119,7 +111,6 @@ public final class KeyboardLayoutSet { boolean mLanguageSwitchKeyEnabled; InputMethodSubtype mSubtype; boolean mIsSpellChecker; - int mOrientation; int mKeyboardWidth; int mKeyboardHeight; // Sparse array of KeyboardLayoutSet element parameters indexed by element's id. @@ -241,41 +232,12 @@ public final class KeyboardLayoutSet { mPackageName, NO_SETTINGS_KEY, mEditorInfo); } - public Builder setScreenGeometry(final int widthPixels, final int heightPixels) { - final Params params = mParams; - params.mOrientation = (heightPixels > widthPixels) - ? Configuration.ORIENTATION_PORTRAIT : Configuration.ORIENTATION_LANDSCAPE; - setDefaultKeyboardSize(widthPixels, heightPixels); + public Builder setKeyboardGeometry(final int keyboardWidth, final int keyboardHeight) { + mParams.mKeyboardWidth = keyboardWidth; + mParams.mKeyboardHeight = keyboardHeight; return this; } - private void setDefaultKeyboardSize(final int widthPixels, final int heightPixels) { - final String keyboardHeightString = ResourceUtils.getDeviceOverrideValue( - mResources, R.array.keyboard_heights); - final float keyboardHeight; - if (TextUtils.isEmpty(keyboardHeightString)) { - keyboardHeight = mResources.getDimension(R.dimen.keyboardHeight); - } else { - keyboardHeight = Float.parseFloat(keyboardHeightString) - * mResources.getDisplayMetrics().density; - } - final float maxKeyboardHeight = mResources.getFraction( - R.fraction.maxKeyboardHeight, heightPixels, heightPixels); - float minKeyboardHeight = mResources.getFraction( - R.fraction.minKeyboardHeight, heightPixels, heightPixels); - if (minKeyboardHeight < 0.0f) { - // Specified fraction was negative, so it should be calculated against display - // width. - minKeyboardHeight = -mResources.getFraction( - R.fraction.minKeyboardHeight, widthPixels, widthPixels); - } - // Keyboard height will not exceed maxKeyboardHeight and will not be less than - // minKeyboardHeight. - mParams.mKeyboardHeight = (int)Math.max( - Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight); - mParams.mKeyboardWidth = widthPixels; - } - public Builder setSubtype(final InputMethodSubtype subtype) { final boolean asciiCapable = subtype.containsExtraValueKey(ASCII_CAPABLE); @SuppressWarnings("deprecation") @@ -317,8 +279,6 @@ public final class KeyboardLayoutSet { } public KeyboardLayoutSet build() { - if (mParams.mOrientation == Configuration.ORIENTATION_UNDEFINED) - throw new RuntimeException("Screen geometry is not specified"); if (mParams.mSubtype == null) throw new RuntimeException("KeyboardLayoutSet subtype is not specified"); final String packageName = mResources.getResourcePackageName( @@ -442,51 +402,4 @@ public final class KeyboardLayoutSet { } } } - - public static KeyboardLayoutSet createKeyboardSetForSpellChecker(final Context context, - final String locale, final String layout) { - final InputMethodSubtype subtype = - AdditionalSubtypeUtils.createAdditionalSubtype(locale, layout, null); - return createKeyboardSet(context, subtype, SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, - SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT, false /* testCasesHaveTouchCoordinates */, - true /* isSpellChecker */); - } - - @UsedForTesting - public static KeyboardLayoutSet createKeyboardSetForTest(final Context context, - final InputMethodSubtype subtype, final int orientation, - final boolean testCasesHaveTouchCoordinates) { - final DisplayMetrics dm = context.getResources().getDisplayMetrics(); - final int width; - final int height; - if (orientation == Configuration.ORIENTATION_LANDSCAPE) { - width = Math.max(dm.widthPixels, dm.heightPixels); - height = Math.min(dm.widthPixels, dm.heightPixels); - } else if (orientation == Configuration.ORIENTATION_PORTRAIT) { - width = Math.min(dm.widthPixels, dm.heightPixels); - height = Math.max(dm.widthPixels, dm.heightPixels); - } else { - throw new RuntimeException("Orientation should be ORIENTATION_LANDSCAPE or " - + "ORIENTATION_PORTRAIT: orientation=" + orientation); - } - return createKeyboardSet(context, subtype, width, height, testCasesHaveTouchCoordinates, - false /* isSpellChecker */); - } - - private static KeyboardLayoutSet createKeyboardSet(final Context context, - final InputMethodSubtype subtype, final int width, final int height, - final boolean testCasesHaveTouchCoordinates, final boolean isSpellChecker) { - final EditorInfo editorInfo = new EditorInfo(); - editorInfo.inputType = InputType.TYPE_CLASS_TEXT; - final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder( - context, editorInfo); - builder.setScreenGeometry(width, height); - builder.setSubtype(subtype); - builder.setIsSpellChecker(isSpellChecker); - if (!testCasesHaveTouchCoordinates) { - // For spell checker and tests - builder.disableTouchPositionCorrectionData(); - } - return builder.build(); - } } diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java index 8880af48c..1ea0f8b96 100644 --- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java +++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java @@ -20,7 +20,6 @@ import android.content.Context; import android.content.SharedPreferences; import android.content.res.Resources; import android.preference.PreferenceManager; -import android.util.DisplayMetrics; import android.util.Log; import android.view.ContextThemeWrapper; import android.view.LayoutInflater; @@ -39,6 +38,7 @@ import com.android.inputmethod.latin.SubtypeSwitcher; import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.settings.SettingsValues; +import com.android.inputmethod.latin.utils.ResourceUtils; public final class KeyboardSwitcher implements KeyboardState.SwitchActions { private static final String TAG = KeyboardSwitcher.class.getSimpleName(); @@ -137,8 +137,9 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions { final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder( mThemeContext, editorInfo); final Resources res = mThemeContext.getResources(); - final DisplayMetrics dm = res.getDisplayMetrics(); - builder.setScreenGeometry(dm.widthPixels, dm.heightPixels); + final int keyboardWidth = ResourceUtils.getDefaultKeyboardWidth(res); + final int keyboardHeight = ResourceUtils.getDefaultKeyboardHeight(res); + builder.setKeyboardGeometry(keyboardWidth, keyboardHeight); builder.setSubtype(mSubtypeSwitcher.getCurrentSubtype()); builder.setOptions( settingsValues.isVoiceKeyEnabled(editorInfo), diff --git a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java index 6782317d0..7a5038843 100644 --- a/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java +++ b/java/src/com/android/inputmethod/keyboard/MainKeyboardView.java @@ -615,7 +615,8 @@ public final class MainKeyboardView extends KeyboardView implements PointerTrack final int keyHeight = keyboard.mMostCommonKeyHeight - keyboard.mVerticalGap; mSpacebarTextSize = keyHeight * mSpacebarTextRatio; if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) { - ResearchLogger.mainKeyboardView_setKeyboard(keyboard); + final int orientation = getContext().getResources().getConfiguration().orientation; + ResearchLogger.mainKeyboardView_setKeyboard(keyboard, orientation); } // This always needs to be set since the accessibility state can diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java index 69ffb4c75..dc815e57d 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardCodesSet.java @@ -53,6 +53,7 @@ public final class KeyboardCodesSet { "key_action_previous", "key_shift_enter", "key_language_switch", + "key_emoji", "key_unspecified", "key_left_parenthesis", "key_right_parenthesis", @@ -89,6 +90,7 @@ public final class KeyboardCodesSet { Constants.CODE_ACTION_PREVIOUS, Constants.CODE_SHIFT_ENTER, Constants.CODE_LANGUAGE_SWITCH, + Constants.CODE_EMOJI, Constants.CODE_UNSPECIFIED, CODE_LEFT_PARENTHESIS, CODE_RIGHT_PARENTHESIS, @@ -116,6 +118,7 @@ public final class KeyboardCodesSet { DEFAULT[12], DEFAULT[13], DEFAULT[14], + DEFAULT[15], CODE_RIGHT_PARENTHESIS, CODE_LEFT_PARENTHESIS, CODE_GREATER_THAN_SIGN, diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java index 4e3f7618b..336db186e 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardIconsSet.java @@ -56,6 +56,7 @@ public final class KeyboardIconsSet { "language_switch_key", R.styleable.Keyboard_iconLanguageSwitchKey, "zwnj_key", R.styleable.Keyboard_iconZwnjKey, "zwj_key", R.styleable.Keyboard_iconZwjKey, + "emoji_key", R.styleable.Keyboard_iconEmojiKey, }; private static int NUM_ICONS = NAMES_AND_ATTR_IDS.length / 2; diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java index 7bb7442f3..b55e19d52 100644 --- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java +++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardTextsSet.java @@ -3151,7 +3151,7 @@ public final class KeyboardTextsSet { /* 7 */ "\u00E7", }; - /* Language zz: No language */ + /* Language zz: Alphabet */ private static final String[] LANGUAGE_zz = { // U+00E0: "à" LATIN SMALL LETTER A WITH GRAVE // U+00E1: "á" LATIN SMALL LETTER A WITH ACUTE @@ -3324,7 +3324,7 @@ public final class KeyboardTextsSet { "uk", LANGUAGE_uk, /* Ukrainian */ "vi", LANGUAGE_vi, /* Vietnamese */ "zu", LANGUAGE_zu, /* Zulu */ - "zz", LANGUAGE_zz, /* No language */ + "zz", LANGUAGE_zz, /* Alphabet */ }; static { diff --git a/java/src/com/android/inputmethod/latin/Constants.java b/java/src/com/android/inputmethod/latin/Constants.java index f91a21c7a..8aec03f71 100644 --- a/java/src/com/android/inputmethod/latin/Constants.java +++ b/java/src/com/android/inputmethod/latin/Constants.java @@ -187,6 +187,7 @@ public final class Constants { public static final int CODE_ACTION_NEXT = -8; public static final int CODE_ACTION_PREVIOUS = -9; public static final int CODE_LANGUAGE_SWITCH = -10; + public static final int CODE_EMOJI = -11; public static final int CODE_SHIFT_ENTER = -12; // Code value representing the code is not specified. public static final int CODE_UNSPECIFIED = -13; @@ -207,6 +208,7 @@ public final class Constants { case CODE_ACTION_NEXT: return "actionNext"; case CODE_ACTION_PREVIOUS: return "actionPrevious"; case CODE_LANGUAGE_SWITCH: return "languageSwitch"; + case CODE_EMOJI: return "emoji"; case CODE_SHIFT_ENTER: return "shiftEnter"; case CODE_UNSPECIFIED: return "unspec"; case CODE_TAB: return "tab"; diff --git a/java/src/com/android/inputmethod/latin/InputView.java b/java/src/com/android/inputmethod/latin/InputView.java index 5359c8185..81ccf83d8 100644 --- a/java/src/com/android/inputmethod/latin/InputView.java +++ b/java/src/com/android/inputmethod/latin/InputView.java @@ -24,7 +24,7 @@ import android.view.View; import android.widget.LinearLayout; public final class InputView extends LinearLayout { - private View mSuggestionStripContainer; + private View mSuggestionStripView; private View mKeyboardView; private int mKeyboardTopPadding; @@ -33,33 +33,29 @@ public final class InputView extends LinearLayout { private final Rect mEventForwardingRect = new Rect(); private final Rect mEventReceivingRect = new Rect(); - public InputView(Context context, AttributeSet attrs) { + public InputView(final Context context, final AttributeSet attrs) { super(context, attrs, 0); } - public void setKeyboardGeometry(int keyboardTopPadding) { + public void setKeyboardGeometry(final int keyboardTopPadding) { mKeyboardTopPadding = keyboardTopPadding; } @Override protected void onFinishInflate() { - mSuggestionStripContainer = findViewById(R.id.suggestions_container); + mSuggestionStripView = findViewById(R.id.suggestion_strip_view); mKeyboardView = findViewById(R.id.keyboard_view); } @Override - public boolean dispatchTouchEvent(MotionEvent me) { - if (mSuggestionStripContainer.getVisibility() == VISIBLE - && mKeyboardView.getVisibility() == VISIBLE - && forwardTouchEvent(me)) { - return true; + public boolean dispatchTouchEvent(final MotionEvent me) { + if (mSuggestionStripView.getVisibility() != VISIBLE + || mKeyboardView.getVisibility() != VISIBLE) { + return super.dispatchTouchEvent(me); } - return super.dispatchTouchEvent(me); - } - // The touch events that hit the top padding of keyboard should be forwarded to - // {@link SuggestionStripView}. - private boolean forwardTouchEvent(MotionEvent me) { + // The touch events that hit the top padding of keyboard should be forwarded to + // {@link SuggestionStripView}. final Rect rect = mInputViewRect; this.getGlobalVisibleRect(rect); final int x = (int)me.getX() + rect.left; @@ -68,7 +64,7 @@ public final class InputView extends LinearLayout { final Rect forwardingRect = mEventForwardingRect; mKeyboardView.getGlobalVisibleRect(forwardingRect); if (!mIsForwardingEvent && !forwardingRect.contains(x, y)) { - return false; + return super.dispatchTouchEvent(me); } final int forwardingLimitY = forwardingRect.top + mKeyboardTopPadding; @@ -93,11 +89,11 @@ public final class InputView extends LinearLayout { } if (!sendToTarget) { - return false; + return super.dispatchTouchEvent(me); } final Rect receivingRect = mEventReceivingRect; - mSuggestionStripContainer.getGlobalVisibleRect(receivingRect); + mSuggestionStripView.getGlobalVisibleRect(receivingRect); final int translatedX = x - receivingRect.left; final int translatedY; if (y < forwardingLimitY) { @@ -107,7 +103,7 @@ public final class InputView extends LinearLayout { translatedY = y - receivingRect.top; } me.setLocation(translatedX, translatedY); - mSuggestionStripContainer.dispatchTouchEvent(me); + mSuggestionStripView.dispatchTouchEvent(me); return true; } } diff --git a/java/src/com/android/inputmethod/latin/LatinIME.java b/java/src/com/android/inputmethod/latin/LatinIME.java index 385e884ab..6339e9c50 100644 --- a/java/src/com/android/inputmethod/latin/LatinIME.java +++ b/java/src/com/android/inputmethod/latin/LatinIME.java @@ -152,7 +152,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private View mExtractArea; private View mKeyPreviewBackingView; - private View mSuggestionsContainer; private SuggestionStripView mSuggestionStripView; // Never null private SuggestedWords mSuggestedWords = SuggestedWords.EMPTY; @@ -667,7 +666,6 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen mExtractArea = getWindow().getWindow().getDecorView() .findViewById(android.R.id.extractArea); mKeyPreviewBackingView = view.findViewById(R.id.key_preview_backing); - mSuggestionsContainer = view.findViewById(R.id.suggestions_container); mSuggestionStripView = (SuggestionStripView)view.findViewById(R.id.suggestion_strip_view); if (mSuggestionStripView != null) mSuggestionStripView.setListener(this, view); @@ -1111,17 +1109,17 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen private void setSuggestionStripShownInternal(final boolean shown, final boolean needsInputViewShown) { // TODO: Modify this if we support suggestions with hard keyboard - if (onEvaluateInputViewShown() && mSuggestionsContainer != null) { + if (onEvaluateInputViewShown() && mSuggestionStripView != null) { final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); final boolean inputViewShown = (mainKeyboardView != null) ? mainKeyboardView.isShown() : false; final boolean shouldShowSuggestions = shown && (needsInputViewShown ? inputViewShown : true); if (isFullscreenMode()) { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.GONE); } else { - mSuggestionsContainer.setVisibility( + mSuggestionStripView.setVisibility( shouldShowSuggestions ? View.VISIBLE : View.INVISIBLE); } } @@ -1142,7 +1140,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen return 0; } final int keyboardHeight = mainKeyboardView.getHeight(); - final int suggestionsHeight = mSuggestionsContainer.getHeight(); + final int suggestionsHeight = mSuggestionStripView.getHeight(); final int displayHeight = getResources().getDisplayMetrics().heightPixels; final Rect rect = new Rect(); mKeyPreviewBackingView.getWindowVisibleDisplayFrame(rect); @@ -1160,7 +1158,7 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen public void onComputeInsets(final InputMethodService.Insets outInsets) { super.onComputeInsets(outInsets); final MainKeyboardView mainKeyboardView = mKeyboardSwitcher.getMainKeyboardView(); - if (mainKeyboardView == null || mSuggestionsContainer == null) { + if (mainKeyboardView == null || mSuggestionStripView == null) { return; } final int adjustedBackingHeight = getAdjustedBackingViewHeight(); @@ -1170,13 +1168,13 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen // be considered. // See {@link android.inputmethodservice.InputMethodService#onComputeInsets}. final int extractHeight = isFullscreenMode() ? mExtractArea.getHeight() : 0; - final int suggestionsHeight = (mSuggestionsContainer.getVisibility() == View.GONE) ? 0 - : mSuggestionsContainer.getHeight(); + final int suggestionsHeight = (mSuggestionStripView.getVisibility() == View.GONE) ? 0 + : mSuggestionStripView.getHeight(); final int extraHeight = extractHeight + backingHeight + suggestionsHeight; int visibleTopY = extraHeight; // Need to set touchable region only if input view is being shown if (mainKeyboardView.isShown()) { - if (mSuggestionsContainer.getVisibility() == View.VISIBLE) { + if (mSuggestionStripView.getVisibility() == View.VISIBLE) { visibleTopY -= suggestionsHeight; } final int touchY = mainKeyboardView.isShowingMoreKeysPanel() ? 0 : visibleTopY; @@ -1512,6 +1510,9 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen case Constants.CODE_LANGUAGE_SWITCH: handleLanguageSwitchKey(); break; + case Constants.CODE_EMOJI: + // TODO: Implement emoji keyboard switch. + break; case Constants.CODE_ENTER: final EditorInfo editorInfo = getCurrentInputEditorInfo(); final int imeOptionsActionId = @@ -2529,7 +2530,8 @@ public class LatinIME extends InputMethodService implements KeyboardActionListen final int maxFreq = AutoCorrectionUtils.getMaxFrequency( suggest.getUnigramDictionaries(), suggestion); if (maxFreq == 0) return null; - userHistoryPredictionDictionary.addToUserHistory(prevWord, secondWord, maxFreq > 0); + userHistoryPredictionDictionary + .addToPersonalizationPredictionDictionary(prevWord, secondWord, maxFreq > 0); return prevWord; } diff --git a/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java b/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java index 9d041f4eb..6498bf9c1 100644 --- a/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java +++ b/java/src/com/android/inputmethod/latin/personalization/DynamicPredictionDictionaryBase.java @@ -31,6 +31,7 @@ import com.android.inputmethod.latin.WordComposer; import com.android.inputmethod.latin.makedict.FormatSpec.FormatOptions; import com.android.inputmethod.latin.settings.Settings; import com.android.inputmethod.latin.utils.ByteArrayWrapper; +import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.BigramDictionaryInterface; import com.android.inputmethod.latin.utils.UserHistoryDictIOUtils.OnAddWordListener; @@ -49,9 +50,6 @@ import java.util.concurrent.locks.ReentrantLock; * This class is a base class of a dictionary for the personalized prediction language model. */ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictionary { - public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) { - // TODO: Implement - } private static final String TAG = DynamicPredictionDictionaryBase.class.getSimpleName(); public static final boolean DBG_SAVE_RESTORE = false; @@ -75,6 +73,9 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona private final ReentrantLock mBigramListLock = new ReentrantLock(); private final SharedPreferences mPrefs; + private final ArrayList<PersonalizationDictionaryUpdateSession> mSessions = + CollectionUtils.newArrayList(); + // Should always be false except when we use this class for test @UsedForTesting boolean isTest = false; @@ -118,14 +119,15 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona } /** - * Pair will be added to the user history dictionary. + * Pair will be added to the personalization prediction dictionary. * * The first word may be null. That means we don't know the context, in other words, * it's only a unigram. The first word may also be an empty string : this means start * context, as in beginning of a sentence for example. * The second word may not be null (a NullPointerException would be thrown). */ - public int addToUserHistory(final String word1, final String word2, final boolean isValid) { + public int addToPersonalizationPredictionDictionary( + final String word1, final String word2, final boolean isValid) { if (word2.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH || (word1 != null && word1.length() >= Constants.DICTIONARY_MAX_WORD_LENGTH)) { return -1; @@ -393,9 +395,14 @@ public abstract class DynamicPredictionDictionaryBase extends ExpandableDictiona final String word1, final String word2, final boolean isValid) { mBigramListLock.lock(); try { - addToUserHistory(word1, word2, isValid); + addToPersonalizationPredictionDictionary(word1, word2, isValid); } finally { mBigramListLock.unlock(); } } + + public void registerUpdateSession(PersonalizationDictionaryUpdateSession session) { + session.setDictionary(this); + mSessions.add(session); + } } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java index 19554d639..e38a235e9 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionary.java @@ -27,7 +27,7 @@ import android.content.Context; public class PersonalizationDictionary extends ExpandableBinaryDictionary { private static final String NAME = "personalization"; - public static void registerUpdateListener(PersonalizationDictionaryUpdateListener listener) { + public static void registerUpdateListener(PersonalizationDictionaryUpdateSession listener) { // TODO: Implement } diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java index 9f013df1c..da256f827 100644 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryHelper.java @@ -20,6 +20,7 @@ import com.android.inputmethod.latin.utils.CollectionUtils; import android.content.Context; import android.content.SharedPreferences; +import android.preference.PreferenceManager; import android.util.Log; import java.lang.ref.SoftReference; @@ -58,6 +59,16 @@ public class PersonalizationDictionaryHelper { } } + public static void + registerPersonalizationDictionaryUpdateSession(final Context context, + final PersonalizationDictionaryUpdateSession session) { + final PersonalizationPredictionDictionary dictionary = + getPersonalizationPredictionDictionary(context, + context.getResources().getConfiguration().locale.toString(), + PreferenceManager.getDefaultSharedPreferences(context)); + dictionary.registerUpdateSession(session); + } + public static PersonalizationPredictionDictionary getPersonalizationPredictionDictionary( final Context context, final String locale, final SharedPreferences sp) { synchronized (sLangPersonalizationDictCache) { diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateListener.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateListener.java deleted file mode 100644 index c78e5a95b..000000000 --- a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateListener.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Copyright (C) 2013 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.latin.personalization; - -public interface PersonalizationDictionaryUpdateListener { - // TODO: Implement -} diff --git a/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java new file mode 100644 index 000000000..d62aec19d --- /dev/null +++ b/java/src/com/android/inputmethod/latin/personalization/PersonalizationDictionaryUpdateSession.java @@ -0,0 +1,66 @@ +/* + * Copyright (C) 2013 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.latin.personalization; + +import java.lang.ref.WeakReference; +import java.util.ArrayList; + +/** + * This class is a session where a data provider can communicate with a personalization + * dictionary. + */ +public abstract class PersonalizationDictionaryUpdateSession { + /** + * This class is a parameter for a new unigram or bigram word which will be added + * to the personalization dictionary. + */ + public static class PersonalizationLanguageModelParam { + public final String mWord0; + public final String mWord1; + public final boolean mIsValid; + public final int mFrequency; + public PersonalizationLanguageModelParam(String word0, String word1, boolean isValid, + int frequency) { + mWord0 = word0; + mWord1 = word1; + mIsValid = isValid; + mFrequency = frequency; + } + } + + // TODO: Use a dynamic binary dictionary instead + public WeakReference<DynamicPredictionDictionaryBase> mDictionary; + + public abstract void onDictionaryReady(); + + public void setDictionary(DynamicPredictionDictionaryBase dictionary) { + mDictionary = new WeakReference<DynamicPredictionDictionaryBase>(dictionary); + } + + public void addToPersonalizationDictionary( + final ArrayList<PersonalizationLanguageModelParam> lmParams) { + final DynamicPredictionDictionaryBase dictionary = mDictionary == null + ? null : mDictionary.get(); + if (dictionary == null) { + return; + } + for (final PersonalizationLanguageModelParam lmParam : lmParams) { + dictionary.addToPersonalizationPredictionDictionary( + lmParam.mWord0, lmParam.mWord1, lmParam.mIsValid); + } + } +} diff --git a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java index 692e7392c..eb6d7c106 100644 --- a/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java +++ b/java/src/com/android/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java @@ -20,7 +20,10 @@ import android.content.Intent; import android.content.SharedPreferences; import android.preference.PreferenceManager; import android.service.textservice.SpellCheckerService; +import android.text.InputType; import android.util.Log; +import android.view.inputmethod.EditorInfo; +import android.view.inputmethod.InputMethodSubtype; import android.view.textservice.SuggestionsInfo; import com.android.inputmethod.keyboard.KeyboardLayoutSet; @@ -33,6 +36,7 @@ import com.android.inputmethod.latin.R; import com.android.inputmethod.latin.SynchronouslyLoadedContactsBinaryDictionary; import com.android.inputmethod.latin.SynchronouslyLoadedUserBinaryDictionary; import com.android.inputmethod.latin.UserBinaryDictionary; +import com.android.inputmethod.latin.utils.AdditionalSubtypeUtils; import com.android.inputmethod.latin.utils.CollectionUtils; import com.android.inputmethod.latin.utils.LocaleUtils; import com.android.inputmethod.latin.utils.StringUtils; @@ -58,6 +62,9 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public static final String PREF_USE_CONTACTS_KEY = "pref_spellcheck_use_contacts"; + private static final int SPELLCHECKER_DUMMY_KEYBOARD_WIDTH = 480; + private static final int SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT = 368; + private final static String[] EMPTY_STRING_ARRAY = new String[0]; private Map<String, DictionaryPool> mDictionaryPools = CollectionUtils.newSynchronizedTreeMap(); private Map<String, UserBinaryDictionary> mUserDictionaries = @@ -401,9 +408,9 @@ public final class AndroidSpellCheckerService extends SpellCheckerService public DictAndKeyboard createDictAndKeyboard(final Locale locale) { final int script = getScriptFromLocale(locale); final String keyboardLayoutName = getKeyboardLayoutNameForScript(script); - final KeyboardLayoutSet keyboardLayoutSet = - KeyboardLayoutSet.createKeyboardSetForSpellChecker(this, locale.toString(), - keyboardLayoutName); + final InputMethodSubtype subtype = AdditionalSubtypeUtils.createAdditionalSubtype( + locale.toString(), keyboardLayoutName, null); + final KeyboardLayoutSet keyboardLayoutSet = createKeyboardSetForSpellChecker(subtype); final DictionaryCollection dictionaryCollection = DictionaryFactory.createMainDictionaryFromManager(this, locale, @@ -431,4 +438,16 @@ public final class AndroidSpellCheckerService extends SpellCheckerService } return new DictAndKeyboard(dictionaryCollection, keyboardLayoutSet); } + + private KeyboardLayoutSet createKeyboardSetForSpellChecker(final InputMethodSubtype subtype) { + final EditorInfo editorInfo = new EditorInfo(); + editorInfo.inputType = InputType.TYPE_CLASS_TEXT; + final KeyboardLayoutSet.Builder builder = new KeyboardLayoutSet.Builder(this, editorInfo); + builder.setKeyboardGeometry( + SPELLCHECKER_DUMMY_KEYBOARD_WIDTH, SPELLCHECKER_DUMMY_KEYBOARD_HEIGHT); + builder.setSubtype(subtype); + builder.setIsSpellChecker(true /* isSpellChecker */); + builder.disableTouchPositionCorrectionData(); + return builder.build(); + } } diff --git a/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java b/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java index ffec57548..22c92446a 100644 --- a/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/ResourceUtils.java @@ -20,10 +20,12 @@ import android.content.res.Resources; import android.content.res.TypedArray; import android.os.Build; import android.text.TextUtils; +import android.util.DisplayMetrics; import android.util.Log; import android.util.TypedValue; import com.android.inputmethod.annotations.UsedForTesting; +import com.android.inputmethod.latin.R; import java.util.ArrayList; import java.util.HashMap; @@ -215,6 +217,35 @@ public final class ResourceUtils { return null; } + public static int getDefaultKeyboardWidth(final Resources res) { + final DisplayMetrics dm = res.getDisplayMetrics(); + return dm.widthPixels; + } + + public static int getDefaultKeyboardHeight(final Resources res) { + final DisplayMetrics dm = res.getDisplayMetrics(); + final String keyboardHeightString = getDeviceOverrideValue(res, R.array.keyboard_heights); + final float keyboardHeight; + if (TextUtils.isEmpty(keyboardHeightString)) { + keyboardHeight = res.getDimension(R.dimen.keyboardHeight); + } else { + keyboardHeight = Float.parseFloat(keyboardHeightString) * dm.density; + } + final float maxKeyboardHeight = res.getFraction( + R.fraction.maxKeyboardHeight, dm.heightPixels, dm.heightPixels); + float minKeyboardHeight = res.getFraction( + R.fraction.minKeyboardHeight, dm.heightPixels, dm.heightPixels); + if (minKeyboardHeight < 0.0f) { + // Specified fraction was negative, so it should be calculated against display + // width. + minKeyboardHeight = -res.getFraction( + R.fraction.minKeyboardHeight, dm.widthPixels, dm.widthPixels); + } + // Keyboard height will not exceed maxKeyboardHeight and will not be less than + // minKeyboardHeight. + return (int)Math.max(Math.min(keyboardHeight, maxKeyboardHeight), minKeyboardHeight); + } + public static boolean isValidFraction(final float fraction) { return fraction >= 0.0f; } diff --git a/java/src/com/android/inputmethod/research/ResearchLogger.java b/java/src/com/android/inputmethod/research/ResearchLogger.java index 0bd493970..3a3408266 100644 --- a/java/src/com/android/inputmethod/research/ResearchLogger.java +++ b/java/src/com/android/inputmethod/research/ResearchLogger.java @@ -1414,7 +1414,8 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang "navigatePrevious", "clobberSettingsKey", "passwordInput", "shortcutKeyEnabled", "hasShortcutKey", "languageSwitchKeyEnabled", "isMultiLine", "tw", "th", "keys"); - public static void mainKeyboardView_setKeyboard(final Keyboard keyboard) { + public static void mainKeyboardView_setKeyboard(final Keyboard keyboard, + final int orientation) { final KeyboardId kid = keyboard.mId; final boolean isPasswordView = kid.passwordInput(); final ResearchLogger researchLogger = getInstance(); @@ -1422,7 +1423,7 @@ public class ResearchLogger implements SharedPreferences.OnSharedPreferenceChang researchLogger.enqueueEvent(LOGSTATEMENT_MAINKEYBOARDVIEW_SETKEYBOARD, KeyboardId.elementIdToName(kid.mElementId), kid.mLocale + ":" + kid.mSubtype.getExtraValueOf(KEYBOARD_LAYOUT_SET), - kid.mOrientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(), + orientation, kid.mWidth, KeyboardId.modeName(kid.mMode), kid.imeAction(), kid.navigateNext(), kid.navigatePrevious(), kid.mClobberSettingsKey, isPasswordView, kid.mShortcutKeyEnabled, kid.mHasShortcutKey, kid.mLanguageSwitchKeyEnabled, kid.isMultiLine(), keyboard.mOccupiedWidth, |