Skip to content

Commit a4691a7

Browse files
committed
fix: focus notif bg color on B
1 parent a2569a3 commit a4691a7

2 files changed

Lines changed: 148 additions & 48 deletions

File tree

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/app/SystemUI/Phone/SystemUIB.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.GmsTile;
4141
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.MuteVisibleNotifications;
4242
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.NewFlashLight;
43+
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.NotificationColor;
4344
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.NotificationImportanceHyperOSFix;
4445
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.NotificationWeather;
4546
import com.sevtinge.hyperceiler.hook.module.rules.systemui.controlcenter.OldWeather;
@@ -192,6 +193,7 @@ public void handleLoadPackage() {
192193
initHook(new DisableTransparent(), mPrefsMap.getBoolean("system_ui_control_center_notification_disable_transparent"));
193194
initHook(ControlCenterStyle.INSTANCE, mPrefsMap.getBoolean("system_control_center_unlock_old"));
194195
initHook(CustomCarrierText.INSTANCE, mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) != 0);
196+
initHook(new NotificationColor(), mPrefsMap.getBoolean("system_ui_control_center_opt_notification_element_background_color"));
195197

196198
// 磁贴
197199
initHook(new AutoCollapse(), mPrefsMap.getBoolean("system_ui_control_auto_close"));

library/hook/src/main/java/com/sevtinge/hyperceiler/hook/module/rules/systemui/plugin/systemui/FlashLightNotificationColor.kt

Lines changed: 146 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,67 +22,165 @@ import android.content.Context
2222
import android.content.Intent
2323

2424
import com.sevtinge.hyperceiler.hook.module.base.BaseHook
25+
import com.sevtinge.hyperceiler.hook.module.base.tool.AppsTool.getPackageVersionCode
2526
import com.sevtinge.hyperceiler.hook.utils.extension.getString
2627
import com.sevtinge.hyperceiler.hook.utils.getObjectField
2728
import io.github.kyuubiran.ezxhelper.core.finder.MethodFinder.`-Static`.methodFinder
29+
import io.github.kyuubiran.ezxhelper.core.misc.params
2830
import io.github.kyuubiran.ezxhelper.core.util.ClassUtil.loadClass
2931
import io.github.kyuubiran.ezxhelper.xposed.dsl.HookFactory.`-Static`.createHook
3032
import org.json.JSONArray
3133
import org.json.JSONObject
3234

