mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-19 21:59:11 +00:00
use some resource strings again
This commit is contained in:
parent
cffdbff23c
commit
2fb618888b
6 changed files with 113 additions and 75 deletions
82
app/src/main/java/helium314/keyboard/settings/Misc.kt
Normal file
82
app/src/main/java/helium314/keyboard/settings/Misc.kt
Normal file
|
@ -0,0 +1,82 @@
|
|||
package helium314.keyboard.settings
|
||||
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.remember
|
||||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
|
||||
|
||||
@Composable
|
||||
fun WithSmallTitle(
|
||||
description: String,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
Column {
|
||||
Text(description, style = MaterialTheme.typography.titleSmall)
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T>DropDownField(
|
||||
items: List<T>,
|
||||
selectedItem: T,
|
||||
onSelected: (T) -> Unit,
|
||||
extraButton: @Composable (() -> Unit)? = null,
|
||||
itemContent: @Composable (T) -> Unit,
|
||||
) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
Box(
|
||||
Modifier.clickable { expanded = !expanded }
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(start = 8.dp, bottom = 4.dp)
|
||||
) {
|
||||
Box(Modifier.weight(1f)) {
|
||||
itemContent(selectedItem)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { expanded = !expanded },
|
||||
enabled = items.size > 1
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_left),
|
||||
"show dropdown",
|
||||
Modifier.rotate(-90f)
|
||||
)
|
||||
}
|
||||
if (extraButton != null)
|
||||
extraButton()
|
||||
}
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
items.forEach {
|
||||
DropdownMenuItem(
|
||||
text = { itemContent(it) },
|
||||
onClick = { expanded = false; onSelected(it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
|
@ -47,6 +47,7 @@ import androidx.compose.ui.tooling.preview.Preview
|
|||
import androidx.compose.ui.unit.dp
|
||||
import androidx.core.content.ContextCompat
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.utils.JniUtils
|
||||
import helium314.keyboard.latin.utils.UncachedInputMethodManagerUtils
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
@ -83,12 +84,20 @@ fun WelcomeWizard(
|
|||
val appName = stringResource(ctx.applicationInfo.labelRes)
|
||||
@Composable fun bigText() {
|
||||
val resource = if (step == 0) R.string.setup_welcome_title else R.string.setup_steps_title
|
||||
Column(Modifier.padding(bottom = 36.dp)) {
|
||||
Text(
|
||||
stringResource(resource, appName),
|
||||
style = MaterialTheme.typography.displayMedium,
|
||||
textAlign = TextAlign.Center,
|
||||
modifier = Modifier.padding(bottom = 36.dp)
|
||||
)
|
||||
if (JniUtils.sHaveGestureLib)
|
||||
Text(
|
||||
stringResource(R.string.setup_welcome_additional_description),
|
||||
style = MaterialTheme.typography.bodyLarge,
|
||||
textAlign = TextAlign.End,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
)
|
||||
}
|
||||
}
|
||||
@Composable fun steps() {
|
||||
if (step == 0)
|
||||
|
|
|
@ -28,6 +28,8 @@ import helium314.keyboard.latin.utils.DictionaryInfoUtils
|
|||
import helium314.keyboard.latin.utils.ScriptUtils.script
|
||||
import helium314.keyboard.latin.utils.SubtypeSettings
|
||||
import helium314.keyboard.latin.utils.locale
|
||||
import helium314.keyboard.settings.DropDownField
|
||||
import helium314.keyboard.settings.WithSmallTitle
|
||||
import java.io.File
|
||||
import java.util.Locale
|
||||
|
||||
|
@ -68,14 +70,18 @@ fun NewDictionaryDialog(
|
|||
val newDictBroadcast = Intent(DictionaryPackConstants.NEW_DICTIONARY_INTENT_ACTION)
|
||||
ctx.sendBroadcast(newDictBroadcast)
|
||||
},
|
||||
confirmButtonText = stringResource(if (dictFile.exists()) R.string.replace_dictionary else android.R.string.ok),
|
||||
title = { Text(stringResource(R.string.add_new_dictionary_title)) },
|
||||
content = {
|
||||
Column {
|
||||
Text(info)
|
||||
Text(info, Modifier.padding(bottom = 10.dp))
|
||||
WithSmallTitle(stringResource(R.string.button_select_language)) {
|
||||
DropDownField(
|
||||
selectedItem = locale,
|
||||
onSelected = { locale = it },
|
||||
items = locales
|
||||
) { Text(it.localizedDisplayName(ctx)) }
|
||||
}
|
||||
if (locale.script() != dictLocale.script()) {
|
||||
// whatever, still allow it if the user wants
|
||||
HorizontalDivider()
|
||||
|
|
|
@ -4,15 +4,12 @@ package helium314.keyboard.settings.dialogs
|
|||
import android.content.Context
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Arrangement
|
||||
import androidx.compose.foundation.layout.Box
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.Row
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.foundation.rememberScrollState
|
||||
import androidx.compose.foundation.verticalScroll
|
||||
import androidx.compose.material3.DropdownMenu
|
||||
import androidx.compose.material3.DropdownMenuItem
|
||||
import androidx.compose.material3.HorizontalDivider
|
||||
import androidx.compose.material3.Icon
|
||||
import androidx.compose.material3.IconButton
|
||||
|
@ -30,7 +27,6 @@ import androidx.compose.runtime.saveable.rememberSaveable
|
|||
import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.draw.rotate
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
|
@ -72,8 +68,10 @@ import helium314.keyboard.latin.utils.getStringResourceOrName
|
|||
import helium314.keyboard.latin.utils.mainLayoutName
|
||||
import helium314.keyboard.latin.utils.prefs
|
||||
import helium314.keyboard.settings.DefaultButton
|
||||
import helium314.keyboard.settings.DropDownField
|
||||
import helium314.keyboard.settings.SettingsActivity
|
||||
import helium314.keyboard.settings.Theme
|
||||
import helium314.keyboard.settings.WithSmallTitle
|
||||
import helium314.keyboard.settings.initPreview
|
||||
import helium314.keyboard.settings.layoutFilePicker
|
||||
import helium314.keyboard.settings.layoutIntent
|
||||
|
@ -441,63 +439,6 @@ private fun MainLayoutRow(
|
|||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
private fun WithSmallTitle(
|
||||
description: String,
|
||||
content: @Composable () -> Unit,
|
||||
) {
|
||||
Column {
|
||||
Text(description, style = MaterialTheme.typography.titleSmall)
|
||||
content()
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun <T>DropDownField(
|
||||
items: List<T>,
|
||||
selectedItem: T,
|
||||
onSelected: (T) -> Unit,
|
||||
extraButton: @Composable (() -> Unit)? = null,
|
||||
itemContent: @Composable (T) -> Unit,
|
||||
) {
|
||||
var expanded by remember { mutableStateOf(false) }
|
||||
Box(
|
||||
Modifier.clickable { expanded = !expanded }
|
||||
) {
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.padding(start = 8.dp, bottom = 4.dp)
|
||||
) {
|
||||
Box(Modifier.weight(1f)) {
|
||||
itemContent(selectedItem)
|
||||
}
|
||||
IconButton(
|
||||
onClick = { expanded = !expanded },
|
||||
enabled = items.size > 1
|
||||
) {
|
||||
Icon(
|
||||
painterResource(R.drawable.ic_arrow_left),
|
||||
"show dropdown",
|
||||
Modifier.rotate(-90f)
|
||||
)
|
||||
}
|
||||
if (extraButton != null)
|
||||
extraButton()
|
||||
}
|
||||
}
|
||||
DropdownMenu(
|
||||
expanded = expanded,
|
||||
onDismissRequest = { expanded = false }
|
||||
) {
|
||||
items.forEach {
|
||||
DropdownMenuItem(
|
||||
text = { itemContent(it) },
|
||||
onClick = { expanded = false; onSelected(it) }
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAvailableSecondaryLocales(context: Context, mainLocale: Locale): List<Locale> =
|
||||
getDictionaryLocales(context).filter { it != mainLocale && it.script() == mainLocale.script() }
|
||||
|
||||
|
|
|
@ -32,8 +32,8 @@ import androidx.compose.ui.text.input.KeyboardType
|
|||
import androidx.compose.ui.unit.dp
|
||||
import helium314.keyboard.latin.R
|
||||
import helium314.keyboard.latin.common.LocaleUtils.localizedDisplayName
|
||||
import helium314.keyboard.settings.DropDownField
|
||||
import helium314.keyboard.settings.SearchScreen
|
||||
import helium314.keyboard.settings.dialogs.DropDownField
|
||||
import helium314.keyboard.settings.dialogs.ThreeButtonAlertDialog
|
||||
import java.util.Locale
|
||||
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
<!-- Title for IME settings screen. The app name should not be translated. -->
|
||||
<string name="ime_settings">HeliBoard Settings</string>
|
||||
<!-- Title for the spell checking service settings screen. The app name should not be translated. -->
|
||||
<string name="android_spell_checker_settings">HeliBoard Spell Checker Settings</string>
|
||||
<string name="android_spell_checker_settings">HeliBoard Spell Checker Settings</string> <!-- todo: was used in top bar, but spell checker settings now don't have one -->
|
||||
<!-- Option to provide vibrate/haptic feedback on keypress -->
|
||||
<string name="vibrate_on_keypress">Vibrate on keypress</string>
|
||||
<!-- Option to provide vibrate/haptic feedback on keypress even in do not disturb mode -->
|
||||
|
|
Loading…
Add table
Reference in a new issue