From a896806fa501e350f5d1c111a5ba98d4c0ec70d4 Mon Sep 17 00:00:00 2001 From: fankesyooni Date: Thu, 2 Feb 2023 05:05:55 +0800 Subject: [PATCH] Modify change Android 12 notification icon style contents to Material 3 in DataConst, SystemUIHooker, MainActivity, activity_main --- .../java/com/fankes/coloros/notify/data/DataConst.kt | 2 +- .../coloros/notify/hook/entity/SystemUIHooker.kt | 10 +++++----- .../fankes/coloros/notify/ui/activity/MainActivity.kt | 10 +++++----- app/src/main/res/layout/activity_main.xml | 11 ++++++----- 4 files changed, 17 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/fankes/coloros/notify/data/DataConst.kt b/app/src/main/java/com/fankes/coloros/notify/data/DataConst.kt index 7350346..75ced94 100644 --- a/app/src/main/java/com/fankes/coloros/notify/data/DataConst.kt +++ b/app/src/main/java/com/fankes/coloros/notify/data/DataConst.kt @@ -31,7 +31,7 @@ object DataConst { val ENABLE_MODULE = PrefsData("_enable_module", true) val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false) val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", false) - val ENABLE_ANDROID12_STYLE = PrefsData("_notify_android12_style", isUpperOfAndroidS) + val ENABLE_MD3_NOTIFY_ICON_STYLE = PrefsData("_notify_icon_md3_style", isUpperOfAndroidS) val ENABLE_NOTIFY_ICON_FIX = PrefsData("_notify_icon_fix", true) val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false) val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true) diff --git a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt index 9b16686..f526b0e 100644 --- a/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt +++ b/app/src/main/java/com/fankes/coloros/notify/hook/entity/SystemUIHooker.kt @@ -441,8 +441,8 @@ object SystemUIHooker : YukiBaseHooker() { /** 重新设置图标 */ setImageDrawable(customPair.first ?: drawable) - /** 是否开启 Android 12 风格 */ - val isA12Style = prefs.get(DataConst.ENABLE_ANDROID12_STYLE) + /** 是否开启 Material 3 风格 */ + val isMaterial3Style = prefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE) /** 旧版风格 */ val oldStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else 0xff707173).toInt() @@ -451,17 +451,17 @@ object SystemUIHooker : YukiBaseHooker() { val newStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else Color.WHITE).toInt() /** 原生着色 */ - val a12Style = if (isUpperOfAndroidS) context.systemAccentColor else + val md3Style = if (isUpperOfAndroidS) context.systemAccentColor else (if (context.isSystemInDarkMode) 0xff707173 else oldStyle).toInt() /** 旧版图标着色 */ val oldApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: oldStyle /** 新版图标着色 */ - val newApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: a12Style + val newApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: md3Style /** 判断风格并开始 Hook */ - if (isA12Style) { + if (isMaterial3Style) { /** 通知图标边框圆角大小 */ background = DrawableBuilder() .rectangle() diff --git a/app/src/main/java/com/fankes/coloros/notify/ui/activity/MainActivity.kt b/app/src/main/java/com/fankes/coloros/notify/ui/activity/MainActivity.kt index 19ec8bb..18ed167 100644 --- a/app/src/main/java/com/fankes/coloros/notify/ui/activity/MainActivity.kt +++ b/app/src/main/java/com/fankes/coloros/notify/ui/activity/MainActivity.kt @@ -122,7 +122,7 @@ class MainActivity : BaseActivity() { } var notifyIconAutoSyncTime = modulePrefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME) binding.devNotifyConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE) - binding.a12StyleConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE) + binding.notifyStyleConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE) binding.notifyIconConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE) binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX) binding.notifyIconCustomCornerItem.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX) && @@ -137,7 +137,7 @@ class MainActivity : BaseActivity() { binding.devNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DEV_NOTIFY) binding.crcpNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_CHANGECP_NOTIFY) binding.dndNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DNDALERT_NOTIFY) - binding.a12StyleConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_ANDROID12_STYLE) + binding.md3StyleConfigSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE) binding.notifyMediaPanelAutoExpSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP) binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE) binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG) @@ -163,7 +163,7 @@ class MainActivity : BaseActivity() { binding.moduleEnableLogSwitch.isVisible = b binding.notifyIconConfigItem.isVisible = b binding.devNotifyConfigItem.isVisible = b - binding.a12StyleConfigItem.isVisible = b + binding.notifyStyleConfigItem.isVisible = b SystemUITool.showNeedRestartSnake(context = this) } binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b -> @@ -235,9 +235,9 @@ class MainActivity : BaseActivity() { modulePrefs.put(DataConst.REMOVE_DNDALERT_NOTIFY, b) SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true) } - binding.a12StyleConfigSwitch.setOnCheckedChangeListener { btn, b -> + binding.md3StyleConfigSwitch.setOnCheckedChangeListener { btn, b -> if (btn.isPressed.not()) return@setOnCheckedChangeListener - modulePrefs.put(DataConst.ENABLE_ANDROID12_STYLE, b) + modulePrefs.put(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE, b) SystemUITool.refreshSystemUI(context = this) } binding.notifyMediaPanelAutoExpSwitch.setOnCheckedChangeListener { btn, b -> diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index eb03471..7804b16 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -446,7 +446,7 @@ @@ -512,7 +512,7 @@ android:lineSpacingExtra="6dp" android:paddingLeft="15dp" android:paddingRight="15dp" - android:text="无论任何版本,开启后都将使用 Android 12 原生通知图标方式为通知栏推送的通知图标增加外部圆形轮廓。\n目标为 Android 12 的系统将自动使用系统主题色着色。" + android:text="无论任何版本,开启后都将使用从 Android 12 开始的 Material 3 通知图标设计方式为通知栏的通知图标增加外部轮廓。\n目标为 Android 12 及以上的系统将自动使用系统主题色着色。" android:textColor="@color/colorTextDark" android:textSize="12sp" /> @@ -814,9 +814,10 @@ android:layout_height="wrap_content" android:layout_marginLeft="15dp" android:layout_marginRight="15dp" + android:layout_marginBottom="10dp" android:alpha="0.6" android:lineSpacingExtra="6dp" - android:text="你可以拖拽滑动条来调整通知栏中图标的边框圆角大小,仅支持启用了 Android 12 通知栏风格的通知图标。" + android:text="你可以拖拽滑动条来调整通知栏中图标的边框圆角大小。" android:textColor="@color/colorTextDark" android:textSize="12sp" />