mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-12 13:17:46 +02:00
feat(YouTube/Overlay buttons): add patch options WiderBottomPadding
This commit is contained in:
@ -72,6 +72,13 @@ object OverlayButtonsPatch : ResourcePatch() {
|
||||
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) {
|
||||
|
||||
/**
|
||||
@ -164,6 +171,7 @@ object OverlayButtonsPatch : ResourcePatch() {
|
||||
"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 ->
|
||||
editor.file.doRecursively loop@{
|
||||
if (it !is Element) return@loop
|
||||
@ -177,27 +185,38 @@ object OverlayButtonsPatch : ResourcePatch() {
|
||||
|
||||
// Adjust Fullscreen Button size and padding
|
||||
it.getAttributeNode("android:id")?.let { attribute ->
|
||||
if (attribute.textContent == "@id/fullscreen_button") {
|
||||
arrayOf(
|
||||
"0.0dip" to arrayOf("paddingLeft", "paddingRight"),
|
||||
"22.0dip" to arrayOf("paddingBottom"),
|
||||
"48.0dip" to arrayOf("layout_height", "layout_width")
|
||||
).forEach { (replace, attributes) ->
|
||||
attributes.forEach { name ->
|
||||
it.getAttributeNode("android:$name").textContent = replace
|
||||
arrayOf(
|
||||
"speed_dialog_button",
|
||||
"copy_video_url_button",
|
||||
"copy_video_url_timestamp_button",
|
||||
"always_repeat_button",
|
||||
"external_download_button",
|
||||
"fullscreen_button"
|
||||
).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
|
||||
arrayOf(
|
||||
"@id/time_bar_chapter_title" to "14.0dip",
|
||||
"@id/timestamps_container" to "12.0dip"
|
||||
).forEach { (id, replace) ->
|
||||
it.getAttributeNode("android:id")?.let { attribute ->
|
||||
if (attribute.textContent == id) {
|
||||
it.getAttributeNode("android:paddingBottom").textContent = replace
|
||||
if (WiderBottomPadding == false) {
|
||||
// Adjust TimeBar and Chapter bottom padding
|
||||
arrayOf(
|
||||
"@id/time_bar_chapter_title" to "14.0dip",
|
||||
"@id/timestamps_container" to "12.0dip"
|
||||
).forEach { (id, replace) ->
|
||||
it.getAttributeNode("android:id")?.let { attribute ->
|
||||
if (attribute.textContent == id) {
|
||||
it.getAttributeNode("android:paddingBottom").textContent = replace
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user