1818 */
1919package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter
2020
21- import android.content.*
22- import android.graphics.drawable.*
23- import android.view.*
24- import com.sevtinge.hyperceiler.module.base.tool.HookTool.*
21+ import android.graphics.drawable.Drawable
22+ import android.graphics.drawable.GradientDrawable
2523import com.sevtinge.hyperceiler.utils.prefs.*
2624import de.robv.android.xposed.*
2725
26+ // from YunZiA
2827object CCGridForHyperOSKt {
2928 private val radius by lazy {
3029 PrefsUtils .mPrefsMap.getInt(" system_ui_control_center_rounded_rect_radius" , 72 ).toFloat() }
3130
3231 @JvmStatic
3332 fun initCCGridForHyperOS (classLoader : ClassLoader ? ) {
34- var warningD: Drawable ? = null
35- var enabledD: Drawable ? = null
36- var restrictedD: Drawable ? = null
37- var disabledD: Drawable ? = null
38- var unavailableD: Drawable ? = null
39- var configuration = 0
40- var orientation: Int
41-
42- 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 () {
43- override fun before (param : MethodHookParam ) {
44- orientation = (param.thisObject as View ).context.resources.configuration.orientation
45- val stackTrace = Thread .currentThread().stackTrace
46- val targetMethods = setOf (
47- " miui.systemui.controlcenter.qs.tileview.QSTileItemView.updateState" ,
48- " miui.systemui.controlcenter.panel.main.recyclerview.MainPanelItemViewHolder.onSuperSaveModeChanged" ,
49- " miui.systemui.controlcenter.qs.tileview.QSTileItemView.updateCustomizeState" ,
50- " miui.systemui.controlcenter.qs.tileview.QSTileItemView.onModeChanged"
51- )
52-
53- val isMethodFound = stackTrace.any { element ->
54- " ${element.className} .${element.methodName} " in targetMethods
55- }
56-
57- if (configuration == orientation && isMethodFound) return
58-
59- val pluginContext: Context = XposedHelpers .getObjectField(param.thisObject, " pluginContext" ) as Context
60-
61- val warning: Int = pluginContext.resources.getIdentifier(" qs_background_warning" , " drawable" , " miui.systemui.plugin" )
62- val enabled: Int = pluginContext.resources.getIdentifier(" qs_background_enabled" , " drawable" , " miui.systemui.plugin" )
63- val restricted: Int = pluginContext.resources.getIdentifier(" qs_background_restricted" , " drawable" , " miui.systemui.plugin" )
64- val disabled: Int = pluginContext.resources.getIdentifier(" qs_background_disabled" , " drawable" , " miui.systemui.plugin" )
65- val unavailable: Int = pluginContext.resources.getIdentifier(" qs_background_unavailable" , " drawable" , " miui.systemui.plugin" )
66- warningD = pluginContext.theme.getDrawable(warning)
67- enabledD = pluginContext.theme.getDrawable(enabled)
68- restrictedD = pluginContext.theme.getDrawable(restricted)
69- disabledD = pluginContext.theme.getDrawable(disabled)
70- unavailableD = pluginContext.theme.getDrawable(unavailable)
71-
72- if (warningD is GradientDrawable ) {
73- (warningD as GradientDrawable ).cornerRadius = radius
74- }
75- if (enabledD is GradientDrawable ) {
76- (enabledD as GradientDrawable ).cornerRadius = radius
77- }
78- if (restrictedD is GradientDrawable ) {
79- (restrictedD as GradientDrawable ).cornerRadius = radius
80- }
81- if (disabledD is GradientDrawable ) {
82- (disabledD as GradientDrawable ).cornerRadius = radius
83- }
84- if (unavailableD is GradientDrawable ) {
85- (unavailableD as GradientDrawable ).cornerRadius = radius
33+ XposedHelpers .findAndHookMethod(" miui.systemui.controlcenter.qs.tileview.QSTileItemIconView" , classLoader, " getActiveBackgroundDrawable" , " com.android.systemui.plugins.qs.QSTile\$ State" , object : XC_MethodHook (){
34+ override fun afterHookedMethod (param : MethodHookParam ? ) {
35+ super .afterHookedMethod(param)
36+ val drawable = param?.result as Drawable
37+ if (drawable is GradientDrawable ) drawable.cornerRadius = radius
38+ param.result = drawable
39+ }
40+ })
41+ XposedHelpers .findAndHookMethod(" miui.systemui.controlcenter.qs.tileview.QSTileItemIconView" , classLoader, " getDisabledBackgroundDrawable" , " com.android.systemui.plugins.qs.QSTile\$ State" , object : XC_MethodHook (){
42+ override fun afterHookedMethod (param : MethodHookParam ? ) {
43+ super .afterHookedMethod(param)
44+ val drawable = param?.result as Drawable
45+ if (drawable is GradientDrawable ) drawable.cornerRadius = radius
46+ param.result = drawable
47+ }
48+ })
49+ XposedHelpers .findAndHookMethod(" miui.systemui.controlcenter.qs.tileview.QSTileItemIconView" , classLoader, " getBackgroundDrawable" , " com.android.systemui.plugins.qs.QSTile\$ State" , object : XC_MethodHook (){
50+ override fun afterHookedMethod (param : MethodHookParam ? ) {
51+ super .afterHookedMethod(param)
52+ val state = param?.args?.get(0 )
53+ val i = XposedHelpers .getIntField(state, " state" )
54+ if (i == 0 ) {
55+ val drawable = param?.result as Drawable
56+ if (drawable is GradientDrawable ) drawable.cornerRadius = radius
57+ param.result = drawable
8658 }
87-
88- configuration = orientation
8959 }
90- }
91- )
60+ })
9261 }
9362}
0 commit comments