mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-06-13 05:37:40 +02:00
feat(YouTube - Snack bar components): Add patch option Apply corner radius to playlist bottom bar
(#137)
* add corner radius for under player snackbar and open playlist bar * fix build error * feat: Add patch option `Apply corner radius to playlist bottom bar` --------- Co-authored-by: inotia00 <108592928+inotia00@users.noreply.github.com>
This commit is contained in:
@ -5,6 +5,7 @@ import app.revanced.patcher.extensions.InstructionExtensions.addInstructions
|
|||||||
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
import app.revanced.patcher.extensions.InstructionExtensions.addInstructionsWithLabels
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.getInstruction
|
||||||
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
import app.revanced.patcher.extensions.InstructionExtensions.replaceInstruction
|
||||||
|
import app.revanced.patcher.patch.booleanOption
|
||||||
import app.revanced.patcher.patch.bytecodePatch
|
import app.revanced.patcher.patch.bytecodePatch
|
||||||
import app.revanced.patcher.patch.resourcePatch
|
import app.revanced.patcher.patch.resourcePatch
|
||||||
import app.revanced.patcher.patch.stringOption
|
import app.revanced.patcher.patch.stringOption
|
||||||
@ -212,6 +213,14 @@ val snackBarComponentsPatch = resourcePatch(
|
|||||||
required = true,
|
required = true,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val applyCornerRadiusToPlaylistBottomBarOption by booleanOption(
|
||||||
|
key = "applyCornerRadiusToPlaylistBottomBar",
|
||||||
|
default = false,
|
||||||
|
title = "Apply corner radius to playlist bottom bar",
|
||||||
|
description = "Whether to apply the same corner radius to the bottom bar of the playlist as the snack bar.",
|
||||||
|
required = true
|
||||||
|
)
|
||||||
|
|
||||||
val darkThemeBackgroundColor = stringOption(
|
val darkThemeBackgroundColor = stringOption(
|
||||||
key = "darkThemeBackgroundColor",
|
key = "darkThemeBackgroundColor",
|
||||||
default = ytBackgroundColorDark,
|
default = ytBackgroundColorDark,
|
||||||
@ -248,6 +257,8 @@ val snackBarComponentsPatch = resourcePatch(
|
|||||||
// Check patch options first.
|
// Check patch options first.
|
||||||
val cornerRadius = cornerRadiusOption
|
val cornerRadius = cornerRadiusOption
|
||||||
.valueOrThrow()
|
.valueOrThrow()
|
||||||
|
val applyCornerRadiusToPlaylistBottomBar =
|
||||||
|
applyCornerRadiusToPlaylistBottomBarOption == true
|
||||||
val darkThemeColor = darkThemeBackgroundColor
|
val darkThemeColor = darkThemeBackgroundColor
|
||||||
.valueOrThrow()
|
.valueOrThrow()
|
||||||
val lightThemeColor = lightThemeBackgroundColor
|
val lightThemeColor = lightThemeBackgroundColor
|
||||||
@ -326,6 +337,27 @@ val snackBarComponentsPatch = resourcePatch(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
document("res/values/dimens.xml").use { document ->
|
||||||
|
val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
||||||
|
|
||||||
|
for (i in 0 until resourcesNode.childNodes.length) {
|
||||||
|
val node = resourcesNode.childNodes.item(i) as? Element ?: continue
|
||||||
|
val dimenName = node.getAttribute("name")
|
||||||
|
|
||||||
|
if (dimenName.equals("snackbar_corner_radius")) {
|
||||||
|
node.textContent = cornerRadius
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (applyCornerRadiusToPlaylistBottomBar) {
|
||||||
|
document("res/drawable/playlist_entry_point_corner_drawable.xml").use { document ->
|
||||||
|
document.getNode("corners").apply {
|
||||||
|
attributes.getNamedItem("android:radius").nodeValue = cornerRadius
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// region add settings
|
// region add settings
|
||||||
|
|
||||||
addPreference(
|
addPreference(
|
||||||
|
Reference in New Issue
Block a user