chore: migrate to new changes from the patcher

This commit is contained in:
oSumAtrIX
2022-10-05 04:13:14 +02:00
parent 3a25dc4fa2
commit 01a4349a3f
212 changed files with 513 additions and 1021 deletions
@@ -2,16 +2,12 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
// TODO: This is more of a class fingerprint than a method fingerprint.
// Convert to a class fingerprint whenever possible.
@Name("license-activity-fingerprint")
@MatchingMethod(
"Lcom/google/android/libraries/social/licenses/LicenseActivity;", "onCreate"
)
@SettingsCompatibility
@Version("0.0.1")
object LicenseActivityFingerprint : MethodFingerprint(
@@ -2,16 +2,12 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
// TODO: This is more of a class fingerprint than a method fingerprint.
// Convert to a class fingerprint whenever possible.
@Name("revanced-settings-activity-fingerprint")
@MatchingMethod(
"Lapp/revanced/integrations/settingsmenu/ReVancedSettingActivity;", "initializeSettings"
)
@SettingsCompatibility
@Version("0.0.1")
object ReVancedSettingsActivityFingerprint : MethodFingerprint(
@@ -2,7 +2,6 @@ package app.revanced.patches.youtube.misc.settings.bytecode.fingerprints
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
import app.revanced.patches.youtube.misc.settings.bytecode.patch.SettingsPatch
@@ -10,9 +9,6 @@ import org.jf.dexlib2.Opcode
import org.jf.dexlib2.iface.instruction.WideLiteralInstruction
@Name("theme-setter-fingerprint")
@MatchingMethod(
"Lfyq;", "a"
)
@SettingsCompatibility
@Version("0.0.1")
object ThemeSetterFingerprint : MethodFingerprint(
@@ -3,14 +3,14 @@ package app.revanced.patches.youtube.misc.settings.bytecode.patch
import app.revanced.patcher.annotation.Description
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.BytecodeData
import app.revanced.patcher.data.BytecodeContext
import app.revanced.patcher.extensions.addInstruction
import app.revanced.patcher.extensions.addInstructions
import app.revanced.patcher.patch.BytecodePatch
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.annotations.Patch
import app.revanced.patcher.patch.impl.BytecodePatch
import app.revanced.patcher.util.smali.toInstruction
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
@@ -40,8 +40,8 @@ import java.io.Closeable
@Version("0.0.1")
class SettingsPatch : BytecodePatch(
listOf(LicenseActivityFingerprint, ReVancedSettingsActivityFingerprint, ThemeSetterFingerprint)
), Closeable {
override fun execute(data: BytecodeData): PatchResult {
) {
override fun execute(context: BytecodeContext): PatchResult {
val licenseActivityResult = LicenseActivityFingerprint.result!!
val settingsResult = ReVancedSettingsActivityFingerprint.result!!
val themeSetterResult = ThemeSetterFingerprint.result!!
@@ -2,12 +2,12 @@ package app.revanced.patches.youtube.misc.settings.resource.patch
import app.revanced.patcher.annotation.Name
import app.revanced.patcher.annotation.Version
import app.revanced.patcher.data.impl.DomFileEditor
import app.revanced.patcher.data.impl.ResourceData
import app.revanced.patcher.data.DomFileEditor
import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchResult
import app.revanced.patcher.patch.PatchResultSuccess
import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotations.DependsOn
import app.revanced.patcher.patch.impl.ResourcePatch
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch
import app.revanced.patches.youtube.misc.mapping.patch.ResourceMappingResourcePatch
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility
@@ -18,19 +18,18 @@ import app.revanced.util.resources.ResourceUtils
import app.revanced.util.resources.ResourceUtils.copyResources
import org.w3c.dom.Element
import org.w3c.dom.Node
import java.io.Closeable
@Name("settings-resource-patch")
@SettingsCompatibility
@DependsOn([FixLocaleConfigErrorPatch::class, ResourceMappingResourcePatch::class])
@Version("0.0.1")
class SettingsResourcePatch : ResourcePatch(), Closeable {
class SettingsResourcePatch : ResourcePatch {
override fun execute(data: ResourceData): PatchResult {
override fun execute(context: ResourceContext): PatchResult {
/*
* create missing directory for the resources
*/
data["res/drawable-ldrtl-xxxhdpi"].mkdirs()
context["res/drawable-ldrtl-xxxhdpi"].mkdirs()
/*
* copy layout resources
@@ -51,10 +50,10 @@ class SettingsResourcePatch : ResourcePatch(), Closeable {
"drawable-ldrtl-xxxhdpi", "quantum_ic_arrow_back_white_24.png"
)
).forEach { resourceGroup ->
data.copyResources("settings", resourceGroup)
context.copyResources("settings", resourceGroup)
}
data.xmlEditor["AndroidManifest.xml"].use { editor ->
context.xmlEditor["AndroidManifest.xml"].use { editor ->
editor.file.getElementsByTagName("manifest").item(0).also {
it.appendChild(it.ownerDocument.createElement("uses-permission").also { element ->
element.setAttribute("android:name", "android.permission.SCHEDULE_EXACT_ALARM")
@@ -62,11 +61,11 @@ class SettingsResourcePatch : ResourcePatch(), Closeable {
}
}
revancedPreferencesEditor = data.xmlEditor["res/xml/revanced_prefs.xml"]
preferencesEditor = data.xmlEditor["res/xml/settings_fragment.xml"]
revancedPreferencesEditor = context.xmlEditor["res/xml/revanced_prefs.xml"]
preferencesEditor = context.xmlEditor["res/xml/settings_fragment.xml"]
stringsEditor = data.xmlEditor["res/values/strings.xml"]
arraysEditor = data.xmlEditor["res/values/arrays.xml"]
stringsEditor = context.xmlEditor["res/values/strings.xml"]
arraysEditor = context.xmlEditor["res/values/arrays.xml"]
// Add the ReVanced settings to the YouTube settings
val youtubePackage = "com.google.android.youtube"