move some icons and iconButtons to separate file

This commit is contained in:
Helium314 2025-02-24 19:17:21 +01:00
parent 875a98d3f4
commit a8bd9058e7
12 changed files with 122 additions and 183 deletions

View file

@ -0,0 +1,59 @@
package helium314.keyboard.settings
import androidx.annotation.StringRes
import androidx.compose.foundation.layout.Column
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.latin.R
@Composable
fun NextScreenIcon() {
Icon(painterResource(R.drawable.ic_arrow_left), null, Modifier.scale(-1f, 1f))
}
@Composable
fun EditButton(enabled: Boolean = true, onClick: () -> Unit) {
IconButton(onClick, enabled = enabled) { Icon(painterResource(R.drawable.ic_edit), "edit") }
}
@Composable
fun DeleteButton(onClick: () -> Unit) {
IconButton(onClick) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
}
@Composable
fun SearchIcon() {
Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key))
}
@Composable
fun CloseIcon(@StringRes resId: Int) {
Icon(painterResource(R.drawable.ic_close), stringResource(resId))
}
@Composable
fun DefaultButton(isDefault: Boolean, onClick: () -> Unit) {
IconButton(onClick = onClick, enabled = !isDefault) {
Icon(painterResource(R.drawable.ic_settings_default), "default")
}
}
@Preview
@Composable
private fun Preview() {
Column(horizontalAlignment = Alignment.CenterHorizontally) {
NextScreenIcon()
SearchIcon()
CloseIcon(R.string.dialog_close)
EditButton { }
DeleteButton { }
DefaultButton(false) { }
}
}

View file

