mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-06-09 08:07:42 +00:00
parent
d0787201ae
commit
20d4704090
3 changed files with 74 additions and 30 deletions
|
@ -8,6 +8,9 @@ import androidx.compose.foundation.clickable
|
||||||
import androidx.compose.foundation.layout.Box
|
import androidx.compose.foundation.layout.Box
|
||||||
import androidx.compose.foundation.layout.Column
|
import androidx.compose.foundation.layout.Column
|
||||||
import androidx.compose.foundation.layout.Row
|
import androidx.compose.foundation.layout.Row
|
||||||
|
import androidx.compose.foundation.layout.RowScope
|
||||||
|
import androidx.compose.foundation.layout.fillMaxWidth
|
||||||
|
import androidx.compose.foundation.layout.heightIn
|
||||||
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.material3.DropdownMenu
|
import androidx.compose.material3.DropdownMenu
|
||||||
|
@ -43,6 +46,25 @@ fun WithSmallTitle(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Composable
|
||||||
|
fun ActionRow(
|
||||||
|
modifier: Modifier = Modifier,
|
||||||
|
onClick: (() -> Unit)? = null,
|
||||||
|
verticalAlignment: Alignment.Vertical = Alignment.CenterVertically,
|
||||||
|
content: @Composable RowScope.() -> Unit
|
||||||
|
) {
|
||||||
|
val clickableModifier = if (onClick != null) Modifier.clickable(onClick = onClick)
|
||||||
|
else Modifier
|
||||||
|
Row(
|
||||||
|
modifier = modifier
|
||||||
|
.then(clickableModifier)
|
||||||
|
.fillMaxWidth()
|
||||||
|
.heightIn(min = 44.dp),
|
||||||
|
verticalAlignment = verticalAlignment,
|
||||||
|
content = content
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
/** Icon if resource is a vector image, (bitmap) Image otherwise */
|
/** Icon if resource is a vector image, (bitmap) Image otherwise */
|
||||||
@Composable
|
@Composable
|
||||||
fun IconOrImage(@DrawableRes resId: Int, name: String?, sizeDp: Float) {
|
fun IconOrImage(@DrawableRes resId: Int, name: String?, sizeDp: Float) {
|
||||||
|
|
|
@ -21,7 +21,6 @@ import androidx.compose.material3.Scaffold
|
||||||
import androidx.compose.material3.Surface
|
import androidx.compose.material3.Surface
|
||||||
import androidx.compose.material3.Switch
|
import androidx.compose.material3.Switch
|
||||||
import androidx.compose.material3.Text
|
import androidx.compose.material3.Text
|
||||||
import androidx.compose.material3.TextButton
|
|
||||||
import androidx.compose.runtime.Composable
|
import androidx.compose.runtime.Composable
|
||||||
import androidx.compose.runtime.LaunchedEffect
|
import androidx.compose.runtime.LaunchedEffect
|
||||||
import androidx.compose.runtime.collectAsState
|
import androidx.compose.runtime.collectAsState
|
||||||
|
@ -73,6 +72,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.ActionRow
|
||||||
import helium314.keyboard.settings.DefaultButton
|
import helium314.keyboard.settings.DefaultButton
|
||||||
import helium314.keyboard.settings.DeleteButton
|
import helium314.keyboard.settings.DeleteButton
|
||||||
import helium314.keyboard.settings.DropDownField
|
import helium314.keyboard.settings.DropDownField
|
||||||
|
@ -156,26 +156,37 @@ fun SubtypeScreen(
|
||||||
MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) }
|
MainLayoutRow(currentSubtype, customMainLayouts) { setCurrentSubtype(it) }
|
||||||
if (availableLocalesForScript.size > 1) {
|
if (availableLocalesForScript.size > 1) {
|
||||||
WithSmallTitle(stringResource(R.string.secondary_locale)) {
|
WithSmallTitle(stringResource(R.string.secondary_locale)) {
|
||||||
TextButton(onClick = { showSecondaryLocaleDialog = true }) {
|
ActionRow(onClick = { showSecondaryLocaleDialog = true }) {
|
||||||
val text = getSecondaryLocales(currentSubtype.extraValues).joinToString(", ") {
|
val text = getSecondaryLocales(currentSubtype.extraValues).joinToString(", ") {
|
||||||
it.localizedDisplayName(ctx.resources)
|
it.localizedDisplayName(ctx.resources)
|
||||||
}.ifEmpty { stringResource(R.string.action_none) }
|
}.ifEmpty { stringResource(R.string.action_none) }
|
||||||
Text(text, Modifier.fillMaxWidth())
|
Text(text, modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.padding(start = 10.dp)
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Row {
|
WithSmallTitle(stringResource(R.string.popup_order_and_hint_source)) {
|
||||||
TextButton(onClick = { showKeyOrderDialog = true }, Modifier.weight(1f))
|
ActionRow(onClick = { showKeyOrderDialog = true }) {
|
||||||
{ Text(stringResource(R.string.popup_order)) }
|
Text(stringResource(R.string.popup_order),
|
||||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
|
modifier = Modifier
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.POPUP_ORDER))
|
.weight(1f)
|
||||||
|
.padding(start = 10.dp)
|
||||||
|
)
|
||||||
|
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.POPUP_ORDER) == null) {
|
||||||
|
setCurrentSubtype(currentSubtype.without(ExtraValue.POPUP_ORDER))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
ActionRow(onClick = { showHintOrderDialog = true }) {
|
||||||
Row {
|
Text(stringResource(R.string.hint_source),
|
||||||
TextButton(onClick = { showHintOrderDialog = true }, Modifier.weight(1f))
|
modifier = Modifier
|
||||||
{ Text(stringResource(R.string.hint_source)) }
|
.weight(1f)
|
||||||
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
|
.padding(start = 10.dp)
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.HINT_ORDER))
|
)
|
||||||
|
DefaultButton(currentSubtype.getExtraValueOf(ExtraValue.HINT_ORDER) == null) {
|
||||||
|
setCurrentSubtype(currentSubtype.without(ExtraValue.HINT_ORDER))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) {
|
if (currentSubtype.locale.script() == ScriptUtils.SCRIPT_LATIN) {
|
||||||
|
@ -185,9 +196,12 @@ fun SubtypeScreen(
|
||||||
Settings.PREF_MORE_POPUP_KEYS,
|
Settings.PREF_MORE_POPUP_KEYS,
|
||||||
Defaults.PREF_MORE_POPUP_KEYS
|
Defaults.PREF_MORE_POPUP_KEYS
|
||||||
)!!
|
)!!
|
||||||
Row {
|
ActionRow(onClick = { showMorePopupsDialog = true }) {
|
||||||
TextButton(onClick = { showMorePopupsDialog = true }, Modifier.weight(1f))
|
Text(stringResource(morePopupKeysResId(value)),
|
||||||
{ Text(stringResource(morePopupKeysResId(value))) }
|
modifier = Modifier
|
||||||
|
.weight(1f)
|
||||||
|
.padding(start = 10.dp)
|
||||||
|
)
|
||||||
DefaultButton(explicitValue == null) {
|
DefaultButton(explicitValue == null) {
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.MORE_POPUPS))
|
setCurrentSubtype(currentSubtype.without(ExtraValue.MORE_POPUPS))
|
||||||
}
|
}
|
||||||
|
@ -195,20 +209,26 @@ fun SubtypeScreen(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (hasLocalizedNumberRow(currentSubtype.locale, ctx)) {
|
if (hasLocalizedNumberRow(currentSubtype.locale, ctx)) {
|
||||||
Row(verticalAlignment = Alignment.CenterVertically) {
|
val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean()
|
||||||
val checked = currentSubtype.getExtraValueOf(ExtraValue.LOCALIZED_NUMBER_ROW)?.toBoolean()
|
WithSmallTitle(stringResource(R.string.number_row)) {
|
||||||
Text(stringResource(R.string.localized_number_row), Modifier.weight(1f))
|
ActionRow {
|
||||||
Switch(
|
Text(stringResource(R.string.localized_number_row),
|
||||||
checked = checked ?: prefs.getBoolean(
|
modifier = Modifier
|
||||||
Settings.PREF_LOCALIZED_NUMBER_ROW,
|
.weight(1f)
|
||||||
Defaults.PREF_LOCALIZED_NUMBER_ROW
|
.padding(start = 10.dp)
|
||||||
),
|
)
|
||||||
onCheckedChange = {
|
Switch(
|
||||||
setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()))
|
checked = checked ?: prefs.getBoolean(
|
||||||
|
Settings.PREF_LOCALIZED_NUMBER_ROW,
|
||||||
|
Defaults.PREF_LOCALIZED_NUMBER_ROW
|
||||||
|
),
|
||||||
|
onCheckedChange = {
|
||||||
|
setCurrentSubtype(currentSubtype.with(ExtraValue.LOCALIZED_NUMBER_ROW, it.toString()))
|
||||||
|
}
|
||||||
|
)
|
||||||
|
DefaultButton(checked == null) {
|
||||||
|
setCurrentSubtype(currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW))
|
||||||
}
|
}
|
||||||
)
|
|
||||||
DefaultButton(checked == null) {
|
|
||||||
setCurrentSubtype(currentSubtype.without(ExtraValue.LOCALIZED_NUMBER_ROW))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -270,6 +270,8 @@
|
||||||
<string name="show_hints">Show key hints</string>
|
<string name="show_hints">Show key hints</string>
|
||||||
<!-- Description of the settings to show hints -->
|
<!-- Description of the settings to show hints -->
|
||||||
<string name="show_hints_summary">Show long-press hints</string>
|
<string name="show_hints_summary">Show long-press hints</string>
|
||||||
|
<!-- Preferences item to set popup key order and select hints source -->
|
||||||
|
<string name="popup_order_and_hint_source">Popup key order and hints source</string>
|
||||||
<!-- Title of the setting to select key hints source -->
|
<!-- Title of the setting to select key hints source -->
|
||||||
<string name="hint_source">Select hint source</string>
|
<string name="hint_source">Select hint source</string>
|
||||||
<!-- Title of the setting to set popup key order -->
|
<!-- Title of the setting to set popup key order -->
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue