generated from ReVanced/revanced-patches-template
-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(youtube):
hide-player-overlay
patch (#1965)
- Loading branch information
1 parent
fcb46d5
commit d233d96
Showing
2 changed files
with
54 additions
and
0 deletions.
There are no files selected for viewing
8 changes: 8 additions & 0 deletions
8
...hes/youtube/layout/hide/player/overlay/annotations/HidePlayerOverlayPatchCompatibility.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,8 @@ | ||
package app.revanced.patches.youtube.layout.hide.player.overlay.annotations | ||
|
||
import app.revanced.patcher.annotation.Compatibility | ||
import app.revanced.patcher.annotation.Package | ||
|
||
@Compatibility([Package("com.google.android.youtube")]) | ||
@Target(AnnotationTarget.CLASS) | ||
internal annotation class HidePlayerOverlayPatchCompatibility |
46 changes: 46 additions & 0 deletions
46
...n/app/revanced/patches/youtube/layout/hide/player/overlay/patch/HidePlayerOverlayPatch.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,46 @@ | ||
package app.revanced.patches.youtube.layout.hide.player.overlay.patch | ||
|
||
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.ResourcePatch | ||
import app.revanced.patcher.patch.annotations.Patch | ||
import app.revanced.patches.youtube.layout.hide.player.overlay.annotations.HidePlayerOverlayPatchCompatibility | ||
|
||
@Patch | ||
@Name("hide-player-overlay") | ||
@Description("Hides the dark player overlay when player controls are visible.") | ||
@HidePlayerOverlayPatchCompatibility | ||
@Version("0.0.1") | ||
class HidePlayerOverlayPatch : ResourcePatch { | ||
override fun execute(context: ResourceContext): PatchResult { | ||
val attributes = arrayOf("height", "width") | ||
|
||
context.xmlEditor[RESOURCE_FILE_PATH].use { editor -> | ||
editor.file.getElementsByTagName("FrameLayout").item(0).childNodes.apply { | ||
for (i in 1 until length) { | ||
val view = item(i) | ||
if ( | ||
view.attributes.getNamedItem("android:id") | ||
?.nodeValue | ||
?.endsWith("scrim_overlay") == true | ||
) { | ||
attributes.forEach { | ||
view.attributes.getNamedItem("android:layout_$it").nodeValue = "0.0dip" | ||
} | ||
break | ||
} | ||
} | ||
} | ||
} | ||
|
||
return PatchResultSuccess() | ||
} | ||
|
||
private companion object { | ||
const val RESOURCE_FILE_PATH = "res/layout/youtube_controls_overlay.xml" | ||
} | ||
} |