Make string translatable

This commit is contained in:
MM20 2024-08-17 00:07:52 +02:00
parent 814c4cd3f5
commit 8bb2184818
No known key found for this signature in database
GPG Key ID: 0B61A8F2DEAFA389
4 changed files with 53 additions and 37 deletions

View File

@ -32,7 +32,7 @@ android {
targetSdk = libs.versions.targetSdk.get().toInt() targetSdk = libs.versions.targetSdk.get().toInt()
@SuppressLint("HighAppVersionCode") @SuppressLint("HighAppVersionCode")
versionCode = System.getenv("VERSION_CODE_OVERRIDE")?.toIntOrNull() ?: 2024072400 versionCode = System.getenv("VERSION_CODE_OVERRIDE")?.toIntOrNull() ?: 2024072400
versionName = "1.32.2" versionName = "1.33.0"
signingConfig = signingConfigs.getByName("debug") signingConfig = signingConfigs.getByName("debug")
} }

View File

@ -26,6 +26,7 @@ import androidx.compose.runtime.setValue
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.pluralStringResource
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.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
@ -125,7 +126,13 @@ fun CalendarSearchSettingsScreen() {
title = plugin.plugin.label, title = plugin.plugin.label,
enabled = state is PluginState.Ready, enabled = state is PluginState.Ready,
summary = (state as? PluginState.SetupRequired)?.message summary = (state as? PluginState.SetupRequired)?.message
?: if (selectedCalendars != null && calendarLists != null) "$selectedCalendars lists selected" ?: if (selectedCalendars != null && calendarLists != null) {
pluralStringResource(
R.plurals.calendar_search_enabled_lists,
selectedCalendars,
selectedCalendars
)
}
else (state as? PluginState.Ready)?.text ?: plugin.plugin.description, else (state as? PluginState.Ready)?.text ?: plugin.plugin.description,
switchValue = enabledProviders.contains(plugin.plugin.authority) && state is PluginState.Ready, switchValue = enabledProviders.contains(plugin.plugin.authority) && state is PluginState.Ready,
onSwitchChanged = { onSwitchChanged = {

View File

@ -16,8 +16,6 @@ import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.fillMaxWidth import androidx.compose.foundation.layout.fillMaxWidth
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.layout.wrapContentHeight
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.foundation.lazy.LazyColumn import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.items import androidx.compose.foundation.lazy.items
import androidx.compose.foundation.rememberScrollState import androidx.compose.foundation.rememberScrollState
@ -33,12 +31,11 @@ import androidx.compose.material.icons.rounded.Place
import androidx.compose.material.icons.rounded.Settings import androidx.compose.material.icons.rounded.Settings
import androidx.compose.material.icons.rounded.Today import androidx.compose.material.icons.rounded.Today
import androidx.compose.material.icons.rounded.Verified import androidx.compose.material.icons.rounded.Verified
import androidx.compose.material3.AlertDialogDefaults
import androidx.compose.material3.BasicAlertDialog
import androidx.compose.material3.CheckboxDefaults import androidx.compose.material3.CheckboxDefaults
import androidx.compose.material3.Icon import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton import androidx.compose.material3.IconButton
import androidx.compose.material3.MaterialTheme import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.ModalBottomSheet
import androidx.compose.material3.Scaffold import androidx.compose.material3.Scaffold
import androidx.compose.material3.Surface import androidx.compose.material3.Surface
import androidx.compose.material3.Text import androidx.compose.material3.Text
@ -55,6 +52,7 @@ 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.pluralStringResource
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.lifecycle.Lifecycle import androidx.lifecycle.Lifecycle
@ -471,17 +469,31 @@ fun PluginSettingsScreen(pluginId: String) {
} }
val calendarLists by remember(plugin.state, plugin.plugin) { val calendarLists by remember(plugin.state, plugin.plugin) {
viewModel.getCalendarLists(plugin.plugin) viewModel.getCalendarLists(plugin.plugin)
}.collectAsStateWithLifecycle(null, minActiveState = Lifecycle.State.RESUMED) }.collectAsStateWithLifecycle(
null,
minActiveState = Lifecycle.State.RESUMED
)
var showDialog by remember { mutableStateOf(false) } var showDialog by remember { mutableStateOf(false) }
val selectedCalendars = remember(excludedCalendars, calendarLists) { val selectedCalendars = remember(excludedCalendars, calendarLists) {
calendarLists?.size?.minus(excludedCalendars.count { it.startsWith(plugin.plugin.authority) }) calendarLists?.size?.minus(excludedCalendars.count {
it.startsWith(
plugin.plugin.authority
)
})
} }
PreferenceWithSwitch( PreferenceWithSwitch(
title = plugin.plugin.label, title = plugin.plugin.label,
enabled = enabledCalendarSearchPlugins != null && state is PluginState.Ready, enabled = enabledCalendarSearchPlugins != null && state is PluginState.Ready,
summary = (state as? PluginState.SetupRequired)?.message summary = (state as? PluginState.SetupRequired)?.message
?: if (selectedCalendars != null && calendarLists != null) "$selectedCalendars lists selected" ?: if (selectedCalendars != null && calendarLists != null) {
else (state as? PluginState.Ready)?.text ?: plugin.plugin.description, pluralStringResource(
R.plurals.calendar_search_enabled_lists,
selectedCalendars,
selectedCalendars
)
}
else (state as? PluginState.Ready)?.text
?: plugin.plugin.description,
switchValue = enabledCalendarSearchPlugins?.contains(plugin.plugin.authority) == true && state is PluginState.Ready, switchValue = enabledCalendarSearchPlugins?.contains(plugin.plugin.authority) == true && state is PluginState.Ready,
onSwitchChanged = { onSwitchChanged = {
viewModel.setCalendarSearchPluginEnabled( viewModel.setCalendarSearchPluginEnabled(
@ -495,40 +507,33 @@ fun PluginSettingsScreen(pluginId: String) {
} }
) )
if (showDialog && calendarLists?.isNotEmpty() == true) { if (showDialog && calendarLists?.isNotEmpty() == true) {
BasicAlertDialog( ModalBottomSheet(
onDismissRequest = { onDismissRequest = {
showDialog = false showDialog = false
}, },
) { ) {
Surface( LazyColumn {
modifier = Modifier.wrapContentWidth() items(calendarLists!!) {
.wrapContentHeight(), CheckboxPreference(
shape = MaterialTheme.shapes.large, title = it.name,
tonalElevation = AlertDialogDefaults.TonalElevation summary = it.owner,
) { iconPadding = false,
LazyColumn { value = it.id !in excludedCalendars,
items(calendarLists!!) { onValueChanged = { value ->
CheckboxPreference( viewModel.setCalendarExcluded(it.id, !value)
title = it.name, },
summary = it.owner,
iconPadding = false,
value = it.id !in excludedCalendars,
onValueChanged = { value ->
viewModel.setCalendarExcluded(it.id, !value)
},
checkboxColors = CheckboxDefaults.colors( checkboxColors = CheckboxDefaults.colors(
checkedColor = if (it.color == 0) MaterialTheme.colorScheme.primary checkedColor = if (it.color == 0) MaterialTheme.colorScheme.primary
else Color( else Color(
it.color.atTone(if (LocalDarkTheme.current) 80 else 40) it.color.atTone(if (LocalDarkTheme.current) 80 else 40)
), ),
checkmarkColor = if (it.color == 0) MaterialTheme.colorScheme.onPrimary checkmarkColor = if (it.color == 0) MaterialTheme.colorScheme.onPrimary
else Color( else Color(
it.color.atTone(if (LocalDarkTheme.current) 20 else 100) it.color.atTone(if (LocalDarkTheme.current) 20 else 100)
)
) )
) )
} )
} }
} }
} }

View File

@ -998,4 +998,8 @@
<string name="profile_private_profile_action_unlock">Unlock</string> <string name="profile_private_profile_action_unlock">Unlock</string>
<string name="profile_private_profile_action_lock">Lock private space</string> <string name="profile_private_profile_action_lock">Lock private space</string>
<string name="hint_drag_and_drop_reorder">Hold and drag items to rearrange them</string> <string name="hint_drag_and_drop_reorder">Hold and drag items to rearrange them</string>
<plurals name="calendar_search_enabled_lists">
<item quantity="one">%1$s list selected</item>
<item quantity="other">%1$s lists selected</item>
</plurals>
</resources> </resources>