Skip to content

Commit a755abd

Browse files
authored
feat: added option to show/hide the emoji key (#319)
* [#234] Added option to show (default) or not the emoji key in the settings menu. * [#234] Added option to show (default) or not the emoji key in the settings menu. Fix: Address reviewer feedback * [#234] Added option to show (default) or not the emoji key in the settings menu. Fix: Address reviewer feedback Refs: #234
1 parent 6636239 commit a755abd

File tree

8 files changed

+69
-10
lines changed

8 files changed

+69
-10
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

77
## [Unreleased]
8+
### Added
9+
- Option to disable the emoji key ([#234])
810

911
## [1.6.0] - 2025-10-29
1012
### Added
@@ -115,6 +117,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
115117
[#206]: https://github.com/FossifyOrg/Keyboard/issues/206
116118
[#222]: https://github.com/FossifyOrg/Keyboard/issues/222
117119
[#230]: https://github.com/FossifyOrg/Keyboard/issues/230
120+
[#234]: https://github.com/FossifyOrg/Keyboard/issues/234
118121
[#238]: https://github.com/FossifyOrg/Keyboard/issues/238
119122
[#239]: https://github.com/FossifyOrg/Keyboard/issues/239
120123
[#251]: https://github.com/FossifyOrg/Keyboard/issues/251

app/src/main/kotlin/org/fossify/keyboard/activities/SettingsActivity.kt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class SettingsActivity : SimpleActivity() {
5959
setupManageKeyboardLanguages()
6060
setupKeyboardLanguage()
6161
setupKeyboardHeightMultiplier()
62+
setupShowEmojiKey()
6263
setupShowClipboardContent()
6364
setupSentencesCapitalization()
6465
setupShowNumbersRow()
@@ -237,6 +238,16 @@ class SettingsActivity : SimpleActivity() {
237238
}
238239
}
239240

241+
private fun setupShowEmojiKey() {
242+
binding.apply {
243+
settingsShowEmojiKeyHolder.setOnClickListener {
244+
settingsShowEmojiKey.toggle()
245+
config.showEmojiKey = settingsShowEmojiKey.isChecked
246+
}
247+
settingsShowEmojiKey.isChecked = config.showEmojiKey
248+
}
249+
}
250+
240251
private fun setupShowNumbersRow() {
241252
binding.apply {
242253
settingsShowNumbersRow.isChecked = config.showNumbersRow

app/src/main/kotlin/org/fossify/keyboard/helpers/Config.kt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ class Config(context: Context) : BaseConfig(context) {
2323
get() = prefs.getBoolean(SENTENCES_CAPITALIZATION, true)
2424
set(enableCapitalization) = prefs.edit().putBoolean(SENTENCES_CAPITALIZATION, enableCapitalization).apply()
2525

26+
var showEmojiKey: Boolean
27+
get() = prefs.getBoolean(SHOW_EMOJI_KEY, true)
28+
set(showEmojiKey) = prefs.edit().putBoolean(SHOW_EMOJI_KEY, showEmojiKey).apply()
29+
2630
var showKeyBorders: Boolean
2731
get() = prefs.getBoolean(SHOW_KEY_BORDERS, true)
2832
set(showKeyBorders) = prefs.edit().putBoolean(SHOW_KEY_BORDERS, showKeyBorders).apply()

app/src/main/kotlin/org/fossify/keyboard/helpers/Constants.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ const val VIBRATE_ON_KEYPRESS = "vibrate_on_keypress"
1515
const val SHOW_POPUP_ON_KEYPRESS = "show_popup_on_keypress"
1616
const val SHOW_KEY_BORDERS = "show_key_borders"
1717
const val SENTENCES_CAPITALIZATION = "sentences_capitalization"
18+
const val SHOW_EMOJI_KEY = "show_emoji_key"
1819
const val LAST_EXPORTED_CLIPS_FOLDER = "last_exported_clips_folder"
1920
const val KEYBOARD_LANGUAGE = "keyboard_language"
2021
const val HEIGHT_PERCENTAGE = "height_percentage"

app/src/main/kotlin/org/fossify/keyboard/services/SimpleKeyboardIME.kt

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
209209
keyboardMode = KEYBOARD_SYMBOLS
210210
R.xml.keys_symbols
211211
}
212-
keyboard = MyKeyboard(this, keyboardXml, enterKeyType)
212+
keyboard = constructKeyboard(keyboardXml, enterKeyType)
213213
keyboardView!!.setKeyboard(keyboard!!)
214214
}
215215
keyboardView!!.invalidateAllKeys()
@@ -234,7 +234,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
234234
R.xml.keys_symbols
235235
}
236236

237-
keyboard = MyKeyboard(this, keyboardXML, enterKeyType)
237+
keyboard = constructKeyboard(keyboardXML, enterKeyType)
238238
keyboardView!!.setKeyboard(keyboard!!)
239239
}
240240

@@ -247,7 +247,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
247247
getKeyboardLayoutXML()
248248
}
249249

250-
keyboard = MyKeyboard(this, keyboardXml, enterKeyType)
250+
keyboard = constructKeyboard(keyboardXml, enterKeyType)
251251
keyboardView!!.setKeyboard(keyboard!!)
252252
}
253253

@@ -337,7 +337,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
337337
// TODO: Change keyboardMode to enum class
338338
keyboardMode = KEYBOARD_LETTERS
339339

340-
keyboard = MyKeyboard(this, getKeyboardLayoutXML(), enterKeyType)
340+
keyboard = constructKeyboard(getKeyboardLayoutXML(), enterKeyType)
341341

342342
val editorInfo = currentInputEditorInfo
343343
if (editorInfo != null && editorInfo.inputType != TYPE_NULL && keyboard?.mShiftState != ShiftState.ON_PERMANENT) {
@@ -399,11 +399,7 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
399399
getKeyboardLayoutXML()
400400
}
401401
}
402-
return MyKeyboard(
403-
context = this,
404-
xmlLayoutResId = keyboardXml,
405-
enterKeyType = enterKeyType,
406-
)
402+
return constructKeyboard(keyboardXml, enterKeyType)
407403
}
408404

409405
override fun onUpdateSelection(oldSelStart: Int, oldSelEnd: Int, newSelStart: Int, newSelEnd: Int, candidatesStart: Int, candidatesEnd: Int) {
@@ -582,4 +578,31 @@ class SimpleKeyboardIME : InputMethodService(), OnKeyboardActionListener, Shared
582578

583579
return Icon.createWithData(byteArray, 0, byteArray.size)
584580
}
581+
582+
private fun adjustForEmojiButton(keyboard: MyKeyboard): MyKeyboard {
583+
if (!config.showEmojiKey && this.keyboardMode == KEYBOARD_LETTERS) {
584+
keyboard.mKeys?.let { keys ->
585+
val emojiKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_EMOJI }
586+
val spaceKeyIndex = keys.indexOfFirst { it.code == MyKeyboard.KEYCODE_SPACE }
587+
588+
if (emojiKeyIndex != -1 && spaceKeyIndex != -1) {
589+
val emojiKey = keys[emojiKeyIndex]
590+
val spaceKey = keys[spaceKeyIndex]
591+
592+
spaceKey.width += emojiKey.width + emojiKey.gap
593+
spaceKey.x = emojiKey.x
594+
595+
val mutableKeys = keys.toMutableList()
596+
mutableKeys.removeAt(emojiKeyIndex)
597+
keyboard.mKeys = mutableKeys
598+
}
599+
}
600+
}
601+
return keyboard
602+
}
603+
604+
private fun constructKeyboard(keyboardXml: Int, enterKeyType: Int): MyKeyboard {
605+
val keyboard = MyKeyboard(this, keyboardXml, enterKeyType)
606+
return adjustForEmojiButton(keyboard)
607+
}
585608
}

app/src/main/res/layout/activity_settings.xml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,21 @@
237237

238238
</RelativeLayout>
239239

240+
<RelativeLayout
241+
android:id="@+id/settings_show_emoji_key_holder"
242+
style="@style/SettingsHolderSwitchStyle"
243+
android:layout_width="match_parent"
244+
android:layout_height="wrap_content">
245+
246+
<org.fossify.commons.views.MyMaterialSwitch
247+
android:id="@+id/settings_show_emoji_key"
248+
style="@style/SettingsSwitchStyle"
249+
android:layout_width="match_parent"
250+
android:layout_height="wrap_content"
251+
android:text="@string/show_emoji_key" />
252+
253+
</RelativeLayout>
254+
240255
<RelativeLayout
241256
android:id="@+id/settings_keyboard_height_multiplier_holder"
242257
style="@style/SettingsHolderTextViewStyle"

app/src/main/res/values-it/strings.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<string name="show_key_borders">Mostra i bordi dei tasti</string>
2929
<string name="show_numbers_row">Mostra i numeri su una riga separata</string>
3030
<string name="start_sentences_capitalized">Inizia le frasi con la lettera maiuscola</string>
31+
<string name="show_emoji_key">Mostra tasto emoji</string>
3132
<string name="emojis">Emoji</string>
3233
<string name="redirection_note">Attiva Tastiera Fossify nella schermata successiva per renderla disponibile. Una volta abilitata, premi \"Indietro\".</string>
3334
<string name="clipboard">Appunti</string>
@@ -46,4 +47,4 @@
4647
<string name="food_and_drink">Cibo e bevande</string>
4748
<string name="travel_and_places">Viaggi e luoghi</string>
4849
<string name="activities">Attività</string>
49-
</resources>
50+
</resources>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@
3636
<string name="show_key_borders">Show key borders</string>
3737
<string name="show_numbers_row">Show numbers on a separate row</string>
3838
<string name="start_sentences_capitalized">Start sentences with a capital letter</string>
39+
<string name="show_emoji_key">Show emoji key</string>
3940
<!-- Emojis -->
4041
<string name="emojis">Emojis</string>
4142
<string name="recently_used">Recently used</string>

0 commit comments

Comments
 (0)