diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index 408712e3ad..e6529948eb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -98,8 +98,6 @@ import eu.kanade.tachiyomi.util.system.isNavigationBarNeedsScrim import eu.kanade.tachiyomi.util.system.openInBrowser import eu.kanade.tachiyomi.util.system.toast import eu.kanade.tachiyomi.util.view.setComposeContent -import `is`.xyz.mpv.MPVLib -import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.channels.awaitClose import kotlinx.coroutines.flow.callbackFlow import kotlinx.coroutines.flow.collectLatest @@ -108,7 +106,6 @@ import kotlinx.coroutines.flow.filter import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.launch -import kotlinx.coroutines.withContext import logcat.LogPriority import tachiyomi.core.i18n.stringResource import tachiyomi.core.util.lang.launchIO @@ -139,7 +136,6 @@ class MainActivity : BaseActivity() { var ready = false private var navigator: Navigator? = null - private val recordMPVVersion = RecordMPVVersion(this) init { registerSecureActivity(this) @@ -593,71 +589,6 @@ class MainActivity : BaseActivity() { ) } } - - data class MPVVersions( - var mpvCommit: String = "", - var buildDate: String = "", - var libPlacebo: String = "", - var ffmpeg: String = "", - ) { - fun trim() { - mpvCommit = mpvCommit.substringBefore("Copyright").trim() - buildDate = buildDate.substringAfter("built on ").trim() - libPlacebo = libPlacebo.substringAfter(": ").trim() - ffmpeg = ffmpeg.substringAfter(": ").trim() - } - } - - internal val mpvVersions = MPVVersions() - - private var recordMPVLog = true - } - - fun onLoggingComplete() { - lifecycleScope.launch { - withContext(Dispatchers.IO) { - mpvVersions.trim() - MPVLib.removeLogObserver(recordMPVVersion) - MPVLib.destroy() - } - } - } - - inner class RecordMPVVersion(private val context: Context) : MPVLib.LogObserver { - init { - MPVLib.create(context, "v") - MPVLib.addLogObserver(this) - MPVLib.init() - } - - override fun logMessage(prefix: String, level: Int, text: String) { - if (prefix != "cplayer") return - - if (level == MPVLib.mpvLogLevel.MPV_LOG_LEVEL_V) { - with(text) { - if (recordMPVLog) { - when { - contains("Copyright ©") -> mpvVersions.mpvCommit = this - contains("built on") -> mpvVersions.buildDate = this - contains("libplacebo version:") -> mpvVersions.libPlacebo = this - contains("FFmpeg version:") -> mpvVersions.ffmpeg = this - else -> { - recordMPVLog = false - // Use a safe way to call back to the MainActivity - safeOnLoggingComplete() - } - } - } - } - } - } - - private fun safeOnLoggingComplete() { - // Ensure we're calling MainActivity's method safely - (context as? MainActivity)?.runOnUiThread { - context.onLoggingComplete() - } - } } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt index f6bd5951d1..ad7e4739f6 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/CrashLogUtil.kt @@ -11,6 +11,7 @@ import eu.kanade.tachiyomi.util.system.WebViewUtil import eu.kanade.tachiyomi.util.system.createFileInCacheDir import eu.kanade.tachiyomi.util.system.toShareIntent import eu.kanade.tachiyomi.util.system.toast +import `is`.xyz.mpv.Utils import tachiyomi.core.util.lang.withNonCancellableContext import tachiyomi.core.util.lang.withUIContext import uy.kohesive.injekt.Injekt @@ -49,9 +50,9 @@ class CrashLogUtil( Device name: ${Build.DEVICE} (${Build.PRODUCT}) Device model: ${Build.MODEL} WebView: ${WebViewUtil.getVersion(context)} - MPVLib version: ${MainActivity.mpvVersions.mpvCommit} (${MainActivity.mpvVersions.buildDate}) - Libplacebo version: ${MainActivity.mpvVersions.libPlacebo} - FFmpeg version: ${MainActivity.mpvVersions.ffmpeg} + MPV version: ${Utils.VERSIONS.mpv} + Libplacebo version: ${Utils.VERSIONS.libPlacebo} + FFmpeg version: ${Utils.VERSIONS.ffmpeg} """.trimIndent() } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 568c7831f4..3246e6c494 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -97,7 +97,7 @@ voyager-transitions = { module = "cafe.adriel.voyager:voyager-transitions", vers ktlint = "org.jlleitschuh.gradle:ktlint-gradle:12.0.3" -aniyomi-mpv = "com.github.aniyomiorg:aniyomi-mpv-lib:1.13.n" +aniyomi-mpv = "com.github.aniyomiorg:aniyomi-mpv-lib:1.14.n" ffmpeg-kit = "com.github.jmir1:ffmpeg-kit:1.13" arthenica-smartexceptions = "com.arthenica:smart-exception-java:0.2.1"