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 package app.revanced.patches.youtube.misc.playercontrols
import app.revanced.patcher.data.ResourceContext import app.revanced.patcher.data.ResourceContext
import app.revanced.patcher.patch.PatchException
import app.revanced.patcher.patch.ResourcePatch import app.revanced.patcher.patch.ResourcePatch
import app.revanced.patcher.patch.annotation.Patch import app.revanced.patcher.patch.annotation.Patch
import app.revanced.patcher.util.DomFileEditor import app.revanced.patcher.util.DomFileEditor
@ -69,30 +68,18 @@ object PlayerControlsResourcePatch : ResourcePatch(), Closeable {
resourceContext.xmlEditor[hostingResourceStream], resourceContext.xmlEditor[hostingResourceStream],
editor, editor,
).use { ).use {
val document = editor.file val element = editor.file.childNodes.findElementByAttributeValueOrThrow(
val children = document.getElementsByTagName("RelativeLayout").item(0).childNodes "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. // 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 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 // voting button id from the voting button view from the youtube_controls_layout.xml host file
val votingButtonId = "@+id/revanced_sb_voting_button" val votingButtonId = "@+id/revanced_sb_voting_button"
view.attributes.getNamedItem("android:layout_toStartOf").nodeValue = element.attributes.getNamedItem("android:layout_toStartOf").nodeValue = votingButtonId
votingButtonId
return
} }
} }
}
throw PatchException("Could not find expected xml to modify")
}
/** /**
* Add new controls to the bottom of the YouTube player. * Add new controls to the bottom of the YouTube player.

View File

@ -22,7 +22,7 @@
android:layout_alignParentTop="true" android:layout_alignParentTop="true"
android:layout_marginTop="2dp" android:layout_marginTop="2dp"
android:layout_marginEnd="4dp" 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:padding="@dimen/controls_overlay_action_button_padding"
android:src="@drawable/revanced_sb_logo" /> android:src="@drawable/revanced_sb_logo" />
</RelativeLayout> </RelativeLayout>