Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 15 additions & 18 deletions app/src/main/java/helium314/keyboard/settings/SearchScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,13 @@ import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
import androidx.compose.ui.draw.drawBehind
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.geometry.Size
import androidx.compose.ui.draw.rotate
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.unit.LayoutDirection
import androidx.compose.ui.unit.dp
import helium314.keyboard.latin.R
import helium314.keyboard.settings.preferences.PreferenceCategory
Expand Down Expand Up @@ -179,7 +175,11 @@ fun SearchSettingsScreen(
.fillMaxWidth()
.padding(start = 16.dp, end = 16.dp, top = if (row.first) 8.dp else 0.dp, bottom = if (row.last) 8.dp else 0.dp)
.clip(shape)
.background(MaterialTheme.colorScheme.surfaceContainer)
// an open fine-tune section (its header and the settings inside) is shaded apart from the card
.background(
if (row.inOpenSection) MaterialTheme.colorScheme.surfaceContainerHigh
else MaterialTheme.colorScheme.surfaceContainer
)
) {
if (row.key == null) {
PreferenceCategory(stringResource(row.titleRes!!))
Expand All @@ -194,17 +194,7 @@ fun SearchSettingsScreen(
// a setting further down in a large card is not on screen after scrolling to it
val bringIntoView = remember { BringIntoViewRequester() }
LaunchedEffect(highlightKey) { if (key == highlightKey) bringIntoView.bringIntoView() }
val nestedLine = MaterialTheme.colorScheme.outlineVariant
val nestedModifier = if (!row.nested) Modifier else Modifier
// a guide line and an indent show that the setting belongs to the fine-tune section above
.drawBehind {
val lineWidth = 2.dp.toPx()
val x = 14.dp.toPx()
val left = if (layoutDirection == LayoutDirection.Rtl) size.width - x - lineWidth else x
drawRect(nestedLine, topLeft = Offset(left, 0f), size = Size(lineWidth, size.height))
}
.padding(start = 20.dp)
Box(Modifier.bringIntoViewRequester(bringIntoView).background(highlight).then(nestedModifier)) {
Box(Modifier.bringIntoViewRequester(bringIntoView).background(highlight)) {
SettingsActivity.settingsContainer[key]?.Preference()
}
}
Expand Down Expand Up @@ -245,8 +235,12 @@ fun SearchSettingsScreen(
/**
* A row of a settings screen: the title of a category ([key] is null) or a setting; first and last row of a card.
* [nested]: the setting is inside an open fine-tune section, i.e. after a fine-tune header in the same card.
* [inOpenSection]: the row is nested or the header of a fine-tune section with settings shown inside.
*/
private data class SettingRow(val id: String, val titleRes: Int?, val key: String?, val first: Boolean = false, val last: Boolean = false, val nested: Boolean = false)
private data class SettingRow(
val id: String, val titleRes: Int?, val key: String?, val first: Boolean = false, val last: Boolean = false,
val nested: Boolean = false, val inOpenSection: Boolean = false
)

private fun settingRows(groups: List<Pair<Int?, List<String>>>): List<SettingRow> = buildList {
groups.forEachIndexed { index, (titleRes, keys) ->
Expand All @@ -259,7 +253,10 @@ private fun settingRows(groups: List<Pair<Int?, List<String>>>): List<SettingRow
if (isFineTuneHeader) inFineTune = true
}
}
group.forEachIndexed { i, row -> add(row.copy(first = i == 0, last = i == group.lastIndex)) }
group.forEachIndexed { i, row ->
val inOpenSection = row.nested || group.getOrNull(i + 1)?.nested == true
add(row.copy(first = i == 0, last = i == group.lastIndex, inOpenSection = inOpenSection))
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ private val modules = listOf(
SettingsModule(SettingsWithoutKey.SCREEN_NAV_PREFERENCES, SettingsDestination.Preferences, R.string.settings_screen_preferences, iconRes = R.drawable.ic_settings_preferences, provider = ::createPreferencesSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_APPEARANCE, SettingsDestination.Appearance, R.string.settings_screen_appearance, iconRes = R.drawable.ic_settings_appearance, provider = ::createAppearanceSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_TOOLBAR, SettingsDestination.Toolbar, R.string.settings_screen_toolbar, iconRes = R.drawable.ic_settings_toolbar, provider = ::createToolbarSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_GESTURES, SettingsDestination.GestureTyping, R.string.settings_screen_gesture, iconRes = R.drawable.ic_settings_gesture, provider = ::createGestureTypingSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_GESTURES, SettingsDestination.GestureTyping, R.string.settings_screen_gestures_swipes, iconRes = R.drawable.ic_settings_gesture, provider = ::createGestureTypingSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_TEXT_CORRECTION, SettingsDestination.TextCorrection, R.string.settings_screen_correction, iconRes = R.drawable.ic_settings_correction, provider = ::createCorrectionSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_SUGGESTIONS, SettingsDestination.Suggestions, R.string.settings_screen_suggestions, iconRes = R.drawable.ic_settings_suggestions, provider = ::createSuggestionsSettings),
SettingsModule(SettingsWithoutKey.SCREEN_NAV_AI_INTEGRATION, SettingsDestination.AIIntegration, R.string.settings_screen_ai_integration, iconRes = R.drawable.ic_proofread, provider = ::createAIIntegrationSettings),
Expand Down Expand Up @@ -219,6 +219,7 @@ object SettingsWithoutKey {
const val BACKGROUND_SERVICES = "background_services"
const val CLOUD_AI_MAX_TOKENS = "cloud_ai_max_tokens"
const val APP_QUIRKS = "app_quirks"
const val KEYPRESS_AUDIO = "keypress_audio"

// Screen Navigation Keys for Settings Search:
const val SCREEN_NAV_SECONDARY_LAYOUTS = "screen_nav_secondary_layouts"
Expand Down
14 changes: 11 additions & 3 deletions app/src/main/java/helium314/keyboard/settings/SettingsNavHost.kt
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
// SPDX-License-Identifier: GPL-3.0-only
package helium314.keyboard.settings

import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.compose.LocalLifecycleOwner
import androidx.lifecycle.Lifecycle
import androidx.compose.animation.core.tween
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
Expand Down Expand Up @@ -52,9 +55,14 @@ fun SettingsNavHost(
val navController = rememberNavController()
val dir = if (LocalLayoutDirection.current == LayoutDirection.Ltr) 1 else -1

LaunchedEffect(navController) {
SettingsDestination.navEvents.collect { route ->
navController.navigate(route)
// only the visible settings activity takes navigation events: with several instances open (e.g. settings opened
// again from the keyboard), a hidden one would otherwise receive the event and nothing happens on screen
val lifecycleOwner = LocalLifecycleOwner.current
LaunchedEffect(navController, lifecycleOwner) {
lifecycleOwner.lifecycle.repeatOnLifecycle(Lifecycle.State.STARTED) {
SettingsDestination.navEvents.collect { route ->
navController.navigate(route)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fun AppearanceScreen(
if (fineTuneThemeExpanded) Settings.PREF_CLEAR_CLIPBOARD_ICON else null,

// Keyboard sizing, layout & fonts
R.string.settings_category_miscellaneous,
R.string.settings_category_size_layout_fonts,
Settings.PREF_KEYBOARD_HEIGHT_SCALE_PREFIX,
Settings.PREF_ENABLE_SPLIT_KEYBOARD,
SettingsWithoutKey.CUSTOM_FONT,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ fun GestureTypingScreen(
}
SearchSettingsScreen(
onClickBack = onClickBack,
title = stringResource(R.string.settings_screen_gesture),
title = stringResource(R.string.settings_screen_gestures_swipes),
settings = items,
headerContent = if (hasGestureLib && gestureEnabled && missingDict) {
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.latin.settings.Defaults
import helium314.keyboard.latin.settings.Settings
import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.preferences.PreferenceCategory
import helium314.keyboard.settings.SearchSettingsScreen
import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.updates.AppUpdatesManager
Expand Down Expand Up @@ -200,6 +201,7 @@ fun MainSettingsScreen(
)
) {
Column {
PreferenceCategory(stringResource(R.string.settings_group_keyboard))
Preference(
name = stringResource(R.string.language_and_layouts_title),
description = enabledSubtypesDescription,
Expand Down Expand Up @@ -234,8 +236,9 @@ fun MainSettingsScreen(
)
) {
Column {
PreferenceCategory(stringResource(R.string.settings_group_typing))
Preference(
name = stringResource(R.string.settings_screen_gesture),
name = stringResource(R.string.settings_screen_gestures_swipes),
onClick = onClickGestureTyping,
icon = R.drawable.ic_settings_gesture
) { NextScreenIcon() }
Expand Down Expand Up @@ -267,6 +270,7 @@ fun MainSettingsScreen(
)
) {
Column {
PreferenceCategory(stringResource(R.string.settings_group_extras))
if (BuildConfig.FLAVOR == "standard" || BuildConfig.FLAVOR == "standardfull") {
Preference(
name = stringResource(R.string.settings_screen_ai_integration),
Expand All @@ -292,6 +296,7 @@ fun MainSettingsScreen(
)
) {
Column {
PreferenceCategory(stringResource(R.string.settings_group_system))
Preference(
name = stringResource(R.string.settings_screen_advanced),
onClick = onClickAdvanced,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.SearchSettingsScreen
import helium314.keyboard.settings.Setting
import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.SettingsDestination
import helium314.keyboard.settings.SettingsWithoutKey
import helium314.keyboard.settings.Theme
import helium314.keyboard.settings.initPreview
import helium314.keyboard.settings.preferences.ExpandablePreference
Expand Down Expand Up @@ -85,10 +87,11 @@ fun PreferencesScreen(
) {
listOf(
// Input & Haptics
R.string.settings_category_input,
R.string.settings_category_input_sound_vibration,
Settings.PREF_KEY_LONGPRESS_TIMEOUT,
Settings.PREF_EMOJI_SKIN_TONE,
Settings.PREF_SHOW_EMOJI_KEY,
SettingsWithoutKey.KEYPRESS_AUDIO,
if (hasVibrator) Settings.PREF_VIBRATE_ON else null,
if (vibrateOn) Settings.PREF_VIBRATION_DURATION_SETTINGS else null,
if (vibrateOn) Settings.PREF_EXPAND_FINE_TUNE_HAPTICS else null,
Expand Down Expand Up @@ -198,6 +201,13 @@ fun createPreferencesSettings(context: Context) = listOf(
)
ListPreference(setting, items, Defaults.PREF_EMOJI_SKIN_TONE) { KeyboardSwitcher.getInstance().setThemeNeedsReload() }
},
Setting(context, SettingsWithoutKey.KEYPRESS_AUDIO, R.string.sound_packs_title, R.string.sound_on_keypress) {
Preference(
name = it.title,
description = it.description,
onClick = { SettingsDestination.navigateTo(SettingsDestination.Sound) }
) { NextScreenIcon() }
},
Setting(context, Settings.PREF_VIBRATE_ON, R.string.vibrate_on_keypress) {
SwitchPreference(it, Defaults.PREF_VIBRATE_ON)
},
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/values-ar/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1755,4 +1755,11 @@
<string name="backup_category_personal_dictionary">القاموس الشخصي</string>
<string name="backup_category_text_expander">موسع النص</string>
<string name="gif_pack_close">إغلاق الحزمة</string>
<string name="settings_screen_gestures_swipes">الإيماءات والسحب</string>
<string name="settings_category_input_sound_vibration">الإدخال والصوت والاهتزاز</string>
<string name="settings_category_size_layout_fonts">الحجم والتخطيط والخطوط</string>
<string name="settings_group_keyboard">لوحة المفاتيح</string>
<string name="settings_group_typing">الكتابة</string>
<string name="settings_group_extras">إضافات</string>
<string name="settings_group_system">نظام</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-be/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1731,4 +1731,11 @@
<string name="backup_category_personal_dictionary">Асабісты слоўнік</string>
<string name="backup_category_text_expander">Расшыральнік тэксту</string>
<string name="gif_pack_close">Зачыніць пакет</string>
<string name="settings_screen_gestures_swipes">Жэсты і правядзенне</string>
<string name="settings_category_input_sound_vibration">Увод, гук і вібрацыя</string>
<string name="settings_category_size_layout_fonts">Памер, макет і шрыфты</string>
<string name="settings_group_keyboard">Клавіятура</string>
<string name="settings_group_typing">Набор тэксту</string>
<string name="settings_group_extras">Дадаткова</string>
<string name="settings_group_system">Сістэма</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-bg/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1731,4 +1731,11 @@
<string name="backup_category_personal_dictionary">Личен речник</string>
<string name="backup_category_text_expander">Текстов разширител</string>
<string name="gif_pack_close">Затвори пакета</string>
<string name="settings_screen_gestures_swipes">Жестове и плъзгания</string>
<string name="settings_category_input_sound_vibration">Вход, звук и вибрация</string>
<string name="settings_category_size_layout_fonts">Размер, оформление и шрифтове</string>
<string name="settings_group_keyboard">Клавиатура</string>
<string name="settings_group_typing">Въвеждане</string>
<string name="settings_group_extras">Екстри</string>
<string name="settings_group_system">Система</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-cs/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1696,4 +1696,11 @@ Umožňuje lokální inferenci GGUF / llama.cpp na zařízení pro korektury a p
<string name="backup_category_personal_dictionary">Osobní slovník</string>
<string name="backup_category_text_expander">Text Expander</string>
<string name="gif_pack_close">Zavřít balíček</string>
<string name="settings_screen_gestures_swipes">Gesta a přejetí</string>
<string name="settings_category_input_sound_vibration">Vstup, zvuk a vibrace</string>
<string name="settings_category_size_layout_fonts">Velikost, rozvržení a písma</string>
<string name="settings_group_keyboard">Klávesnice</string>
<string name="settings_group_typing">Psaní</string>
<string name="settings_group_extras">Extra</string>
<string name="settings_group_system">Systém</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-de/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1747,4 +1747,11 @@ Ermöglicht lokale GGUF / llama.cpp-Inferenz für Korrekturlesen und Umschreiben
<string name="backup_category_personal_dictionary">Persönliches Wörterbuch</string>
<string name="backup_category_text_expander">Textexpander</string>
<string name="gif_pack_close">Paket schließen</string>
<string name="settings_screen_gestures_swipes">Gesten und Wischen</string>
<string name="settings_category_input_sound_vibration">Eingabe, Ton und Vibration</string>
<string name="settings_category_size_layout_fonts">Größe, Layout und Schriftarten</string>
<string name="settings_group_keyboard">Tastatur</string>
<string name="settings_group_typing">Tippen</string>
<string name="settings_group_extras">Extras</string>
<string name="settings_group_system">System</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-el/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1797,4 +1797,11 @@
<string name="no_dictionary_message">\"Χωρίς λεξικό, θα λαμβάνετε μόνο προτάσεις για κείμενο που καταχωρίσατε πριν.&lt;br&gt;
Μπορείτε να κάνετε λήψη λεξικών%1$sή να ελέγξετε εάν ένα λεξικό για το \"%2$s\" μπορεί να ληφθεί απευθείας%3$s.\"</string>
<string name="gif_pack_close">Κλείσιμο πακέτου</string>
<string name="settings_screen_gestures_swipes">Χειρονομίες και ολισθήσεις</string>
<string name="settings_category_input_sound_vibration">Είσοδος, ήχος &amp; δόνηση</string>
<string name="settings_category_size_layout_fonts">Μέγεθος, διάταξη &amp; γραμματοσειρές</string>
<string name="settings_group_keyboard">Πληκτρολόγιο</string>
<string name="settings_group_typing">Δακτυλογραφία</string>
<string name="settings_group_extras">Έξτρα</string>
<string name="settings_group_system">Σύστημα</string>
</resources>
7 changes: 7 additions & 0 deletions app/src/main/res/values-es-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1763,4 +1763,11 @@ Permite la inferencia GGUF / llama.cpp en el dispositivo para corrección y rees
<string name="backup_category_personal_dictionary">Diccionario personal</string>
<string name="backup_category_text_expander">Expansor de texto</string>
<string name="gif_pack_close">Cerrar paquete</string>
<string name="settings_screen_gestures_swipes">Gestos y deslizamientos</string>
<string name="settings_category_input_sound_vibration">Entrada, sonido y vibración</string>
<string name="settings_category_size_layout_fonts">Tamaño, diseño y fuentes</string>
<string name="settings_group_keyboard">Teclado</string>
<string name="settings_group_typing">Escritura</string>
<string name="settings_group_extras">Extras</string>
<string name="settings_group_system">Sistema</string>
</resources>
Loading
Loading