fix(YouTube/Settings): some preferences are not linked correctly

This commit is contained in:
inotia00 2024-05-01 02:10:35 +09:00
parent 1b271e45d7
commit bdff8e5430

View File

@ -167,7 +167,9 @@ object SettingsPatch : BaseResourcePatch(
} }
override fun close() { override fun close() {
// Set ReVanced Patches Version
// region set ReVanced Patches Version
val jarManifest = classLoader.getResources("META-INF/MANIFEST.MF") val jarManifest = classLoader.getResources("META-INF/MANIFEST.MF")
while (jarManifest.hasMoreElements()) while (jarManifest.hasMoreElements())
contexts.updatePatchStatusSettings( contexts.updatePatchStatusSettings(
@ -177,34 +179,20 @@ object SettingsPatch : BaseResourcePatch(
.getValue("Version") + "" .getValue("Version") + ""
) )
// Endregion // endregion
// Set ReVanced Integrations Version // region set ReVanced Integrations Version
SettingsBytecodePatch.contexts.classes.forEach { classDef ->
if (classDef.sourceFile != "BuildConfig.java")
return@forEach
classDef.fields.forEach { field -> val buildConfigMutableClass = SettingsBytecodePatch.contexts.findClass { it.sourceFile == "BuildConfig.java" }!!.mutableClass
if (field.name == "VERSION_NAME") { val versionNameField = buildConfigMutableClass.fields.single { it.name == "VERSION_NAME" }
contexts.updatePatchStatusSettings( val versionName = versionNameField.initialValue.toString().trim().replace("\"","").replace(""", "")
"ReVanced Integrations",
field.initialValue.toString().trim()
)
}
}
}
contexts["res/xml/revanced_prefs.xml"].apply { contexts.updatePatchStatusSettings(
writeText( "ReVanced Integrations",
readText() versionName
.replace( )
""",
""
)
)
}
// Endregion // endregion
} }
} }