fix(YouTube/Settings): patch version in Patch Information is no longer updated manually

This commit is contained in:
inotia00 2024-03-22 18:56:23 +09:00
parent 26f29c0a12
commit a49264c29b
2 changed files with 19 additions and 1 deletions

View File

@ -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
}
}

View File

@ -394,7 +394,7 @@
<Preference android:title=" " android:selectable="false" android:summary="@string/pref_about_category" />
<PreferenceScreen android:title="@string/revanced_patches_information" android:summary="@string/revanced_patches_information_summary" >
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_tool_used" />
<Preference android:title="ReVanced Patches" android:selectable="false" android:summary="2.220.1" />
<Preference android:title="ReVanced Patches" android:selectable="false" android:summary="" />
<Preference android:title="ReVanced Integrations" android:selectable="false" android:summary="" />
<Preference android:title=" " android:selectable="false" android:summary="@string/revanced_ads" />