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:35 +08:00
parent c95c36c76a
commit d589ef2cd0

View File

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