fix(YouTube - SponsorBlock): Fade out SB buttons without overlapping other buttons (#3719)

This commit is contained in:
LisoUseInAIKyrios 2024-09-29 17:13:21 -04:00 committed by GitHub
parent 5e5a55f6af
commit bf9610894f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 23 deletions

View File

@ -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,29 +68,17 @@ object PlayerControlsResourcePatch : ResourcePatch(), Closeable {
resourceContext.xmlEditor[hostingResourceStream],
editor,
).use {
val document = editor.file
val children = document.getElementsByTagName("RelativeLayout").item(0).childNodes
val element = editor.file.childNodes.findElementByAttributeValueOrThrow(
"android:id",
"@id/player_video_heading"
)
// 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)
// 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
}
}
// 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.
// voting button id from the voting button view from the youtube_controls_layout.xml host file
val votingButtonId = "@+id/revanced_sb_voting_button"
element.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId
}
throw PatchException("Could not find expected xml to modify")
}
/**

View File

@ -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>