Skip to content

Commit e451068

Browse files
committed
Merge remote-tracking branch 'origin/master' into GradleCodegen
2 parents bcbc8df + 04fe0ce commit e451068

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

dataconnect/app/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ dependencies {
8585
dataconnect {
8686
// The version of https://www.npmjs.com/package/firebase-tools to use to perform the
8787
// Data Connect code generation.
88-
firebaseToolsVersion = "13.23.0"
88+
firebaseToolsVersion = "13.25.0"
8989

9090
// The directory that contains dataconnect.yaml to use as input when performing
9191
// the Data Connect code generation.

dataconnect/app/src/main/java/com/google/firebase/example/dataconnect/ui/components/ReviewCard.kt

Lines changed: 22 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package com.google.firebase.example.dataconnect.ui.components
22

3+
import android.os.Build
34
import android.widget.Space
45
import androidx.compose.foundation.background
56
import androidx.compose.foundation.layout.Column
@@ -17,17 +18,17 @@ import androidx.compose.ui.semantics.text
1718
import androidx.compose.ui.text.font.FontWeight
1819
import androidx.compose.ui.tooling.preview.Preview
1920
import androidx.compose.ui.unit.dp
21+
import com.google.firebase.dataconnect.LocalDate
22+
import com.google.firebase.dataconnect.toJavaLocalDate
2023
import java.text.SimpleDateFormat
21-
import java.time.LocalDate
22-
import java.time.LocalDateTime
23-
import java.util.Date
24+
import java.time.format.DateTimeFormatter
2425
import java.util.Locale
2526

2627

2728
@Composable
2829
fun ReviewCard(
2930
userName: String,
30-
date: Date,
31+
date: LocalDate,
3132
rating: Double,
3233
text: String,
3334
movieName: String? = null
@@ -55,10 +56,23 @@ fun ReviewCard(
5556
modifier = Modifier.padding(bottom = 8.dp)
5657
) {
5758
Text(
58-
text = SimpleDateFormat(
59-
"dd MMM, yyyy",
60-
Locale.getDefault()
61-
).format(date),
59+
text =
60+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
61+
val dateFormatter = DateTimeFormatter.ofPattern("dd MMM, yyyy", Locale.getDefault())
62+
date.toJavaLocalDate().format(dateFormatter)
63+
} else {
64+
val parseableDateString = date.run {
65+
val year = "$year".padStart(4, '0')
66+
val month = "$month".padStart(2, '0')
67+
val day = "$day".padStart(2, '0')
68+
"$year-$month-$day"
69+
}
70+
val dateParser = SimpleDateFormat("y-M-d", Locale.US)
71+
val parsedDate = dateParser.parse(parseableDateString) ?:
72+
throw Exception("INTERNAL ERROR: unparseable date string: $parseableDateString")
73+
val dateFormatter = SimpleDateFormat("dd MMM, yyyy", Locale.getDefault())
74+
dateFormatter.format(parsedDate)
75+
},
6276
style = MaterialTheme.typography.titleMedium
6377
)
6478
Spacer(modifier = Modifier.width(8.dp))

gradle/libs.versions.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
agp = "8.7.2"
33
coilCompose = "2.7.0"
44
firebaseAuth = "23.1.0"
5-
firebaseDataConnect = "16.0.0-beta02"
5+
firebaseDataConnect = "16.0.0-beta03"
66
kotlin = "2.0.21"
77
coreKtx = "1.13.1"
88
junit = "4.13.2"

0 commit comments

Comments
 (0)