LatinIME: Add option to always show the emoji key for non-tablets
Includes Iffbd5096d86edd279bc00fbbe4b4ec4d6d1614cc.
Co-authored-by: LuK1337 <priv.luk@gmail.com>
Change-Id: I5951524caba8413e9a0244ddc43869b4d1c97007
diff --git a/java/res/values-sw430dp/config-per-form-factor.xml b/java/res/values-sw430dp/config-per-form-factor.xml
index 8868081..1a539c1 100644
--- a/java/res/values-sw430dp/config-per-form-factor.xml
+++ b/java/res/values-sw430dp/config-per-form-factor.xml
@@ -24,6 +24,7 @@
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">true</bool>
<bool name="config_default_sound_enabled">false</bool>
+ <bool name="config_enable_show_emoji_key_option">true</bool>
<bool name="config_enable_show_voice_key_option">true</bool>
<bool name="config_key_selection_by_dragging_finger">true</bool>
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
diff --git a/java/res/values-sw600dp/config-per-form-factor.xml b/java/res/values-sw600dp/config-per-form-factor.xml
index bb2eaa8..eff3ce6 100644
--- a/java/res/values-sw600dp/config-per-form-factor.xml
+++ b/java/res/values-sw600dp/config-per-form-factor.xml
@@ -24,6 +24,7 @@
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">false</bool>
<bool name="config_default_sound_enabled">false</bool>
+ <bool name="config_enable_show_emoji_key_option">false</bool>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_key_selection_by_dragging_finger">false</bool>
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
diff --git a/java/res/values-sw768dp/config-per-form-factor.xml b/java/res/values-sw768dp/config-per-form-factor.xml
index 45ff0b1..1596db1 100644
--- a/java/res/values-sw768dp/config-per-form-factor.xml
+++ b/java/res/values-sw768dp/config-per-form-factor.xml
@@ -24,6 +24,7 @@
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">false</bool>
<bool name="config_default_sound_enabled">false</bool>
+ <bool name="config_enable_show_emoji_key_option">false</bool>
<bool name="config_enable_show_voice_key_option">false</bool>
<bool name="config_key_selection_by_dragging_finger">false</bool>
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
diff --git a/java/res/values/attrs.xml b/java/res/values/attrs.xml
index a41427e..c771f11 100644
--- a/java/res/values/attrs.xml
+++ b/java/res/values/attrs.xml
@@ -503,6 +503,7 @@
<attr name="clobberSettingsKey" format="boolean" />
<attr name="hasShortcutKey" format="boolean" />
<attr name="numberRowEnabled" format="boolean" />
+ <attr name="emojiKeyEnabled" format="boolean" />
<attr name="languageSwitchKeyEnabled" format="boolean" />
<attr name="isMultiLine" format="boolean" />
<attr name="imeAction" format="enum">
diff --git a/java/res/values/cm_strings.xml b/java/res/values/cm_strings.xml
index c21c2b2..c7c9e74 100644
--- a/java/res/values/cm_strings.xml
+++ b/java/res/values/cm_strings.xml
@@ -43,4 +43,8 @@
<!-- Preference item for enabling longpress key hints -->
<string name="show_longpress_hints">Show long-press key hints</string>
<string name="show_longpress_hints_summary">Shows long-press hints for supported keys</string>
+
+ <!-- Preference item for always showing the emoji key -->
+ <string name="show_emoji_key">Show emoji key</string>
+ <string name="show_emoji_key_summary">Always show emoji key. When this option is enabled, the language switch key cannot be shown.</string>
</resources>
diff --git a/java/res/values/config-per-form-factor.xml b/java/res/values/config-per-form-factor.xml
index 67fc751..a5259a6 100644
--- a/java/res/values/config-per-form-factor.xml
+++ b/java/res/values/config-per-form-factor.xml
@@ -24,6 +24,7 @@
<!-- Whether or not Popup on key press is enabled by default -->
<bool name="config_default_key_preview_popup">true</bool>
<bool name="config_default_sound_enabled">false</bool>
+ <bool name="config_enable_show_emoji_key_option">true</bool>
<bool name="config_enable_show_voice_key_option">true</bool>
<bool name="config_key_selection_by_dragging_finger">true</bool>
<!-- Showing more keys keyboard, just above the touched point if true, aligned to the key if
diff --git a/java/res/xml/key_space_5kw.xml b/java/res/xml/key_space_5kw.xml
index 692c245..d845e2e 100644
--- a/java/res/xml/key_space_5kw.xml
+++ b/java/res/xml/key_space_5kw.xml
@@ -45,6 +45,7 @@
latin:keyStyle="zwnjKeyStyle" />
</case>
<case
+ latin:emojiKeyEnabled="false"
latin:languageSwitchKeyEnabled="true"
>
<Key
@@ -53,6 +54,15 @@
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="40%p" />
</case>
+ <case
+ latin:emojiKeyEnabled="true"
+ >
+ <Key
+ latin:keyStyle="emojiKeyStyle" />
+ <Key
+ latin:keyStyle="spaceKeyStyle"
+ latin:keyWidth="40%p" />
+ </case>
<!-- languageSwitchKeyEnabled="false" -->
<default>
<Key
diff --git a/java/res/xml/prefs_screen_preferences.xml b/java/res/xml/prefs_screen_preferences.xml
index 5ba0908..d2dc51e 100644
--- a/java/res/xml/prefs_screen_preferences.xml
+++ b/java/res/xml/prefs_screen_preferences.xml
@@ -31,6 +31,12 @@
android:defaultValue="false"
android:persistent="true" />
<CheckBoxPreference
+ android:key="pref_show_emoji_key"
+ android:title="@string/show_emoji_key"
+ android:summary="@string/show_emoji_key_summary"
+ android:defaultValue="false"
+ android:persistent="true" />
+ <CheckBoxPreference
android:key="pref_show_longpress_hints"
android:title="@string/show_longpress_hints"
android:summary="@string/show_longpress_hints_summary"
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardId.java b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
index c9d3073..5e06191 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardId.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardId.java
@@ -80,6 +80,7 @@
public final boolean mClobberSettingsKey;
public final boolean mNumberRowEnabled;
public final boolean mLanguageSwitchKeyEnabled;
+ public final boolean mEmojiKeyEnabled;
public final String mCustomActionLabel;
public final boolean mHasShortcutKey;
public final boolean mIsSplitLayout;
@@ -96,6 +97,7 @@
mClobberSettingsKey = params.mNoSettingsKey;
mNumberRowEnabled = params.mNumberRowEnabled;
mLanguageSwitchKeyEnabled = params.mLanguageSwitchKeyEnabled;
+ mEmojiKeyEnabled = params.mEmojiKeyEnabled;
mCustomActionLabel = (mEditorInfo.actionLabel != null)
? mEditorInfo.actionLabel.toString() : null;
mHasShortcutKey = params.mVoiceInputKeyEnabled;
@@ -115,6 +117,7 @@
id.mNumberRowEnabled,
id.mHasShortcutKey,
id.mLanguageSwitchKeyEnabled,
+ id.mEmojiKeyEnabled,
id.isMultiLine(),
id.imeAction(),
id.mCustomActionLabel,
@@ -137,6 +140,7 @@
&& other.mNumberRowEnabled == mNumberRowEnabled
&& other.mHasShortcutKey == mHasShortcutKey
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
+ && other.mEmojiKeyEnabled == mEmojiKeyEnabled
&& other.isMultiLine() == isMultiLine()
&& other.imeAction() == imeAction()
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
@@ -208,6 +212,7 @@
(passwordInput() ? " passwordInput" : ""),
(mHasShortcutKey ? " hasShortcutKey" : ""),
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
+ (mEmojiKeyEnabled ? " emojiKeyEnabled" : ""),
(isMultiLine() ? " isMultiLine" : ""),
(mIsSplitLayout ? " isSplitLayout" : "")
);
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
index a97e5f6..18390fc 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardLayoutSet.java
@@ -120,6 +120,7 @@
boolean mNoSettingsKey;
boolean mNumberRowEnabled;
boolean mLanguageSwitchKeyEnabled;
+ boolean mEmojiKeyEnabled;
RichInputMethodSubtype mSubtype;
boolean mIsSpellChecker;
int mKeyboardWidth;
@@ -333,6 +334,11 @@
return this;
}
+ public Builder setEmojiKeyEnabled(final boolean enabled) {
+ mParams.mEmojiKeyEnabled = enabled;
+ return this;
+ }
+
public Builder disableTouchPositionCorrectionData() {
mParams.mDisableTouchPositionCorrectionDataForTest = true;
return this;
diff --git a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
index 9578b4b..2b95d4a 100644
--- a/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
+++ b/java/src/com/android/inputmethod/keyboard/KeyboardSwitcher.java
@@ -123,6 +123,7 @@
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
builder.setNumberRowEnabled(settingsValues.mShowNumberRow);
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
+ builder.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey);
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
&& settingsValues.mIsSplitKeyboardEnabled);
mKeyboardLayoutSet = builder.build();
diff --git a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
index d5e8753..35928d6 100644
--- a/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
+++ b/java/src/com/android/inputmethod/keyboard/internal/KeyboardBuilder.java
@@ -668,6 +668,9 @@
final boolean languageSwitchKeyEnabledMatched = matchBoolean(caseAttr,
R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
id.mLanguageSwitchKeyEnabled);
+ final boolean emojiKeyEnabledMatched = matchBoolean(caseAttr,
+ R.styleable.Keyboard_Case_emojiKeyEnabled,
+ id.mEmojiKeyEnabled);
final boolean isMultiLineMatched = matchBoolean(caseAttr,
R.styleable.Keyboard_Case_isMultiLine, id.isMultiLine());
final boolean imeActionMatched = matchInteger(caseAttr,
@@ -684,7 +687,7 @@
&& keyboardThemeMacthed && modeMatched && navigateNextMatched
&& navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
&& hasShortcutKeyMatched && numberRowEnabledMatched
- && languageSwitchKeyEnabledMatched
+ && languageSwitchKeyEnabledMatched && emojiKeyEnabledMatched
&& isMultiLineMatched && imeActionMatched && isIconDefinedMatched
&& localeCodeMatched && languageCodeMatched && countryCodeMatched
&& splitLayoutMatched;
@@ -715,6 +718,8 @@
"numberRowEnabled"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_languageSwitchKeyEnabled,
"languageSwitchKeyEnabled"),
+ booleanAttr(caseAttr, R.styleable.Keyboard_Case_emojiKeyEnabled,
+ "emojiKeyEnabled"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_isMultiLine,
"isMultiLine"),
booleanAttr(caseAttr, R.styleable.Keyboard_Case_isSplitLayout,
diff --git a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
index d9858e6..aba14ee 100644
--- a/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
+++ b/java/src/com/android/inputmethod/latin/settings/PreferencesSettingsFragment.java
@@ -56,6 +56,11 @@
// initialization method of these classes here. See {@link LatinIME#onCreate()}.
RichInputMethodManager.init(context);
+ final boolean showEmojiKeyOption = res.getBoolean(
+ R.bool.config_enable_show_emoji_key_option);
+ if (!showEmojiKeyOption) {
+ removePreference(Settings.PREF_SHOW_EMOJI_KEY);
+ }
final boolean showVoiceKeyOption = res.getBoolean(
R.bool.config_enable_show_voice_key_option);
if (!showVoiceKeyOption) {
diff --git a/java/src/com/android/inputmethod/latin/settings/Settings.java b/java/src/com/android/inputmethod/latin/settings/Settings.java
index 3b3d943..803153e 100644
--- a/java/src/com/android/inputmethod/latin/settings/Settings.java
+++ b/java/src/com/android/inputmethod/latin/settings/Settings.java
@@ -79,6 +79,7 @@
BuildCompatUtils.EFFECTIVE_SDK_INT >= Build.VERSION_CODES.LOLLIPOP;
public static final String PREF_SHOW_LANGUAGE_SWITCH_KEY =
"pref_show_language_switch_key";
+ public static final String PREF_SHOW_EMOJI_KEY = "pref_show_emoji_key";
public static final String PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST =
"pref_include_other_imes_in_language_switch_list";
public static final String PREF_CUSTOM_INPUT_STYLES = "custom_input_styles";
diff --git a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
index 463b938..6eb8e98 100644
--- a/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
+++ b/java/src/com/android/inputmethod/latin/settings/SettingsValues.java
@@ -71,6 +71,7 @@
public final boolean mShowLongpressHints;
public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsLanguageSwitchKey;
+ public final boolean mShowsEmojiKey;
public final boolean mUseContactsDict;
public final boolean mUsePersonalizedDicts;
public final boolean mUseDoubleSpacePeriod;
@@ -149,6 +150,7 @@
: true /* forcibly */;
mShowsLanguageSwitchKey = Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS
? Settings.readShowsLanguageSwitchKey(prefs) : true /* forcibly */;
+ mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, false);
mUseContactsDict = prefs.getBoolean(Settings.PREF_KEY_USE_CONTACTS_DICT, true);
mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true)