Modify change wallpaperColor function's return value that cannot obtain return default color in FunctionFactory

This commit is contained in:
2023-02-07 06:23:15 +08:00
parent 27cfcbada6
commit b9e1d1abe7

View File

@@ -356,12 +356,12 @@ val Context.systemAccentColor
/**
* 获取系统壁纸颜色
* @return [Int] 无法获取时返回透明
* @return [Int] 无法获取时返回默认颜
*/
val Context.wallpaperColor
get() = safeOfNan {
WallpaperManager.getInstance(this).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb() ?: 0
}
get() = runCatching {
WallpaperManager.getInstance(this).getWallpaperColors(WallpaperManager.FLAG_SYSTEM)?.primaryColor?.toArgb()
}.getOrNull() ?: (if (isSystemInDarkMode) 0xFFD8D8D8.toInt() else 0xFF707173.toInt())
/**
* 获取较浅的颜色