Skip to content

Commit 7d483bc

Browse files
committed
opt: CCGridForHyperOSKt
1 parent 3db0848 commit 7d483bc

6 files changed

Lines changed: 50 additions & 71 deletions

File tree

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

Lines changed: 20 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,20 @@
1818
*/
1919
package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter;
2020

21+
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logD;
2122
import static com.sevtinge.hyperceiler.utils.prefs.PrefsUtils.mPrefsMap;
2223

2324
import android.content.Context;
2425
import android.graphics.drawable.Drawable;
2526
import android.graphics.drawable.GradientDrawable;
27+
import android.view.View;
2628

2729
import com.sevtinge.hyperceiler.module.base.tool.HookTool;
2830

31+
import java.util.Arrays;
32+
import java.util.HashSet;
33+
import java.util.Set;
34+
2935
import de.robv.android.xposed.XC_MethodHook;
3036
import de.robv.android.xposed.XposedHelpers;
3137

@@ -53,12 +59,7 @@ protected void before(XC_MethodHook.MethodHookParam param) {
5359
new HookTool.MethodHook() {
5460
@Override
5561
protected void before(MethodHookParam param) {
56-
if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect_opt")) {
57-
if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
58-
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
59-
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
60-
}
61-
} else {
62+
if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
6263
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
6364
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
6465
}
@@ -68,54 +69,33 @@ protected void before(MethodHookParam param) {
6869

6970
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader,
7071
"updateResources",
71-
new Object[]{new HookTool.MethodHook() {
72+
new HookTool.MethodHook() {
7273
@Override
7374
protected void before(MethodHookParam param) {
74-
if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect_opt")) {
75-
if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
76-
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
77-
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
78-
if (warningD != null) {
79-
GradientDrawable warningG = (GradientDrawable) warningD;
80-
warningG.setCornerRadius(radius);
81-
}
82-
if (enabledD != null) {
83-
GradientDrawable enabledG = (GradientDrawable) enabledD;
84-
enabledG.setCornerRadius(radius);
85-
}
86-
if (restrictedD != null) {
87-
GradientDrawable restrictedG = (GradientDrawable) restrictedD;
88-
restrictedG.setCornerRadius(radius);
89-
}
90-
if (disabledD != null) {
91-
GradientDrawable disabledG = (GradientDrawable) disabledD;
92-
disabledG.setCornerRadius(radius);
93-
}
94-
if (unavailableD != null) {
95-
GradientDrawable unavailableG = (GradientDrawable) unavailableD;
96-
unavailableG.setCornerRadius(radius);
97-
}
98-
}
99-
} else {
100-
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
101-
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
75+
if (warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
76+
if (warningD != null) {
10277
GradientDrawable warningG = (GradientDrawable) warningD;
10378
warningG.setCornerRadius(radius);
104-
79+
}
80+
if (enabledD != null) {
10581
GradientDrawable enabledG = (GradientDrawable) enabledD;
10682
enabledG.setCornerRadius(radius);
107-
83+
}
84+
if (restrictedD != null) {
10885
GradientDrawable restrictedG = (GradientDrawable) restrictedD;
10986
restrictedG.setCornerRadius(radius);
110-
87+
}
88+
if (disabledD != null) {
11189
GradientDrawable disabledG = (GradientDrawable) disabledD;
11290
disabledG.setCornerRadius(radius);
113-
91+
}
92+
if (unavailableD != null) {
11493
GradientDrawable unavailableG = (GradientDrawable) unavailableD;
11594
unavailableG.setCornerRadius(radius);
11695
}
11796
}
118-
}});
97+
}
98+
);
11999

