Skip to content

Your Android phone and your Windows PC, working as one. Local-first, end-to-end encrypted, no account.

i18n(android): use locale-aware date pattern and zoom formatting

Jochen Kirstätterbc776626dc40
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/ui/desk/DeskScreen.kt b/android/app/src/main/kotlin/app/nectarlink/android/ui/desk/DeskScreen.kt
index a97d566..8772519 100644
--- a/android/app/src/main/kotlin/app/nectarlink/android/ui/desk/DeskScreen.kt
+++ b/android/app/src/main/kotlin/app/nectarlink/android/ui/desk/DeskScreen.kt
@@ -2,6 +2,7 @@
package app.nectarlink.android.ui.desk
import android.app.Activity
+import android.text.format.DateFormat
import android.view.WindowManager
import androidx.compose.foundation.BorderStroke
import androidx.compose.foundation.Image
@@ -507,15 +508,19 @@ private fun DeskClockDisplay() {
}
}
- val timeFormat = remember { SimpleDateFormat("HH:mm", Locale.getDefault()) }
- val secFormat = remember { SimpleDateFormat(":ss", Locale.getDefault()) }
- val dateFormat = remember { SimpleDateFormat("EEEE, MMMM d", Locale.getDefault()) }
+ val locale = Locale.getDefault()
+ val timeFormat = remember(locale) { SimpleDateFormat("HH:mm", locale) }
+ val secFormat = remember(locale) { SimpleDateFormat(":ss", locale) }
+ val dateFormat = remember(locale) {
+ val pattern = DateFormat.getBestDateTimePattern(locale, "EEEEMMMMd")
+ SimpleDateFormat(pattern, locale)
+ }
val minuteKey = nowMs / 60_000L
val secondKey = nowMs / 1_000L
- val timeText = remember(minuteKey) { timeFormat.format(Date(minuteKey * 60_000L)) }
- val dateText = remember(minuteKey) { dateFormat.format(Date(minuteKey * 60_000L)) }
- val secText = remember(secondKey) { secFormat.format(Date(secondKey * 1_000L)) }
+ val timeText = remember(minuteKey, locale) { timeFormat.format(Date(minuteKey * 60_000L)) }
+ val dateText = remember(minuteKey, locale) { dateFormat.format(Date(minuteKey * 60_000L)) }
+ val secText = remember(secondKey, locale) { secFormat.format(Date(secondKey * 1_000L)) }
Row(
verticalAlignment = Alignment.Bottom,
diff --git a/android/app/src/main/kotlin/app/nectarlink/android/ui/webcam/WebcamScreen.kt b/android/app/src/main/kotlin/app/nectarlink/android/ui/webcam/WebcamScreen.kt
index f3475b3..1110823 100644
--- a/android/app/src/main/kotlin/app/nectarlink/android/ui/webcam/WebcamScreen.kt
+++ b/android/app/src/main/kotlin/app/nectarlink/android/ui/webcam/WebcamScreen.kt
@@ -60,7 +60,6 @@ import app.nectarlink.android.R
import app.nectarlink.android.core.Device
import app.nectarlink.android.ui.detached
import app.nectarlink.android.webcam.WebcamService
-import java.util.Locale
@OptIn(ExperimentalLayoutApi::class)
@Composable
@@ -406,7 +405,7 @@ fun WebcamScreen(
Column(verticalArrangement = Arrangement.spacedBy(8.dp)) {
val zoomLabel = stringResource(
R.string.webcam_zoom_label,
- String.format(Locale.US, "%.1f", session.zoomRatio).toFloat(),
+ session.zoomRatio,
)
Text(
zoomLabel,