From f3cadf594d2f7727c3a3f65b7fc46e33c2e858f6 Mon Sep 17 00:00:00 2001 From: FooIbar <118464521+FooIbar@users.noreply.github.com> Date: Sun, 27 Oct 2024 11:23:35 +0800 Subject: [PATCH] Fix crash on devices without WallpaperService --- app/src/main/kotlin/com/hippo/ehviewer/ui/theme/Theme.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/theme/Theme.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/theme/Theme.kt index af17f67e2..8c1c33bde 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/theme/Theme.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/theme/Theme.kt @@ -79,7 +79,7 @@ typealias WallPaperPalette = Triple @Composable @RequiresApi(Build.VERSION_CODES.O_MR1) fun extractWallPaperPalette(): WallPaperPalette? { - val colors = WallpaperManager.getInstance(LocalContext.current).getWallpaperColors(WallpaperManager.FLAG_SYSTEM) ?: return null + val colors = WallpaperManager.getInstance(LocalContext.current)?.getWallpaperColors(WallpaperManager.FLAG_SYSTEM) ?: return null val primary = colors.primaryColor.toArgb().let { Color(it) } val secondary = colors.secondaryColor?.toArgb()?.let { Color(it) } val tertiary = colors.tertiaryColor?.toArgb()?.let { Color(it) }