From 7d483bc416c9f96f525b7b1dc1dfc07ac0f0e72f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E7=BB=80=E6=BC=93=E4=B8=A8Sevtinge?=
<89193494+Sevtinge@users.noreply.github.com>
Date: Tue, 31 Dec 2024 01:12:38 +0800
Subject: [PATCH] opt: CCGridForHyperOSKt
---
.../controlcenter/CCGridForHyperOS.java | 60 +++++++------------
.../controlcenter/CCGridForHyperOSKt.kt | 18 +++++-
.../fragment/app/systemui/TileSettings.java | 6 --
app/src/main/res/values-zh-rCN/strings.xml | 2 -
app/src/main/res/values/strings.xml | 2 -
.../xml/system_ui_control_center_tiles.xml | 33 ++++------
6 files changed, 50 insertions(+), 71 deletions(-)
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.java
index a4ef9977d..954a88957 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOS.java
@@ -18,14 +18,20 @@
*/
package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter;
+import static com.sevtinge.hyperceiler.utils.log.XposedLogUtils.logD;
import static com.sevtinge.hyperceiler.utils.prefs.PrefsUtils.mPrefsMap;
import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
+import android.view.View;
import com.sevtinge.hyperceiler.module.base.tool.HookTool;
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.Set;
+
import de.robv.android.xposed.XC_MethodHook;
import de.robv.android.xposed.XposedHelpers;
@@ -53,12 +59,7 @@ protected void before(XC_MethodHook.MethodHookParam param) {
new HookTool.MethodHook() {
@Override
protected void before(MethodHookParam param) {
- if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect_opt")) {
- if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
- getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
- // XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
- }
- } else {
+ if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
// XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
}
@@ -68,54 +69,33 @@ protected void before(MethodHookParam param) {
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader,
"updateResources",
- new Object[]{new HookTool.MethodHook() {
+ new HookTool.MethodHook() {
@Override
protected void before(MethodHookParam param) {
- if (mPrefsMap.getBoolean("system_ui_control_center_rounded_rect_opt")) {
- if ((boolean) param.args[1] && (boolean) param.args[2] || warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) {
- getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
- // XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
- if (warningD != null) {
- GradientDrawable warningG = (GradientDrawable) warningD;
- warningG.setCornerRadius(radius);
- }
- if (enabledD != null) {
- GradientDrawable enabledG = (GradientDrawable) enabledD;
- enabledG.setCornerRadius(radius);
- }
- if (restrictedD != null) {
- GradientDrawable restrictedG = (GradientDrawable) restrictedD;
- restrictedG.setCornerRadius(radius);
- }
- if (disabledD != null) {
- GradientDrawable disabledG = (GradientDrawable) disabledD;
- disabledG.setCornerRadius(radius);
- }
- if (unavailableD != null) {
- GradientDrawable unavailableG = (GradientDrawable) unavailableD;
- unavailableG.setCornerRadius(radius);
- }
- }
- } else {
- getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
- // XposedHelpers.callMethod(param.thisObject, "updateResources"); // 为什么能跑起来?
+ if (warningD == null || enabledD == null || restrictedD == null || disabledD == null || unavailableD == null) getPluginResources((Context) XposedHelpers.getObjectField(param.thisObject, "pluginContext"));
+ if (warningD != null) {
GradientDrawable warningG = (GradientDrawable) warningD;
warningG.setCornerRadius(radius);
-
+ }
+ if (enabledD != null) {
GradientDrawable enabledG = (GradientDrawable) enabledD;
enabledG.setCornerRadius(radius);
-
+ }
+ if (restrictedD != null) {
GradientDrawable restrictedG = (GradientDrawable) restrictedD;
restrictedG.setCornerRadius(radius);
-
+ }
+ if (disabledD != null) {
GradientDrawable disabledG = (GradientDrawable) disabledD;
disabledG.setCornerRadius(radius);
-
+ }
+ if (unavailableD != null) {
GradientDrawable unavailableG = (GradientDrawable) unavailableD;
unavailableG.setCornerRadius(radius);
}
}
- }});
+ }
+ );
XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader,
"setCornerRadius", float.class,
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOSKt.kt b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOSKt.kt
index 526a2a814..bea67f91e 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOSKt.kt
+++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/CCGridForHyperOSKt.kt
@@ -30,7 +30,7 @@ object CCGridForHyperOSKt {
@JvmStatic
fun initCCGridForHyperOS(classLoader: ClassLoader?) {
- XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "getActiveBackgroundDrawable", "com.android.systemui.plugins.qs.QSTile\$State", object : XC_MethodHook(){
+ /*XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "getActiveBackgroundDrawable", "com.android.systemui.plugins.qs.QSTile\$State", object : XC_MethodHook(){
override fun afterHookedMethod(param: MethodHookParam?) {
super.afterHookedMethod(param)
val drawable = param?.result as Drawable
@@ -57,6 +57,22 @@ object CCGridForHyperOSKt {
param.result = drawable
}
}
+ })*/
+ XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "setDisabledBg", Drawable::class.java, object : XC_MethodHook(){
+ override fun beforeHookedMethod(param: MethodHookParam?) {
+ super.beforeHookedMethod(param)
+ val drawable = param?.args?.get(0) as Drawable
+ if (drawable is GradientDrawable) drawable.cornerRadius = radius
+ param.args[0] = drawable
+ }
+ })
+ XposedHelpers.findAndHookMethod("miui.systemui.controlcenter.qs.tileview.QSTileItemIconView", classLoader, "setEnabledBg", Drawable::class.java, object : XC_MethodHook(){
+ override fun beforeHookedMethod(param: MethodHookParam?) {
+ super.beforeHookedMethod(param)
+ val drawable = param?.args?.get(0) as Drawable
+ if (drawable is GradientDrawable) drawable.cornerRadius = radius
+ param.args[0] = drawable
+ }
})
}
}
\ No newline at end of file
diff --git a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java
index a221920c6..3bdd4fc57 100644
--- a/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java
+++ b/app/src/main/java/com/sevtinge/hyperceiler/ui/fragment/app/systemui/TileSettings.java
@@ -1,7 +1,6 @@
package com.sevtinge.hyperceiler.ui.fragment.app.systemui;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.getWhoAmI;
-import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isAndroidVersion;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreAndroidVersion;
import static com.sevtinge.hyperceiler.utils.devicesdk.SystemSDKKt.isMoreHyperOSVersion;
import static com.sevtinge.hyperceiler.utils.shell.ShellUtils.rootExecCmd;
@@ -28,7 +27,6 @@ public class TileSettings extends DashboardFragment implements Preference.OnPref
SwitchPreference mNewCCGridLabel;
SwitchPreference mRoundedRect;
SeekBarPreferenceCompat mRoundedRectRadius;
- SwitchPreference mRoundedRectOpt;
SeekBarPreferenceCompat mSunshineModeHighBrightness;
DropDownPreference mFiveG;
DropDownPreference mSunshineMode;
@@ -47,7 +45,6 @@ public void initPrefs() {
mFiveG = findPreference("prefs_key_system_control_center_5g_new_tile");
mRoundedRect = findPreference("prefs_key_system_ui_control_center_rounded_rect");
mRoundedRectRadius = findPreference("prefs_key_system_ui_control_center_rounded_rect_radius");
- mRoundedRectOpt = findPreference("prefs_key_system_ui_control_center_rounded_rect_opt");
mTaplus = findPreference("prefs_key_security_center_taplus");
mNewCCGridLabel = findPreference("prefs_key_system_control_center_qs_tile_label");
mSunshineMode = findPreference("prefs_key_system_control_center_sunshine_new_mode");
@@ -85,8 +82,6 @@ public void initPrefs() {
mNewCCGridLabel.setVisible(true);
}
- mRoundedRectOpt.setVisible(PrefsUtils.getSharedBoolPrefs(getContext(), "prefs_key_system_ui_control_center_rounded_rect", false) && isAndroidVersion(34));
-
mFiveG.setVisible(TelephonyManager.getDefault().isFiveGCapable());
mSunshineModeHighBrightness.setVisible(Integer.parseInt(PrefsUtils.mSharedPreferences.getString("prefs_key_system_control_center_sunshine_new_mode_high", "0")) == 3);;
@@ -111,7 +106,6 @@ public void killTaplus() {
private void setCanBeVisibleRoundedRect(boolean mode) {
mRoundedRectRadius.setVisible(mode && isMoreHyperOSVersion(1f));
- mRoundedRectOpt.setVisible(mode && isAndroidVersion(34));
}
private void setCanBeVisibleSunshineBrightness(int mode) {
diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml
index ea33263f8..55473ec29 100644
--- a/app/src/main/res/values-zh-rCN/strings.xml
+++ b/app/src/main/res/values-zh-rCN/strings.xml
@@ -1049,8 +1049,6 @@
圆角矩形磁贴
强制背景模糊
圆角大小
- 使用更激进的圆角矩形磁贴优化
- 可能导致部分或全部圆角矩形磁贴恢复默认
补全磁贴列表
通知与控制中心头部渐变模糊
对调控制中心与通知抽屉
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0a3632db6..5086a15b9 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1042,8 +1042,6 @@
Expand notifications
When the screen is on, the pop-up notification doesn\'t play the alert sound.
Rounded rectangle tile
- Use more aggressive optimizations
- This may cause some or all of the rounded rectangular tiles to revert to their defaults
Force background blur
Rounded radius
Disable hide extremely dark tiles
diff --git a/app/src/main/res/xml/system_ui_control_center_tiles.xml b/app/src/main/res/xml/system_ui_control_center_tiles.xml
index 146f14c4a..97b6eb8b1 100644
--- a/app/src/main/res/xml/system_ui_control_center_tiles.xml
+++ b/app/src/main/res/xml/system_ui_control_center_tiles.xml
@@ -31,6 +31,12 @@
android:summary="@string/system_ui_control_auto_close_more"
android:title="@string/system_ui_control_auto_close" />
+
+
@@ -46,9 +52,13 @@
+ android:key="prefs_key_security_center_reduce_bright_colors_tile"
+ android:title="@string/security_center_reduce_bright_colors_tile" />
+
+
-
-
-
-
-
-