generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
646 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
...in/kotlin/app/revanced/patches/youtube/misc/settings/annotations/SettingsCompatibility.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package app.revanced.patches.youtube.misc.settings.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[Package( | ||
"com.google.android.youtube", arrayOf() | ||
)] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class SettingsCompatibility |
28 changes: 28 additions & 0 deletions
28
...evanced/patches/youtube/misc/settings/bytecode/fingerprints/LicenseActivityFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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.FuzzyPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility | ||
|
||
// 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" | ||
) | ||
@FuzzyPatternScanMethod(2) | ||
@ReturnYouTubeDislikeCompatibility | ||
@Version("0.0.2") | ||
object LicenseActivityFingerprint : MethodFingerprint( | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
{ methodDef -> | ||
methodDef.definingClass.endsWith("LicenseActivity;") && methodDef.name == "onCreate" | ||
} | ||
) |
28 changes: 28 additions & 0 deletions
28
...atches/youtube/misc/settings/bytecode/fingerprints/ReVancedSettingsActivityFingerprint.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
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.FuzzyPatternScanMethod | ||
import app.revanced.patcher.fingerprint.method.annotation.MatchingMethod | ||
import app.revanced.patcher.fingerprint.method.impl.MethodFingerprint | ||
import app.revanced.patches.youtube.layout.returnyoutubedislike.annotations.ReturnYouTubeDislikeCompatibility | ||
|
||
// 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" | ||
) | ||
@FuzzyPatternScanMethod(2) | ||
@ReturnYouTubeDislikeCompatibility | ||
@Version("0.0.2") | ||
object ReVancedSettingsActivityFingerprint : MethodFingerprint( | ||
null, | ||
null, | ||
null, | ||
null, | ||
null, | ||
{ methodDef -> | ||
methodDef.definingClass.endsWith("ReVancedSettingActivity;") && methodDef.name == "initializeSettings" | ||
} | ||
) |
56 changes: 56 additions & 0 deletions
56
src/main/kotlin/app/revanced/patches/youtube/misc/settings/bytecode/patch/SettingsPatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
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.extensions.addInstruction | ||
import app.revanced.patcher.extensions.addInstructions | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Dependencies | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patcher.patch.impl.BytecodePatch | ||
import app.revanced.patches.youtube.misc.integrations.patch.IntegrationsPatch | ||
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility | ||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.LicenseActivityFingerprint | ||
import app.revanced.patches.youtube.misc.settings.bytecode.fingerprints.ReVancedSettingsActivityFingerprint | ||
import app.revanced.patches.youtube.misc.settings.resource.patch.SettingsResourcePatch | ||
|
||
@Patch | ||
@Dependencies([IntegrationsPatch::class, SettingsResourcePatch::class]) | ||
@Name("settings") | ||
@Description("Adds settings for ReVanced to YouTube.") | ||
@SettingsCompatibility | ||
@Version("0.0.1") | ||
class SettingsPatch : BytecodePatch( | ||
listOf(LicenseActivityFingerprint, ReVancedSettingsActivityFingerprint) | ||
) { | ||
override fun execute(data: BytecodeData): PatchResult { | ||
val licenseActivityResult = LicenseActivityFingerprint.result!! | ||
val settingsResult = ReVancedSettingsActivityFingerprint.result!! | ||
|
||
val licenseActivityClass = licenseActivityResult.mutableClass | ||
val settingsClass = settingsResult.mutableClass | ||
|
||
val onCreate = licenseActivityResult.mutableMethod | ||
val setThemeMethodName = "setTheme" | ||
val initializeSettings = settingsResult.mutableMethod | ||
|
||
// First add the setTheme call to the onCreate method to not affect the offsets. | ||
onCreate.addInstructions( | ||
1, | ||
""" | ||
invoke-static { p0 }, ${settingsClass.type}->${initializeSettings.name}(${licenseActivityClass.type})V | ||
return-void | ||
""" | ||
) | ||
|
||
// Add the initializeSettings call to the onCreate method. | ||
onCreate.addInstruction( | ||
0, | ||
"invoke-static { p0 }, ${settingsClass.type}->$setThemeMethodName(${licenseActivityClass.type})V" | ||
) | ||
return PatchResultSuccess() | ||
} | ||
} |
60 changes: 60 additions & 0 deletions
60
...kotlin/app/revanced/patches/youtube/misc/settings/resource/patch/SettingsResourcePatch.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
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.ResourceData | ||
import app.revanced.patcher.patch.PatchResult | ||
import app.revanced.patcher.patch.PatchResultSuccess | ||
import app.revanced.patcher.patch.annotations.Dependencies | ||
import app.revanced.patcher.patch.impl.ResourcePatch | ||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch | ||
import app.revanced.patches.youtube.misc.settings.annotations.SettingsCompatibility | ||
import app.revanced.util.resources.ResourceUtils | ||
import app.revanced.util.resources.ResourceUtils.copyResources | ||
import app.revanced.util.resources.ResourceUtils.copyXmlNode | ||
|
||
@Name("settings-resource-patch") | ||
@SettingsCompatibility | ||
@Dependencies([FixLocaleConfigErrorPatch::class]) | ||
@Version("0.0.1") | ||
class SettingsResourcePatch : ResourcePatch() { | ||
override fun execute(data: ResourceData): PatchResult { | ||
/* | ||
* Copy strings | ||
*/ | ||
|
||
data.copyXmlNode("settings/host", "values/strings.xml", "resources") | ||
|
||
/* | ||
* Copy arrays | ||
*/ | ||
|
||
data.copyXmlNode("settings/host", "values/arrays.xml", "resources") | ||
|
||
/* | ||
* Copy preference fragments | ||
*/ | ||
|
||
data.copyXmlNode("settings/host", "xml/settings_fragment.xml", "PreferenceScreen") | ||
|
||
/* | ||
* Copy layout resources | ||
*/ | ||
arrayOf( | ||
ResourceUtils.ResourceGroup( | ||
"layout", | ||
"xsettings_toolbar.xml", | ||
"xsettings_with_toolbar.xml", | ||
"xsettings_with_toolbar_layout.xml" | ||
), | ||
ResourceUtils.ResourceGroup( | ||
"xml", | ||
"revanced_prefs.xml" | ||
) | ||
).forEach { resourceGroup -> | ||
data.copyResources("settings", resourceGroup) | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<resources> | ||
<string-array name="revanced_button_location_entries"> | ||
<item>@string/revanced_button_location_entry_none</item> | ||
<item>@string/revanced_button_location_entry_player</item> | ||
<item>@string/revanced_button_location_entry_buttoncontainer</item> | ||
<item>@string/revanced_button_location_entry_both</item> | ||
</string-array> | ||
<string-array name="revanced_button_location_entry_values"> | ||
<item>NONE</item> | ||
<item>PLAYER</item> | ||
<item>BUTTON_CONTAINER</item> | ||
<item>BOTH</item> | ||
</string-array> | ||
</resources> |
Oops, something went wrong.