-
Notifications
You must be signed in to change notification settings - Fork 8
fix: Themes (wip) #3
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: main
Are you sure you want to change the base?
Conversation
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.
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() { |
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.
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 |
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.
Name this variable properly
try { | ||
if (value != null) { | ||
Log.d("Unbound", "[Themes] Applying semantic $key") | ||
val implementation = theme.getDeclaredMethod(method) |
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.
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 |
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.
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") { |
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.
Don't chain accessors on methods that might return null.
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