generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 211
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(youtube):
remove-player-button-background
patch (#855)
Co-authored-by: oSumAtrIX <johan.melkonyan1@web.de>
- Loading branch information
1 parent
4416a85
commit fa9c291
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
12 changes: 12 additions & 0 deletions
12
.../youtube/layout/playerbuttonbackground/annotations/PlayerButtonBackgroundCompatibility.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,12 @@ | ||
package app.revanced.patches.youtube.layout.playerbuttonbackground.annotations | ||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility( | ||
[ | ||
Package("com.google.android.youtube", arrayOf("17.34.36","17.36.37", "17.36.39", "17.38.36", "17.39.35", "17.40.41", "17.42.35", "17.43.36", "17.45.36")) | ||
] | ||
) | ||
@Target(AnnotationTarget.CLASS) | ||
@Retention(AnnotationRetention.RUNTIME) | ||
internal annotation class PlayerButtonBackgroundCompatibility |
41 changes: 41 additions & 0 deletions
41
...vanced/patches/youtube/layout/playerbuttonbackground/patch/PlayerButtonBackgroundPatch.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,41 @@ | ||
package app.revanced.patches.youtube.layout.playerbuttonbackground.patch | ||
|
||
import app.revanced.extensions.doRecursively | ||
import app.revanced.patcher.annotation.Description | ||
import app.revanced.patcher.annotation.Name | ||
import app.revanced.patcher.annotation.Version | ||
import app.revanced.patcher.data.ResourceContext | ||
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.ResourcePatch | ||
import app.revanced.patches.youtube.layout.playerbuttonbackground.annotations.PlayerButtonBackgroundCompatibility | ||
import app.revanced.patches.youtube.misc.manifest.patch.FixLocaleConfigErrorPatch | ||
import org.w3c.dom.Element | ||
|
||
@Patch | ||
@DependsOn([FixLocaleConfigErrorPatch::class]) | ||
@Name("remove-player-button-background") | ||
@Description("Removes the background from the video player buttons.") | ||
@PlayerButtonBackgroundCompatibility | ||
@Version("0.0.1") | ||
class PlayerButtonBackgroundPatch : ResourcePatch { | ||
private companion object { | ||
const val RESOURCE_FILE_PATH = "res/drawable/player_button_circle_background.xml" | ||
} | ||
|
||
override fun execute(context: ResourceContext): PatchResult { | ||
context.xmlEditor[RESOURCE_FILE_PATH].use { editor -> | ||
editor.file.doRecursively node@{ node -> | ||
if (node !is Element) return@node | ||
|
||
node.getAttributeNode("android:color")?.let { attribute -> | ||
attribute.textContent = "@android:color/transparent" | ||
} | ||
} | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
} |