Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/java/com/keyflux/ThemeHooker.kt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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 }
Expand All @@ -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 }
Expand All @@ -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 }
}
}
Expand Down