diff --git a/app/src/main/java/org/mozilla/fenix/home/WallpapersObserver.kt b/app/src/main/java/org/mozilla/fenix/home/WallpapersObserver.kt index 25456f43ff53..d9868c77b0cc 100644 --- a/app/src/main/java/org/mozilla/fenix/home/WallpapersObserver.kt +++ b/app/src/main/java/org/mozilla/fenix/home/WallpapersObserver.kt @@ -15,6 +15,8 @@ import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.cancel import kotlinx.coroutines.launch import mozilla.components.lib.state.Store +import org.mozilla.fenix.R +import org.mozilla.fenix.addons.showSnackBar import org.mozilla.fenix.components.AppStore import org.mozilla.fenix.components.appstate.AppAction import org.mozilla.fenix.components.appstate.AppState @@ -38,6 +40,7 @@ class WallpapersObserver( ) : DefaultLifecycleObserver { @VisibleForTesting internal var observeWallpapersStoreSubscription: Store.Subscription? = null + @VisibleForTesting internal var wallpapersScope = CoroutineScope(Dispatchers.Main.immediate) @@ -91,6 +94,13 @@ class WallpapersObserver( bitmap?.let { it.scaleToBottomOfView(wallpaperImageView) wallpaperImageView.isVisible = true + } ?: run { + with(wallpaperImageView) { + showSnackBar( + view = this, + text = resources.getString(R.string.wallpaper_select_error_snackbar_message), + ) + } } } } diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt index 3515d1d720c6..a8bf280e6257 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt @@ -422,7 +422,7 @@ class WallpapersUseCases( * * @param wallpaper The selected wallpaper. */ - suspend operator fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState + suspend operator fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState } @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) @@ -435,7 +435,7 @@ class WallpapersUseCases( * * @param wallpaper The selected wallpaper. */ - override suspend fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState { + override suspend fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState { settings.currentWallpaperName = wallpaper.name settings.currentWallpaperTextColor = wallpaper.textColor ?: 0 settings.currentWallpaperCardColor = wallpaper.cardColor ?: 0 @@ -462,7 +462,7 @@ class WallpapersUseCases( * * @param wallpaper The selected wallpaper. */ - override suspend fun invoke(wallpaper: Wallpaper) : Wallpaper.ImageFileState { + override suspend fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState { return if (wallpaper == Wallpaper.Default || fileManager.wallpaperImagesExist(wallpaper)) { selectWallpaper(wallpaper) dispatchDownloadState(wallpaper, Wallpaper.ImageFileState.Downloaded)