120100
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader,
121101
"setCornerRadius", float.class,

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object CCGridForHyperOSKt {
3030

3131
@JvmStatic
3232
fun initCCGridForHyperOS(classLoader: ClassLoader?) {
33-
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "getActiveBackgroundDrawable", "com.android.systemui.plugins.qs.QSTile\$State", object : XC_MethodHook(){
33+
/*XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "getActiveBackgroundDrawable", "com.android.systemui.plugins.qs.QSTile\$State", object : XC_MethodHook(){
3434
override fun afterHookedMethod(param: MethodHookParam?) {
3535
super.afterHookedMethod(param)
3636
val drawable = param?.result as Drawable
@@ -57,6 +57,22 @@ object CCGridForHyperOSKt {
5757
param.result = drawable
5858
}
5959
}
60+
})*/
61+
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "setDisabledBg", Drawable::class.java, object : XC_MethodHook(){
62+
override fun beforeHookedMethod(param: MethodHookParam?) {
63+
super.beforeHookedMethod(param)
64+
val drawable = param?.args?.get(0) as Drawable
65+
if (drawable is GradientDrawable) drawable.cornerRadius = radius
66+
param.args[0] = drawable
67+
}
68+
})
69+
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "setEnabledBg", Drawable::class.java, object : XC_MethodHook(){
70+
override fun beforeHookedMethod(param: MethodHookParam?) {
71+
super.beforeHookedMethod(param)
72+
val drawable = param?.args?.get(0) as Drawable
73+
if (drawable is GradientDrawable) drawable.cornerRadius = radius
74+
param.args[0] = drawable
75+
}
6076
})
6177
}
6278
}

app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package com.sevtinge.hyperceiler.ui.fragment.app.systemui;
22

