Skip to content

Commit

Permalink
feat: 系统界面-通知与控制中心-解除自定义动作应用限制 && 自定义动作按钮大小
Browse files Browse the repository at this point in the history
  • Loading branch information
HChenX committed Mar 26, 2024
1 parent 834aa16 commit 5284b85
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
import com.sevtinge.hyperceiler.module.hook.systemui.DisableBottomBar;
import com.sevtinge.hyperceiler.module.hook.systemui.DisableMiuiMultiWinSwitch;
import com.sevtinge.hyperceiler.module.hook.systemui.DisableTransparent;
import com.sevtinge.hyperceiler.module.hook.systemui.MediaButton;
import com.sevtinge.hyperceiler.module.hook.systemui.MonetThemeOverlay;
import com.sevtinge.hyperceiler.module.hook.systemui.NotificationFix;
import com.sevtinge.hyperceiler.module.hook.systemui.NotificationFreeform;
Expand All @@ -40,6 +41,7 @@
import com.sevtinge.hyperceiler.module.hook.systemui.StatusBarActions;
import com.sevtinge.hyperceiler.module.hook.systemui.UiLockApp;
import com.sevtinge.hyperceiler.module.hook.systemui.UnlockClipboard;
import com.sevtinge.hyperceiler.module.hook.systemui.UnlockCustomActions;
import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.AddBlurEffectToNotificationView;
import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.AllowAllThemesNotificationBlur;
import com.sevtinge.hyperceiler.module.hook.systemui.controlcenter.CCGrid;
Expand Down Expand Up @@ -157,6 +159,9 @@ public void handleLoadPackage() {

initHook(new StatusBarIcon());
initHook(new IconsFromSystemManager());
initHook(new UnlockCustomActions(), mPrefsMap.getBoolean("system_ui_control_center_media_control_unlock_custom_actions"));
initHook(new MediaButton(), mPrefsMap.getInt("system_ui_control_center_media_control_media_button", 140) != 140
|| mPrefsMap.getInt("system_ui_control_center_media_control_media_button_custom", 140) != 140);
initHook(new SquigglyProgress(), mPrefsMap.getStringAsInt("system_ui_control_center_media_control_progress_mode", 0) == 1);
initHook(new MediaControlSeekbarCustom(), mPrefsMap.getStringAsInt("system_ui_control_center_media_control_progress_mode", 0) == 2);
initHook(new MediaControlPanelTimeViewTextSize(), mPrefsMap.getInt("system_ui_control_center_media_control_time_view_text_size", 13) != 13);
Expand Down Expand Up @@ -233,6 +238,8 @@ public void handleLoadPackage() {
initHook(new DisplayHardwareDetail(), mPrefsMap.getBoolean("system_ui_statusbar_battery_enable") ||
mPrefsMap.getBoolean("system_ui_statusbar_temp_enable"));

// initHook(new DisplayHardwareDetailForHyper(), true);

// 灵动提示
initHook(HideStrongToast.INSTANCE, mPrefsMap.getBoolean("system_ui_status_bar_strong_toast_hide"));

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.sevtinge.hyperceiler.module.hook.systemui;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.Icon;
import android.media.session.MediaController;
import android.media.session.PlaybackState;
import android.os.UserHandle;

import com.sevtinge.hyperceiler.module.base.BaseHook;

import java.lang.reflect.Method;

import de.robv.android.xposed.XposedHelpers;

public class MediaButton extends BaseHook {
private String pkg = null;
private final int type = mPrefsMap.getInt("system_ui_control_center_media_control_media_button", 140);
private final int typeCustom = mPrefsMap.getInt("system_ui_control_center_media_control_media_button_custom", 140);

@Override
public void init() throws NoSuchMethodException {
findAndHookMethod("com.android.systemui.media.controls.pipeline.MediaDataManager",
"createActionsFromState", String.class, MediaController.class, UserHandle.class,
new MethodHook() {
@Override
protected void before(MethodHookParam param) {
pkg = (String) param.args[0];
}
}
);

findAndHookMethod("com.android.systemui.media.controls.pipeline.MediaDataManager$createActionsFromState$customActions$1",
"invoke", Object.class, new MethodHook() {

@Override
protected void after(MethodHookParam param) throws Throwable {
if (typeCustom != 140) {
PlaybackState.CustomAction customAction = (PlaybackState.CustomAction) param.args[0];
Object MediaAction = param.getResult();
Object mediaDataManager = XposedHelpers.getObjectField(param.thisObject, "this$0");
Context context = (Context) XposedHelpers.getObjectField(mediaDataManager, "context");
Icon createWithResource = Icon.createWithResource(pkg, customAction.getIcon());
Drawable loadDrawable = createWithResource.loadDrawable(context);
Class<?> DrawableUtils = findClassIfExists("com.miui.utils.DrawableUtils", lpparam.classLoader);
Method method = DrawableUtils.getDeclaredMethod("drawable2Bitmap", Drawable.class);
Bitmap bitmap = (Bitmap) method.invoke(null, loadDrawable);
loadDrawable = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap,
typeCustom, typeCustom, true));
XposedHelpers.setObjectField(MediaAction, "icon", loadDrawable);
}
}
}
);

findAndHookMethod("com.android.systemui.media.controls.pipeline.MediaDataManager",
"getStandardAction", MediaController.class, long.class, long.class,
new MethodHook() {
@Override
protected void after(MethodHookParam param) throws Throwable {
if (type != 140) {
Object MediaAction = param.getResult();
Context context = (Context) XposedHelpers.getObjectField(param.thisObject, "context");
Drawable drawable = (Drawable) XposedHelpers.getObjectField(MediaAction, "icon");
Class<?> DrawableUtils = findClassIfExists("com.miui.utils.DrawableUtils", lpparam.classLoader);
Method method = DrawableUtils.getDeclaredMethod("drawable2Bitmap", Drawable.class);
Bitmap bitmap = (Bitmap) method.invoke(null, drawable);
drawable = new BitmapDrawable(context.getResources(), Bitmap.createScaledBitmap(bitmap,
type, type, true));
XposedHelpers.setObjectField(MediaAction, "icon", drawable);
}
}
}
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.sevtinge.hyperceiler.module.hook.systemui;

import com.sevtinge.hyperceiler.module.base.BaseHook;

import java.util.ArrayList;

import de.robv.android.xposed.XposedHelpers;

public class UnlockCustomActions extends BaseHook {

@Override
public void init() throws NoSuchMethodException {
findAndHookMethod("com.android.systemui.media.controls.pipeline.MediaDataManager$createActionsFromState$customActions$1",
"invoke", Object.class
, new MethodHook() {
@Override
protected void before(MethodHookParam param) {
Object INSTANCE = XposedHelpers.getStaticObjectField(
findClassIfExists("com.android.systemui.statusbar.notification.NotificationSettingsManager$Holder"),
"INSTANCE");
XposedHelpers.setObjectField(INSTANCE, "mHiddenCustomActionsList", new ArrayList<>());
}

}
);
}
}
3 changes: 3 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -813,8 +813,11 @@
<string name="system_ui_control_center_media_control_progress_wavy">波浪</string>
<string name="system_ui_control_center_media_control_progress_sleek">圆滑</string>
<string name="system_ui_control_center_media_control_progress_thickness">粗细</string>
<string name="system_ui_control_center_media_control_unlock_custom_actions">解除自定义动作应用限制</string>
<string name="system_ui_control_center_media_control_time_view_text_size">时间预览文本大小</string>
<string name="system_ui_control_center_media_control_panel_background_mix">优化音乐面板背景混色效果</string>
<string name="system_ui_control_center_media_control_media_button_custom">自定义动作按钮大小</string>
<string name="system_ui_control_center_media_control_media_button">固有动作按钮大小</string>
<string name="system_ui_control_center_remove_media_control_panel_background">移除卡片混色背景</string>
<string name="system_ui_control_center_media_control_panel_background_mix_blur_radius">背景模糊半径</string>
<string name="system_ui_control_center_media_control_panel_background_mix_overlay">背景叠加层透明度</string>
Expand Down
3 changes: 3 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -793,10 +793,13 @@
<string name="system_ui_control_center_default_background_alpha">Default Background value</string>
<string name="system_ui_control_center_media_control_panel_background_mix">Optimize the color mixing effect of the media control panel</string>
<string name="system_ui_control_center_media_control_progress">Progress Bar</string>
<string name="system_ui_control_center_media_control_unlock_custom_actions">Remove the restriction on the application of custom actions for media notification cards</string>
<string name="system_ui_control_center_media_control_progress_wavy">Wavy</string>
<string name="system_ui_control_center_media_control_progress_sleek">Sleek</string>
<string name="system_ui_control_center_media_control_progress_thickness">Thickness</string>
<string name="system_ui_control_center_media_control_time_view_text_size">Time view text size</string>
<string name="system_ui_control_center_media_control_media_button_custom">Customize the size of the action button</string>
<string name="system_ui_control_center_media_control_media_button">Intrinsic action button size</string>
<string name="system_ui_control_center_remove_media_control_panel_background">Remove mixed color background from card</string>
<string name="system_ui_control_center_media_control_panel_background_mix_blur_radius">Background blur radius</string>
<string name="system_ui_control_center_media_control_panel_background_mix_overlay">Opacity of the background overlay layer</string>
Expand Down
28 changes: 28 additions & 0 deletions app/src/main/res/xml/system_ui_control_center.xml
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,33 @@
android:key="prefs_key_system_ui_control_center_media_control_panel_background_mix"
android:title="@string/system_ui_control_center_media_control_panel_background_mix" />

<SwitchPreference
android:defaultValue="false"
android:key="prefs_key_system_ui_control_center_media_control_unlock_custom_actions"
android:title="@string/system_ui_control_center_media_control_unlock_custom_actions" />

<SeekBarPreferenceEx
android:key="prefs_key_system_ui_control_center_media_control_media_button_custom"
android:title="@string/system_ui_control_center_media_control_media_button_custom"
app:format="%d dp"
app:maxValue="200"
app:minValue="50"
app:defaultValueText="@string/array_default"
android:defaultValue="140"
app:showSeekBarValue="true"
app:stepValue="1" />

<SeekBarPreferenceEx
android:key="prefs_key_system_ui_control_center_media_control_media_button"
android:title="@string/system_ui_control_center_media_control_media_button"
app:format="%d dp"
app:maxValue="200"
app:minValue="50"
app:defaultValueText="@string/array_default"
android:defaultValue="140"
app:showSeekBarValue="true"
app:stepValue="1" />

<SeekBarPreferenceEx
android:defaultValue="40"
android:dependency="prefs_key_system_ui_control_center_media_control_panel_background_mix"
Expand Down Expand Up @@ -173,6 +200,7 @@
<SeekBarPreferenceEx
android:key="prefs_key_system_ui_control_center_media_control_progress_thickness"
android:title="@string/system_ui_control_center_media_control_progress_thickness"
app:defaultValueText="@string/array_default"
app:format="%d dp"
app:maxValue="260"
app:minValue="20"
Expand Down

0 comments on commit 5284b85

Please sign in to comment.