Show parsed Markdown for new version info (closes #6940)

This commit is contained in:
arkon 2022-04-17 11:30:05 -04:00
parent c475acd1ea
commit ef1bb4e800
5 changed files with 13 additions and 5 deletions

View file

@ -234,6 +234,7 @@ dependencies {
exclude(group = "androidx.viewpager", module = "viewpager") exclude(group = "androidx.viewpager", module = "viewpager")
} }
implementation(libs.insetter) implementation(libs.insetter)
implementation(libs.markwon)
// Conductor // Conductor
implementation(libs.bundles.conductor) implementation(libs.bundles.conductor)

View file

@ -121,6 +121,7 @@ class AboutController : SettingsController(), NoAppBarElevationController {
is AppUpdateResult.NoNewUpdate -> { is AppUpdateResult.NoNewUpdate -> {
activity?.toast(R.string.update_check_no_new_updates) activity?.toast(R.string.update_check_no_new_updates)
} }
else -> {}
} }
} catch (error: Exception) { } catch (error: Exception) {
activity?.toast(error.message) activity?.toast(error.message)

View file

@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.R
import eu.kanade.tachiyomi.data.updater.AppUpdateResult import eu.kanade.tachiyomi.data.updater.AppUpdateResult
import eu.kanade.tachiyomi.data.updater.AppUpdateService import eu.kanade.tachiyomi.data.updater.AppUpdateService
import eu.kanade.tachiyomi.ui.base.controller.DialogController import eu.kanade.tachiyomi.ui.base.controller.DialogController
import io.noties.markwon.Markwon
class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) { class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) {
@ -16,15 +17,18 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl
) )
override fun onCreateDialog(savedViewState: Bundle?): Dialog { override fun onCreateDialog(savedViewState: Bundle?): Dialog {
val releaseBody = (args.getString(BODY_KEY) ?: "")
.replace("""---(\R|.)*Checksums(\R|.)*""".toRegex(), "")
val info = Markwon.create(activity!!).toMarkdown(releaseBody)
return MaterialAlertDialogBuilder(activity!!) return MaterialAlertDialogBuilder(activity!!)
.setTitle(R.string.update_check_notification_update_available) .setTitle(R.string.update_check_notification_update_available)
.setMessage(args.getString(BODY_KEY) ?: "") .setMessage(info)
.setPositiveButton(R.string.update_check_confirm) { _, _ -> .setPositiveButton(R.string.update_check_confirm) { _, _ ->
val appContext = applicationContext applicationContext?.let { context ->
if (appContext != null) {
// Start download // Start download
val url = args.getString(URL_KEY) ?: "" val url = args.getString(URL_KEY) ?: ""
AppUpdateService.start(appContext, url) AppUpdateService.start(context, url)
} }
} }
.setNegativeButton(R.string.update_check_ignore, null) .setNegativeButton(R.string.update_check_ignore, null)

View file

@ -56,6 +56,8 @@ image-decoder = "com.github.tachiyomiorg:image-decoder:7481a4a"
natural-comparator = "com.github.gpanther:java-nat-sort:natural-comparator-1.1" natural-comparator = "com.github.gpanther:java-nat-sort:natural-comparator-1.1"
markwon = "io.noties.markwon:core:4.6.2"
material = "com.google.android.material:material:1.7.0-alpha01" material = "com.google.android.material:material:1.7.0-alpha01"
androidprocessbutton = "com.github.dmytrodanylyk.android-process-button:library:1.0.4" androidprocessbutton = "com.github.dmytrodanylyk.android-process-button:library:1.0.4"
flexible-adapter-core = "com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533" flexible-adapter-core = "com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533"