@ -144,13 +144,13 @@ fun <T: Any?> SearchScreen(
}, },
actions = { actions = {
IconButton(onClick = { setShowSearch(!showSearch) }) IconButton(onClick = { setShowSearch(!showSearch) })
{ Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key)) } { SearchIcon() }
if (menu != null) if (menu != null)
Box { Box {
var showMenu by remember { mutableStateOf(false) } var showMenu by remember { mutableStateOf(false) }
IconButton( IconButton(
onClick = { showMenu = true } onClick = { showMenu = true }
) { Icon(painterResource(R.drawable.ic_arrow_left,), "menu", Modifier.rotate(-90f)) } ) { Icon(painterResource(R.drawable.ic_arrow_left), "menu", Modifier.rotate(-90f)) }
DropdownMenu( DropdownMenu(
expanded = showMenu, expanded = showMenu,
onDismissRequest = { showMenu = false } onDismissRequest = { showMenu = false }
@ -224,11 +224,11 @@ fun ExpandableSearchField(
value = search, value = search,
onValueChange = onSearchChange, onValueChange = onSearchChange,
modifier = modifier.focusRequester(focusRequester), modifier = modifier.focusRequester(focusRequester),
leadingIcon = { Icon(painterResource(R.drawable.sym_keyboard_search_lxx), stringResource(R.string.label_search_key)) }, leadingIcon = { SearchIcon() },
trailingIcon = { IconButton(onClick = { trailingIcon = { IconButton(onClick = {
if (search.text.isBlank()) onDismiss() if (search.text.isBlank()) onDismiss()
else onSearchChange(TextFieldValue()) else onSearchChange(TextFieldValue())
}) { Icon(painterResource(R.drawable.ic_close), stringResource(android.R.string.cancel)) } }, }) { CloseIcon(android.R.string.cancel) } },
singleLine = true, singleLine = true,
colors = colors colors = colors
) )

View file

@ -14,7 +14,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton import androidx.compose.material3.RadioButton
@ -46,6 +45,8 @@ import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.getStringResourceOrName import helium314.keyboard.latin.utils.getStringResourceOrName
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.DeleteButton
import helium314.keyboard.settings.EditButton
import helium314.keyboard.settings.Setting import helium314.keyboard.settings.Setting
import helium314.keyboard.settings.SettingsActivity import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.SettingsDestination import helium314.keyboard.settings.SettingsDestination
@ -164,15 +165,12 @@ private fun AddColorRow(onDismissRequest: () -> Unit, userColors: Collection<Str
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
singleLine = true singleLine = true
) )
IconButton( EditButton(textValue.text.isNotEmpty() && textValue.text !in userColors) {
enabled = textValue.text.isNotEmpty() && textValue.text !in userColors, onDismissRequest()
onClick = { prefs.edit().putString(prefKey, textValue.text).apply()
onDismissRequest() SettingsDestination.navigateTo(targetScreen)
prefs.edit().putString(prefKey, textValue.text).apply() keyboardNeedsReload = true
SettingsDestination.navigateTo(targetScreen) }
keyboardNeedsReload = true
}
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
} }
} }
@ -207,15 +205,11 @@ private fun ColorItemRow(onDismissRequest: () -> Unit, item: String, isSelected:
) )
if (isUser) { if (isUser) {
var showDialog by remember { mutableStateOf(false) } var showDialog by remember { mutableStateOf(false) }
IconButton( DeleteButton { showDialog = true }
onClick = { showDialog = true } EditButton {
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) } onDismissRequest()
IconButton( SettingsDestination.navigateTo(targetScreen + item)
onClick = { }
onDismissRequest()
SettingsDestination.navigateTo(targetScreen + item)
}
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
if (showDialog) if (showDialog)
ConfirmationDialog( ConfirmationDialog(
onDismissRequest = { showDialog = false }, onDismissRequest = { showDialog = false },

View file

@ -9,8 +9,6 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.HorizontalDivider import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -22,7 +20,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import androidx.compose.ui.unit.em import androidx.compose.ui.unit.em
@ -32,6 +29,7 @@ import helium314.keyboard.latin.R
import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
import helium314.keyboard.latin.utils.DictionaryInfoUtils import helium314.keyboard.latin.utils.DictionaryInfoUtils
import helium314.keyboard.latin.utils.createDictionaryTextAnnotated import helium314.keyboard.latin.utils.createDictionaryTextAnnotated
import helium314.keyboard.settings.DeleteButton
import helium314.keyboard.settings.dictionaryFilePicker import helium314.keyboard.settings.dictionaryFilePicker
import helium314.keyboard.settings.screens.getUserAndInternalDictionaries import helium314.keyboard.settings.screens.getUserAndInternalDictionaries
import java.util.Locale import java.util.Locale
@ -72,9 +70,7 @@ fun DictionaryDialog(
Column { Column {
Text(header.info(LocalContext.current.resources.configuration.locale()), style = MaterialTheme.typography.bodyMedium) Text(header.info(LocalContext.current.resources.configuration.locale()), style = MaterialTheme.typography.bodyMedium)
} }
IconButton( DeleteButton { showDeleteDialog = true }
onClick = { showDeleteDialog = true }
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
} }
} }
if (showDeleteDialog) if (showDeleteDialog)

View file

@ -3,7 +3,6 @@ package helium314.keyboard.settings.dialogs
import android.widget.Toast import android.widget.Toast
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.material3.TextField import androidx.compose.material3.TextField
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -16,7 +15,6 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalDensity import androidx.compose.ui.platform.LocalDensity
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.TextFieldValue
import helium314.keyboard.latin.R import helium314.keyboard.latin.R
@ -26,6 +24,7 @@ import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.SubtypeSettings import helium314.keyboard.latin.utils.SubtypeSettings
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.getStringResourceOrName import helium314.keyboard.latin.utils.getStringResourceOrName
import helium314.keyboard.settings.CloseIcon
import helium314.keyboard.settings.SettingsActivity import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.keyboardNeedsReload import helium314.keyboard.settings.keyboardNeedsReload
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
@ -88,7 +87,7 @@ fun LayoutEditDialog(
onValueChange = { displayNameValue = it }, onValueChange = { displayNameValue = it },
isError = !nameValid, isError = !nameValid,
supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) }, supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) },
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), stringResource(R.string.name_invalid)) }, trailingIcon = { if (!nameValid) CloseIcon(R.string.name_invalid) },
) )
}, },
checkTextValid = { text -> checkTextValid = { text ->

View file

@ -10,7 +10,6 @@ import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.lazy.rememberLazyListState import androidx.compose.foundation.lazy.rememberLazyListState
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.RadioButton import androidx.compose.material3.RadioButton
@ -45,6 +44,8 @@ import helium314.keyboard.latin.utils.SubtypeSettings
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.getStringResourceOrName import helium314.keyboard.latin.utils.getStringResourceOrName
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.DeleteButton
import helium314.keyboard.settings.EditButton
import helium314.keyboard.settings.Setting import helium314.keyboard.settings.Setting
import helium314.keyboard.settings.SettingsActivity import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.keyboardNeedsReload import helium314.keyboard.settings.keyboardNeedsReload
@ -139,10 +140,9 @@ private fun AddLayoutRow(onNewLayout: (String) -> Unit, layoutType: LayoutType,
modifier = Modifier.weight(1f), modifier = Modifier.weight(1f),
singleLine = true singleLine = true
) )
IconButton( EditButton(textValue.text.isNotEmpty() && LayoutUtilsCustom.getLayoutName(textValue.text, layoutType) !in userLayouts) {
enabled = textValue.text.isNotEmpty() && LayoutUtilsCustom.getLayoutName(textValue.text, layoutType) !in userLayouts, onNewLayout(textValue.text)
onClick = { onNewLayout(textValue.text) } }
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
} }
} }
@ -186,9 +186,7 @@ private fun LayoutItemRow(
) )
if (isCustom) { if (isCustom) {
var showDeleteDialog by remember { mutableStateOf(false) } var showDeleteDialog by remember { mutableStateOf(false) }
IconButton( DeleteButton { showDeleteDialog = true }
onClick = { showDeleteDialog = true }
) { Icon(painterResource(R.drawable.ic_bin), stringResource(R.string.delete)) }
if (showDeleteDialog) { if (showDeleteDialog) {
val inUse = SubtypeSettings.getAdditionalSubtypes().any { st -> val inUse = SubtypeSettings.getAdditionalSubtypes().any { st ->
val map = LayoutType.getLayoutMap(st.getExtraValueOf(ExtraValue.KEYBOARD_LAYOUT_SET)) val map = LayoutType.getLayoutMap(st.getExtraValueOf(ExtraValue.KEYBOARD_LAYOUT_SET))
@ -206,9 +204,7 @@ private fun LayoutItemRow(
) )
} }
} }
IconButton( EditButton { onClickEdit(layoutName to (if (isCustom) null else LayoutUtils.getContent(layoutType, layoutName, ctx))) }
onClick = { onClickEdit(layoutName to (if (isCustom) null else LayoutUtils.getContent(layoutType, layoutName, ctx))) }
) { Icon(painterResource(R.drawable.ic_edit), "edit") }
} }
} }

View file

@ -68,6 +68,7 @@ import helium314.keyboard.latin.utils.getSecondaryLocales
import helium314.keyboard.latin.utils.getStringResourceOrName import helium314.keyboard.latin.utils.getStringResourceOrName
import helium314.keyboard.latin.utils.mainLayoutName import helium314.keyboard.latin.utils.mainLayoutName
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.DefaultButton
import helium314.keyboard.settings.SettingsActivity import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.layoutFilePicker import helium314.keyboard.settings.layoutFilePicker
import helium314.keyboard.settings.layoutIntent import helium314.keyboard.settings.layoutIntent
@ -125,18 +126,16 @@ fun SubtypeDialog(
Row { Row {
TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f)) TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f))
{ Text(stringResource(R.string.popup_order), style = MaterialTheme.typography.bodyLarge) } { Text(stringResource(R.string.popup_order), style = MaterialTheme.typography.bodyLarge) }
DefaultButton( DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
{ currentSubtype = currentSubtype.without(ExtraValue.POPUP_ORDER) }, currentSubtype = currentSubtype.without(ExtraValue.POPUP_ORDER)
currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null }
)
} }
Row { Row {
TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f)) TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f))
{ Text(stringResource(R.string.hint_source), style = MaterialTheme.typography.bodyLarge) } { Text(stringResource(R.string.hint_source), style = MaterialTheme.typography.bodyLarge) }
DefaultButton( DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
{ currentSubtype = currentSubtype.without(ExtraValue.HINT_ORDER) }, currentSubtype = currentSubtype.without(ExtraValue.HINT_ORDER)
currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null }
)
} }
if (currentSubtype.locale.script() == SCRIPT_LATIN) { if (currentSubtype.locale.script() == SCRIPT_LATIN) {
WithSmallTitle(stringResource(R.string.show_popup_keys_title)) { WithSmallTitle(stringResource(R.string.show_popup_keys_title)) {
@ -145,10 +144,9 @@ fun SubtypeDialog(
Row { Row {
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f)) TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
{ Text(stringResource(morePopupKeysResId(value))) } { Text(stringResource(morePopupKeysResId(value))) }
DefaultButton( DefaultButton(explicitValue == null) {
{ currentSubtype = currentSubtype.without(ExtraValue.MORE_POPUPS) }, currentSubtype = currentSubtype.without(ExtraValue.MORE_POPUPS)
explicitValue == null }
)
} }
} }
} }
@ -162,10 +160,9 @@ fun SubtypeDialog(
currentSubtype = currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()) currentSubtype = currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString())
} }
) )
DefaultButton( DefaultButton(checked == null) {
{ currentSubtype = currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW) }, currentSubtype = currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW)
checked == null }
)
} }
} }
HorizontalDivider() HorizontalDivider()
@ -183,10 +180,9 @@ fun SubtypeDialog(
onSelected = { onSelected = {
currentSubtype = currentSubtype.withLayout(type, it) currentSubtype = currentSubtype.withLayout(type, it)
}, },
extraButton = { DefaultButton( extraButton = { DefaultButton(explicitLayout == null) {
onDefault = { currentSubtype = currentSubtype.withoutLayout(type) }, currentSubtype = currentSubtype.withoutLayout(type)
isDefault = explicitLayout == null } },
) },
) { ) {
val displayName = if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it) val displayName = if (LayoutUtilsCustom.isCustomLayout(it)) LayoutUtilsCustom.getDisplayName(it)
else it.getStringResourceOrName("layout_", ctx) else it.getStringResourceOrName("layout_", ctx)
@ -462,19 +458,6 @@ fun <T>DropDownField(
} }
} }
@Composable
private fun DefaultButton(
onDefault: () -> Unit,
isDefault: Boolean
) {
IconButton(
onClick = onDefault,
enabled = !isDefault
) {
Icon(painterResource(R.drawable.ic_settings_default), "default")
}
}
private fun getAvailableSecondaryLocales(context: Context, mainLocale: Locale): List<Locale> = private fun getAvailableSecondaryLocales(context: Context, mainLocale: Locale): List<Locale> =
getDictionaryLocales(context).filter { it != mainLocale && it.script() == mainLocale.script() } getDictionaryLocales(context).filter { it != mainLocale && it.script() == mainLocale.script() }

