From 63c77da48aadf4b2c9e3dc3444ba4c3cd56d26e4 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: Mon, 27 May 2024 23:57:21 +0800 Subject: [PATCH] opt: systemui - control center - hide delimiter, now support display device name --- .../systemui/controlcenter/HideDelimiter.java | 83 ++++++++++++++----- app/src/main/res/values-zh-rCN/strings.xml | 3 +- app/src/main/res/values/arrays.xml | 10 ++- app/src/main/res/values/strings.xml | 1 + .../main/res/xml/system_ui_control_center.xml | 2 +- 5 files changed, 73 insertions(+), 26 deletions(-) diff --git a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java index c3760bd6b1..55fb2b32c6 100644 --- a/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java +++ b/app/src/main/java/com/sevtinge/hyperceiler/module/hook/systemui/controlcenter/HideDelimiter.java @@ -18,6 +18,8 @@ */ package com.sevtinge.hyperceiler.module.hook.systemui.controlcenter; +import static com.sevtinge.hyperceiler.utils.PropUtils.getProp; + import android.view.View; import android.widget.TextView; @@ -28,6 +30,8 @@ public class HideDelimiter extends BaseHook { boolean operator = mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0) == 1; + int prefs = mPrefsMap.getStringAsInt("system_ui_control_center_hide_operator", 0); + String deviceName = getProp("persist.sys.device_name"); @Override public void init() { @@ -39,7 +43,11 @@ public void init() { @Override protected void before(MethodHookParam param) { String mCurrentCarrier = (String) param.args[0]; - param.args[0] = operator ? mCurrentCarrier.replace(" | ", "") : ""; + switch (prefs) { + case 1 -> param.args[0] = mCurrentCarrier.replace(" | ", ""); + case 2 -> param.args[0] = ""; + case 3 -> param.args[0] = deviceName; + } } } ); @@ -50,38 +58,67 @@ protected void before(MethodHookParam param) { @Override protected void before(MethodHookParam param) { String mCurrentCarrier = (String) XposedHelpers.getObjectField(param.thisObject, "mCurrentCarrier"); - String updatedCarrier = mCurrentCarrier.replace(" | ", ""); - XposedHelpers.setObjectField(param.thisObject, "mCurrentCarrier", operator ? updatedCarrier : ""); + switch (prefs) { + case 1 -> mCurrentCarrier = mCurrentCarrier.replace(" | ", ""); + case 2 -> mCurrentCarrier = ""; + case 3 -> mCurrentCarrier = deviceName; + } + XposedHelpers.setObjectField(param.thisObject, "mCurrentCarrier", mCurrentCarrier); } } ); - findAndHookMethod("androidx.constraintlayout.core.PriorityGoalRow$GoalVariableAccessor$$ExternalSyntheticOutline0", - "m", String.class, String.class, new MethodHook() { - @Override - protected void before(MethodHookParam param) throws Throwable { - super.before(param); - if (param.args[1].equals(" | ")) { - param.args[1] = ""; - } - } + if (prefs == 3) { + findAndHookMethod("com.android.keyguard.clock.KeyguardClockContainer$mCarrierTextCallback$1", "onCarrierTextChanged", String.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + param.args[0] = deviceName; } - ); + }); - findAndHookMethodSilently("androidx.concurrent.futures.AbstractResolvableFuture$$ExternalSyntheticOutline0", - "m", String.class, String.class, String.class, - new MethodHook() { - @Override - protected void before(MethodHookParam param) { - if (param.args[1].equals(" | ")) { - param.args[1] = ""; + findAndHookMethod("com.android.keyguard.clock.KeyguardClockContainer$mCarrierTextCallback$1", "onCarrierTextChanged", String.class, int.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + param.args[0] = deviceName; + } + }); + + findAndHookMethod("com.android.systemui.statusbar.policy.MiuiCarrierTextControllerImpl", "updateCarrierText", new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + XposedHelpers.setObjectField(param.thisObject, "mCurrentCarrier", deviceName); + } + }); + } else { + findAndHookMethod("androidx.constraintlayout.core.PriorityGoalRow$GoalVariableAccessor$$ExternalSyntheticOutline0", + "m", String.class, String.class, new MethodHook() { + @Override + protected void before(MethodHookParam param) throws Throwable { + super.before(param); + // param.args[0] = deviceName; + if (param.args[1].equals(" | ")) { + param.args[1] = ""; + } } } - } - ); + ); + + findAndHookMethodSilently("androidx.concurrent.futures.AbstractResolvableFuture$$ExternalSyntheticOutline0", + "m", String.class, String.class, String.class, + new MethodHook() { + @Override + protected void before(MethodHookParam param) { + // param.args[0] = deviceName; + if (param.args[1].equals(" | ")) { + param.args[1] = ""; + } + } + } + ); + } } - if (!operator) { + if (prefs == 2) { MethodHook hideOperatorHook = new MethodHook() { @Override protected void after(MethodHookParam param) throws Throwable { diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index a3e544afdd..699632d33f 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -860,8 +860,9 @@ 补全磁贴列表 对调控制中心与通知抽屉 运营商名称自定义 - 只隐藏分隔线 + 隐藏分隔线 隐藏全部名称 + 显示设备名称 蓝牙磁贴样式 蓝牙磁贴移至网络磁贴区域 扩展通知菜单 diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 89efda6fd8..254b0d45d4 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -303,9 +303,17 @@ - @string/control_center_5g_off + @string/array_default @string/system_ui_control_center_hide_delimiter @string/system_ui_control_center_hide_name + @string/system_ui_control_center_hide_display_device_name + + + + 0 + 1 + 2 + 3 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index de3eeb422f..ea7bc45ef8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -843,6 +843,7 @@ Switch control center and notification drawer Carrier name customization Only dividers are hidden + Display device name Hide all names Bluetooth tile style Move the bluetooth tile near the network tile diff --git a/app/src/main/res/xml/system_ui_control_center.xml b/app/src/main/res/xml/system_ui_control_center.xml index 43bb6ef216..4936cae689 100644 --- a/app/src/main/res/xml/system_ui_control_center.xml +++ b/app/src/main/res/xml/system_ui_control_center.xml @@ -429,7 +429,7 @@ android:key="prefs_key_system_ui_control_center_hide_operator" android:title="@string/system_ui_control_center_hide_operator" app:entries="@array/system_ui_control_center_hide_operator" - app:entryValues="@array/status_bar_icon_mode_value" /> + app:entryValues="@array/system_ui_control_center_hide_operator_value" />