diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.kt index 40025ba0c..0774efde5 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.kt +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.kt @@ -31,43 +31,47 @@ object CCGridForHyperOS { @JvmStatic fun initCCGridForHyperOS(classLoader: ClassLoader?) { - XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "setCornerRadius", Float::class.javaPrimitiveType, object : MethodHook() { - override fun before(param: MethodHookParam) { - param.args[0] = radius - } - } - ) - var warningD: Drawable? = null var enabledD: Drawable? = null var restrictedD: Drawable? = null var disabledD: Drawable? = null var unavailableD: Drawable? = null + var updateTemp1 = false + var updateTemp2 = false XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "updateIcon", "com.android.systemui.plugins.qs.QSTile\$State", Boolean::class.javaPrimitiveType, Boolean::class.javaPrimitiveType, object : MethodHook() { override fun before(param: MethodHookParam) { - val pluginContext: Context = - XposedHelpers.getObjectField(param?.thisObject, "pluginContext") as Context; - if (warningD == null) { + val param1 = param.args[1] as Boolean + val param2 = param.args[2] as Boolean + val update = (param1 && param2 && (!updateTemp1 || !updateTemp2)) + if (update) { + updateTemp1 = param1 + updateTemp2 = param2 + } + + val pluginContext: Context = XposedHelpers.getObjectField(param.thisObject, "pluginContext") as Context + + if (warningD == null || update) { val warning: Int = pluginContext.resources.getIdentifier("qs_background_warning", "drawable", "miui.systemui.plugin") warningD = pluginContext.theme.getDrawable(warning); } - if (enabledD == null) { + if (enabledD == null || update) { val enabled: Int = pluginContext.resources.getIdentifier("qs_background_enabled", "drawable", "miui.systemui.plugin") enabledD = pluginContext.theme.getDrawable(enabled); } - if (restrictedD == null) { + if (restrictedD == null || update) { val restricted: Int = pluginContext.resources.getIdentifier("qs_background_restricted", "drawable", "miui.systemui.plugin") restrictedD = pluginContext.theme.getDrawable(restricted); } - if (disabledD == null) { + if (disabledD == null || update) { val disabled: Int = pluginContext.resources.getIdentifier("qs_background_disabled", "drawable", "miui.systemui.plugin") disabledD = pluginContext.theme.getDrawable(disabled); } - if (unavailableD == null) { + if (unavailableD == null || update) { val unavailable: Int = pluginContext.resources.getIdentifier("qs_background_unavailable", "drawable", "miui.systemui.plugin") unavailableD = pluginContext.theme.getDrawable(unavailable); } + if (warningD is GradientDrawable) { (warningD as GradientDrawable).cornerRadius = radius }