mirror of
https://github.com/inotia00/revanced-patches.git
synced 2025-05-02 15:44:37 +02:00
feat(youtube/custom-seekbar-color): remove patch options, integrate into settings
This commit is contained in:
parent
3b6848ab1a
commit
c833cc3fdf
@ -1,11 +1,13 @@
|
||||
package app.revanced.patches.youtube.layout.seekbar.seekbarcolor.resource.patch
|
||||
|
||||
import app.revanced.extensions.doRecursively
|
||||
import app.revanced.patcher.annotation.Description
|
||||
import app.revanced.patcher.annotation.Name
|
||||
import app.revanced.patcher.annotation.Version
|
||||
import app.revanced.patcher.data.ResourceContext
|
||||
import app.revanced.patcher.patch.*
|
||||
import app.revanced.patcher.patch.PatchResult
|
||||
import app.revanced.patcher.patch.PatchResultError
|
||||
import app.revanced.patcher.patch.PatchResultSuccess
|
||||
import app.revanced.patcher.patch.ResourcePatch
|
||||
import app.revanced.patcher.patch.annotations.DependsOn
|
||||
import app.revanced.patcher.patch.annotations.Patch
|
||||
import app.revanced.patches.shared.annotation.YouTubeCompatibility
|
||||
@ -28,19 +30,19 @@ class ThemePatch : ResourcePatch {
|
||||
override fun execute(context: ResourceContext): PatchResult {
|
||||
|
||||
context.xmlEditor["res/drawable/resume_playback_progressbar_drawable.xml"].use {
|
||||
it.file.doRecursively {
|
||||
arrayOf("color").forEach replacement@{ replacement ->
|
||||
if (it !is Element) return@replacement
|
||||
|
||||
it.getAttributeNode("android:$replacement")?.let { attribute ->
|
||||
if (attribute.textContent.startsWith("@color/"))
|
||||
attribute.textContent = resumedProgressBarColor
|
||||
}
|
||||
}
|
||||
val layerList = it.file.getElementsByTagName("layer-list").item(0) as Element
|
||||
val progressNode = layerList.getElementsByTagName("item").item(1) as Element
|
||||
if (!progressNode.getAttributeNode("android:id").value.endsWith("progress")) {
|
||||
return PatchResultError("Could not find progress bar")
|
||||
}
|
||||
val scaleNode = progressNode.getElementsByTagName("scale").item(0) as Element
|
||||
val shapeNode = scaleNode.getElementsByTagName("shape").item(0) as Element
|
||||
val replacementNode = it.file.createElement(
|
||||
"app.revanced.integrations.patches.utils.ProgressBarDrawable")
|
||||
scaleNode.replaceChild(replacementNode, shapeNode)
|
||||
}
|
||||
|
||||
/*
|
||||
/**
|
||||
* Add settings
|
||||
*/
|
||||
SettingsPatch.addPreference(
|
||||
@ -54,15 +56,4 @@ class ThemePatch : ResourcePatch {
|
||||
|
||||
return PatchResultSuccess()
|
||||
}
|
||||
|
||||
companion object : OptionsContainer() {
|
||||
var resumedProgressBarColor: String? by option(
|
||||
PatchOption.StringOption(
|
||||
key = "resumedProgressBarColor",
|
||||
default = "#ffff0000",
|
||||
title = "Resumed progressbar color",
|
||||
description = "Resumed progressbar color in playlists and history. Can be a hex color or a resource reference."
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user