Skip to content

Conversation

Covkie
Copy link
Contributor

@Covkie Covkie commented Feb 2, 2025

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

Copy link
Member

@marioparaschiv marioparaschiv left a 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() {
Copy link
Member

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
Copy link
Member

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)
Copy link
Member

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
Copy link
Member

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") {
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants