mirror of
https://github.com/fankes/MIUINativeNotifyIcon.git
synced 2025-09-06 02:35:32 +08:00
优化 Android 12 风格通知图标深色模式的颜色
This commit is contained in:
@@ -532,7 +532,10 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
setColorFilter(if (isUseAndroid12Style || customIconColor == 0) supportColor else customIconColor)
|
||||
/** Android 12 设置图标外圈颜色 */
|
||||
if (isUseAndroid12Style && customIconColor != 0)
|
||||
background = DrawableBuilder().rounded().solidColor(customIconColor).build()
|
||||
background = DrawableBuilder()
|
||||
.rounded()
|
||||
.solidColor(if (context.isSystemInDarkMode) customIconColor.brighter else customIconColor)
|
||||
.build()
|
||||
/** 设置原生的背景边距 */
|
||||
if (isUseAndroid12Style) setPadding(4.dp(context), 4.dp(context), 4.dp(context), 4.dp(context))
|
||||
} else {
|
||||
@@ -545,8 +548,13 @@ class SystemUIHooker : YukiBaseHooker() {
|
||||
/** 设置图标着色 */
|
||||
setColorFilter(supportColor)
|
||||
/** Android 12 设置图标外圈颜色 */
|
||||
if (isUseAndroid12Style) background =
|
||||
DrawableBuilder().rounded().solidColor(if (hasIconColor) iconColor else context.systemAccentColor).build()
|
||||
(if (hasIconColor) iconColor else context.systemAccentColor).also {
|
||||
if (isUseAndroid12Style)
|
||||
background = DrawableBuilder()
|
||||
.rounded()
|
||||
.solidColor(if (context.isSystemInDarkMode) it.brighter else it)
|
||||
.build()
|
||||
}
|
||||
/** 设置原生的背景边距 */
|
||||
if (isUseAndroid12Style) setPadding(4.dp(context), 4.dp(context), 4.dp(context), 4.dp(context))
|
||||
} else iconImageView.apply {
|
||||
|
@@ -308,6 +308,19 @@ val Context.wallpaperColor
|
||||
WallpaperManager.getInstance(this).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb() ?: 0
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取较浅的颜色
|
||||
* @return [Int]
|
||||
*/
|
||||
val Int.brighter: Int
|
||||
get() {
|
||||
val hsv = FloatArray(3)
|
||||
Color.colorToHSV(this, hsv)
|
||||
hsv[1] = hsv[1] - 0.3f
|
||||
hsv[2] = hsv[2] + 0.3f
|
||||
return Color.HSVToColor(hsv)
|
||||
}
|
||||
|
||||
/**
|
||||
* 是否为白色
|
||||
* @return [Boolean]
|
||||
|
Reference in New Issue
Block a user