Skip to content

Commit

Permalink
opt: systemui - control center - hide delimiter, now support display …
Browse files Browse the repository at this point in the history
…device name
  • Loading branch information
Sevtinge committed May 27, 2024
1 parent 567ee1d commit 63c77da
Show file tree
Hide file tree
Showing 5 changed files with 73 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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() {
Expand All @@ -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;
}
}
}
);
Expand All @@ -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 {
Expand Down
3 changes: 2 additions & 1 deletion app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -860,8 +860,9 @@
<string name="system_ui_control_center_fix_tiles_list">补全磁贴列表</string>
<string name="system_ui_control_center_switch_cc_and_notification_title">对调控制中心与通知抽屉</string>
<string name="system_ui_control_center_hide_operator">运营商名称自定义</string>
<string name="system_ui_control_center_hide_delimiter">只隐藏分隔线</string>
<string name="system_ui_control_center_hide_delimiter">隐藏分隔线</string>
<string name="system_ui_control_center_hide_name">隐藏全部名称</string>
<string name="system_ui_control_center_hide_display_device_name">显示设备名称</string>
<string name="system_ui_control_center_cc_bluetooth_tile_style_title">蓝牙磁贴样式</string>
<string name="system_ui_control_center_cc_bluetooth_tile_style_sum">蓝牙磁贴移至网络磁贴区域</string>
<string name="system_ui_control_center_notifrowmenu">扩展通知菜单</string>
Expand Down
10 changes: 9 additions & 1 deletion app/src/main/res/values/arrays.xml
Original file line number Diff line number Diff line change
Expand Up @@ -303,9 +303,17 @@
</string-array>

<string-array name="system_ui_control_center_hide_operator">
<item>@string/control_center_5g_off</item>
<item>@string/array_default</item>
<item>@string/system_ui_control_center_hide_delimiter</item>
<item>@string/system_ui_control_center_hide_name</item>
<item>@string/system_ui_control_center_hide_display_device_name</item>
</string-array>

<string-array name="system_ui_control_center_hide_operator_value">
<item>0</item>
<item>1</item>
<item>2</item>
<item>3</item>
</string-array>

<string-array name="status_bar_icon_mode_value">
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -843,6 +843,7 @@
<string name="system_ui_control_center_switch_cc_and_notification_title">Switch control center and notification drawer</string>
<string name="system_ui_control_center_hide_operator">Carrier name customization</string>
<string name="system_ui_control_center_hide_delimiter">Only dividers are hidden</string>
<string name="system_ui_control_center_hide_display_device_name">Display device name</string>
<string name="system_ui_control_center_hide_name">Hide all names</string>
<string name="system_ui_control_center_cc_bluetooth_tile_style_title">Bluetooth tile style</string>
<string name="system_ui_control_center_cc_bluetooth_tile_style_sum">Move the bluetooth tile near the network tile</string>
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/xml/system_ui_control_center.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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" />

<DropDownPreference
android:defaultValue="1"
Expand Down

0 comments on commit 63c77da

Please sign in to comment.