|
1 |
| -@file:Suppress("NAME_SHADOWING") |
2 |
| - |
3 | 1 | package app.revanced.patches.spotify.layout.theme
|
4 | 2 |
|
5 | 3 | import app.revanced.patcher.patch.resourcePatch
|
6 |
| -import app.revanced.patcher.patch.stringOption |
7 | 4 | import org.w3c.dom.Element
|
8 | 5 |
|
9 | 6 | @Suppress("unused")
|
10 | 7 | val customThemePatch = resourcePatch(
|
11 | 8 | name = "Custom theme",
|
12 |
| - description = "Applies a custom theme.", |
| 9 | + description = "Applies a custom theme (defaults to amoled black)", |
13 | 10 | use = false,
|
14 | 11 | ) {
|
15 | 12 | compatibleWith("com.spotify.music")
|
16 | 13 |
|
17 |
| - val backgroundColor by stringOption( |
18 |
| - key = "backgroundColor", |
19 |
| - default = "@android:color/black", |
20 |
| - title = "Primary background color", |
21 |
| - description = "The background color. Can be a hex color or a resource reference.", |
22 |
| - required = true, |
23 |
| - ) |
24 |
| - |
25 |
| - val backgroundColorSecondary by stringOption( |
26 |
| - key = "backgroundColorSecondary", |
27 |
| - default = "#ff282828", |
28 |
| - title = "Secondary background color", |
29 |
| - description = "The secondary background color. (e.g. search box, artist & podcast). Can be a hex color or a resource reference.", |
30 |
| - required = true, |
31 |
| - ) |
32 |
| - |
33 |
| - val accentColor by stringOption( |
34 |
| - key = "accentColor", |
35 |
| - default = "#ff1ed760", |
36 |
| - title = "Accent color", |
37 |
| - description = "The accent color ('Spotify green' by default). Can be a hex color or a resource reference.", |
38 |
| - required = true, |
39 |
| - ) |
| 14 | + dependsOn(customThemeByteCodePatch) |
40 | 15 |
|
41 |
| - val accentColorPressed by stringOption( |
42 |
| - key = "accentColorPressed", |
43 |
| - default = "#ff169c46", |
44 |
| - title = "Pressed dark theme accent color", |
45 |
| - description = |
46 |
| - "The color when accented buttons are pressed, by default slightly darker than accent. " + |
47 |
| - "Can be a hex color or a resource reference.", |
48 |
| - required = true, |
49 |
| - ) |
| 16 | + val backgroundColor by spotifyBackgroundColor() |
| 17 | + val backgroundColorSecondary by spotifyBackgroundColorSecondary() |
| 18 | + val accentColor by spotifyAccentColor() |
| 19 | + val accentColorPressed by spotifyAccentColorPressed() |
50 | 20 |
|
51 | 21 | execute {
|
52 |
| - val backgroundColor = backgroundColor!! |
53 |
| - val backgroundColorSecondary = backgroundColorSecondary!! |
54 |
| - val accentColor = accentColor!! |
55 |
| - val accentColorPressed = accentColorPressed!! |
56 |
| - |
57 | 22 | document("res/values/colors.xml").use { document ->
|
58 | 23 | val resourcesNode = document.getElementsByTagName("resources").item(0) as Element
|
59 | 24 |
|
60 | 25 | val childNodes = resourcesNode.childNodes
|
61 | 26 | for (i in 0 until childNodes.length) {
|
62 | 27 | val node = childNodes.item(i) as? Element ?: continue
|
63 | 28 |
|
64 |
| - node.textContent = |
65 |
| - when (node.getAttribute("name")) { |
66 |
| - "dark_base_background_elevated_base", "design_dark_default_color_background", |
67 |
| - "design_dark_default_color_surface", "gray_7", "gray_background", "gray_layer", |
68 |
| - "sthlm_blk", |
| 29 | + node.textContent = when (node.getAttribute("name")) { |
| 30 | + // Gradient next to user photo and "All" in home page |
| 31 | + "dark_base_background_base", |
| 32 | + // Main background |
| 33 | + "gray_7", |
| 34 | + // Left sidebar background in tablet mode |
| 35 | + "gray_10", |
| 36 | + // Add account, Settings and privacy, View Profile left sidebar background |
| 37 | + "dark_base_background_elevated_base", |
| 38 | + // Song/player background |
| 39 | + "bg_gradient_start_color", "bg_gradient_end_color", |
| 40 | + // Login screen |
| 41 | + "sthlm_blk", "sthlm_blk_grad_start", "stockholm_black", |
| 42 | + // Misc |
| 43 | + "image_placeholder_color", |
69 | 44 | -> backgroundColor
|
70 | 45 |
|
71 |
| - "gray_15" -> backgroundColorSecondary |
72 |
| - |
73 |
| - "dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor |
74 |
| - |
75 |
| - "dark_brightaccent_background_press" -> accentColorPressed |
76 |
| - else -> continue |
77 |
| - } |
| 46 | + // Track credits, merch in song player |
| 47 | + "track_credits_card_bg", "benefit_list_default_color", "merch_card_background", |
| 48 | + // Playlist list background in home page |
| 49 | + "opacity_white_10", |
| 50 | + // About artist background in song player |
| 51 | + "gray_15", |
| 52 | + // What's New pills background |
| 53 | + "dark_base_background_tinted_highlight" |
| 54 | + -> backgroundColorSecondary |
| 55 | + |
| 56 | + "dark_brightaccent_background_base", "dark_base_text_brightaccent", "green_light" -> accentColor |
| 57 | + "dark_brightaccent_background_press" -> accentColorPressed |
| 58 | + else -> continue |
| 59 | + } |
78 | 60 | }
|
79 | 61 | }
|
80 | 62 | }
|
|
0 commit comments