Skip to content

Commit b1b9758

Browse files
committed
opt: a14 can choose Use more aggressive optimizations for ccgrid
1 parent 7b5a072 commit b1b9758

5 files changed

Lines changed: 70 additions & 33 deletions

File tree

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

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

21-
import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logD;
2221
import static com.sevtinge.hyperceiler.utils.prefs.PrefsUtils.mPrefsMap;
2322

2423
import android.content.Context;
2524
import android.graphics.drawable.Drawable;
2625
import android.graphics.drawable.GradientDrawable;
27-
import android.view.View;
2826

2927
import com.sevtinge.hyperceiler.module.base.tool.HookTool;
3028

31-
import java.util.Arrays;
32-
import java.util.HashSet;
33-
import java.util.Set;
34-
3529
import de.robv.android.xposed.XC_MethodHook;
3630
import de.robv.android.xposed.XposedHelpers;
3731

@@ -59,7 +53,12 @@ protected void before(XC_MethodHook.MethodHookParam param) {
5953
new HookTool.MethodHook() {
6054
@Override
6155
protected void before(MethodHookParam param) {
62-
if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
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 {
6362
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
6463
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
6564
}
@@ -69,33 +68,54 @@ protected void before(MethodHookParam param) {
6968

7069
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader,
7170
"updateResources",
72-
new HookTool.MethodHook() {
71+
new Object[]{new HookTool.MethodHook() {
7372
@Override
7473
protected void before(MethodHookParam param) {
75-
if (warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
76-
if (warningD != null) {
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"); // 为什么能跑起来?
77102
GradientDrawable warningG = (GradientDrawable) warningD;
78103
warningG.setCornerRadius(radius);
79-
}
80-
if (enabledD != null) {
104+
81105
GradientDrawable enabledG = (GradientDrawable) enabledD;
82106
enabledG.setCornerRadius(radius);
83-
}
84-
if (restrictedD != null) {
107+
85108
GradientDrawable restrictedG = (GradientDrawable) restrictedD;
86109
restrictedG.setCornerRadius(radius);
87-
}
88-
if (disabledD != null) {
110+
89111
GradientDrawable disabledG = (GradientDrawable) disabledD;
90112
disabledG.setCornerRadius(radius);
91-
}
92-
if (unavailableD != null) {
113+
93114
GradientDrawable unavailableG = (GradientDrawable) unavailableD;
94115
unavailableG.setCornerRadius(radius);
95116
}
96117
}
97-
}
98-
);
118+
}});
99119

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

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
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;
45
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion;
56
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion;
67
import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.rootExecCmd;
@@ -27,6 +28,7 @@ public class TileSettings extends DashboardFragment implements Preference.OnPref
2728
SwitchPreference mNewCCGridLabel;
2829
SwitchPreference mRoundedRect;
2930
SeekBarPreferenceCompat mRoundedRectRadius;
31+
SwitchPreference mRoundedRectOpt;
3032
SeekBarPreferenceCompat mSunshineModeHighBrightness;
3133
DropDownPreference mFiveG;
3234
DropDownPreference mSunshineMode;
@@ -45,6 +47,7 @@ public void initPrefs() {
4547
mFiveG = findPreference("prefs_key_system_control_center_5g_new_tile");
4648
mRoundedRect = findPreference("prefs_key_system_ui_control_center_rounded_rect");
4749
mRoundedRectRadius = findPreference("prefs_key_system_ui_control_center_rounded_rect_radius");
50+
mRoundedRectOpt = findPreference("prefs_key_system_ui_control_center_rounded_rect_opt");
4851
mTaplus = findPreference("prefs_key_security_center_taplus");
4952
mNewCCGridLabel = findPreference("prefs_key_system_control_center_qs_tile_label");
5053
mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode");
@@ -82,6 +85,8 @@ public void initPrefs() {
8285
mNewCCGridLabel.setVisible(true);
8386
}
8487

88+
mRoundedRectOpt.setVisible(PrefsUtils.getSharedBoolPrefs(getContext(), "prefs_key_system_ui_control_center_rounded_rect", false) && isAndroidVersion(34));
89+
8590
mFiveG.setVisible(TelephonyManager.getDefault().isFiveGCapable());
8691
mSunshineModeHighBrightness.setVisible(Integer.parseInt(PrefsUtils.mSharedPreferences.getString("prefs_key_system_control_center_sunshine_new_mode_high", "0")) == 3);;
8792

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

107112
private void setCanBeVisibleRoundedRect(boolean mode) {
108113
mRoundedRectRadius.setVisible(mode && isMoreHyperOSVersion(1f));
114+
mRoundedRectOpt.setVisible(mode && isAndroidVersion(34));
109115
}
110116

111117
private void setCanBeVisibleSunshineBrightness(int mode) {

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

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

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1042,6 +1042,8 @@
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>
10451047
<string name="system_ui_control_center_statusbar_blur">Force background blur</string>
10461048
<string name="system_ui_control_center_rounded_rect_radius">Rounded radius</string>
10471049
<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: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,6 @@
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-
4034
</PreferenceCategory>
4135

4236
<PreferenceCategory>
@@ -52,13 +46,9 @@
5246

5347
<SwitchPreference
5448
android:defaultValue="false"
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" />
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" />
6252

6353
<fan.preference.DropDownPreference
6454
android:defaultValue="0"
@@ -94,6 +84,16 @@
9484
app:stepValue="1"
9585
app:isPreferenceVisible="false"/>
9686

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,6 +127,13 @@
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+
130137
<SwitchPreference
131138
android:defaultValue="false"
132139
android:key="prefs_key_system_ui_control_center_qs_open_color"

0 commit comments

Comments
 (0)