View file

@ -4,7 +4,6 @@ package helium314.keyboard.settings.screens
import android.annotation.SuppressLint import android.annotation.SuppressLint
import android.content.Context import android.content.Context
import android.os.Build import android.os.Build
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -12,10 +11,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.keyboard.KeyboardActionListener import helium314.keyboard.keyboard.KeyboardActionListener
@ -33,6 +29,7 @@ import helium314.keyboard.latin.settings.DebugSettings
import helium314.keyboard.latin.settings.Defaults import helium314.keyboard.latin.settings.Defaults
import helium314.keyboard.latin.settings.Settings import helium314.keyboard.latin.settings.Settings
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.SettingsContainer import helium314.keyboard.settings.SettingsContainer
import helium314.keyboard.settings.preferences.ListPreference import helium314.keyboard.settings.preferences.ListPreference
import helium314.keyboard.settings.SettingsWithoutKey import helium314.keyboard.settings.SettingsWithoutKey
@ -195,13 +192,7 @@ fun createAdvancedSettings(context: Context) = listOf(
Preference( Preference(
name = it.title, name = it.title,
onClick = { SettingsDestination.navigateTo(SettingsDestination.Debug) } onClick = { SettingsDestination.navigateTo(SettingsDestination.Debug) }
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
}, },
Setting(context, Settings.PREF_EMOJI_MAX_SDK, R.string.prefs_key_emoji_max_sdk) { setting -> Setting(context, Settings.PREF_EMOJI_MAX_SDK, R.string.prefs_key_emoji_max_sdk) { setting ->
SliderPreference( SliderPreference(

View file

@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size import androidx.compose.foundation.layout.size
import androidx.compose.foundation.shape.CircleShape import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.Icon
import androidx.compose.material3.LocalContentColor import androidx.compose.material3.LocalContentColor
import androidx.compose.material3.LocalTextStyle import androidx.compose.material3.LocalTextStyle
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
@ -39,7 +38,6 @@ import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.TextFieldValue import androidx.compose.ui.text.input.TextFieldValue
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
@ -57,9 +55,9 @@ import helium314.keyboard.latin.settings.Settings
import helium314.keyboard.latin.settings.colorPrefsAndResIds import helium314.keyboard.latin.settings.colorPrefsAndResIds
import helium314.keyboard.latin.settings.getColorPrefsToHideInitially import helium314.keyboard.latin.settings.getColorPrefsToHideInitially
import helium314.keyboard.latin.utils.Log import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.ResourceUtils
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.CloseIcon
import helium314.keyboard.settings.SearchScreen import helium314.keyboard.settings.SearchScreen
import helium314.keyboard.settings.SettingsActivity import helium314.keyboard.settings.SettingsActivity
import helium314.keyboard.settings.Theme import helium314.keyboard.settings.Theme
@ -138,7 +136,7 @@ fun ColorsScreen(
}, },
isError = !nameValid, isError = !nameValid,
// supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) } // todo: this is cutting off bottom half of the actual text... // supportingText = { if (!nameValid) Text(stringResource(R.string.name_invalid)) } // todo: this is cutting off bottom half of the actual text...
trailingIcon = { if (!nameValid) Icon(painterResource(R.drawable.ic_close), null) }, trailingIcon = { if (!nameValid) CloseIcon(R.string.name_invalid) },
singleLine = true, singleLine = true,
) )
}, },

