fix: Use deprecated members to ensure backwards compatibility
By migrating to early to new APIs of ReVanced Patcher, if you were to use old versions of ReVanced Patcher, you would get compatibility issues. By using deprecated members until most have updated ReVanced Patcher, we can ensure seamless migration.
This commit is contained in:
@ -60,7 +60,9 @@ abstract class BaseGmsCoreSupportResourcePatch(
|
||||
appendChild(child)
|
||||
}
|
||||
|
||||
document["AndroidManifest.xml"].use { document ->
|
||||
xmlEditor["AndroidManifest.xml"].use { editor ->
|
||||
val document = editor.file
|
||||
|
||||
val applicationNode =
|
||||
document
|
||||
.getElementsByTagName("application")
|
||||
@ -92,8 +94,8 @@ abstract class BaseGmsCoreSupportResourcePatch(
|
||||
private fun ResourceContext.patchManifest() {
|
||||
val packageName = ChangePackageNamePatch.setOrGetFallbackPackageName(toPackageName)
|
||||
|
||||
val manifest = this.get("AndroidManifest.xml", false).readText()
|
||||
this.get("AndroidManifest.xml", false).writeText(
|
||||
val manifest = this.get("AndroidManifest.xml").readText()
|
||||
this.get("AndroidManifest.xml").writeText(
|
||||
manifest.replace(
|
||||
"package=\"$fromPackageName",
|
||||
"package=\"$packageName",
|
||||
|
@ -16,14 +16,16 @@ object ResourceMappingPatch : ResourcePatch() {
|
||||
|
||||
override fun execute(context: ResourceContext) {
|
||||
// save the file in memory to concurrently read from
|
||||
val resourceXmlFile = context.get("res/values/public.xml", false).readBytes()
|
||||
val resourceXmlFile = context.get("res/values/public.xml").readBytes()
|
||||
|
||||
// create a synchronized list to store the resource mappings
|
||||
val mappings = Collections.synchronizedList(mutableListOf<ResourceElement>())
|
||||
|
||||
for (threadIndex in 0 until THREAD_COUNT) {
|
||||
threadPoolExecutor.execute thread@{
|
||||
context.document[resourceXmlFile.inputStream()].use { document ->
|
||||
context.xmlEditor[resourceXmlFile.inputStream()].use { editor ->
|
||||
val document = editor.file
|
||||
|
||||
val resources = document.documentElement.childNodes
|
||||
val resourcesLength = resources.length
|
||||
val jobSize = resourcesLength / THREAD_COUNT
|
||||
|
@ -23,8 +23,8 @@ abstract class BaseSettingsResourcePatch(
|
||||
private val rootPreference: Pair<IntentPreference, String>? = null,
|
||||
dependencies: Set<PatchClass> = emptySet(),
|
||||
) : ResourcePatch(
|
||||
dependencies = setOf(AddResourcesPatch::class) + dependencies,
|
||||
),
|
||||
dependencies = setOf(AddResourcesPatch::class) + dependencies,
|
||||
),
|
||||
MutableSet<BasePreference> by mutableSetOf(),
|
||||
Closeable {
|
||||
private lateinit var context: ResourceContext
|
||||
@ -51,13 +51,17 @@ abstract class BaseSettingsResourcePatch(
|
||||
|
||||
// Add the root preference to an existing fragment if needed.
|
||||
rootPreference?.let { (intentPreference, fragment) ->
|
||||
context.document["res/xml/$fragment.xml"].use {
|
||||
it.getNode("PreferenceScreen").addPreference(intentPreference)
|
||||
context.xmlEditor["res/xml/$fragment.xml"].use { editor ->
|
||||
val document = editor.file
|
||||
|
||||
document.getNode("PreferenceScreen").addPreference(intentPreference)
|
||||
}
|
||||
}
|
||||
|
||||
// Add all preferences to the ReVanced fragment.
|
||||
context.document["res/xml/revanced_prefs.xml"].use { document ->
|
||||
context.xmlEditor["res/xml/revanced_prefs.xml"].use { editor ->
|
||||
val document = editor.file
|
||||
|
||||
val revancedPreferenceScreenNode = document.getNode("PreferenceScreen")
|
||||
forEach { revancedPreferenceScreenNode.addPreference(it) }
|
||||
}
|
||||
|
Reference in New Issue
Block a user