Skip to content

Commit e7daef1

Browse files
committed
chore: fix warn and lints
1 parent 38cf7fa commit e7daef1

3 files changed

Lines changed: 14 additions & 6 deletions

File tree

‎app/lint.xml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<lint>
3+
<issue id="NonObservableLocale" severity="ignore" />
4+
</lint>

‎app/src/main/java/app/batstats/ui/screens/BatterySettingsScreen.kt‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import androidx.compose.material3.*
2222
import androidx.compose.runtime.*
2323
import androidx.compose.ui.Modifier
2424
import androidx.compose.ui.input.nestedscroll.nestedScroll
25+
import androidx.compose.ui.platform.LocalConfiguration
2526
import androidx.compose.ui.res.stringResource
2627
import androidx.compose.ui.unit.dp
2728
import androidx.lifecycle.compose.collectAsStateWithLifecycle
@@ -51,7 +52,6 @@ import io.github.mlmgames.settings.ui.dialogs.SliderSettingDialog
5152
import kotlinx.coroutines.launch
5253
import org.koin.androidx.compose.koinViewModel
5354
import org.koin.compose.koinInject
54-
import java.util.Locale
5555

5656
@OptIn(ExperimentalMaterial3Api::class)
5757
@Composable
@@ -402,10 +402,11 @@ private fun RenderSettingField(
402402
}
403403
}
404404
Slider::class -> {
405+
val currentLocale = LocalConfiguration.current.locales[0]
405406
@Suppress("UNCHECKED_CAST")
406407
val anyField = field as SettingField<AppSettings, Any?>
407408
val subtitle = when (val value = anyField.get(settings)) {
408-
is Float, is Double -> String.format(Locale.getDefault(), "%.1f", (value as Number).toDouble())
409+
is Float, is Double -> String.format(currentLocale, "%.1f", (value as Number).toDouble())
409410
is Int, is Long -> value.toString()
410411
else -> ""
411412
}

‎app/src/main/java/app/batstats/ui/screens/DashboardScreen.kt‎

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import androidx.compose.animation.slideInVertically
1616
import androidx.compose.animation.slideOutVertically
1717
import androidx.compose.animation.togetherWith
1818
import androidx.compose.foundation.Canvas
19+
import androidx.compose.ui.platform.LocalConfiguration
1920
import androidx.compose.foundation.background
2021
import androidx.compose.foundation.layout.Arrangement
2122
import androidx.compose.foundation.layout.Box
@@ -122,8 +123,9 @@ fun DashboardScreen(
122123

123124
val scrollBehavior = TopAppBarDefaults.exitUntilCollapsedScrollBehavior()
124125

125-
val timeFormatter = remember(Locale.getDefault()) {
126-
DateTimeFormatter.ofPattern("HH:mm:ss", Locale.getDefault())
126+
val currentLocale = LocalConfiguration.current.locales[0]
127+
val timeFormatter = remember(currentLocale) {
128+
DateTimeFormatter.ofPattern("HH:mm:ss", currentLocale)
127129
}
128130

129131
Scaffold(
@@ -495,8 +497,9 @@ private fun ControlCenter(
495497
}
496498

497499
if (session != null) {
498-
val shortTime = remember(Locale.getDefault()) {
499-
DateTimeFormatter.ofPattern("HH:mm", Locale.getDefault())
500+
val shortLocale = LocalConfiguration.current.locales[0]
501+
val shortTime = remember(shortLocale) {
502+
DateTimeFormatter.ofPattern("HH:mm", shortLocale)
500503
}
501504
val startedAt = remember(session.startTime) {
502505
Instant.ofEpochMilli(session.startTime)

0 commit comments

Comments
 (0)