3335
object FlashLightNotificationColor : BaseHook() {
3436
override fun init() {
35-
loadClass("miui.systemui.flashlight.MiFlashlightManager").methodFinder()
36-
.filterByName("getExtraMiuiFocusParam")
37-
.single().createHook {
38-
after {
39-
val mContext = it.thisObject.getObjectField("context") as Context
40-
val stringTitle = mContext.getString("flashlight_notification_content_title")
41-
val stringText = mContext.getString("flashlight_notification_content_text")
42-
val button = mContext.getString("flashlight_notification_button")
43-
val intent = Intent("miui.systemui.action.ACTION_CLOSE_FLASHLIGHT").apply {
44-
setPackage("miui.systemui.plugin")
45-
}
46-
val uri = intent.toUri(Intent.URI_INTENT_SCHEME)
47-
48-
val paramV2Obj = JSONObject().apply {
49-
put("protocol", 1)
50-
put("ticker", stringText)
51-
put("tickerPic", "miui.focus.pic_ticker_pic")
52-
put("tickerPicDark", "miui.focus.pic_ticker_pic")
53-
put("aodTitle", stringText)
54-
put("aodPic", "miui.focus.pic_ado_pic")
55-
put("scene", "template_v2")
56-
put("enableFloat", true)
57-
put("updatable", true)
58-
put("reopen", "reopen")
59-
put("baseInfo", JSONObject().apply {
60-
put("title", stringTitle)
61-
put("colorTitle", "")
62-
put("content", stringText)
63-
put("colorContent", "")
64-
put("subContent", "")
65-
put("colorSubContent", "")
66-
put("type", 2)
67-
})
68-
put("bgInfo", JSONObject().apply {
69-
put("colorBg", "")
70-
})
71-
put("actions", JSONArray().apply {
72-
put(JSONObject().apply {
73-
put("actionTitle", button)
74-
put("actionIntentType", 2)
75-
put("actionIntent", uri)
76-
put("actionIcon", "miui.focus.pic_mark_v2")
37+
if (getPackageVersionCode(lpparam) >= 170000000) {
38+
loadClass("miui.systemui.flashlight.NotificationManager").methodFinder()
39+
.filterByName("getExtraMiuiFocusParam")
40+
.single().createHook {
41+
before {
42+
val mContext = it.args[0] as Context
43+
val stringTitle = mContext.getString("flashlight_notification_content_title")
44+
val stringText = mContext.getString("flashlight_notification_content_text")
45+
val button = mContext.getString("flashlight_notification_button")
46+
val intent = Intent("miui.systemui.action.ACTION_CLOSE_FLASHLIGHT").apply {
47+
setPackage("miui.systemui.plugin")
48+
}
49+
val uri = intent.toUri(Intent.URI_INTENT_SCHEME)
50+
51+
val paramV2Obj = JSONObject().apply {
52+
put("protocol", 1)
53+
put("business", "miui_flashlight")
54+
put("ticker", stringText)
55+
put("tickerPic", "miui.focus.pic_ticker_pic")
56+
put("tickerPicDark", "miui.focus.pic_ticker_pic")
57+
put("aodTitle", stringText)
58+
put("aodPic", "miui.focus.pic_ado_pic")
59+
put("scene", "template_v2")
60+
put("enableFloat", false)
61+
put("updatable", true)
62+
put("reopen", "reopen")
63+
put("islandFirstFloat", false)
64+
65+
put("param_island", JSONObject().apply {
66+
put("islandProperty", 2)
67+
68+
put("bigIslandArea", JSONObject().apply {
69+
put("imageTextInfoLeft", JSONObject().apply {
70+
put("type", 1)
71+
put("picInfo", JSONObject().apply {
72+
put("type", 3)
73+
put("pic", "flash_light_icon")
74+
})
75+
})
76+
})
77+
78+
put("smallIslandArea", JSONObject().apply {
79+
put("picInfo", JSONObject().apply {
80+
put("type", 3)
81+
put("pic", "flash_light_icon")
82+
})
83+
})
7784
})
78-
})
79-
}
80-
val jSONObject = JSONObject().apply {
81-
put("param_v2", paramV2Obj)
85+
86+
put("baseInfo", JSONObject().apply {
87+
put("title", stringTitle)
88+
put("colorTitle", "")
89+
put("content", stringText)
90+
put("colorContent", "")
91+
put("subContent", "")
92+
put("colorSubContent", "")
93+
put("type", 2)
94+
})
95+
96+
put("bgInfo", JSONObject().apply {
97+
put("colorBg", "")
98+
})
99+
100+
put("iconTextInfo", JSONObject().apply {
101+
put("title", stringTitle)
102+
put("content", stringText)
103+
put("subContent", "")
104+
put("colorSubContent", "")
105+
put("colorSubContentDark", "")
106+
put("animIconInfo", JSONObject().apply {
107+
put("src", "doubleCharge")
108+
put("type", "2")
109+
})
110+
})
111+
112+
put("actions", JSONArray().apply {
113+
put(JSONObject().apply {
114+
put("actionTitle", button)
115+
put("actionIntentType", 2)
116+
put("actionIntent", uri)
117+
put("actionIcon", "miui.focus.pic_mark_v2")
118+
})
119+
})
120+
}
121+
122+
val resultObj = JSONObject().apply {
123+
put("param_v2", paramV2Obj)
124+
}
125+
126+
it.result = resultObj.toString()
127+
82128
}
129+
}
130+
} else {
131+
loadClass("miui.systemui.flashlight.MiFlashlightManager").methodFinder()
132+
.filterByName("getExtraMiuiFocusParam")
133+
.single().createHook {
134+
after {
135+
val mContext = it.thisObject.getObjectField("context") as Context
136+
val stringTitle =
137+
mContext.getString("flashlight_notification_content_title")
138+
val stringText = mContext.getString("flashlight_notification_content_text")
139+
val button = mContext.getString("flashlight_notification_button")
140+
val intent = Intent("miui.systemui.action.ACTION_CLOSE_FLASHLIGHT").apply {
141+
setPackage("miui.systemui.plugin")
142+
}
143+
val uri = intent.toUri(Intent.URI_INTENT_SCHEME)
83144

84-
it.result = jSONObject.toString()
145+
val paramV2Obj = JSONObject().apply {
146+
put("protocol", 1)
147+
put("ticker", stringText)
148+
put("tickerPic", "miui.focus.pic_ticker_pic")
149+
put("tickerPicDark", "miui.focus.pic_ticker_pic")
150+
put("aodTitle", stringText)
151+
put("aodPic", "miui.focus.pic_ado_pic")
152+
put("scene", "template_v2")
153+
put("enableFloat", true)
154+
put("updatable", true)
155+
put("reopen", "reopen")
156+
put("baseInfo", JSONObject().apply {
157+
put("title", stringTitle)
158+
put("colorTitle", "")
159+
put("content", stringText)
160+
put("colorContent", "")
161+
put("subContent", "")
162+
put("colorSubContent", "")
163+
put("type", 2)
164+
})
165+
put("bgInfo", JSONObject().apply {
166+
put("colorBg", "")
167+
})
168+
put("actions", JSONArray().apply {
169+
put(JSONObject().apply {
170+
put("actionTitle", button)
171+
put("actionIntentType", 2)
172+
put("actionIntent", uri)
173+
put("actionIcon", "miui.focus.pic_mark_v2")
174+
})
175+
})
176+
}
177+
val jSONObject = JSONObject().apply {
178+
put("param_v2", paramV2Obj)
179+
}
180+
181+
it.result = jSONObject.toString()
182+
}
85183
}
86-
}
184+
}
87185
}
88186
}

0 commit comments

Comments
 (0)