Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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

// 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
}
}
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.
// 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")
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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