-
-
Notifications
You must be signed in to change notification settings - Fork 434
fix(Spotify): Apply accent colour in more places #5039
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Conversation
patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt
Outdated
Show resolved
Hide resolved
...ions/spotify/src/main/java/app/revanced/extension/spotify/layout/theme/CustomThemePatch.java
Outdated
Show resolved
Hide resolved
patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/CustomThemePatch.kt
Show resolved
Hide resolved
...ions/spotify/src/main/java/app/revanced/extension/spotify/layout/theme/CustomThemePatch.java
Outdated
Show resolved
Hide resolved
For future reference: If the Spotify Lottie animations always use the same theme colors for all animation files (and all usage of that color should be replaced), it's probably better to use what's here and replace the colors in the parser. But if more fine grained replacement is desired, the colors could be replaced in the Lottie animations JSON before the animation is parsed. Then some animations can be ignored and/or animation colors can be selectively replaced. ReVanced YouTube does this for the animated launch splash screen. Only the red seekbar color is replaced, but the identical red YouTube play icon in the same animation is not changed. Line 356 in b1b2b80
Line 172 in b1b2b80
|
This comment was marked as resolved.
This comment was marked as resolved.
@LisoUseInAIKyrios Interesting! I did look into patching the JSON text directly instead of during parsing, but it quickly starting getting long and complex because of the amount of files that needed to be replaced and the code associated with it. I went with doing it this way because it is far more simple and also probably more futureproof if Spotify decides to convert more of its buttons into animations. The default green accent is a pretty unique brand colour so it shouldn't affect much unintended areas. Good to know though in case we want to exclude some icons later. The technique to call obfuscated methods from extensions in there is pretty sweet. |
No, this PR only deals with accent colours for now. |
patches/src/main/kotlin/app/revanced/patches/spotify/layout/theme/Fingerprints.kt
Outdated
Show resolved
Hide resolved
Do resource colors pass through this function which converts ARGB to RGB too? If yes, then the resource patches can likely be moved to this new approach which would also caught colors we should be patching but aren't |
If all the colors can be replaced at runtime, then it opens the possibility changing the theme color in app (and not specify theme colors at patch time). But that also requires adding an in app settings menu which currently does not exist. |
Replacing at runtime also allows us to fix more hardcoded colors which are present all over the app |
Unfortunately I don't think the resource colours pass through this function at all.
The patch does intercept and replace hardcoded colours at runtime, but it's only configurable at build time for now. |
Resource colors are ARGB too, and if the app is converting hardcoded ARGB to RGB then perhaps it also does for resource colors with a different function?
Colors being configurable only at build time is fine for now |
I went digging and couldn't find anything worthwhile. I think keeping it a resource patch is fine tho. And also, it supports Material 3 dynamic colours as well since we fetch colours from resources. So I don't think there's going to be a big audience of people who like to change their accent colours super often. FWIW, Material 3 colours:
|
@@ -125,6 +126,38 @@ private val customThemeBytecodePatch = bytecodePatch { | |||
SETTINGS_HEADER_COLOR_LITERAL, | |||
backgroundColorSecondary!! | |||
) | |||
|
|||
// Hijacks a util method that removes alpha to replace hardcoded accent colors |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comments end with punctuation
// Hijacks a util method that removes alpha to replace hardcoded accent colors | |
// Hijacks a util method that removes alpha to replace hardcoded accent colors. |
addInstructions(0, """ | ||
invoke-static { p0, p1 }, $EXTENSION_CLASS_DESCRIPTOR->replaceColor(J)J | ||
move-result-wide p0 | ||
""") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be formatted like this
addInstructions(0, """ | |
invoke-static { p0, p1 }, $EXTENSION_CLASS_DESCRIPTOR->replaceColor(J)J | |
move-result-wide p0 | |
""") | |
addInstructions( | |
0, | |
""" | |
invoke-static { p0, p1 }, $EXTENSION_CLASS_DESCRIPTOR->replaceColor(J)J | |
move-result-wide p0 | |
""" | |
) |
// Lottie JSON parser method | ||
// It's a gigantic method that parses each value, including the solid color | ||
parseLottieJsonFingerprint.method.apply { | ||
val invokeIdx = indexOfFirstInstructionOrThrow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Variables names should not be shortened
val invokeIdx = indexOfFirstInstructionOrThrow { | |
val invokeIndex = indexOfFirstInstructionOrThrow { |
// It's a gigantic method that parses each value, including the solid color | ||
parseLottieJsonFingerprint.method.apply { | ||
val invokeIdx = indexOfFirstInstructionOrThrow { | ||
val ref = this.getReference<MethodReference>() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Explicit receiver not needed
val ref = this.getReference<MethodReference>() | |
val ref = getReference<MethodReference>() |
// Lottie JSON parser method | ||
// It's a gigantic method that parses each value, including the solid color | ||
parseLottieJsonFingerprint.method.apply { | ||
val invokeIdx = indexOfFirstInstructionOrThrow { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I dont remember but isnt there a helper function for this codeblock?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think for a situation like this. There is a helper for overriding constants passed into methods, but not quite this.
Apply the accent colour in more places by patching:
Lottie animations are used in places like the "add to" buttons (you can see a small animation when clicking it) and the animated waves when playing a playlist on your homepage.