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

feat(YouTube/Overlay buttons): add patch option WiderButtonsSpace #87

Merged
merged 3 commits into from
Sep 30, 2024
Merged
Changes from 1 commit
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
Expand Up @@ -78,6 +78,15 @@ object OverlayButtonsPatch : BaseResourcePatch(
description = "Change the icons at the top of the player.",
required = true
)

// Option to choose wider between-buttons space
private val WiderButtonsSpace by booleanPatchOption(
key = "WiderButtonsSpace",
default = false,
title = "Wider between-buttons space",
description = "Prevent adjacent button presses by increasing the horizontal spacing between buttons.",
required = true
)

/**
* Main execution method for applying the patch.
Expand Down Expand Up @@ -160,11 +169,11 @@ object OverlayButtonsPatch : BaseResourcePatch(
}

// Merge XML nodes from the host to their respective XML files.
context.copyXmlNode(
"youtube/overlaybuttons/shared/host",
"layout/youtube_controls_bottom_ui_container.xml",
"android.support.constraint.ConstraintLayout"
)
context.copyXmlNode(
if (WiderButtonsSpace) "youtube/overlaybuttons/shared/host-wide" else "youtube/overlaybuttons/shared/host",
"layout/youtube_controls_bottom_ui_container.xml",
"android.support.constraint.ConstraintLayout"
)

// Modify the layout of fullscreen button for newer YouTube versions (19.09.xx+)
arrayOf(
Expand Down Expand Up @@ -198,19 +207,21 @@ object OverlayButtonsPatch : BaseResourcePatch(
)

// Adjust TimeBar and Chapter bottom padding
val timBarItem = mutableMapOf(
"@id/time_bar_chapter_title" to "16.0dip",
"@id/timestamps_container" to "14.0dip"
)
if (WiderButtonsSpace == false) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to the code when the PR was first opened, bottom margin was set only when WiderButtonsSpace was FALSE

val timBarItem = mutableMapOf(
"@id/time_bar_chapter_title" to "16.0dip",
"@id/timestamps_container" to "14.0dip"
)
}

if (isButton) {
node.setAttribute("android:layout_marginBottom", marginBottom)
node.setAttribute("android:paddingLeft", "0.0dip")
node.setAttribute("android:paddingRight", "0.0dip")
node.setAttribute("android:paddingBottom", "22.0dip")
if (heightIsNotZero && widthIsNotZero) {
node.setAttribute("android:layout_height", "48.0dip")
node.setAttribute("android:layout_width", "48.0dip")
node.setAttribute("android:layout_height", if (WiderButtonsSpace) "56.0dip" else "48.0dip")
node.setAttribute("android:layout_width", if (WiderButtonsSpace) "56.0dip" else "48.0dip")
}
} else if (timBarItem.containsKey(id)) {
node.setAttribute("android:layout_marginBottom", marginBottom)
Expand Down Expand Up @@ -259,3 +270,4 @@ object OverlayButtonsPatch : BaseResourcePatch(
SettingsPatch.updatePatchStatus(this)
}
}