mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Fix notification panel maybe freeze problem in SystemUIHooker
- Remove replacement notification icon views function - Use a new way to fix notification icons color
This commit is contained in:
@@ -416,23 +416,14 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
iconView: ImageView
|
||||
) = runInSafe {
|
||||
compatCustomIcon(context, isGrayscaleIcon, packageName).also { customTriple ->
|
||||
/** 设置一个用于替换的图标 */
|
||||
val placeholderView = ImageView(context)
|
||||
/** 克隆之前图标的所有布局信息 */
|
||||
(iconView.parent as? ViewGroup?)?.apply { addView(placeholderView.apply { layoutParams = iconView.layoutParams }) }
|
||||
?: loggerE(msg = "Cannot got the orginal notification icon's parent view \"${nf.packageName}\"(\"${nf.opPkg}\") of $nf")
|
||||
/** 将之前图标的间距设置为一个超大值以达到隐藏的效果 */
|
||||
999.also { iconView.setPadding(it, it, it, it) }
|
||||
/** 清除之前图标可能存在的背景 */
|
||||
iconView.background = null
|
||||
when {
|
||||
ConfigData.isEnableNotifyIconForceAppIcon -> placeholderView.apply {
|
||||
ConfigData.isEnableNotifyIconForceAppIcon -> iconView.apply {
|
||||
/** 重新设置图标 */
|
||||
setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName))
|
||||
/** 设置默认样式 */
|
||||
setDefaultNotifyIconViewStyle()
|
||||
}
|
||||
(customTriple.first != null && customTriple.third.not()) || isGrayscaleIcon -> placeholderView.apply {
|
||||
(customTriple.first != null && customTriple.third.not()) || isGrayscaleIcon -> iconView.apply {
|
||||
/** 设置不要裁切到边界 */
|
||||
clipToOutline = false
|
||||
/** 重新设置图标 */
|
||||
@@ -470,7 +461,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
setPadding(0, 0, 0, 0)
|
||||
}
|
||||
}
|
||||
else -> placeholderView.apply {
|
||||
else -> iconView.apply {
|
||||
/** 重新设置图标 */
|
||||
setImageDrawable(nf.compatPushingIcon(drawable))
|
||||
/** 设置默认样式 */
|
||||
@@ -822,7 +813,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
||||
/** 替换通知图标和样式 */
|
||||
NotificationHeaderViewWrapperClass.hook {
|
||||
injectMember {
|
||||
method { name = "resolveHeaderViews" }
|
||||
method { name { it == "resolveHeaderViews" || it == "onContentUpdated" } }.all()
|
||||
afterHook {
|
||||
NotificationHeaderViewWrapperClass.toClass()
|
||||
.field { name = "mIcon" }.get(instance).cast<ImageView>()?.apply {
|
||||
|
Reference in New Issue
Block a user