mirror of
https://github.com/vitorpamplona/amethyst.git
synced 2024-09-29 16:30:49 +00:00
add string resources
This commit is contained in:
parent
6e89e69fb6
commit
e2ef7cfd70
@ -86,7 +86,7 @@ class Account(
|
||||
|
||||
var userProfileCache: User? = null
|
||||
fun updateAutomaticallyStartPlayback(
|
||||
automaticallyStartPlayback: Boolean?,
|
||||
automaticallyStartPlayback: Boolean?
|
||||
) {
|
||||
settings.automaticallyStartPlayback = automaticallyStartPlayback
|
||||
live.invalidateData()
|
||||
@ -94,7 +94,7 @@ class Account(
|
||||
}
|
||||
|
||||
fun updateAutomaticallyShowUrlPreview(
|
||||
automaticallyShowUrlPreview: Boolean?,
|
||||
automaticallyShowUrlPreview: Boolean?
|
||||
) {
|
||||
settings.automaticallyShowUrlPreview = automaticallyShowUrlPreview
|
||||
live.invalidateData()
|
||||
@ -102,14 +102,13 @@ class Account(
|
||||
}
|
||||
|
||||
fun updateAutomaticallyShowImages(
|
||||
automaticallyShowImages: Boolean?,
|
||||
automaticallyShowImages: Boolean?
|
||||
) {
|
||||
settings.automaticallyShowImages = automaticallyShowImages
|
||||
live.invalidateData()
|
||||
saveable.invalidateData()
|
||||
}
|
||||
|
||||
|
||||
fun updateOptOutOptions(warnReports: Boolean, filterSpam: Boolean) {
|
||||
warnAboutPostsWithReports = warnReports
|
||||
filterSpamFromStrangers = filterSpam
|
||||
|
@ -55,6 +55,7 @@ import androidx.compose.ui.platform.LocalClipboardManager
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.platform.LocalView
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.AnnotatedString
|
||||
import androidx.compose.ui.text.Placeholder
|
||||
import androidx.compose.ui.text.PlaceholderVerticalAlign
|
||||
@ -321,7 +322,7 @@ fun LoadImageBox(showImage: MutableState<Boolean>) {
|
||||
contentAlignment = Alignment.Center
|
||||
) {
|
||||
Text(
|
||||
text = "Load Image",
|
||||
text = stringResource(R.string.load_image),
|
||||
style = TextStyle(color = Color.Black, fontSize = 18.sp)
|
||||
)
|
||||
}
|
||||
|
@ -50,19 +50,19 @@ class AccountViewModel(val account: Account, private val themeViewModel: ThemeVi
|
||||
}
|
||||
|
||||
fun updateAutomaticallyStartPlayback(
|
||||
automaticallyStartPlayback: Boolean?,
|
||||
automaticallyStartPlayback: Boolean?
|
||||
) {
|
||||
account.updateAutomaticallyStartPlayback(automaticallyStartPlayback)
|
||||
}
|
||||
|
||||
fun updateAutomaticallyShowUrlPreview(
|
||||
automaticallyShowUrlPreview: Boolean?,
|
||||
automaticallyShowUrlPreview: Boolean?
|
||||
) {
|
||||
account.updateAutomaticallyShowUrlPreview(automaticallyShowUrlPreview)
|
||||
}
|
||||
|
||||
fun updateAutomaticallyShowImages(
|
||||
automaticallyShowImages: Boolean?,
|
||||
automaticallyShowImages: Boolean?
|
||||
) {
|
||||
account.updateAutomaticallyShowImages(automaticallyShowImages)
|
||||
}
|
||||
|
@ -27,6 +27,7 @@ import androidx.compose.runtime.setValue
|
||||
import androidx.compose.ui.Alignment
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.intl.Locale
|
||||
import androidx.compose.ui.unit.dp
|
||||
@ -90,7 +91,13 @@ fun SettingsScreen(
|
||||
nav: (String) -> Unit
|
||||
) {
|
||||
val scope = rememberCoroutineScope()
|
||||
val selectedItens = persistentListOf("Always", "Wifi-only", "Never")
|
||||
val selectedItens = persistentListOf(
|
||||
stringResource(R.string.always),
|
||||
stringResource(R.string.wifi_only),
|
||||
stringResource(R.string.never).replaceFirstChar {
|
||||
it.uppercase()
|
||||
}
|
||||
)
|
||||
val settings = accountViewModel.account.settings
|
||||
val index = if (settings.automaticallyShowImages == null) { 0 } else {
|
||||
if (settings.automaticallyShowImages == true) 1 else 2
|
||||
@ -102,7 +109,11 @@ fun SettingsScreen(
|
||||
if (settings.automaticallyShowUrlPreview == true) 1 else 2
|
||||
}
|
||||
|
||||
val themeItens = persistentListOf("System", "Light", "Dark")
|
||||
val themeItens = persistentListOf(
|
||||
stringResource(R.string.system),
|
||||
stringResource(R.string.light),
|
||||
stringResource(R.string.dark)
|
||||
)
|
||||
val themeIndex = accountViewModel.currentTheme()
|
||||
|
||||
val context = LocalContext.current
|
||||
@ -116,14 +127,14 @@ fun SettingsScreen(
|
||||
.verticalScroll(rememberScrollState()),
|
||||
horizontalAlignment = Alignment.CenterHorizontally
|
||||
) {
|
||||
Section("Application preferences")
|
||||
Section(stringResource(R.string.application_preferences))
|
||||
|
||||
Row(
|
||||
verticalAlignment = Alignment.CenterVertically,
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
TextSpinner(
|
||||
label = "Language",
|
||||
label = stringResource(R.string.language),
|
||||
placeholder = languageList[languageIndex],
|
||||
options = languageList,
|
||||
onSelect = {
|
||||
@ -146,7 +157,7 @@ fun SettingsScreen(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
TextSpinner(
|
||||
label = "Theme",
|
||||
label = stringResource(R.string.theme),
|
||||
placeholder = themeItens[themeIndex],
|
||||
options = themeItens,
|
||||
onSelect = {
|
||||
@ -166,7 +177,7 @@ fun SettingsScreen(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
TextSpinner(
|
||||
label = "Automatically load images/gifs",
|
||||
label = stringResource(R.string.automatically_load_images_gifs),
|
||||
placeholder = selectedItens[index],
|
||||
options = selectedItens,
|
||||
onSelect = {
|
||||
@ -192,7 +203,7 @@ fun SettingsScreen(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
TextSpinner(
|
||||
label = "Automatically play videos",
|
||||
label = stringResource(R.string.automatically_play_videos),
|
||||
placeholder = selectedItens[videoIndex],
|
||||
options = selectedItens,
|
||||
onSelect = {
|
||||
@ -218,7 +229,7 @@ fun SettingsScreen(
|
||||
modifier = Modifier.fillMaxWidth()
|
||||
) {
|
||||
TextSpinner(
|
||||
label = "Automatically show url preview",
|
||||
label = stringResource(R.string.automatically_show_url_preview),
|
||||
placeholder = selectedItens[linkIndex],
|
||||
options = selectedItens,
|
||||
onSelect = {
|
||||
@ -229,7 +240,7 @@ fun SettingsScreen(
|
||||
}
|
||||
|
||||
scope.launch(Dispatchers.IO) {
|
||||
accountViewModel.updateAutomaticallyStartPlayback(automaticallyShowUrlPreview)
|
||||
accountViewModel.updateAutomaticallyShowUrlPreview(automaticallyShowUrlPreview)
|
||||
LocalPreferences.saveToEncryptedStorage(accountViewModel.account)
|
||||
}
|
||||
},
|
||||
|
@ -484,4 +484,16 @@
|
||||
<string name="add_sensitive_content_label">Sensitive Content</string>
|
||||
<string name="add_sensitive_content_description">Adds sensitive content warning before showing this content</string>
|
||||
<string name="settings">Settings</string>
|
||||
<string name="always">Always</string>
|
||||
<string name="wifi_only">Wifi-only</string>
|
||||
<string name="system">System</string>
|
||||
<string name="light">Light</string>
|
||||
<string name="dark">Dark</string>
|
||||
<string name="application_preferences">Application preferences</string>
|
||||
<string name="language">Language</string>
|
||||
<string name="theme">Theme</string>
|
||||
<string name="automatically_load_images_gifs">Automatically load images/gifs</string>
|
||||
<string name="automatically_play_videos">Automatically play videos</string>
|
||||
<string name="automatically_show_url_preview">Automatically show url preview</string>
|
||||
<string name="load_image">Load Image</string>
|
||||
</resources>
|
||||
|
Loading…
Reference in New Issue
Block a user