2025-01-25 22:07:56 +01:00
|
|
|
// SPDX-License-Identifier: GPL-3.0-only
|
2025-01-26 18:25:43 +01:00
|
|
|
package helium314.keyboard.settings.screens
|
2025-01-25 22:07:56 +01:00
|
|
|
|
2025-02-06 19:47:24 +01:00
|
|
|
import androidx.compose.foundation.layout.Column
|
|
|
|
import androidx.compose.foundation.rememberScrollState
|
|
|
|
import androidx.compose.foundation.verticalScroll
|
2025-01-25 22:07:56 +01:00
|
|
|
import androidx.compose.material3.Icon
|
|
|
|
import androidx.compose.material3.Surface
|
|
|
|
import androidx.compose.runtime.Composable
|
|
|
|
import androidx.compose.ui.Modifier
|
|
|
|
import androidx.compose.ui.draw.scale
|
|
|
|
import androidx.compose.ui.platform.LocalContext
|
|
|
|
import androidx.compose.ui.res.painterResource
|
|
|
|
import androidx.compose.ui.res.stringResource
|
|
|
|
import androidx.compose.ui.tooling.preview.Preview
|
|
|
|
import helium314.keyboard.latin.R
|
|
|
|
import helium314.keyboard.latin.settings.AboutFragment
|
|
|
|
import helium314.keyboard.latin.settings.AdvancedSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.AppearanceSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.CorrectionSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.GestureSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.LanguageSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.PreferencesSettingsFragment
|
|
|
|
import helium314.keyboard.latin.settings.ToolbarSettingsFragment
|
|
|
|
import helium314.keyboard.latin.utils.JniUtils
|
2025-02-01 08:35:14 +01:00
|
|
|
import helium314.keyboard.latin.utils.getActivity
|
2025-02-01 10:32:06 +01:00
|
|
|
import helium314.keyboard.latin.utils.switchTo
|
2025-01-26 18:25:43 +01:00
|
|
|
import helium314.keyboard.settings.Preference
|
|
|
|
import helium314.keyboard.settings.PreferenceCategory
|
|
|
|
import helium314.keyboard.settings.SearchPrefScreen
|
|
|
|
import helium314.keyboard.settings.Theme
|
2025-01-25 22:07:56 +01:00
|
|
|
|
|
|
|
@Composable
|
|
|
|
fun MainSettingsScreen(
|
|
|
|
onClickAbout: () -> Unit,
|
|
|
|
onClickTextCorrection: () -> Unit,
|
2025-01-26 21:16:26 +01:00
|
|
|
onClickPreferences: () -> Unit,
|
2025-01-28 16:14:42 +01:00
|
|
|
onClickToolbar: () -> Unit,
|
2025-01-29 22:04:23 +01:00
|
|
|
onClickGestureTyping: () -> Unit,
|
2025-01-29 23:18:06 +01:00
|
|
|
onClickAdvanced: () -> Unit,
|
2025-01-29 23:34:21 +01:00
|
|
|
onClickAppearance: () -> Unit,
|
2025-01-25 22:07:56 +01:00
|
|
|
onClickBack: () -> Unit,
|
|
|
|
) {
|
|
|
|
val ctx = LocalContext.current
|
|
|
|
SearchPrefScreen(
|
|
|
|
onClickBack = onClickBack,
|
|
|
|
title = stringResource(R.string.ime_settings),
|
2025-02-06 19:47:24 +01:00
|
|
|
prefs = emptyList(),
|
2025-01-25 22:07:56 +01:00
|
|
|
) {
|
2025-02-06 19:47:24 +01:00
|
|
|
Column(Modifier.verticalScroll(rememberScrollState())) {
|
2025-01-29 22:04:23 +01:00
|
|
|
Preference(
|
2025-02-06 19:47:24 +01:00
|
|
|
name = stringResource(R.string.settings_screen_preferences),
|
|
|
|
onClick = onClickPreferences,
|
|
|
|
icon = R.drawable.ic_settings_preferences_foreground
|
2025-02-02 17:58:18 +01:00
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
2025-02-06 19:47:24 +01:00
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_appearance),
|
|
|
|
onClick = onClickAppearance,
|
|
|
|
icon = R.drawable.ic_settings_appearance_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_toolbar),
|
|
|
|
onClick = onClickToolbar,
|
|
|
|
icon = R.drawable.ic_settings_toolbar_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
if (JniUtils.sHaveGestureLib)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_gesture),
|
|
|
|
onClick = onClickGestureTyping,
|
|
|
|
icon = R.drawable.ic_settings_gesture_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_correction),
|
|
|
|
onClick = onClickTextCorrection,
|
|
|
|
icon = R.drawable.ic_settings_correction_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_advanced),
|
|
|
|
onClick = onClickAdvanced,
|
|
|
|
icon = R.drawable.ic_settings_advanced_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_about),
|
|
|
|
onClick = onClickAbout,
|
|
|
|
icon = R.drawable.ic_settings_about_foreground
|
|
|
|
) {
|
|
|
|
Icon(
|
|
|
|
painter = painterResource(R.drawable.ic_arrow_left),
|
|
|
|
modifier = Modifier.scale(-1f, 1f),
|
|
|
|
contentDescription = null
|
|
|
|
)
|
|
|
|
}
|
|
|
|
PreferenceCategory(title = "old screens")
|
2025-01-25 22:07:56 +01:00
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.language_and_layouts_title),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(LanguageSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_preferences),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(PreferencesSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_appearance),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(AppearanceSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_toolbar),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(ToolbarSettingsFragment()) }
|
|
|
|
)
|
|
|
|
if (JniUtils.sHaveGestureLib)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_gesture),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(GestureSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_correction),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(CorrectionSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_advanced),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(AdvancedSettingsFragment()) }
|
|
|
|
)
|
|
|
|
Preference(
|
|
|
|
name = stringResource(R.string.settings_screen_about),
|
|
|
|
onClick = { ctx.getActivity()?.switchTo(AboutFragment()) }
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
@Preview
|
|
|
|
@Composable
|
|
|
|
private fun PreviewScreen() {
|
|
|
|
Theme(true) {
|
|
|
|
Surface {
|
2025-01-30 21:38:13 +01:00
|
|
|
MainSettingsScreen({}, {}, {}, {}, {}, {}, {}, {})
|
2025-01-25 22:07:56 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|