优化深色模式的 Android 12 通知图标颜色

This commit is contained in:
2022-02-28 22:07:34 +08:00
parent f066382d4c
commit 018c137d85
2 changed files with 13 additions and 7 deletions

View File

@@ -30,7 +30,7 @@ android {
buildTypes {
release {
minifyEnabled true
minifyEnabled false
signingConfig signingConfigs.debug
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}

View File

@@ -230,18 +230,24 @@ class HookEntry : YukiHookXposedInitProxy {
val oldStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else 0xff707173).toInt()
/** 新版风格 */
val newStyle = (if (context.isSystemInDarkMode) 0xff2d2d2d else Color.WHITE).toInt()
val newStyle = (if (context.isSystemInDarkMode) 0xffdcdcdc else Color.WHITE).toInt()
/** 图标着色 */
val applyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: oldStyle
/** 优化风格 */
val fixStyle = (if (context.isSystemInDarkMode) 0xff707173 else oldStyle).toInt()
/** 旧版图标着色 */
val oldApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: oldStyle
/** 新版图标着色 */
val newApplyColor = customPair.second.takeIf { it != 0 } ?: iconColor.takeIf { it != 0 } ?: fixStyle
/** 判断风格并开始 Hook */
if (isA12Style) {
background = DrawableBuilder().rounded().solidColor(applyColor).build()
setColorFilter(if (isA12Style) newStyle else oldStyle)
background = DrawableBuilder().rounded().solidColor(newApplyColor).build()
setColorFilter(newStyle)
setPadding(2.dp(context), 2.dp(context), 2.dp(context), 2.dp(context))
} else {
background = null
setColorFilter(applyColor)
setColorFilter(oldApplyColor)
setPadding(0, 0, 0, 0)
}
}