View file

@ -4,13 +4,10 @@ package helium314.keyboard.settings.screens
import androidx.compose.foundation.layout.Column import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll import androidx.compose.foundation.verticalScroll
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.latin.R import helium314.keyboard.latin.R
@ -28,6 +25,7 @@ import helium314.keyboard.latin.utils.displayName
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.latin.utils.switchTo import helium314.keyboard.latin.utils.switchTo
import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.preferences.Preference import helium314.keyboard.settings.preferences.Preference
import helium314.keyboard.settings.preferences.PreferenceCategory import helium314.keyboard.settings.preferences.PreferenceCategory
import helium314.keyboard.settings.SearchSettingsScreen import helium314.keyboard.settings.SearchSettingsScreen
@ -60,113 +58,53 @@ fun MainSettingsScreen(
description = enabledSubtypes.joinToString(", ") { it.displayName(ctx) }, description = enabledSubtypes.joinToString(", ") { it.displayName(ctx) },
onClick = onClickLanguage, onClick = onClickLanguage,
icon = R.drawable.ic_settings_languages_foreground icon = R.drawable.ic_settings_languages_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_preferences), name = stringResource(R.string.settings_screen_preferences),
onClick = onClickPreferences, onClick = onClickPreferences,
icon = R.drawable.ic_settings_preferences_foreground icon = R.drawable.ic_settings_preferences_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_appearance), name = stringResource(R.string.settings_screen_appearance),
onClick = onClickAppearance, onClick = onClickAppearance,
icon = R.drawable.ic_settings_appearance_foreground icon = R.drawable.ic_settings_appearance_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_toolbar), name = stringResource(R.string.settings_screen_toolbar),
onClick = onClickToolbar, onClick = onClickToolbar,
icon = R.drawable.ic_settings_toolbar_foreground icon = R.drawable.ic_settings_toolbar_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
if (JniUtils.sHaveGestureLib) if (JniUtils.sHaveGestureLib)
Preference( Preference(
name = stringResource(R.string.settings_screen_gesture), name = stringResource(R.string.settings_screen_gesture),
onClick = onClickGestureTyping, onClick = onClickGestureTyping,
icon = R.drawable.ic_settings_gesture_foreground icon = R.drawable.ic_settings_gesture_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_correction), name = stringResource(R.string.settings_screen_correction),
onClick = onClickTextCorrection, onClick = onClickTextCorrection,
icon = R.drawable.ic_settings_correction_foreground icon = R.drawable.ic_settings_correction_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_secondary_layouts), name = stringResource(R.string.settings_screen_secondary_layouts),
onClick = onClickLayouts, onClick = onClickLayouts,
icon = R.drawable.ic_ime_switcher icon = R.drawable.ic_ime_switcher
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.dictionary_settings_category), name = stringResource(R.string.dictionary_settings_category),
onClick = onClickDictionaries, onClick = onClickDictionaries,
icon = R.drawable.ic_dictionary icon = R.drawable.ic_dictionary
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_advanced), name = stringResource(R.string.settings_screen_advanced),
onClick = onClickAdvanced, onClick = onClickAdvanced,
icon = R.drawable.ic_settings_advanced_foreground icon = R.drawable.ic_settings_advanced_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
Preference( Preference(
name = stringResource(R.string.settings_screen_about), name = stringResource(R.string.settings_screen_about),
onClick = onClickAbout, onClick = onClickAbout,
icon = R.drawable.ic_settings_about_foreground icon = R.drawable.ic_settings_about_foreground
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
PreferenceCategory(title = "old screens") PreferenceCategory(title = "old screens")
Preference( Preference(
name = stringResource(R.string.language_and_layouts_title), name = stringResource(R.string.language_and_layouts_title),

View file

@ -7,15 +7,12 @@ import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.heightIn import androidx.compose.foundation.layout.heightIn
import androidx.compose.foundation.layout.padding import androidx.compose.foundation.layout.padding
import androidx.compose.material3.Icon
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import helium314.keyboard.latin.R import helium314.keyboard.latin.R
@ -28,6 +25,7 @@ import helium314.keyboard.latin.utils.SubtypeSettings.getSystemLocales
import helium314.keyboard.latin.utils.getSecondaryLocales import helium314.keyboard.latin.utils.getSecondaryLocales
import helium314.keyboard.latin.utils.locale import helium314.keyboard.latin.utils.locale
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.SearchScreen import helium314.keyboard.settings.SearchScreen
import helium314.keyboard.settings.SettingsDestination import helium314.keyboard.settings.SettingsDestination
import java.util.Locale import java.util.Locale
@ -63,11 +61,7 @@ fun PersonalDictionariesScreen(
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Text(it.getLocaleDisplayNameForUserDictSettings(ctx), style = MaterialTheme.typography.bodyLarge) Text(it.getLocaleDisplayNameForUserDictSettings(ctx), style = MaterialTheme.typography.bodyLarge)
Icon( NextScreenIcon()
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
} }
} }
) )

