mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube/Overlay buttons): add patch options WiderBottomPadding
This commit is contained in:
@ -72,6 +72,13 @@ object OverlayButtonsPatch : ResourcePatch() {
|
|||||||
required = true
|
required = true
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val WiderBottomPadding by booleanPatchOption(
|
||||||
|
key = "WiderBottomPadding",
|
||||||
|
default = false,
|
||||||
|
title = "Wider bottom padding",
|
||||||
|
description = "Apply wider bottom padding. Click effect may not be shown in the correct position."
|
||||||
|
)
|
||||||
|
|
||||||
override fun execute(context: ResourceContext) {
|
override fun execute(context: ResourceContext) {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -164,6 +171,7 @@ object OverlayButtonsPatch : ResourcePatch() {
|
|||||||
"android.support.constraint.ConstraintLayout"
|
"android.support.constraint.ConstraintLayout"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val bottomPadding = if (WiderBottomPadding == true) "31.0dip" else "22.0dip"
|
||||||
context.xmlEditor["res/layout/youtube_controls_bottom_ui_container.xml"].use { editor ->
|
context.xmlEditor["res/layout/youtube_controls_bottom_ui_container.xml"].use { editor ->
|
||||||
editor.file.doRecursively loop@{
|
editor.file.doRecursively loop@{
|
||||||
if (it !is Element) return@loop
|
if (it !is Element) return@loop
|
||||||
@ -177,27 +185,38 @@ object OverlayButtonsPatch : ResourcePatch() {
|
|||||||
|
|
||||||
// Adjust Fullscreen Button size and padding
|
// Adjust Fullscreen Button size and padding
|
||||||
it.getAttributeNode("android:id")?.let { attribute ->
|
it.getAttributeNode("android:id")?.let { attribute ->
|
||||||
if (attribute.textContent == "@id/fullscreen_button") {
|
arrayOf(
|
||||||
arrayOf(
|
"speed_dialog_button",
|
||||||
"0.0dip" to arrayOf("paddingLeft", "paddingRight"),
|
"copy_video_url_button",
|
||||||
"22.0dip" to arrayOf("paddingBottom"),
|
"copy_video_url_timestamp_button",
|
||||||
"48.0dip" to arrayOf("layout_height", "layout_width")
|
"always_repeat_button",
|
||||||
).forEach { (replace, attributes) ->
|
"external_download_button",
|
||||||
attributes.forEach { name ->
|
"fullscreen_button"
|
||||||
it.getAttributeNode("android:$name").textContent = replace
|
).forEach { targetId ->
|
||||||
|
if (attribute.textContent.endsWith(targetId)) {
|
||||||
|
arrayOf(
|
||||||
|
"0.0dip" to arrayOf("paddingLeft", "paddingRight"),
|
||||||
|
bottomPadding to arrayOf("paddingBottom"),
|
||||||
|
"48.0dip" to arrayOf("layout_height", "layout_width")
|
||||||
|
).forEach { (replace, attributes) ->
|
||||||
|
attributes.forEach { name ->
|
||||||
|
it.getAttributeNode("android:$name").textContent = replace
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Adjust TimeBar and Chapter bottom padding
|
if (WiderBottomPadding == false) {
|
||||||
arrayOf(
|
// Adjust TimeBar and Chapter bottom padding
|
||||||
"@id/time_bar_chapter_title" to "14.0dip",
|
arrayOf(
|
||||||
"@id/timestamps_container" to "12.0dip"
|
"@id/time_bar_chapter_title" to "14.0dip",
|
||||||
).forEach { (id, replace) ->
|
"@id/timestamps_container" to "12.0dip"
|
||||||
it.getAttributeNode("android:id")?.let { attribute ->
|
).forEach { (id, replace) ->
|
||||||
if (attribute.textContent == id) {
|
it.getAttributeNode("android:id")?.let { attribute ->
|
||||||
it.getAttributeNode("android:paddingBottom").textContent = replace
|
if (attribute.textContent == id) {
|
||||||
|
it.getAttributeNode("android:paddingBottom").textContent = replace
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user