mirror of
https://github.com/fankes/ColorOSNotifyIcon.git
synced 2025-09-06 02:35:41 +08:00
修复状态栏动态小图标被破坏的问题
This commit is contained in:
@@ -26,6 +26,7 @@ import android.content.Context
|
|||||||
import android.content.Intent
|
import android.content.Intent
|
||||||
import android.graphics.Bitmap
|
import android.graphics.Bitmap
|
||||||
import android.graphics.Color
|
import android.graphics.Color
|
||||||
|
import android.graphics.drawable.BitmapDrawable
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.graphics.drawable.Icon
|
import android.graphics.drawable.Icon
|
||||||
import android.graphics.drawable.VectorDrawable
|
import android.graphics.drawable.VectorDrawable
|
||||||
@@ -223,13 +224,13 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
* @param isGrayscaleIcon 是否为灰度图标
|
* @param isGrayscaleIcon 是否为灰度图标
|
||||||
* @param packageName APP 包名
|
* @param packageName APP 包名
|
||||||
* @param drawable 原始图标
|
* @param drawable 原始图标
|
||||||
* @return [Bitmap]
|
* @return [Pair] - ([Drawable] 图标,[Boolean] 是否替换)
|
||||||
*/
|
*/
|
||||||
private fun PackageParam.compatStatusIcon(context: Context, isGrayscaleIcon: Boolean, packageName: String, drawable: Drawable) =
|
private fun PackageParam.compatStatusIcon(context: Context, isGrayscaleIcon: Boolean, packageName: String, drawable: Drawable) =
|
||||||
compatCustomIcon(isGrayscaleIcon, packageName).first.also {
|
compatCustomIcon(isGrayscaleIcon, packageName).first.also {
|
||||||
/** 打印日志 */
|
/** 打印日志 */
|
||||||
printLogcat(tag = "StatusIcon", context, packageName, isCustom = it != null, isGrayscaleIcon)
|
printLogcat(tag = "StatusIcon", context, packageName, isCustom = it != null, isGrayscaleIcon)
|
||||||
} ?: drawable.toBitmap()
|
}?.let { Pair(BitmapDrawable(context.resources, it), true) } ?: Pair(drawable, false)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 自动适配通知栏小图标
|
* 自动适配通知栏小图标
|
||||||
@@ -376,24 +377,21 @@ class HookEntry : YukiHookXposedInitProxy {
|
|||||||
name = "getSbn"
|
name = "getSbn"
|
||||||
}.get(firstArgs).invoke<StatusBarNotification>()?.also { nf ->
|
}.get(firstArgs).invoke<StatusBarNotification>()?.also { nf ->
|
||||||
nf.notification.smallIcon.loadDrawable(context).also { iconDrawable ->
|
nf.notification.smallIcon.loadDrawable(context).also { iconDrawable ->
|
||||||
StatusBarIconClass.clazz.field {
|
compatStatusIcon(
|
||||||
name = "icon"
|
context = context,
|
||||||
type = IconClass
|
isGrayscaleIcon = isGrayscaleIcon(context, iconDrawable),
|
||||||
}.get(result).set(
|
packageName = nf.packageName,
|
||||||
Icon.createWithBitmap(
|
drawable = iconDrawable
|
||||||
compatStatusIcon(
|
).also { pair ->
|
||||||
context = context,
|
if (pair.second) StatusBarIconClass.clazz.field {
|
||||||
isGrayscaleIcon = isGrayscaleIcon(context, iconDrawable),
|
name = "icon"
|
||||||
packageName = nf.packageName,
|
type = IconClass
|
||||||
drawable = iconDrawable
|
}.get(result).set(Icon.createWithBitmap(pair.first.toBitmap()))
|
||||||
)
|
/** 刷新图标缓存 */
|
||||||
).apply {
|
if (nf.packageName == MODULE_PACKAGE_NAME &&
|
||||||
/** 刷新图标缓存 */
|
nf.notification.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
||||||
if (nf.packageName == MODULE_PACKAGE_NAME &&
|
) cachingIconDatas()
|
||||||
nf.notification.channelId == IconRuleManagerTool.NOTIFY_CHANNEL
|
}
|
||||||
) cachingIconDatas()
|
|
||||||
}
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user