diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 68dbd17b..7070291e 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -228,6 +228,8 @@ dependencies { implementation(libs.timber) implementation(libs.aboutlibraries.core) implementation(libs.aboutlibraries.compose.m3) + implementation(libs.multiplatform.markdown.renderer) + implementation(libs.multiplatform.markdown.renderer.m3) androidTestImplementation(platform(libs.androidx.compose.bom)) androidTestImplementation(libs.androidx.compose.ui.test.junit4) diff --git a/app/src/main/java/com/github/damontecres/wholphin/ui/setup/InstallUpdatePage.kt b/app/src/main/java/com/github/damontecres/wholphin/ui/setup/InstallUpdatePage.kt index 95a1aaf4..c9ff33aa 100644 --- a/app/src/main/java/com/github/damontecres/wholphin/ui/setup/InstallUpdatePage.kt +++ b/app/src/main/java/com/github/damontecres/wholphin/ui/setup/InstallUpdatePage.kt @@ -54,6 +54,7 @@ import com.github.damontecres.wholphin.util.LoadingState import com.github.damontecres.wholphin.util.Release import com.github.damontecres.wholphin.util.UpdateChecker import com.github.damontecres.wholphin.util.Version +import com.mikepenz.markdown.m3.Markdown import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch @@ -120,27 +121,21 @@ fun InstallUpdatePage( LoadingState.Success -> release?.let { - if (it.version.isGreaterThan(viewModel.currentVersion)) { - InstallUpdatePageContent( - currentVersion = viewModel.currentVersion, - release = it, - onInstallRelease = { - if (!permissions) { - launcher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE) - } else { - viewModel.installRelease(it) - } - }, - onCancel = { - viewModel.navigationManager.goBack() - }, - modifier = modifier, - ) - } else { - Text( - text = "No update available", - ) - } + InstallUpdatePageContent( + currentVersion = viewModel.currentVersion, + release = it, + onInstallRelease = { + if (!permissions) { + launcher.launch(Manifest.permission.WRITE_EXTERNAL_STORAGE) + } else { + viewModel.installRelease(it) + } + }, + onCancel = { + viewModel.navigationManager.goBack() + }, + modifier = modifier, + ) } } } @@ -202,11 +197,14 @@ fun InstallUpdatePageContent( }, ) { item { - Text( - // TODO render markdown - text = release.notes.joinToString("\n\n") + (release.body ?: ""), - style = MaterialTheme.typography.bodyLarge, - color = MaterialTheme.colorScheme.onSurface, + Markdown( + (release.notes.joinToString("\n\n") + (release.body ?: "")) + .replace( + Regex("https://github.com/damontecres/\\w+/pull/(\\d+)"), + "#$1", + ) + // Remove the last line for full changelog since its just a link + .replace(Regex("\\*\\*Full Changelog\\*\\*.*"), ""), ) } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 8e585bdb..09177416 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -9,6 +9,7 @@ coreKtx = "1.17.0" appcompat = "1.7.1" composeBom = "2025.10.00" compose-runtime = "1.9.3" +multiplatformMarkdownRenderer = "0.37.0" timber = "5.0.1" tvFoundation = "1.0.0-alpha12" tvMaterial = "1.0.1" @@ -56,6 +57,8 @@ androidx-datastore = { module = "androidx.datastore:datastore", version.ref = "d desugar_jdk_libs = { module = "com.android.tools:desugar_jdk_libs", version.ref = "desugar_jdk_libs" } hilt-android = { module = "com.google.dagger:hilt-android", version.ref = "hilt" } hilt-android-compiler = { module = "com.google.dagger:hilt-android-compiler", version.ref = "hilt" } +multiplatform-markdown-renderer = { module = "com.mikepenz:multiplatform-markdown-renderer", version.ref = "multiplatformMarkdownRenderer" } +multiplatform-markdown-renderer-m3 = { module = "com.mikepenz:multiplatform-markdown-renderer-m3", version.ref = "multiplatformMarkdownRenderer" } protobuf-kotlin-lite = { module = "com.google.protobuf:protobuf-kotlin-lite", version.ref = "protobuf-javalite" } kotlinx-coroutines-android = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-android", version.ref = "kotlinx-coroutines-android" } kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }