From ef1bb4e8002e72a7416b5ecf6b4754c03da49cb9 Mon Sep 17 00:00:00 2001 From: arkon Date: Sun, 17 Apr 2022 11:30:05 -0400 Subject: [PATCH] Show parsed Markdown for new version info (closes #6940) --- app/build.gradle.kts | 1 + .../eu/kanade/tachiyomi/ui/more/AboutController.kt | 1 + .../tachiyomi/ui/more/NewUpdateDialogController.kt | 12 ++++++++---- .../widget/preference/ThemesPreferenceAdapter.kt | 2 +- gradle/libs.versions.toml | 2 ++ 5 files changed, 13 insertions(+), 5 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 3521711746..32adbe1003 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -234,6 +234,7 @@ dependencies { exclude(group = "androidx.viewpager", module = "viewpager") } implementation(libs.insetter) + implementation(libs.markwon) // Conductor implementation(libs.bundles.conductor) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt index 6bbaa033a2..f2d42c376d 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/AboutController.kt @@ -121,6 +121,7 @@ class AboutController : SettingsController(), NoAppBarElevationController { is AppUpdateResult.NoNewUpdate -> { activity?.toast(R.string.update_check_no_new_updates) } + else -> {} } } catch (error: Exception) { activity?.toast(error.message) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt index cb52be32f3..0961313969 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/more/NewUpdateDialogController.kt @@ -8,6 +8,7 @@ import eu.kanade.tachiyomi.R import eu.kanade.tachiyomi.data.updater.AppUpdateResult import eu.kanade.tachiyomi.data.updater.AppUpdateService import eu.kanade.tachiyomi.ui.base.controller.DialogController +import io.noties.markwon.Markwon class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundle) { @@ -16,15 +17,18 @@ class NewUpdateDialogController(bundle: Bundle? = null) : DialogController(bundl ) 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!!) .setTitle(R.string.update_check_notification_update_available) - .setMessage(args.getString(BODY_KEY) ?: "") + .setMessage(info) .setPositiveButton(R.string.update_check_confirm) { _, _ -> - val appContext = applicationContext - if (appContext != null) { + applicationContext?.let { context -> // Start download val url = args.getString(URL_KEY) ?: "" - AppUpdateService.start(appContext, url) + AppUpdateService.start(context, url) } } .setNegativeButton(R.string.update_check_ignore, null) diff --git a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt index 4c5bd324d7..38e71410f7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/widget/preference/ThemesPreferenceAdapter.kt @@ -25,7 +25,7 @@ class ThemesPreferenceAdapter(private val clickListener: OnItemClickListener) : override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): ThemeViewHolder { val themeResIds = ThemingDelegate.getThemeResIds(themes[viewType], preferences.themeDarkAmoled().get()) val themedContext = themeResIds.fold(parent.context) { - context, themeResId -> + context, themeResId -> ContextThemeWrapper(context, themeResId) } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 768e2af450..a670204f0a 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -56,6 +56,8 @@ image-decoder = "com.github.tachiyomiorg:image-decoder:7481a4a" 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" androidprocessbutton = "com.github.dmytrodanylyk.android-process-button:library:1.0.4" flexible-adapter-core = "com.github.arkon.FlexibleAdapter:flexible-adapter:c8013533"