Skip to content

Commit df951e6

Browse files
committed
opt: CCGridForHyperOSKt
by YunZiA
1 parent b102c2c commit df951e6

3 files changed

Lines changed: 36 additions & 75 deletions

File tree

app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOSKt.kt

Lines changed: 29 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -18,76 +18,45 @@
1818
*/
1919
package 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
2523
import com.sevtinge.hyperceiler.utils.prefs.*
2624
import de.robv.android.xposed.*
2725

26+
// from YunZiA
2827
object 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
}

app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/plugin/NewPluginHelperKt.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,6 @@ object NewPluginHelperKt : BaseHook() {
6969
logD(TAG, lpparam.packageName, "Plugin for sysui volume loaded.")
7070

7171
val loaders = listOf(
72-
/*Triple(
73-
"QSVolumeOrBrightnessValue",
74-
true,
75-
QSVolumeOrBrightnessValue::initQSVolumeOrBrightnessValue
76-
),*/
7772
Triple(
7873
"NewShowVolumePct",
7974
mPrefsMap.getBoolean("system_cc_volume_showpct_title"),
@@ -154,11 +149,6 @@ object NewPluginHelperKt : BaseHook() {
154149
logD(TAG, lpparam.packageName, "Plugin for sysui NotificationStatPluginImpl loaded.")
155150

156151
val loaders = listOf(
157-
/*Triple(
158-
"QSVolumeOrBrightnessValue",
159-
true,
160-
QSVolumeOrBrightnessValue::initQSVolumeOrBrightnessValue
161-
),*/
162152
Triple(
163153
"FocusNotifLyric",
164154
mPrefsMap.getBoolean("system_ui_statusbar_music_switch"),
@@ -176,11 +166,6 @@ object NewPluginHelperKt : BaseHook() {
176166
else -> {
177167
val classLoader: ClassLoader = factory.pluginCtxRef.get()!!.classLoader
178168
val loaders = listOf(
179-
/*Triple(
180-
"QSVolumeOrBrightnessValue",
181-
true,
182-
QSVolumeOrBrightnessValue::initQSVolumeOrBrightnessValue
183-
),*/
184169
Triple(
185170
"ShowDeviceName",
186171
mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 3,

app/src/main/res/xml/prefs_about_contributor.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,13 @@
330330
android:action="android.intent.action.VIEW"
331331
android:data="https://github.com/YifePlayte" />
332332
</Preference>
333+
<Preference
334+
android:summary="GitHub@YunZiA"
335+
android:title="YunZiA">
336+
<intent
337+
android:action="android.intent.action.VIEW"
338+
android:data="https://github.com/YunZiA" />
339+
</Preference>
333340
<Preference
334341
android:summary="GitHub@Nep-Timeline"
335342
android:title="YuSaki丶Kanade">

0 commit comments

Comments
 (0)