Skip to content
This repository has been archived by the owner on Jan 2, 2025. It is now read-only.

Commit

Permalink
opt: CCGridForHyperOSKt
Browse files Browse the repository at this point in the history
  • Loading branch information
Sevtinge committed Dec 30, 2024
1 parent 3db0848 commit 7d483bc
Show file tree
Hide file tree
Showing 6 changed files with 50 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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"); // 为什么能跑起来?
}
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
}
})
}
}
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand All @@ -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");
Expand Down Expand Up @@ -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);;

Expand All @@ -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) {
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1049,8 +1049,6 @@
<string name="system_ui_control_center_rounded_rect">圆角矩形磁贴</string>
<string name="system_ui_control_center_statusbar_blur">强制背景模糊</string>
<string name="system_ui_control_center_rounded_rect_radius">圆角大小</string>
<string name="system_ui_control_center_rounded_rect_opt">使用更激进的圆角矩形磁贴优化</string>
<string name="system_ui_control_center_rounded_rect_opt_desc">可能导致部分或全部圆角矩形磁贴恢复默认</string>
<string name="system_ui_control_center_fix_tiles_list">补全磁贴列表</string>
<string name="system_ui_shade_header_gradient_blur">通知与控制中心头部渐变模糊</string>
<string name="system_ui_control_center_switch_cc_and_notification_title">对调控制中心与通知抽屉</string>
Expand Down
2 changes: 0 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1042,8 +1042,6 @@
<string name="system_ui_control_center_expand_notification">Expand notifications</string>
<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>
<string name="system_ui_control_center_rounded_rect">Rounded rectangle tile</string>
<string name="system_ui_control_center_rounded_rect_opt">Use more aggressive optimizations</string>
<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>
<string name="system_ui_control_center_statusbar_blur">Force background blur</string>
<string name="system_ui_control_center_rounded_rect_radius">Rounded radius</string>
<string name="system_ui_control_center_fix_tiles_list">Disable hide extremely dark tiles</string>
Expand Down
33 changes: 13 additions & 20 deletions app/src/main/res/xml/system_ui_control_center_tiles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@
android:summary="@string/system_ui_control_auto_close_more"
android:title="@string/system_ui_control_auto_close" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_snow_leopard_mode"
android:title="@string/system_ui_control_center_snow_leopard_mode"
android:summary="@string/system_ui_control_center_snow_leopard_mode_desc" />

</PreferenceCategory>

<PreferenceCategory>
Expand All @@ -46,9 +52,13 @@

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_snow_leopard_mode"
android:title="@string/system_ui_control_center_snow_leopard_mode"
android:summary="@string/system_ui_control_center_snow_leopard_mode_desc" />
android:key="prefs_key_security_center_reduce_bright_colors_tile"
android:title="@string/security_center_reduce_bright_colors_tile" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_fix_tiles_list"
android:title="@string/system_ui_control_center_fix_tiles_list" />

<fan.preference.DropDownPreference
android:defaultValue="0"
Expand Down Expand Up @@ -84,16 +94,6 @@
app:stepValue="1"
app:isPreferenceVisible="false"/>

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_security_center_reduce_bright_colors_tile"
android:title="@string/security_center_reduce_bright_colors_tile" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_fix_tiles_list"
android:title="@string/system_ui_control_center_fix_tiles_list" />

<fan.preference.DropDownPreference
android:defaultValue="0"
android:key="prefs_key_security_flash_light_switch"
Expand Down Expand Up @@ -127,13 +127,6 @@
app:showSeekBarValue="true"
app:stepValue="1" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_rounded_rect_opt"
android:title="@string/system_ui_control_center_rounded_rect_opt"
android:summary="@string/system_ui_control_center_rounded_rect_opt_desc"
app:isPreferenceVisible="false"/>

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_qs_open_color"
Expand Down

0 comments on commit 7d483bc

Please sign in to comment.