add option for separate emoji key

This commit is contained in:
dslul 2020-09-30 16:11:13 +02:00
parent b5735b7ad5
commit d5339b7ffb
14 changed files with 63 additions and 68 deletions

View file

@ -80,6 +80,7 @@ public final class KeyboardId {
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 @@ public final class KeyboardId {
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 @@ public final class KeyboardId {
id.mHasShortcutKey,
id.mNumberRowEnabled,
id.mLanguageSwitchKeyEnabled,
id.mEmojiKeyEnabled,
id.isMultiLine(),
id.imeAction(),
id.mCustomActionLabel,
@ -137,6 +140,7 @@ public final class KeyboardId {
&& other.mHasShortcutKey == mHasShortcutKey
&& other.mNumberRowEnabled == mNumberRowEnabled
&& other.mLanguageSwitchKeyEnabled == mLanguageSwitchKeyEnabled
&& other.mEmojiKeyEnabled == mEmojiKeyEnabled
&& other.isMultiLine() == isMultiLine()
&& other.imeAction() == imeAction()
&& TextUtils.equals(other.mCustomActionLabel, mCustomActionLabel)
@ -208,6 +212,7 @@ public final class KeyboardId {
(mHasShortcutKey ? " hasShortcutKey" : ""),
(mNumberRowEnabled ? " numberRowEnabled" : ""),
(mLanguageSwitchKeyEnabled ? " languageSwitchKeyEnabled" : ""),
(mEmojiKeyEnabled ? " emojiKeyEnabled" : ""),
(isMultiLine() ? " isMultiLine" : ""),
(mIsSplitLayout ? " isSplitLayout" : "")
);

View file

@ -121,6 +121,7 @@ public final class KeyboardLayoutSet {
boolean mNoSettingsKey;
boolean mNumberRowEnabled;
boolean mLanguageSwitchKeyEnabled;
boolean mEmojiKeyEnabled;
RichInputMethodSubtype mSubtype;
boolean mIsSpellChecker;
int mKeyboardWidth;
@ -335,6 +336,11 @@ public final class KeyboardLayoutSet {
return this;
}
public Builder setEmojiKeyEnabled(final boolean enabled) {
mParams.mEmojiKeyEnabled = enabled;
return this;
}
public Builder disableTouchPositionCorrectionData() {
mParams.mDisableTouchPositionCorrectionDataForTest = true;
return this;

View file

@ -117,6 +117,7 @@ public final class KeyboardSwitcher implements KeyboardState.SwitchActions {
builder.setVoiceInputKeyEnabled(settingsValues.mShowsVoiceInputKey);
builder.setNumberRowEnabled(settingsValues.mShowsNumberRow);
builder.setLanguageSwitchKeyEnabled(mLatinIME.shouldShowLanguageSwitchKey());
builder.setEmojiKeyEnabled(settingsValues.mShowsEmojiKey);
builder.setSplitLayoutEnabledByUser(ProductionFlags.IS_SPLIT_KEYBOARD_SUPPORTED
&& settingsValues.mIsSplitKeyboardEnabled);
mKeyboardLayoutSet = builder.build();

View file

@ -668,6 +668,9 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
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,
@ -683,8 +686,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
final boolean selected = keyboardLayoutSetMatched && keyboardLayoutSetElementMatched
&& keyboardThemeMacthed && modeMatched && navigateNextMatched
&& navigatePreviousMatched && passwordInputMatched && clobberSettingsKeyMatched
&& hasShortcutKeyMatched && languageSwitchKeyEnabledMatched && numberRowEnabledMatched
&& isMultiLineMatched && imeActionMatched && isIconDefinedMatched
&& hasShortcutKeyMatched && numberRowEnabledMatched && languageSwitchKeyEnabledMatched
&& emojiKeyEnabledMatched && isMultiLineMatched && imeActionMatched && isIconDefinedMatched
&& localeCodeMatched && languageCodeMatched && countryCodeMatched
&& splitLayoutMatched;
@ -714,6 +717,8 @@ public class KeyboardBuilder<KP extends KeyboardParams> {
"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,

View file

@ -1,23 +1,9 @@
/*
* 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 org.dslul.openboard.inputmethod.latin.define
import android.content.SharedPreferences
object DebugFlags {
const val DEBUG_ENABLED = false
@JvmStatic
fun init(prefs: SharedPreferences?) {}
}

View file

@ -1,18 +1,3 @@
/*
* Copyright (C) 2015 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 org.dslul.openboard.inputmethod.latin.define
/**

View file

@ -1,20 +1,5 @@
/*
* Copyright (C) 2011 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 org.dslul.openboard.inputmethod.latin.define
object JniLibName {
const val JNI_LIB_NAME = "jni_latinime" //public static final String JNI_LIB_NAME2 = "jni_latinimegoogle";
const val JNI_LIB_NAME = "jni_latinime"
}

View file

@ -1,18 +1,3 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.dslul.openboard.inputmethod.latin.define
object ProductionFlags {
@ -24,11 +9,6 @@ object ProductionFlags {
*/
const val INCLUDE_RAW_SUGGESTIONS = false
/**
* When false, the metrics logging is not yet ready to be enabled.
*/
const val IS_METRICS_LOGGING_SUPPORTED = false
/**
* When `false`, the split keyboard is not yet ready to be enabled.
*/

View file

@ -75,6 +75,8 @@ public final class Settings implements SharedPreferences.OnSharedPreferenceChang
Build.VERSION.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";

View file

@ -71,6 +71,7 @@ public class SettingsValues {
public final boolean mIncludesOtherImesInLanguageSwitchList;
public final boolean mShowsNumberRow;
public final boolean mShowsLanguageSwitchKey;
public final boolean mShowsEmojiKey;
public final boolean mUsePersonalizedDicts;
public final boolean mUseDoubleSpacePeriod;
public final boolean mBlockPotentiallyOffensive;
@ -145,6 +146,7 @@ public class SettingsValues {
mIncludesOtherImesInLanguageSwitchList = !Settings.ENABLE_SHOW_LANGUAGE_SWITCH_KEY_SETTINGS || prefs.getBoolean(Settings.PREF_INCLUDE_OTHER_IMES_IN_LANGUAGE_SWITCH_LIST, false) /* forcibly */;
mShowsNumberRow = prefs.getBoolean(Settings.PREF_SHOW_NUMBER_ROW, false);
mShowsLanguageSwitchKey = prefs.getBoolean(Settings.PREF_SHOW_LANGUAGE_SWITCH_KEY, false);
mShowsEmojiKey = prefs.getBoolean(Settings.PREF_SHOW_EMOJI_KEY, false);
mUsePersonalizedDicts = prefs.getBoolean(Settings.PREF_KEY_USE_PERSONALIZED_DICTS, true);
mUseDoubleSpacePeriod = prefs.getBoolean(Settings.PREF_KEY_USE_DOUBLE_SPACE_PERIOD, true)
&& inputAttributes.mIsGeneralTextInput;

View file

@ -502,6 +502,7 @@
<attr name="clobberSettingsKey" format="boolean" />
<attr name="hasShortcutKey" format="boolean" />
<attr name="languageSwitchKeyEnabled" format="boolean" />
<attr name="emojiKeyEnabled" format="boolean" />
<attr name="numberRowEnabled" format="boolean" />
<attr name="isMultiLine" format="boolean" />
<attr name="imeAction" format="enum">

View file

@ -570,4 +570,6 @@ mobile devices. [CHAR LIMIT=25] -->
<string name="more_keys_strip_description">More keys</string>
<string name="prefs_force_incognito_mode">Force incognito mode</string>
<string name="prefs_force_incognito_mode_summary">Disable learning of new words</string>
<string name="show_emoji_key">Show emoji key</string>
<string name="show_emoji_key_summary">Show a separate emoji key. When disabled, the emoji keyboard is still accessible by long-pressing the ENTER button.</string>
</resources>

View file

@ -44,8 +44,10 @@
<Key
latin:keyStyle="zwnjKeyStyle" />
</case>
<case
latin:languageSwitchKeyEnabled="true"
latin:emojiKeyEnabled="false"
>
<Key
latin:keyStyle="languageSwitchKeyStyle" />
@ -53,6 +55,33 @@
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="40%p" />
</case>
<case
latin:languageSwitchKeyEnabled="false"
latin:emojiKeyEnabled="true"
>
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="40%p" />
<Key
latin:keyStyle="emojiKeyStyle"
latin:backgroundType="functional" />
</case>
<case
latin:languageSwitchKeyEnabled="true"
latin:emojiKeyEnabled="true"
>
<Key
latin:keyStyle="languageSwitchKeyStyle" />
<Key
latin:keyStyle="spaceKeyStyle"
latin:keyWidth="30%p" />
<Key
latin:keyStyle="emojiKeyStyle"
latin:backgroundType="functional" />
</case>
<!-- languageSwitchKeyEnabled="false" -->
<default>
<Key

View file

@ -28,6 +28,12 @@
android:summary="@string/number_row_summary"
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_key_use_double_space_period"
android:title="@string/use_double_space_period"