@@ -269,6 +269,13 @@ object SystemUIHooker : YukiBaseHooker() {
269269 return xmsfPkg.ifBlank { targetPkg.ifBlank { packageName } }
270270 }
271271
272+ /* *
273+ * 获取 MIUI 自己设置的通知图标
274+ * @return [Icon] or null
275+ */
276+ @Suppress(" DEPRECATION" )
277+ private val StatusBarNotification .miuiAppIcon get() = notification?.extras?.getParcelable<Icon ?>(" miui.appIcon" )
278+
272279 /* *
273280 * 打印日志
274281 * @param tag 标识
@@ -528,11 +535,8 @@ object SystemUIHooker : YukiBaseHooker() {
528535 loggerDebug(tag = " Notification Panel Icon" , context, notifyInstance, isCustom = customIcon != null , isGrayscaleIcon)
529536 /* * 处理自定义通知图标优化 */
530537 when {
531- ConfigData .isEnableNotifyIconForceAppIcon -> {
532- @Suppress(" DEPRECATION" )
533- val miuiAppIcon = notifyInstance.notification?.extras?.getParcelable<Icon ?>(" miui.appIcon" )
534- setDefaultNotifyIcon(drawable = miuiAppIcon?.loadDrawable(context) ? : context.appIconOf(notifyInstance.nfPkgName))
535- }
538+ ConfigData .isEnableNotifyIconForceAppIcon ->
539+ setDefaultNotifyIcon(drawable = notifyInstance.miuiAppIcon?.loadDrawable(context) ? : context.appIconOf(notifyInstance.nfPkgName))
536540 customIcon != null -> iconView.apply {
537541 /* * 设置不要裁切到边界 */
538542 clipToOutline = false
@@ -982,14 +986,11 @@ object SystemUIHooker : YukiBaseHooker() {
982986 /* * 修改 MIUI 风格通知栏的通知图标 */
983987 MiuiNotificationViewWrapperClass ?.apply {
984988 constructor ().hook().after {
989+ val nf = instance.getRowPair().second.getSbn() ? : return @after
985990 field { name = " mAppIcon" }.get(instance).cast<ImageView >()?.clone {
986- compatNotifyIcon(
987- context = context,
988- nf = instance.getRowPair().second.getSbn(),
989- iconView = this ,
990- isUseMaterial3Style = true ,
991- isMiuiPanel = true
992- )
991+ if (ConfigData .isEnableReplaceMiuiStyleNotifyIcon || ConfigData .isEnableNotifyIconForceAppIcon)
992+ compatNotifyIcon(context, nf, iconView = this , isUseMaterial3Style = true , isMiuiPanel = true )
993+ else setImageDrawable(nf.miuiAppIcon?.loadDrawable(context) ? : context.appIconOf(nf.packageName))
993994 }
994995 }
995996 }
@@ -1001,15 +1002,12 @@ object SystemUIHooker : YukiBaseHooker() {
10011002 param(BooleanType )
10021003 }.hook().after {
10031004 field { name = " mAppIcon" }.get(instance).cast<ImageView >()?.apply {
1004- compatNotifyIcon(
1005- context = context,
1006- nf = NotificationChildrenContainerClass .field {
1007- name = " mContainingNotification"
1008- }.get(instance).any()?.getSbn(),
1009- iconView = this ,
1010- isUseMaterial3Style = true ,
1011- isMiuiPanel = true
1012- )
1005+ val nf = NotificationChildrenContainerClass .field {
1006+ name = " mContainingNotification"
1007+ }.get(instance).any()?.getSbn() ? : return @after
1008+ if (ConfigData .isEnableReplaceMiuiStyleNotifyIcon || ConfigData .isEnableNotifyIconForceAppIcon)
1009+ compatNotifyIcon(context, nf, iconView = this , isUseMaterial3Style = true , isMiuiPanel = true )
1010+ else setImageDrawable(nf.miuiAppIcon?.loadDrawable(context) ? : context.appIconOf(nf.packageName))
10131011 }
10141012 }
10151013 }
0 commit comments