mirror of
https://github.com/revanced/revanced-patches
synced 2024-12-28 18:15:48 +01:00
fix(YouTube - SponsorBlock): Fade out SB buttons without overlapping other buttons (#3719)
This commit is contained in:
parent
5e5a55f6af
commit
bf9610894f
@ -1,7 +1,6 @@
|
||||
package app.revanced.patches.youtube.misc.playercontrols
|
||||
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.PatchException
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotation.Patch
|
||||
import app.revanced.patcher.util.DomFileEditor
|
||||
@ -69,30 +68,18 @@ object PlayerControlsResourcePatch : ResourcePatch(), Closeable {
|
||||
resourceContext.xmlEditor[hostingResourceStream],
|
||||
editor,
|
||||
).use {
|
||||
val document = editor.file
|
||||
val children = document.getElementsByTagName("RelativeLayout").item(0).childNodes
|
||||
|
||||
// Replace the startOf with the voting button view so that the button does not overlap
|
||||
for (index in 1 until children.length) {
|
||||
val view = children.item(index)
|
||||
val element = editor.file.childNodes.findElementByAttributeValueOrThrow(
|
||||
"android:id",
|
||||
"@id/player_video_heading"
|
||||
)
|
||||
|
||||
// FIXME: This uses hard coded values that only works with SponsorBlock.
|
||||
// If other top buttons are added by other patches, this code must be changed.
|
||||
if (view.hasAttributes() && view.attributes.getNamedItem("android:id")
|
||||
.nodeValue.endsWith("live_chat_overlay_button")
|
||||
) {
|
||||
// voting button id from the voting button view from the youtube_controls_layout.xml host file
|
||||
val votingButtonId = "@+id/revanced_sb_voting_button"
|
||||
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue =
|
||||
votingButtonId
|
||||
|
||||
return
|
||||
element.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw PatchException("Could not find expected xml to modify")
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new controls to the bottom of the YouTube player.
|
||||
|
@ -22,7 +22,7 @@
|
||||
android:layout_alignParentTop="true"
|
||||
android:layout_marginTop="2dp"
|
||||
android:layout_marginEnd="4dp"
|
||||
android:layout_toStartOf="@+id/player_additional_view_container"
|
||||
android:layout_toStartOf="@id/music_app_deeplink_button"
|
||||
android:padding="@dimen/controls_overlay_action_button_padding"
|
||||
android:src="@drawable/revanced_sb_logo" />
|
||||
</RelativeLayout>
|
||||
|
Loading…
Reference in New Issue
Block a user