From a49264c29b765848281c0f32c9de85e1b741b0d2 Mon Sep 17 00:00:00 2001 From: inotia00 <108592928+inotia00@users.noreply.github.com> Date: Fri, 22 Mar 2024 18:56:23 +0900 Subject: [PATCH] fix(YouTube/Settings): patch version in `Patch Information` is no longer updated manually --- .../youtube/utils/settings/SettingsPatch.kt | 18 ++++++++++++++++++ .../youtube/settings/xml/revanced_prefs.xml | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt index dac20cecd..5bc7e9374 100644 --- a/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt +++ b/src/main/kotlin/app/revanced/patches/youtube/utils/settings/SettingsPatch.kt @@ -12,11 +12,13 @@ import app.revanced.patches.youtube.utils.settings.ResourceUtils.addReVancedPref import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatus import app.revanced.patches.youtube.utils.settings.ResourceUtils.updatePatchStatusSettings import app.revanced.util.ResourceGroup +import app.revanced.util.classLoader import app.revanced.util.copyResources import org.w3c.dom.Element import java.io.Closeable import java.util.concurrent.Executors import java.util.concurrent.TimeUnit +import java.util.jar.Manifest @Patch( name = "Settings", @@ -181,6 +183,19 @@ object SettingsPatch : AbstractSettingsResourcePatch( } override fun close() { + // Set ReVanced Patches Version + val jarManifest = classLoader.getResources("META-INF/MANIFEST.MF") + while (jarManifest.hasMoreElements()) + contexts.updatePatchStatusSettings( + "ReVanced Patches", + Manifest(jarManifest.nextElement().openStream()) + .mainAttributes + .getValue("Version") + "" + ) + + // Endregion + + // Set ReVanced Integrations Version SettingsBytecodePatch.contexts.classes.forEach { classDef -> if (classDef.sourceFile != "BuildConfig.java") return@forEach @@ -204,5 +219,8 @@ object SettingsPatch : AbstractSettingsResourcePatch( ) ) } + + // Endregion + } } \ No newline at end of file diff --git a/src/main/resources/youtube/settings/xml/revanced_prefs.xml b/src/main/resources/youtube/settings/xml/revanced_prefs.xml index 2db5eb550..f1f73adde 100644 --- a/src/main/resources/youtube/settings/xml/revanced_prefs.xml +++ b/src/main/resources/youtube/settings/xml/revanced_prefs.xml @@ -394,7 +394,7 @@ - +