Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions app/src/main/kotlin/app/grapheneos/info/ui/releases/Changelog.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ import org.w3c.dom.Document
import org.w3c.dom.Node
import org.xml.sax.InputSource
import java.io.StringReader
import java.time.LocalDate
import java.time.format.DateTimeFormatter
import java.time.format.DateTimeParseException
import java.time.format.FormatStyle
import java.util.Locale
import javax.xml.parsers.DocumentBuilderFactory

@Composable
Expand Down Expand Up @@ -151,18 +156,36 @@ private fun ParseChildren(

val annotatedString = annotatedStringBuilder.toAnnotatedString()

ClickableText(
text = annotatedString,
modifier = modifier.semantics { heading() },
onClick = { offset ->
annotatedString
.getStringAnnotations("URL", offset, offset).firstOrNull()
?.let { annotation ->
localUriHandler.openUri(annotation.item)
}
},
style = typography.titleLarge,
)
val buildDate = try {
LocalDate.parse(
annotatedString.text.take(8),
DateTimeFormatter.ofPattern("yyyyMMdd", Locale.ROOT)
)
} catch (_: DateTimeParseException) {
null
}

Column {
ClickableText(
text = annotatedString,
modifier = modifier.semantics { heading() },
onClick = { offset ->
annotatedString
.getStringAnnotations("URL", offset, offset).firstOrNull()
?.let { annotation ->
localUriHandler.openUri(annotation.item)
}
},
style = typography.titleLarge,
)
buildDate?.let {
Text(
text = it.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)) + " (UTC)",
style = typography.titleSmall,
color = MaterialTheme.colorScheme.onSurfaceVariant
)
}
}
}

"content" -> NodeToComposable(
Expand Down