From 5f4ee23fb83f339a6cab0d71fc33f79fa9c2e521 Mon Sep 17 00:00:00 2001 From: Sohan Ali Date: Tue, 23 Jun 2026 04:34:32 +0000 Subject: [PATCH] fix(theme): restrict AMOLED overrides to dark theme Prevent AMOLED color replacements from being applied when the app is using a light theme, avoiding unreadable black text on black backgrounds after theme switches. --- app/src/main/java/com/keyflux/ThemeHooker.kt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/src/main/java/com/keyflux/ThemeHooker.kt b/app/src/main/java/com/keyflux/ThemeHooker.kt index 767ffa3..b64a9d6 100644 --- a/app/src/main/java/com/keyflux/ThemeHooker.kt +++ b/app/src/main/java/com/keyflux/ThemeHooker.kt @@ -1,5 +1,6 @@ package com.keyflux +import android.content.res.Configuration import android.content.res.Resources import android.content.res.TypedArray import de.robv.android.xposed.XC_MethodHook @@ -21,6 +22,8 @@ object ThemeHooker { override fun afterHookedMethod(param: MethodHookParam) { if (!enableAmoled) return val res = param.thisObject as? Resources ?: return + val isDarkMode = (res.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES + if (!isDarkMode) return val id = param.args[0] as Int val result = param.result as Int overrideColor(res, id, result)?.let { param.result = it } @@ -40,6 +43,8 @@ object ThemeHooker { override fun afterHookedMethod(param: MethodHookParam) { if (!enableAmoled) return val res = param.thisObject as? Resources ?: return + val isDarkMode = (res.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES + if (!isDarkMode) return val id = param.args[0] as Int val result = param.result as Int overrideColor(res, id, result)?.let { param.result = it } @@ -64,6 +69,8 @@ object ThemeHooker { val colorId = typedArray.getResourceId(index, 0) if (colorId != 0) { val res = typedArray.resources ?: return + val isDarkMode = (res.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) == Configuration.UI_MODE_NIGHT_YES + if (!isDarkMode) return overrideColor(res, colorId, result)?.let { param.result = it } } }