Modify change Android 12 notification icon style contents to Material 3 in DataConst, SystemUIHooker, MainActivity, activity_main

This commit is contained in:
2023-02-02 05:05:55 +08:00
parent 5e56c1bc57
commit a896806fa5
4 changed files with 17 additions and 16 deletions

View File

@@ -31,7 +31,7 @@ object DataConst {
val ENABLE_MODULE = PrefsData("_enable_module", true) val ENABLE_MODULE = PrefsData("_enable_module", true)
val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false) val ENABLE_MODULE_LOG = PrefsData("_enable_module_log", false)
val ENABLE_COLOR_ICON_COMPAT = PrefsData("_color_icon_compat", 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_FIX = PrefsData("_notify_icon_fix", true)
val ENABLE_NOTIFY_ICON_FORCE_APP_ICON = PrefsData("_notify_icon_force_app_icon", false) 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) val ENABLE_NOTIFY_ICON_FIX_NOTIFY = PrefsData("_notify_icon_fix_notify", true)

View File

@@ -441,8 +441,8 @@ object SystemUIHooker : YukiBaseHooker() {
/** 重新设置图标 */ /** 重新设置图标 */
setImageDrawable(customPair.first ?: drawable) setImageDrawable(customPair.first ?: drawable)
/** 是否开启 Android 12 风格 */ /** 是否开启 Material 3 风格 */
val isA12Style = prefs.get(DataConst.ENABLE_ANDROID12_STYLE) val isMaterial3Style = prefs.get(DataConst.ENABLE_MD3_NOTIFY_ICON_STYLE)
/** 旧版风格 */ /** 旧版风格 */
val oldStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else 0xff707173).toInt() 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 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() (if (context.isSystemInDarkMode) 0xff707173 else oldStyle).toInt()
/** 旧版图标着色 */ /** 旧版图标着色 */
val oldApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: oldStyle 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 */ /** 判断风格并开始 Hook */
if (isA12Style) { if (isMaterial3Style) {
/** 通知图标边框圆角大小 */ /** 通知图标边框圆角大小 */
background = DrawableBuilder() background = DrawableBuilder()
.rectangle() .rectangle()

View File

@@ -122,7 +122,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
} }
var notifyIconAutoSyncTime = modulePrefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME) var notifyIconAutoSyncTime = modulePrefs.get(DataConst.NOTIFY_ICON_FIX_AUTO_TIME)
binding.devNotifyConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE) 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.notifyIconConfigItem.isVisible = modulePrefs.get(DataConst.ENABLE_MODULE)
binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX) binding.notifyIconFixButton.isVisible = modulePrefs.get(DataConst.ENABLE_NOTIFY_ICON_FIX)
binding.notifyIconCustomCornerItem.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<ActivityMainBinding>() {
binding.devNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DEV_NOTIFY) binding.devNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DEV_NOTIFY)
binding.crcpNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_CHANGECP_NOTIFY) binding.crcpNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_CHANGECP_NOTIFY)
binding.dndNotifyConfigSwitch.isChecked = modulePrefs.get(DataConst.REMOVE_DNDALERT_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.notifyMediaPanelAutoExpSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_NOTIFY_MEDIA_PANEL_AUTO_EXP)
binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE) binding.moduleEnableSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE)
binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG) binding.moduleEnableLogSwitch.isChecked = modulePrefs.get(DataConst.ENABLE_MODULE_LOG)
@@ -163,7 +163,7 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
binding.moduleEnableLogSwitch.isVisible = b binding.moduleEnableLogSwitch.isVisible = b
binding.notifyIconConfigItem.isVisible = b binding.notifyIconConfigItem.isVisible = b
binding.devNotifyConfigItem.isVisible = b binding.devNotifyConfigItem.isVisible = b
binding.a12StyleConfigItem.isVisible = b binding.notifyStyleConfigItem.isVisible = b
SystemUITool.showNeedRestartSnake(context = this) SystemUITool.showNeedRestartSnake(context = this)
} }
binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b -> binding.moduleEnableLogSwitch.setOnCheckedChangeListener { btn, b ->
@@ -235,9 +235,9 @@ class MainActivity : BaseActivity<ActivityMainBinding>() {
modulePrefs.put(DataConst.REMOVE_DNDALERT_NOTIFY, b) modulePrefs.put(DataConst.REMOVE_DNDALERT_NOTIFY, b)
SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true) SystemUITool.refreshSystemUI(context = this, isRefreshCacheOnly = true)
} }
binding.a12StyleConfigSwitch.setOnCheckedChangeListener { btn, b -> binding.md3StyleConfigSwitch.setOnCheckedChangeListener { btn, b ->
if (btn.isPressed.not()) return@setOnCheckedChangeListener 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) SystemUITool.refreshSystemUI(context = this)
} }
binding.notifyMediaPanelAutoExpSwitch.setOnCheckedChangeListener { btn, b -> binding.notifyMediaPanelAutoExpSwitch.setOnCheckedChangeListener { btn, b ->

View File

@@ -446,7 +446,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/a12_style_config_item" android:id="@+id/notify_style_config_item"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
@@ -493,13 +493,13 @@
</LinearLayout> </LinearLayout>
<com.fankes.coloros.notify.ui.widget.MaterialSwitch <com.fankes.coloros.notify.ui.widget.MaterialSwitch
android:id="@+id/a12_style_config_switch" android:id="@+id/md3_style_config_switch"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
android:paddingLeft="15dp" android:paddingLeft="15dp"
android:paddingRight="15dp" android:paddingRight="15dp"
android:text="启用 Android 12 通知风格" android:text="启用 Material 3 通知图标风格"
android:textAllCaps="false" android:textAllCaps="false"
android:textColor="@color/colorTextGray" android:textColor="@color/colorTextGray"
android:textSize="15sp" /> android:textSize="15sp" />
@@ -512,7 +512,7 @@
android:lineSpacingExtra="6dp" android:lineSpacingExtra="6dp"
android:paddingLeft="15dp" android:paddingLeft="15dp"
android:paddingRight="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:textColor="@color/colorTextDark"
android:textSize="12sp" /> android:textSize="12sp" />
@@ -814,9 +814,10 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="15dp" android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" android:layout_marginRight="15dp"
android:layout_marginBottom="10dp"
android:alpha="0.6" android:alpha="0.6"
android:lineSpacingExtra="6dp" android:lineSpacingExtra="6dp"
android:text="你可以拖拽滑动条来调整通知栏中图标的边框圆角大小,仅支持启用了 Android 12 通知栏风格的通知图标。" android:text="你可以拖拽滑动条来调整通知栏中图标的边框圆角大小。"
android:textColor="@color/colorTextDark" android:textColor="@color/colorTextDark"
android:textSize="12sp" /> android:textSize="12sp" />
</LinearLayout> </LinearLayout>