33
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.getWhoAmI;
4-
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isAndroidVersion;
54
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion;
65
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion;
76
import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.rootExecCmd;
@@ -28,7 +27,6 @@ public class TileSettings extends DashboardFragment implements Preference.OnPref
2827
SwitchPreference mNewCCGridLabel;
2928
SwitchPreference mRoundedRect;
3029
SeekBarPreferenceCompat mRoundedRectRadius;
31-
SwitchPreference mRoundedRectOpt;
3230
SeekBarPreferenceCompat mSunshineModeHighBrightness;
3331
DropDownPreference mFiveG;
3432
DropDownPreference mSunshineMode;
@@ -47,7 +45,6 @@ public void initPrefs() {
4745
mFiveG = findPreference("prefs_key_system_control_center_5g_new_tile");
4846
mRoundedRect = findPreference("prefs_key_system_ui_control_center_rounded_rect");
4947
mRoundedRectRadius = findPreference("prefs_key_system_ui_control_center_rounded_rect_radius");
50-
mRoundedRectOpt = findPreference("prefs_key_system_ui_control_center_rounded_rect_opt");
5148
mTaplus = findPreference("prefs_key_security_center_taplus");
5249
mNewCCGridLabel = findPreference("prefs_key_system_control_center_qs_tile_label");
5350
mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode");
@@ -85,8 +82,6 @@ public void initPrefs() {
8582
mNewCCGridLabel.setVisible(true);
8683
}
8784

88-
mRoundedRectOpt.setVisible(PrefsUtils.getSharedBoolPrefs(getContext(), "prefs_key_system_ui_control_center_rounded_rect", false) && isAndroidVersion(34));
89-
9085
mFiveG.setVisible(TelephonyManager.getDefault().isFiveGCapable());
9186
mSunshineModeHighBrightness.setVisible(Integer.parseInt(PrefsUtils.mSharedPreferences.getString("prefs_key_system_control_center_sunshine_new_mode_high", "0")) == 3);;
9287

@@ -111,7 +106,6 @@ public void killTaplus() {
111106

112107
private void setCanBeVisibleRoundedRect(boolean mode) {
113108
mRoundedRectRadius.setVisible(mode && isMoreHyperOSVersion(1f));
114-
mRoundedRectOpt.setVisible(mode && isAndroidVersion(34));
115109
}
116110

117111
private void setCanBeVisibleSunshineBrightness(int mode) {

app/src/main/res/values-zh-rCN/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,8 +1049,6 @@
10491049
<string name="system_ui_control_center_rounded_rect">圆角矩形磁贴</string>
10501050
<string name="system_ui_control_center_statusbar_blur">强制背景模糊</string>
10511051
<string name="system_ui_control_center_rounded_rect_radius">圆角大小</string>
1052-
<string name="system_ui_control_center_rounded_rect_opt">使用更激进的圆角矩形磁贴优化</string>
1053-
<string name="system_ui_control_center_rounded_rect_opt_desc">可能导致部分或全部圆角矩形磁贴恢复默认</string>
10541052
<string name="system_ui_control_center_fix_tiles_list">补全磁贴列表</string>
10551053
<string name="system_ui_shade_header_gradient_blur">通知与控制中心头部渐变模糊</string>
10561054
<string name="system_ui_control_center_switch_cc_and_notification_title">对调控制中心与通知抽屉</string>

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,8 +1042,6 @@
10421042
<string name="system_ui_control_center_expand_notification">Expand notifications</string>
10431043
<string name="system_ui_control_center_mute_visible_notice_desc">When the screen is on, the pop-up notification doesn\'t play the alert sound.</string>
10441044
<string name="system_ui_control_center_rounded_rect">Rounded rectangle tile</string>
1045-
<string name="system_ui_control_center_rounded_rect_opt">Use more aggressive optimizations</string>
1046-
<string name="system_ui_control_center_rounded_rect_opt_desc">This may cause some or all of the rounded rectangular tiles to revert to their defaults</string>
10471045
<string name="system_ui_control_center_statusbar_blur">Force background blur</string>
10481046
<string name="system_ui_control_center_rounded_rect_radius">Rounded radius</string>
10491047
<string name="system_ui_control_center_fix_tiles_list">Disable hide extremely dark tiles</string>

app/src/main/res/xml/system_ui_control_center_tiles.xml

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,12 @@
3131
android:summary="@string/system_ui_control_auto_close_more"
3232
android:title="@string/system_ui_control_auto_close" />
3333

34+
<SwitchPreference
35+
android:defaultValue="false"
36+
android:key="prefs_key_system_ui_control_center_snow_leopard_mode"
37+
android:title="@string/system_ui_control_center_snow_leopard_mode"
38+
android:summary="@string/system_ui_control_center_snow_leopard_mode_desc" />
39+
3440
</PreferenceCategory>
3541

3642
<PreferenceCategory>
@@ -46,9 +52,13 @@
4652

4753
<SwitchPreference
4854
android:defaultValue="false"
49-
android:key="prefs_key_system_ui_control_center_snow_leopard_mode"
50-
android:title="@string/system_ui_control_center_snow_leopard_mode"
51-
android:summary="@string/system_ui_control_center_snow_leopard_mode_desc" />
55+
android:key="prefs_key_security_center_reduce_bright_colors_tile"
56+
android:title="@string/security_center_reduce_bright_colors_tile" />
57+
58+
<SwitchPreference
59+
android:defaultValue="false"
60+
android:key="prefs_key_system_ui_control_center_fix_tiles_list"
61+
android:title="@string/system_ui_control_center_fix_tiles_list" />
5262

5363
<fan.preference.DropDownPreference
5464
android:defaultValue="0"
@@ -84,16 +94,6 @@
8494
app:stepValue="1"
8595
app:isPreferenceVisible="false"/>
8696

87-
<SwitchPreference
88-
android:defaultValue="false"
89-
android:key="prefs_key_security_center_reduce_bright_colors_tile"
90-
android:title="@string/security_center_reduce_bright_colors_tile" />
91-
92-
<SwitchPreference
93-
android:defaultValue="false"
94-
android:key="prefs_key_system_ui_control_center_fix_tiles_list"
95-
android:title="@string/system_ui_control_center_fix_tiles_list" />
96-
9797
<fan.preference.DropDownPreference
9898
android:defaultValue="0"
9999
android:key="prefs_key_security_flash_light_switch"
@@ -127,13 +127,6 @@
127127
app:showSeekBarValue="true"
128128
app:stepValue="1" />
129129

130-
<SwitchPreference
131-
android:defaultValue="false"
132-
android:key="prefs_key_system_ui_control_center_rounded_rect_opt"
133-
android:title="@string/system_ui_control_center_rounded_rect_opt"
134-
android:summary="@string/system_ui_control_center_rounded_rect_opt_desc"
135-
app:isPreferenceVisible="false"/>
136-
137130
<SwitchPreference
138131
android:defaultValue="false"
139132
android:key="prefs_key_system_ui_control_center_qs_open_color"

0 commit comments

Comments
 (0)