mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 10:45:20 +08:00
Merge code
This commit is contained in:
@@ -264,6 +264,28 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 自动适配状态栏、通知栏自定义小图标
|
||||||
|
* @param isGrayscaleIcon 是否为灰度图标
|
||||||
|
* @param packageName APP 包名
|
||||||
|
* @return [Pair] - ([Bitmap] 位图,[Int] 颜色)
|
||||||
|
*/
|
||||||
|
private fun PackageParam.compatCustomIcon(isGrayscaleIcon: Boolean, packageName: String): Pair<Bitmap?, Int> {
|
||||||
|
var customPair: Pair<Bitmap?, Int>? = null
|
||||||
|
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
||||||
|
run {
|
||||||
|
if (iconDatas.isNotEmpty())
|
||||||
|
iconDatas.forEach {
|
||||||
|
if (packageName == it.packageName && isAppNotifyHookOf(it)) {
|
||||||
|
if (!isGrayscaleIcon || isAppNotifyHookAllOf(it))
|
||||||
|
customPair = Pair(it.iconBitmap, it.iconColor)
|
||||||
|
return@run
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return customPair ?: Pair(null, 0)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Hook 状态栏小图标
|
* Hook 状态栏小图标
|
||||||
*
|
*
|
||||||
@@ -293,23 +315,12 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
val isNotGrayscaleIcon = notifyInstance.isXmsf || !isGrayscaleIcon(context, iconDrawable)
|
val isNotGrayscaleIcon = notifyInstance.isXmsf || !isGrayscaleIcon(context, iconDrawable)
|
||||||
|
|
||||||
/** 目标彩色通知 APP 图标 */
|
/** 目标彩色通知 APP 图标 */
|
||||||
var customIcon: Bitmap? = null
|
val customIcon = compatCustomIcon(!isNotGrayscaleIcon, notifyInstance.opPkgName).first
|
||||||
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
|
||||||
run {
|
|
||||||
if (iconDatas.isNotEmpty())
|
|
||||||
iconDatas.forEach {
|
|
||||||
if (notifyInstance.opPkgName == it.packageName && isAppNotifyHookOf(it)) {
|
|
||||||
if (isNotGrayscaleIcon || isAppNotifyHookAllOf(it))
|
|
||||||
customIcon = it.iconBitmap
|
|
||||||
return@run
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/** 打印日志 */
|
/** 打印日志 */
|
||||||
printLogcat(tag = "StatusIcon", context, notifyInstance, isCustom = customIcon != null, !isNotGrayscaleIcon)
|
printLogcat(tag = "StatusIcon", context, notifyInstance, isCustom = customIcon != null, !isNotGrayscaleIcon)
|
||||||
when {
|
when {
|
||||||
/** 处理自定义通知图标优化 */
|
/** 处理自定义通知图标优化 */
|
||||||
customIcon != null -> it(customIcon!!)
|
customIcon != null -> it(customIcon)
|
||||||
/** 若不是灰度图标自动处理为圆角 */
|
/** 若不是灰度图标自动处理为圆角 */
|
||||||
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable).toBitmap())
|
isNotGrayscaleIcon -> it(notifyInstance.compatNotifyIcon(context, iconDrawable).toBitmap())
|
||||||
}
|
}
|
||||||
@@ -332,9 +343,6 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
if (!prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)) return@safeRun
|
if (!prefs.getBoolean(ENABLE_COLOR_ICON_HOOK, default = true)) return@safeRun
|
||||||
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
/** 获取通知对象 - 由于 MIUI 的版本迭代不规范性可能是空的 */
|
||||||
expandedNf?.let { notifyInstance ->
|
expandedNf?.let { notifyInstance ->
|
||||||
/** 是否开启修复 APP 的彩色图标 */
|
|
||||||
val isNotifyIconFix = prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true)
|
|
||||||
|
|
||||||
/** 新版风格反色 */
|
/** 新版风格反色 */
|
||||||
val newStyle = if (context.isSystemInDarkMode) 0xFF2D2D2D.toInt() else Color.WHITE
|
val newStyle = if (context.isSystemInDarkMode) 0xFF2D2D2D.toInt() else Color.WHITE
|
||||||
|
|
||||||
@@ -363,22 +371,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
val isGrayscaleIcon = !notifyInstance.isXmsf && isGrayscaleIcon(context, iconDrawable)
|
val isGrayscaleIcon = !notifyInstance.isXmsf && isGrayscaleIcon(context, iconDrawable)
|
||||||
|
|
||||||
/** 自定义默认小图标 */
|
/** 自定义默认小图标 */
|
||||||
var customIcon: Bitmap? = null
|
var customIcon: Bitmap?
|
||||||
|
|
||||||
/** 自定义默认小图标颜色 */
|
/** 自定义默认小图标颜色 */
|
||||||
var customIconColor = 0
|
var customIconColor: Int
|
||||||
|
compatCustomIcon(isGrayscaleIcon, notifyInstance.opPkgName).also {
|
||||||
if (isNotifyIconFix) run {
|
customIcon = it.first
|
||||||
if (iconDatas.isNotEmpty())
|
customIconColor = it.second
|
||||||
iconDatas.forEach {
|
|
||||||
if (notifyInstance.opPkgName == it.packageName && isAppNotifyHookOf(it)) {
|
|
||||||
if (!isGrayscaleIcon || isAppNotifyHookAllOf(it)) {
|
|
||||||
customIcon = it.iconBitmap
|
|
||||||
customIconColor = it.iconColor
|
|
||||||
return@run
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
/** 打印日志 */
|
/** 打印日志 */
|
||||||
printLogcat(tag = "NotifyIcon", context, notifyInstance, isCustom = customIcon != null, isGrayscaleIcon)
|
printLogcat(tag = "NotifyIcon", context, notifyInstance, isCustom = customIcon != null, isGrayscaleIcon)
|
||||||
@@ -446,18 +445,7 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
val isNotGrayscaleIcon = notifyInstance.isXmsf || !isGrayscaleIcon(context, iconDrawable)
|
val isNotGrayscaleIcon = notifyInstance.isXmsf || !isGrayscaleIcon(context, iconDrawable)
|
||||||
|
|
||||||
/** 获取目标修复彩色图标的 APP */
|
/** 获取目标修复彩色图标的 APP */
|
||||||
var isTargetFixApp = false
|
val isTargetFixApp = compatCustomIcon(!isNotGrayscaleIcon, notifyInstance.opPkgName).first != null
|
||||||
/** 如果开启了自定义通知图标优化 */
|
|
||||||
if (prefs.getBoolean(ENABLE_NOTIFY_ICON_FIX, default = true))
|
|
||||||
run {
|
|
||||||
if (iconDatas.isNotEmpty())
|
|
||||||
iconDatas.forEach {
|
|
||||||
if (notifyInstance.opPkgName == it.packageName && isAppNotifyHookOf(it)) {
|
|
||||||
if (isNotGrayscaleIcon || isAppNotifyHookAllOf(it)) isTargetFixApp = true
|
|
||||||
return@run
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
/**
|
||||||
* 只要不是灰度就返回彩色图标
|
* 只要不是灰度就返回彩色图标
|
||||||
* 否则不对颜色进行反色处理防止一些系统图标出现异常
|
* 否则不对颜色进行反色处理防止一些系统图标出现异常
|
||||||
|
Reference in New Issue
Block a user