View file

@ -5,7 +5,6 @@ import android.Manifest
import android.content.Context import android.content.Context
import androidx.activity.compose.rememberLauncherForActivityResult import androidx.activity.compose.rememberLauncherForActivityResult
import androidx.activity.result.contract.ActivityResultContracts import androidx.activity.result.contract.ActivityResultContracts
import androidx.compose.material3.Icon
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
import androidx.compose.runtime.Composable import androidx.compose.runtime.Composable
@ -15,10 +14,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.scale
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
import androidx.compose.ui.tooling.preview.Preview import androidx.compose.ui.tooling.preview.Preview
import helium314.keyboard.latin.R import helium314.keyboard.latin.R
@ -28,6 +24,7 @@ import helium314.keyboard.latin.settings.Settings
import helium314.keyboard.latin.utils.Log import helium314.keyboard.latin.utils.Log
import helium314.keyboard.latin.utils.getActivity import helium314.keyboard.latin.utils.getActivity
import helium314.keyboard.latin.utils.prefs import helium314.keyboard.latin.utils.prefs
import helium314.keyboard.settings.NextScreenIcon
import helium314.keyboard.settings.SettingsContainer import helium314.keyboard.settings.SettingsContainer
import helium314.keyboard.settings.preferences.ListPreference import helium314.keyboard.settings.preferences.ListPreference
import helium314.keyboard.settings.SettingsWithoutKey import helium314.keyboard.settings.SettingsWithoutKey
@ -85,13 +82,7 @@ fun createCorrectionSettings(context: Context) = listOf(
Preference( Preference(
name = stringResource(R.string.edit_personal_dictionary), name = stringResource(R.string.edit_personal_dictionary),
onClick = { SettingsDestination.navigateTo(SettingsDestination.PersonalDictionaries) }, onClick = { SettingsDestination.navigateTo(SettingsDestination.PersonalDictionaries) },
) { ) { NextScreenIcon() }
Icon(
painter = painterResource(R.drawable.ic_arrow_left),
modifier = Modifier.scale(-1f, 1f),
contentDescription = null
)
}
}, },
Setting(context, Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE, Setting(context, Settings.PREF_BLOCK_POTENTIALLY_OFFENSIVE,
R.string.prefs_block_potentially_offensive_title, R.string.prefs_block_potentially_offensive_summary R.string.prefs_block_potentially_offensive_title, R.string.prefs_block_potentially_offensive_summary