mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-04 09:45:34 +08:00
Fix some system's notification icons maybe reset by the system cause wrong icon color in SystemUIHooker
This commit is contained in:
@@ -418,15 +418,24 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
iconView: ImageView
|
iconView: ImageView
|
||||||
) = runInSafe {
|
) = runInSafe {
|
||||||
compatCustomIcon(context, isGrayscaleIcon, packageName).also { customPair ->
|
compatCustomIcon(context, isGrayscaleIcon, packageName).also { customPair ->
|
||||||
|
/** 设置一个用于替换的图标 */
|
||||||
|
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 {
|
when {
|
||||||
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON) && isEnableHookColorNotifyIcon(isHooking = false) ->
|
prefs.get(DataConst.ENABLE_NOTIFY_ICON_FORCE_APP_ICON) && isEnableHookColorNotifyIcon(isHooking = false) ->
|
||||||
iconView.apply {
|
placeholderView.apply {
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName))
|
setImageDrawable(appIcons[packageName] ?: context.appIconOf(packageName))
|
||||||
/** 设置默认样式 */
|
/** 设置默认样式 */
|
||||||
setDefaultNotifyIconViewStyle()
|
setDefaultNotifyIconViewStyle()
|
||||||
}
|
}
|
||||||
customPair.first != null || isGrayscaleIcon -> iconView.apply {
|
customPair.first != null || isGrayscaleIcon -> placeholderView.apply {
|
||||||
/** 设置不要裁切到边界 */
|
/** 设置不要裁切到边界 */
|
||||||
clipToOutline = false
|
clipToOutline = false
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
@@ -467,7 +476,7 @@ object SystemUIHooker : YukiBaseHooker() {
|
|||||||
setPadding(0, 0, 0, 0)
|
setPadding(0, 0, 0, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else -> iconView.apply {
|
else -> placeholderView.apply {
|
||||||
/** 重新设置图标 */
|
/** 重新设置图标 */
|
||||||
setImageDrawable(nf.compatPushingIcon(drawable))
|
setImageDrawable(nf.compatPushingIcon(drawable))
|
||||||
/** 设置默认样式 */
|
/** 设置默认样式 */
|
||||||
|
Reference in New Issue
Block a user