From b5151f0a6bcddb48b2a204beacd25417b398cdf1 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Wed, 13 Nov 2024 18:32:06 -0800 Subject: [PATCH 1/5] fix: some minor fixes for easier customization --- .../ferrostar/composeui/formatting/DateTimeFormatter.kt | 8 +++++--- .../com/stadiamaps/ferrostar/core/NavigationViewModel.kt | 2 +- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt index 020fe50f..81054a91 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt @@ -4,18 +4,20 @@ import android.icu.util.ULocale import java.util.Locale import kotlinx.datetime.LocalDateTime import kotlinx.datetime.toJavaLocalDateTime +import java.time.format.FormatStyle interface DateTimeFormatter { fun format(dateTime: LocalDateTime): String } class EstimatedArrivalDateTimeFormatter( - private var localeOverride: ULocale? = null, + private var locale: ULocale = ULocale.getDefault(), + private val unitStyle: FormatStyle = FormatStyle.LONG ) : DateTimeFormatter { override fun format(dateTime: LocalDateTime): String { - val locale = localeOverride?.let { Locale(it.language, it.country) } ?: Locale.getDefault() + val locale = locale.let { Locale(it.language, it.country) } val formatter = - java.time.format.DateTimeFormatter.ofLocalizedTime(java.time.format.FormatStyle.SHORT) + java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle) .withLocale(locale) return formatter.format(dateTime.toJavaLocalDateTime()) } diff --git a/android/core/src/main/java/com/stadiamaps/ferrostar/core/NavigationViewModel.kt b/android/core/src/main/java/com/stadiamaps/ferrostar/core/NavigationViewModel.kt index 7dbd9121..86a6448b 100644 --- a/android/core/src/main/java/com/stadiamaps/ferrostar/core/NavigationViewModel.kt +++ b/android/core/src/main/java/com/stadiamaps/ferrostar/core/NavigationViewModel.kt @@ -104,7 +104,7 @@ interface NavigationViewModel { * interface that is reused across navigation sessions will probably need to craft their own view * model. */ -class DefaultNavigationViewModel( +open class DefaultNavigationViewModel( private val ferrostarCore: FerrostarCore, private val annotationPublisher: AnnotationPublisher<*> = NoOpAnnotationPublisher() ) : ViewModel(), NavigationViewModel { From 8a989e73ef391901819482632a23de2b84474d27 Mon Sep 17 00:00:00 2001 From: Archdoog Date: Thu, 14 Nov 2024 02:34:23 +0000 Subject: [PATCH 2/5] Apply automatic changes --- .../ferrostar/composeui/formatting/DateTimeFormatter.kt | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt index 81054a91..1f917a27 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt @@ -1,10 +1,10 @@ package com.stadiamaps.ferrostar.composeui.formatting import android.icu.util.ULocale +import java.time.format.FormatStyle import java.util.Locale import kotlinx.datetime.LocalDateTime import kotlinx.datetime.toJavaLocalDateTime -import java.time.format.FormatStyle interface DateTimeFormatter { fun format(dateTime: LocalDateTime): String @@ -16,9 +16,7 @@ class EstimatedArrivalDateTimeFormatter( ) : DateTimeFormatter { override fun format(dateTime: LocalDateTime): String { val locale = locale.let { Locale(it.language, it.country) } - val formatter = - java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle) - .withLocale(locale) + val formatter = java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle).withLocale(locale) return formatter.format(dateTime.toJavaLocalDateTime()) } } From a1dd74bce7c78d7acf0734e2ebd635f3dcd61ec5 Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Wed, 13 Nov 2024 18:49:44 -0800 Subject: [PATCH 3/5] fix: some minor fixes for easier customization --- .../ferrostar/composeui/formatting/DateTimeFormatter.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt index 81054a91..b149c145 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt @@ -11,11 +11,11 @@ interface DateTimeFormatter { } class EstimatedArrivalDateTimeFormatter( - private var locale: ULocale = ULocale.getDefault(), + private var localeOverride: ULocale? = null, private val unitStyle: FormatStyle = FormatStyle.LONG ) : DateTimeFormatter { override fun format(dateTime: LocalDateTime): String { - val locale = locale.let { Locale(it.language, it.country) } + val locale = localeOverride?.let { Locale(it.language, it.country) } ?: Locale.getDefault() val formatter = java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle) .withLocale(locale) From a7d5d28a6a71aacd590fd36147f9c6c7ad714b35 Mon Sep 17 00:00:00 2001 From: Archdoog Date: Thu, 14 Nov 2024 02:53:15 +0000 Subject: [PATCH 4/5] Apply automatic changes --- .../ferrostar/composeui/formatting/DateTimeFormatter.kt | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt index d0a27fde..bb5e0f09 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt @@ -16,9 +16,7 @@ class EstimatedArrivalDateTimeFormatter( ) : DateTimeFormatter { override fun format(dateTime: LocalDateTime): String { val locale = localeOverride?.let { Locale(it.language, it.country) } ?: Locale.getDefault() - val formatter = - java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle) - .withLocale(locale) + val formatter = java.time.format.DateTimeFormatter.ofLocalizedTime(unitStyle).withLocale(locale) return formatter.format(dateTime.toJavaLocalDateTime()) } } From 2d4f5f7111bae8d66f73d0d84bd1120ecd9d15bf Mon Sep 17 00:00:00 2001 From: Jacob Fielding Date: Wed, 13 Nov 2024 18:56:49 -0800 Subject: [PATCH 5/5] fix: some minor fixes for easier customization --- .../ferrostar/composeui/formatting/DateTimeFormatter.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt index bb5e0f09..8576731c 100644 --- a/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt +++ b/android/composeui/src/main/java/com/stadiamaps/ferrostar/composeui/formatting/DateTimeFormatter.kt @@ -12,7 +12,7 @@ interface DateTimeFormatter { class EstimatedArrivalDateTimeFormatter( private var localeOverride: ULocale? = null, - private val unitStyle: FormatStyle = FormatStyle.LONG + private val unitStyle: FormatStyle = FormatStyle.SHORT ) : DateTimeFormatter { override fun format(dateTime: LocalDateTime): String { val locale = localeOverride?.let { Locale(it.language, it.country) } ?: Locale.getDefault()