@@ -82,11 +82,11 @@ object ThemePatch : ResourcePatch() {
82
82
private const val ADVANCED_DARK_COLOR = " #FF252A3A"
83
83
private const val ADVANCED_LIGHT_COLOR = " #FFF2F8FF"
84
84
85
- private const val SEEKBAR_COLOR = " #FFFF0000"
86
85
private val DarkThemeBackgroundColor by stringPatchOption(
87
86
key = " DarkThemeBackgroundColor" ,
88
87
default = AMOLED_BLACK_COLOR ,
89
88
values = mapOf (
89
+ " Advanced Dark Color" to ADVANCED_DARK_COLOR ,
90
90
" Black" to AMOLED_BLACK_COLOR ,
91
91
" Catppuccin (Mocha)" to CATPPUCCIN_MOCHA_COLOR ,
92
92
" Dark Pink" to DARK_PINK_COLOR ,
@@ -101,21 +101,11 @@ object ThemePatch : ResourcePatch() {
101
101
required = true
102
102
)
103
103
104
- private val AdvancedDarkThemeBackgroundColor by stringPatchOption(
105
- key = " AdvancedDarkThemeBackgroundColor" ,
106
- default = ADVANCED_DARK_COLOR ,
107
- values = mapOf (
108
- " Advanced Dark Color" to ADVANCED_DARK_COLOR
109
- ),
110
- title = " Advanced dark theme color" ,
111
- description = " Can be a hex color (#AARRGGBB) or a color resource reference." ,
112
- required = true
113
- )
114
-
115
104
private val LightThemeBackgroundColor by stringPatchOption(
116
105
key = " LightThemeBackgroundColor" ,
117
106
default = WHITE_COLOR ,
118
107
values = mapOf (
108
+ " Advanced Light Color" to ADVANCED_LIGHT_COLOR ,
119
109
" White" to WHITE_COLOR ,
120
110
" Catppuccin (Latte)" to CATPPUCCIN_LATTE_COLOR ,
121
111
" Light Pink" to LIGHT_PINK_COLOR ,
@@ -129,28 +119,6 @@ object ThemePatch : ResourcePatch() {
129
119
description = " Can be a hex color (#AARRGGBB) or a color resource reference." ,
130
120
)
131
121
132
- private val AdvancedLightThemeBackgroundColor by stringPatchOption(
133
- key = " AdvancedLightThemeBackgroundColor" ,
134
- default = ADVANCED_LIGHT_COLOR ,
135
- values = mapOf (
136
- " Advanced Light Color" to ADVANCED_LIGHT_COLOR
137
- ),
138
- title = " Advanced light theme color" ,
139
- description = " Can be a hex color (#AARRGGBB) or a color resource reference." ,
140
- required = true
141
- )
142
-
143
- private val SeekbarBackgroundColor by stringPatchOption(
144
- key = " SeekbarBackgroundColor" ,
145
- default = SEEKBAR_COLOR ,
146
- values = mapOf (
147
- " Seekbar Color" to SEEKBAR_COLOR
148
- ),
149
- title = " Seekbar color" ,
150
- description = " Can be a hex color (#AARRGGBB) or a color resource reference." ,
151
- required = true
152
- )
153
-
154
122
private fun getThemeString (
155
123
darkThemeColor : String ,
156
124
lightThemeColor : String
@@ -163,6 +131,7 @@ object ThemePatch : ResourcePatch() {
163
131
164
132
private fun getDarkThemeString (darkThemeColor : String ) =
165
133
when (darkThemeColor) {
134
+ ADVANCED_DARK_COLOR -> " Advanced Dark Color"
166
135
AMOLED_BLACK_COLOR -> " Black"
167
136
CATPPUCCIN_MOCHA_COLOR -> " Catppuccin (Mocha)"
168
137
DARK_PINK_COLOR -> " Dark Pink"
@@ -174,14 +143,9 @@ object ThemePatch : ResourcePatch() {
174
143
else -> " Custom"
175
144
}
176
145
177
- private fun getAdvancedDarkThemeColorString (advancedDarkThemeColor : String ) =
178
- when (advancedDarkThemeColor) {
179
- ADVANCED_DARK_COLOR -> " Advanced Dark Color"
180
- else -> " Custom"
181
- }
182
-
183
146
private fun getLightThemeString (lightThemeColor : String ) =
184
147
when (lightThemeColor) {
148
+ ADVANCED_LIGHT_COLOR -> " Advanced Light Color"
185
149
CATPPUCCIN_LATTE_COLOR -> " Catppuccin (Latte)"
186
150
LIGHT_PINK_COLOR -> " Light Pink"
187
151
LIGHT_BLUE_COLOR -> " Light Blue"
@@ -192,35 +156,14 @@ object ThemePatch : ResourcePatch() {
192
156
else -> " Custom"
193
157
}
194
158
195
- private fun getAdvancedLightThemeColorString (advancedLightThemeColor : String ) =
196
- when (advancedLightThemeColor) {
197
- ADVANCED_LIGHT_COLOR -> " Advanced Light Color"
198
- else -> " Custom"
199
- }
200
-
201
- private fun getSeekbarString (seekbarColor : String ) =
202
- when (seekbarColor) {
203
- SEEKBAR_COLOR -> " Seekbar Color"
204
- else -> " Custom"
205
- }
206
-
207
159
override fun execute (context : ResourceContext ) {
208
160
209
161
val darkThemeColor = DarkThemeBackgroundColor
210
162
? : throw PatchException (" Invalid dark color." )
211
163
212
- val advancedDarkThemeColor = AdvancedDarkThemeBackgroundColor
213
- ? : throw PatchException (" Invalid advanced dark color." )
214
-
215
164
val lightThemeColor = LightThemeBackgroundColor
216
165
? : throw PatchException (" Invalid light color." )
217
166
218
- val advancedLightThemeColor = AdvancedLightThemeBackgroundColor
219
- ? : throw PatchException (" Invalid advanced light color." )
220
-
221
- val seekbarColor = SeekbarBackgroundColor
222
- ? : throw PatchException (" Invalid seekbar color." )
223
-
224
167
arrayOf(" values" , " values-v31" ).forEach { path ->
225
168
context.xmlEditor[" res/$path /colors.xml" ].use { editor ->
226
169
val resourcesNode = editor.file.getElementsByTagName(" resources" ).item(0 ) as Element
@@ -230,8 +173,7 @@ object ThemePatch : ResourcePatch() {
230
173
231
174
node.textContent = when (node.getAttribute(" name" )) {
232
175
" yt_black0" , " yt_black1" , " yt_black1_opacity95" , " yt_black1_opacity98" , " yt_black2" , " yt_black3" ,
233
- " yt_black4" , " yt_status_bar_background_dark" , " material_grey_850" , " material_grey_900" -> darkThemeColor
234
- " yt_navy_blue" -> advancedDarkThemeColor
176
+ " yt_black4" , " yt_navy_blue" , " yt_status_bar_background_dark" , " material_grey_850" , " material_grey_900" -> darkThemeColor
235
177
236
178
else -> continue
237
179
}
@@ -247,30 +189,14 @@ object ThemePatch : ResourcePatch() {
247
189
val node = children.item(i) as ? Element ? : continue
248
190
249
191
node.textContent = when (node.getAttribute(" name" )) {
250
- " yt_white1" , " yt_white1_opacity95" , " yt_white1_opacity98" ,
192
+ " yt_pale_blue " , " yt_white1" , " yt_white1_opacity95" , " yt_white1_opacity98" ,
251
193
" yt_white2" , " yt_white3" , " yt_white4" ,
252
194
-> lightThemeColor
253
- " yt_pale_blue" -> advancedLightThemeColor
254
195
255
- else -> continue
256
- }
257
- }
258
- }
259
-
260
- context.xmlEditor[" res/values/colors.xml" ].use { editor ->
261
- val resourcesNode = editor.file.getElementsByTagName(" resources" ).item(0 ) as Element
262
-
263
- val children = resourcesNode.childNodes
264
- for (i in 0 until children.length) {
265
- val node = children.item(i) as ? Element ? : continue
266
-
267
- node.textContent = when (node.getAttribute(" name" )) {
268
- " inline_time_bar_colorized_bar_played_color_dark" -> seekbarColor
269
-
270
- else -> continue
271
- }
196
+ else -> continue
272
197
}
273
198
}
199
+ }
274
200
275
201
val currentTheme = if (isMonetPatchIncluded)
276
202
" MaterialYou " + getThemeString(darkThemeColor, lightThemeColor)
0 commit comments