Draft
Conversation
marioparaschiv
requested changes
Feb 18, 2025
Member
marioparaschiv
left a comment
There was a problem hiding this comment.
Great so far! Would love to see some more error prevention and handling of possible nullish values.
|
|
||
| val themeManager = Unbound.info.classLoader.loadClass("com.discord.theme.ThemeManager") | ||
| fun hookIsThemeMethods(methodName: String, expectedType: String) { | ||
| XposedBridge.hookMethod(themeManager.getDeclaredMethod(methodName), object : XC_MethodHook() { |
Member
There was a problem hiding this comment.
Could you a predicate for error prevention here incase getDeclaredMethod doesn't return anything
| fun hookIsThemeMethods(methodName: String, expectedType: String) { | ||
| XposedBridge.hookMethod(themeManager.getDeclaredMethod(methodName), object : XC_MethodHook() { | ||
| override fun beforeHookedMethod(param: MethodHookParam) { | ||
| val buh = themeType == expectedType |
Member
There was a problem hiding this comment.
Name this variable properly
| try { | ||
| if (value != null) { | ||
| Log.d("Unbound", "[Themes] Applying semantic $key") | ||
| val implementation = theme.getDeclaredMethod(method) |
Member
There was a problem hiding this comment.
An error prevention predicate here aswell
| }) | ||
| semanticHooks.add(hook) | ||
| } else { throw IllegalArgumentException("value parsed to null.") } | ||
| } catch (e: NoSuchMethodException) { // Common as most semantic strings aren't native |
Member
There was a problem hiding this comment.
Instead of catching it's better to prevent. Throwing errors is usually very slow due to stack traces. The predicate above should prevent this from throwing in the first place.
| val getterMethod = "get" + segments.joinToString("") { it.lowercase().replaceFirstChar(Char::uppercase) } | ||
|
|
||
|
|
||
| if (obj.get("type").asString == "color") { |
Member
There was a problem hiding this comment.
Don't chain accessors on methods that might return null.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
doesnt function if you enable directly after adding | should impl https://developer.android.com/reference/android/os/FileObserver to update addons
semantic keys of type raw are unimplemented | should call ColorUtilsKt.getThemeColor to resolve it.
Certain semantic colours are not injected correctly - is determined to be a client issue so unrelated.
def needs cleanup
Tested with: https://github.com/catppuccin/vendetta/tree/feat/unbound-support/themes/unbound