mirror of
https://github.com/florisboard/florisboard.git
synced 2024-09-19 19:42:20 +02:00
add the option to select the spacebar character
This commit is contained in:
parent
80541095fd
commit
2d42ed1c06
@ -26,6 +26,7 @@ import dev.patrickgold.florisboard.ime.core.Subtype
|
||||
import dev.patrickgold.florisboard.ime.input.HapticVibrationMode
|
||||
import dev.patrickgold.florisboard.ime.input.InputFeedbackActivationMode
|
||||
import dev.patrickgold.florisboard.ime.keyboard.IncognitoMode
|
||||
import dev.patrickgold.florisboard.ime.keyboard.SpaceBarMode
|
||||
import dev.patrickgold.florisboard.ime.landscapeinput.LandscapeInputUiMode
|
||||
import dev.patrickgold.florisboard.ime.media.emoji.EmojiHairStyle
|
||||
import dev.patrickgold.florisboard.ime.media.emoji.EmojiRecentlyUsedHelper
|
||||
@ -396,9 +397,9 @@ class AppPrefs : PreferenceModel("florisboard-app-prefs") {
|
||||
key = "keyboard__utility_key_action",
|
||||
default = UtilityKeyAction.DYNAMIC_SWITCH_LANGUAGE_EMOJIS,
|
||||
)
|
||||
val spaceBarLanguageDisplayEnabled = boolean(
|
||||
key = "keyboard__space_bar_language_display_enabled",
|
||||
default = true,
|
||||
val spaceBarMode = enum(
|
||||
key = "keyboard__space_bar_display_mode",
|
||||
default = SpaceBarMode.CURRENT_LANGUAGE
|
||||
)
|
||||
val fontSizeMultiplierPortrait = int(
|
||||
key = "keyboard__font_size_multiplier_portrait",
|
||||
|
@ -20,6 +20,7 @@ import androidx.compose.runtime.Composable
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.app.LocalNavController
|
||||
import dev.patrickgold.florisboard.app.Routes
|
||||
import dev.patrickgold.florisboard.ime.keyboard.SpaceBarMode
|
||||
import dev.patrickgold.florisboard.ime.landscapeinput.LandscapeInputUiMode
|
||||
import dev.patrickgold.florisboard.ime.onehanded.OneHandedMode
|
||||
import dev.patrickgold.florisboard.ime.text.key.KeyHintMode
|
||||
@ -72,10 +73,10 @@ fun KeyboardScreen() = FlorisScreen {
|
||||
entries = UtilityKeyAction.listEntries(),
|
||||
visibleIf = { prefs.keyboard.utilityKeyEnabled isEqualTo true },
|
||||
)
|
||||
SwitchPreference(
|
||||
prefs.keyboard.spaceBarLanguageDisplayEnabled,
|
||||
title = stringRes(R.string.pref__keyboard__space_bar_language_display_enabled__label),
|
||||
summary = stringRes(R.string.pref__keyboard__space_bar_language_display_enabled__summary),
|
||||
ListPreference(
|
||||
prefs.keyboard.spaceBarMode,
|
||||
title = stringRes(R.string.pref__keyboard__space_bar_mode__label),
|
||||
entries = SpaceBarMode.listEntries()
|
||||
)
|
||||
DialogSliderPreference(
|
||||
primaryPref = prefs.keyboard.fontSizeMultiplierPortrait,
|
||||
|
@ -0,0 +1,32 @@
|
||||
package dev.patrickgold.florisboard.ime.keyboard
|
||||
|
||||
import androidx.compose.runtime.Composable
|
||||
import dev.patrickgold.florisboard.R
|
||||
import dev.patrickgold.florisboard.lib.compose.stringRes
|
||||
import dev.patrickgold.jetpref.datastore.ui.listPrefEntries
|
||||
|
||||
enum class SpaceBarMode {
|
||||
NOTHING,
|
||||
CURRENT_LANGUAGE,
|
||||
SPACE_BAR_KEY;
|
||||
|
||||
companion object {
|
||||
@Composable
|
||||
fun listEntries() = listPrefEntries {
|
||||
entry(
|
||||
key = NOTHING,
|
||||
label = stringRes(R.string.enum__space_bar_mode__nothing),
|
||||
)
|
||||
entry(
|
||||
key = CURRENT_LANGUAGE,
|
||||
label = stringRes(R.string.enum__space_bar_mode__current_language),
|
||||
)
|
||||
entry(
|
||||
key = SPACE_BAR_KEY,
|
||||
label = stringRes(R.string.enum__space_bar_mode__space_bar_key),
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -68,6 +68,7 @@ import dev.patrickgold.florisboard.ime.input.InputEventDispatcher
|
||||
import dev.patrickgold.florisboard.ime.keyboard.ComputingEvaluator
|
||||
import dev.patrickgold.florisboard.ime.keyboard.FlorisImeSizing
|
||||
import dev.patrickgold.florisboard.ime.keyboard.KeyboardMode
|
||||
import dev.patrickgold.florisboard.ime.keyboard.SpaceBarMode
|
||||
import dev.patrickgold.florisboard.ime.popup.ExceptionsForKeyCodes
|
||||
import dev.patrickgold.florisboard.ime.popup.PopupUiController
|
||||
import dev.patrickgold.florisboard.ime.popup.rememberPopupUiController
|
||||
@ -373,18 +374,21 @@ private fun TextKeyButton(
|
||||
) { }
|
||||
val isTelpadKey = key.computedData.type == KeyType.NUMERIC && evaluator.keyboard.mode == KeyboardMode.PHONE
|
||||
key.label?.let { label ->
|
||||
var customLabel = label
|
||||
if (key.computedData.code == KeyCode.SPACE) {
|
||||
val prefs by florisPreferenceModel()
|
||||
val displayLanguageName by prefs.keyboard.spaceBarLanguageDisplayEnabled.observeAsState()
|
||||
if (!displayLanguageName) {
|
||||
return@let
|
||||
val spaceBarMode by prefs.keyboard.spaceBarMode.observeAsState()
|
||||
when(spaceBarMode) {
|
||||
SpaceBarMode.NOTHING -> return@let
|
||||
SpaceBarMode.CURRENT_LANGUAGE -> {}
|
||||
SpaceBarMode.SPACE_BAR_KEY -> customLabel = "␣"
|
||||
}
|
||||
}
|
||||
Text(
|
||||
modifier = Modifier
|
||||
.wrapContentSize()
|
||||
.align(if (isTelpadKey) BiasAlignment(-0.5f, 0f) else Alignment.Center),
|
||||
text = label,
|
||||
text = customLabel,
|
||||
color = keyStyle.foreground.solidColor(context),
|
||||
fontSize = fontSize,
|
||||
maxLines = if (key.computedData.code == KeyCode.VIEW_NUMERIC_ADVANCED) 2 else 1,
|
||||
|
@ -308,6 +308,7 @@
|
||||
<string name="pref__keyboard__utility_key_action__label" comment="Preference title">Utility key action</string>
|
||||
<string name="pref__keyboard__space_bar_language_display_enabled__label" comment="Preference title">Display language on space bar</string>
|
||||
<string name="pref__keyboard__space_bar_language_display_enabled__summary" comment="Preference summary">Displays the current active language name on the space bar</string>
|
||||
<string name="pref__keyboard__space_bar_mode__label" comment="Preference title">Spacebar label</string>
|
||||
<string name="pref__keyboard__font_size_multiplier__label" comment="Preference title">Font size multiplier</string>
|
||||
<string name="pref__keyboard__group_layout__label" comment="Preference group title">Layout</string>
|
||||
<string name="pref__keyboard__one_handed_mode__label" comment="Preference title">One-handed mode</string>
|
||||
@ -850,6 +851,9 @@
|
||||
<string name="enum__utility_key_action__switch_keyboard_app" comment="Enum value label">Switch keyboard app</string>
|
||||
<string name="enum__utility_key_action__dynamic_switch_language_emojis" comment="Enum value label">Dynamic: Switch to emojis / Switch language</string>
|
||||
|
||||
<string name="enum__space_bar_mode__nothing" comment="Enum value label">No label</string>
|
||||
<string name="enum__space_bar_mode__current_language" comment="Enum value label">Current language</string>
|
||||
<string name="enum__space_bar_mode__space_bar_key" comment="Enum value label">␣</string>
|
||||
|
||||
<!-- Unit strings (symbols) -->
|
||||
<string name="unit__hours__symbol" translatable="false">{v} h</string>
|
||||
|
Loading…
Reference in New Issue
Block a user