From a1e54854c5fd5a98b54bc813d561851d974e0765 Mon Sep 17 00:00:00 2001 From: m-gianfagna Date: Tue, 11 Nov 2025 18:47:30 +0100 Subject: [PATCH 1/3] [#234] Added option to show (default) or not the emoji key in the settings menu. --- CHANGELOG.md | 14 +++++++- .../keyboard/activities/SettingsActivity.kt | 11 ++++++ .../org/fossify/keyboard/helpers/Config.kt | 4 +++ .../org/fossify/keyboard/helpers/Constants.kt | 1 + .../keyboard/services/SimpleKeyboardIME.kt | 36 +++++++++++++++---- app/src/main/res/layout/activity_settings.xml | 15 ++++++++ app/src/main/res/values-it/strings.xml | 3 +- app/src/main/res/values/strings.xml | 1 + 8 files changed, 76 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0b25c90c..3ecc5718 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +## [1.7.0] - 2025-11-11 +### Added +- Option to show (default) or not the emoji key + +### Changed +- Update translations + +### Fixed +- Feature added ([#234]) + ## [1.6.0] - 2025-10-29 ### Added - Added Colemak, Colemak-DH, Workman, Asset, Niro, Soul layouts @@ -115,6 +125,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#206]: https://github.com/FossifyOrg/Keyboard/issues/206 [#222]: https://github.com/FossifyOrg/Keyboard/issues/222 [#230]: https://github.com/FossifyOrg/Keyboard/issues/230 +[#234]: https://github.com/FossifyOrg/Keyboard/issues/234 [#238]: https://github.com/FossifyOrg/Keyboard/issues/238 [#239]: https://github.com/FossifyOrg/Keyboard/issues/239 [#251]: https://github.com/FossifyOrg/Keyboard/issues/251 @@ -123,7 +134,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#265]: https://github.com/FossifyOrg/Keyboard/issues/265 [#274]: https://github.com/FossifyOrg/Keyboard/issues/274 -[Unreleased]: https://github.com/FossifyOrg/Keyboard/compare/1.6.0...HEAD +[Unreleased]: https://github.com/FossifyOrg/Keyboard/compare/1.7.0...HEAD +[1.7.0]: https://github.com/FossifyOrg/Keyboard/compare/1.6.0...1.7.0 [1.6.0]: https://github.com/FossifyOrg/Keyboard/compare/1.5.0...1.6.0 [1.5.0]: https://github.com/FossifyOrg/Keyboard/compare/1.4.0...1.5.0 [1.4.0]: https://github.com/FossifyOrg/Keyboard/compare/1.3.0...1.4.0 diff --git a/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt b/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt index be7267ce..08c0eb45 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt @@ -59,6 +59,7 @@ class SettingsActivity : SimpleActivity() { setupManageKeyboardLanguages() setupKeyboardLanguage() setupKeyboardHeightMultiplier() + setupShowEmojiKey() setupShowClipboardContent() setupSentencesCapitalization() setupShowNumbersRow() @@ -237,6 +238,16 @@ class SettingsActivity : SimpleActivity() { } } + private fun setupShowEmojiKey() { + binding.apply { + settingsShowEmojiKeyHolder.setOnClickListener { + settingsShowEmojiKey.toggle() + config.showEmojiKey = settingsShowEmojiKey.isChecked + } + settingsShowEmojiKey.isChecked = config.showEmojiKey + } + } + private fun setupShowNumbersRow() { binding.apply { settingsShowNumbersRow.isChecked = config.showNumbersRow diff --git a/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt b/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt index 1fe5bb24..9d5499e4 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt @@ -23,6 +23,10 @@ class Config(context: Context) : BaseConfig(context) { get() = prefs.getBoolean(SENTENCES_CAPITALIZATION, true) set(enableCapitalization) = prefs.edit().putBoolean(SENTENCES_CAPITALIZATION, enableCapitalization).apply() + var showEmojiKey: Boolean + get() = prefs.getBoolean(SHOW_EMOJI_KEY, true) + set(showEmojiKey) = prefs.edit().putBoolean(SHOW_EMOJI_KEY, showEmojiKey).apply() + var showKeyBorders: Boolean get() = prefs.getBoolean(SHOW_KEY_BORDERS, true) set(showKeyBorders) = prefs.edit().putBoolean(SHOW_KEY_BORDERS, showKeyBorders).apply() diff --git a/app/src/main/kotlin/org/fossify/keyboard/helpers/Constants.kt b/app/src/main/kotlin/org/fossify/keyboard/helpers/Constants.kt index 3aa71601..dfa1c6ea 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/helpers/Constants.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/helpers/Constants.kt @@ -15,6 +15,7 @@ const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress" const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress" const val SHOW_KEY_BORDERS = "show_key_borders" const val SENTENCES_CAPITALIZATION = "sentences_capitalization" +const val SHOW_EMOJI_KEY = "show_emoji_key" const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder" const val KEYBOARD_LANGUAGE = "keyboard_language" const val HEIGHT_PERCENTAGE = "height_percentage" diff --git a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt index 8ce056fa..f277e8a8 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -112,7 +112,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared inputTypeClass = attribute!!.inputType and TYPE_MASK_CLASS inputTypeClassVariation = attribute.inputType and TYPE_MASK_VARIATION enterKeyType = attribute.imeOptions and (IME_MASK_ACTION or IME_FLAG_NO_ENTER_ACTION) - keyboard = createNewKeyboard() + keyboard = createNewKeyboard().adjustForEmojiButton() keyboardView?.setKeyboard(keyboard!!) keyboardView?.setEditorInfo(attribute) if (isNougatPlus()) { @@ -209,7 +209,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared keyboardMode = KEYBOARD_SYMBOLS R.xml.keys_symbols } - keyboard = MyKeyboard(this, keyboardXml, enterKeyType) + keyboard = MyKeyboard(this, keyboardXml, enterKeyType).adjustForEmojiButton() keyboardView!!.setKeyboard(keyboard!!) } keyboardView!!.invalidateAllKeys() @@ -234,7 +234,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared R.xml.keys_symbols } - keyboard = MyKeyboard(this, keyboardXML, enterKeyType) + keyboard = MyKeyboard(this, keyboardXML, enterKeyType).adjustForEmojiButton() keyboardView!!.setKeyboard(keyboard!!) } @@ -247,7 +247,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared getKeyboardLayoutXML() } - keyboard = MyKeyboard(this, keyboardXml, enterKeyType) + keyboard = MyKeyboard(this, keyboardXml, enterKeyType).adjustForEmojiButton() keyboardView!!.setKeyboard(keyboard!!) } @@ -337,7 +337,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared // TODO: Change keyboardMode to enum class keyboardMode = KEYBOARD_LETTERS - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType) + keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType).adjustForEmojiButton() val editorInfo = currentInputEditorInfo if (editorInfo != null && editorInfo.inputType != TYPE_NULL && keyboard?.mShiftState != ShiftState.ON_PERMANENT) { @@ -364,7 +364,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } override fun reloadKeyboard() { - val keyboard = createNewKeyboard() + val keyboard = createNewKeyboard().adjustForEmojiButton() this.keyboard = keyboard keyboardView?.setKeyboard(keyboard) } @@ -403,7 +403,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared context = this, xmlLayoutResId = keyboardXml, enterKeyType = enterKeyType, - ) + ).adjustForEmojiButton() } override fun onUpdateSelection(oldSelStart: Int, oldSelEnd: Int, newSelStart: Int, newSelEnd: Int, candidatesStart: Int, candidatesEnd: Int) { @@ -582,4 +582,26 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared return Icon.createWithData(byteArray, 0, byteArray.size) } + + private fun MyKeyboard.adjustForEmojiButton(): MyKeyboard { + if (!config.showEmojiKey && keyboardMode == KEYBOARD_LETTERS) { + mKeys?.let { keys -> + val emojiKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_EMOJI } + val spaceKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_SPACE } + + if (emojiKeyIndex != -1 && spaceKeyIndex != -1) { + val emojiKey = keys[emojiKeyIndex] + val spaceKey = keys[spaceKeyIndex] + + spaceKey.width += emojiKey.width + emojiKey.gap + spaceKey.x = emojiKey.x + + val mutableKeys = keys.toMutableList() + mutableKeys.removeAt(emojiKeyIndex) + mKeys = mutableKeys + } + } + } + return this + } } diff --git a/app/src/main/res/layout/activity_settings.xml b/app/src/main/res/layout/activity_settings.xml index 2529d2f8..82850b41 100644 --- a/app/src/main/res/layout/activity_settings.xml +++ b/app/src/main/res/layout/activity_settings.xml @@ -237,6 +237,21 @@ + + + + + + Mostra i bordi dei tasti Mostra i numeri su una riga separata Inizia le frasi con la lettera maiuscola + Mostra tasto emoji Emoji Attiva Tastiera Fossify nella schermata successiva per renderla disponibile. Una volta abilitata, premi \"Indietro\". Appunti @@ -46,4 +47,4 @@ Cibo e bevande Viaggi e luoghi Attività - \ No newline at end of file + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dbadaef0..10499b1d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -36,6 +36,7 @@ Show key borders Show numbers on a separate row Start sentences with a capital letter + Show emoji key Emojis Recently used From 9e08c3ff772fecd3f476e9a972c102d19c835e3a Mon Sep 17 00:00:00 2001 From: m-gianfagna Date: Wed, 12 Nov 2025 20:19:22 +0100 Subject: [PATCH 2/3] [#234] Added option to show (default) or not the emoji key in the settings menu. Fix: Address reviewer feedback --- CHANGELOG.md | 7 +-- .../keyboard/services/SimpleKeyboardIME.kt | 48 +++++++++++-------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3ecc5718..67ba8798 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] - ## [1.7.0] - 2025-11-11 ### Added - Option to show (default) or not the emoji key @@ -16,6 +15,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Feature added ([#234]) +### Added +- Option to disable the emoji key ([#234]) + ## [1.6.0] - 2025-10-29 ### Added - Added Colemak, Colemak-DH, Workman, Asset, Niro, Soul layouts @@ -134,8 +136,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 [#265]: https://github.com/FossifyOrg/Keyboard/issues/265 [#274]: https://github.com/FossifyOrg/Keyboard/issues/274 -[Unreleased]: https://github.com/FossifyOrg/Keyboard/compare/1.7.0...HEAD -[1.7.0]: https://github.com/FossifyOrg/Keyboard/compare/1.6.0...1.7.0 +[Unreleased]: https://github.com/FossifyOrg/Keyboard/compare/1.6.0...HEAD [1.6.0]: https://github.com/FossifyOrg/Keyboard/compare/1.5.0...1.6.0 [1.5.0]: https://github.com/FossifyOrg/Keyboard/compare/1.4.0...1.5.0 [1.4.0]: https://github.com/FossifyOrg/Keyboard/compare/1.3.0...1.4.0 diff --git a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt index f277e8a8..9f79f1ed 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -112,7 +112,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared inputTypeClass = attribute!!.inputType and TYPE_MASK_CLASS inputTypeClassVariation = attribute.inputType and TYPE_MASK_VARIATION enterKeyType = attribute.imeOptions and (IME_MASK_ACTION or IME_FLAG_NO_ENTER_ACTION) - keyboard = createNewKeyboard().adjustForEmojiButton() + keyboard = createNewKeyboard() keyboardView?.setKeyboard(keyboard!!) keyboardView?.setEditorInfo(attribute) if (isNougatPlus()) { @@ -209,7 +209,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared keyboardMode = KEYBOARD_SYMBOLS R.xml.keys_symbols } - keyboard = MyKeyboard(this, keyboardXml, enterKeyType).adjustForEmojiButton() + keyboard = constructKeyboard(keyboardXml, enterKeyType, keyboardMode) keyboardView!!.setKeyboard(keyboard!!) } keyboardView!!.invalidateAllKeys() @@ -234,7 +234,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared R.xml.keys_symbols } - keyboard = MyKeyboard(this, keyboardXML, enterKeyType).adjustForEmojiButton() + keyboard = constructKeyboard(keyboardXML, enterKeyType, keyboardMode) keyboardView!!.setKeyboard(keyboard!!) } @@ -247,7 +247,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared getKeyboardLayoutXML() } - keyboard = MyKeyboard(this, keyboardXml, enterKeyType).adjustForEmojiButton() + keyboard = constructKeyboard(keyboardXml, enterKeyType, keyboardMode) keyboardView!!.setKeyboard(keyboard!!) } @@ -337,7 +337,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared // TODO: Change keyboardMode to enum class keyboardMode = KEYBOARD_LETTERS - keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType).adjustForEmojiButton() + keyboard = constructKeyboard(getKeyboardLayoutXML(), enterKeyType, keyboardMode) val editorInfo = currentInputEditorInfo if (editorInfo != null && editorInfo.inputType != TYPE_NULL && keyboard?.mShiftState != ShiftState.ON_PERMANENT) { @@ -364,7 +364,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } override fun reloadKeyboard() { - val keyboard = createNewKeyboard().adjustForEmojiButton() + val keyboard = createNewKeyboard() this.keyboard = keyboard keyboardView?.setKeyboard(keyboard) } @@ -378,32 +378,29 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } private fun createNewKeyboard(): MyKeyboard { - val keyboardXml = when (inputTypeClass) { + val keyboardXml: Int + when (inputTypeClass) { TYPE_CLASS_NUMBER -> { keyboardMode = KEYBOARD_NUMBERS - R.xml.keys_numbers + keyboardXml = R.xml.keys_numbers } TYPE_CLASS_PHONE -> { keyboardMode = KEYBOARD_PHONE - R.xml.keys_phone + keyboardXml = R.xml.keys_phone } TYPE_CLASS_DATETIME -> { keyboardMode = KEYBOARD_SYMBOLS - R.xml.keys_symbols + keyboardXml = R.xml.keys_symbols } else -> { keyboardMode = KEYBOARD_LETTERS - getKeyboardLayoutXML() + keyboardXml = getKeyboardLayoutXML() } } - return MyKeyboard( - context = this, - xmlLayoutResId = keyboardXml, - enterKeyType = enterKeyType, - ).adjustForEmojiButton() + return constructKeyboard(keyboardXml, enterKeyType, keyboardMode) } override fun onUpdateSelection(oldSelStart: Int, oldSelEnd: Int, newSelStart: Int, newSelEnd: Int, candidatesStart: Int, candidatesEnd: Int) { @@ -583,9 +580,9 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared return Icon.createWithData(byteArray, 0, byteArray.size) } - private fun MyKeyboard.adjustForEmojiButton(): MyKeyboard { - if (!config.showEmojiKey && keyboardMode == KEYBOARD_LETTERS) { - mKeys?.let { keys -> + private fun adjustForEmojiButton(keyboard: MyKeyboard, mode: Int): MyKeyboard { + if (!config.showEmojiKey && mode == KEYBOARD_LETTERS) { + keyboard.mKeys?.let { keys -> val emojiKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_EMOJI } val spaceKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_SPACE } @@ -598,10 +595,19 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared val mutableKeys = keys.toMutableList() mutableKeys.removeAt(emojiKeyIndex) - mKeys = mutableKeys + keyboard.mKeys = mutableKeys } } } - return this + return keyboard + } + + private fun constructKeyboard(xmlLayoutResId: Int, enterKeyType: Int, mode: Int): MyKeyboard { + val newKeyboard = MyKeyboard( + context = this, + xmlLayoutResId = xmlLayoutResId, + enterKeyType = enterKeyType + ) + return adjustForEmojiButton(newKeyboard, mode) } } From cb89b2b75a37defd5c865c2100dbd019bfce6785 Mon Sep 17 00:00:00 2001 From: m-gianfagna Date: Mon, 24 Nov 2025 18:09:02 +0100 Subject: [PATCH 3/3] [#234] Added option to show (default) or not the emoji key in the settings menu. Fix: Address reviewer feedback --- CHANGELOG.md | 10 ------ .../keyboard/services/SimpleKeyboardIME.kt | 35 ++++++++----------- 2 files changed, 15 insertions(+), 30 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 67ba8798..30d19a51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,16 +5,6 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). ## [Unreleased] -## [1.7.0] - 2025-11-11 -### Added -- Option to show (default) or not the emoji key - -### Changed -- Update translations - -### Fixed -- Feature added ([#234]) - ### Added - Option to disable the emoji key ([#234]) diff --git a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt index 9f79f1ed..9a33440e 100644 --- a/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt +++ b/app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt @@ -209,7 +209,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared keyboardMode = KEYBOARD_SYMBOLS R.xml.keys_symbols } - keyboard = constructKeyboard(keyboardXml, enterKeyType, keyboardMode) + keyboard = constructKeyboard(keyboardXml, enterKeyType) keyboardView!!.setKeyboard(keyboard!!) } keyboardView!!.invalidateAllKeys() @@ -234,7 +234,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared R.xml.keys_symbols } - keyboard = constructKeyboard(keyboardXML, enterKeyType, keyboardMode) + keyboard = constructKeyboard(keyboardXML, enterKeyType) keyboardView!!.setKeyboard(keyboard!!) } @@ -247,7 +247,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared getKeyboardLayoutXML() } - keyboard = constructKeyboard(keyboardXml, enterKeyType, keyboardMode) + keyboard = constructKeyboard(keyboardXml, enterKeyType) keyboardView!!.setKeyboard(keyboard!!) } @@ -337,7 +337,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared // TODO: Change keyboardMode to enum class keyboardMode = KEYBOARD_LETTERS - keyboard = constructKeyboard(getKeyboardLayoutXML(), enterKeyType, keyboardMode) + keyboard = constructKeyboard(getKeyboardLayoutXML(), enterKeyType) val editorInfo = currentInputEditorInfo if (editorInfo != null && editorInfo.inputType != TYPE_NULL && keyboard?.mShiftState != ShiftState.ON_PERMANENT) { @@ -378,29 +378,28 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared } private fun createNewKeyboard(): MyKeyboard { - val keyboardXml: Int - when (inputTypeClass) { + val keyboardXml = when (inputTypeClass) { TYPE_CLASS_NUMBER -> { keyboardMode = KEYBOARD_NUMBERS - keyboardXml = R.xml.keys_numbers + R.xml.keys_numbers } TYPE_CLASS_PHONE -> { keyboardMode = KEYBOARD_PHONE - keyboardXml = R.xml.keys_phone + R.xml.keys_phone } TYPE_CLASS_DATETIME -> { keyboardMode = KEYBOARD_SYMBOLS - keyboardXml = R.xml.keys_symbols + R.xml.keys_symbols } else -> { keyboardMode = KEYBOARD_LETTERS - keyboardXml = getKeyboardLayoutXML() + getKeyboardLayoutXML() } } - return constructKeyboard(keyboardXml, enterKeyType, keyboardMode) + return constructKeyboard(keyboardXml, enterKeyType) } override fun onUpdateSelection(oldSelStart: Int, oldSelEnd: Int, newSelStart: Int, newSelEnd: Int, candidatesStart: Int, candidatesEnd: Int) { @@ -580,8 +579,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared return Icon.createWithData(byteArray, 0, byteArray.size) } - private fun adjustForEmojiButton(keyboard: MyKeyboard, mode: Int): MyKeyboard { - if (!config.showEmojiKey && mode == KEYBOARD_LETTERS) { + private fun adjustForEmojiButton(keyboard: MyKeyboard): MyKeyboard { + if (!config.showEmojiKey && this.keyboardMode == KEYBOARD_LETTERS) { keyboard.mKeys?.let { keys -> val emojiKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_EMOJI } val spaceKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_SPACE } @@ -602,12 +601,8 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared return keyboard } - private fun constructKeyboard(xmlLayoutResId: Int, enterKeyType: Int, mode: Int): MyKeyboard { - val newKeyboard = MyKeyboard( - context = this, - xmlLayoutResId = xmlLayoutResId, - enterKeyType = enterKeyType - ) - return adjustForEmojiButton(newKeyboard, mode) + private fun constructKeyboard(keyboardXml: Int, enterKeyType: Int): MyKeyboard { + val keyboard = MyKeyboard(this, keyboardXml, enterKeyType) + return adjustForEmojiButton(keyboard) } }