diff --git a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt index 9980410c96..ca97ad3655 100644 --- a/app/src/main/java/org/mozilla/fenix/utils/Settings.kt +++ b/app/src/main/java/org/mozilla/fenix/utils/Settings.kt @@ -200,14 +200,6 @@ class Settings(private val appContext: Context) : PreferencesHolder { default = 0, ) - /** - * A cache of the background color to use on cards overlaying the current wallpaper. - */ - var currentWallpaperCardColor by longPreference( - appContext.getPreferenceKey(R.string.pref_key_current_wallpaper_card_color), - default = 0, - ) - /** * Indicates if the current legacy wallpaper should be migrated. */ diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManager.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManager.kt index 14285d21dd..68dbb48b83 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManager.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManager.kt @@ -37,7 +37,8 @@ class LegacyWallpaperFileManager( name = name, collection = Wallpaper.DefaultCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ) diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt index d53c1478fb..897478d018 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/Wallpaper.kt @@ -14,13 +14,17 @@ import java.util.Date * @property collection The name of the collection the wallpaper belongs to. * is not restricted. * @property textColor The 8 digit hex code color that should be used for text overlaying the wallpaper. - * @property cardColor The 8 digit hex code color that should be used for cards overlaying the wallpaper. + * @property cardColorLight The 8 digit hex code color that should be used for cards overlaying the wallpaper + * when the user's theme is set to Light. + * @property cardColorDark The 8 digit hex code color that should be used for cards overlaying the wallpaper + * when the user's theme is set to Dark. */ data class Wallpaper( val name: String, val collection: Collection, val textColor: Long?, - val cardColor: Long?, + val cardColorLight: Long?, + val cardColorDark: Long?, val thumbnailFileState: ImageFileState, val assetsFileState: ImageFileState, ) { @@ -84,7 +88,8 @@ data class Wallpaper( name = defaultName, collection = DefaultCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = ImageFileState.Downloaded, assetsFileState = ImageFileState.Downloaded, ) @@ -115,12 +120,12 @@ data class Wallpaper( fun getCurrentWallpaperFromSettings(settings: Settings): Wallpaper? { val name = settings.currentWallpaperName val textColor = settings.currentWallpaperTextColor - val cardColor = settings.currentWallpaperCardColor - return if (name.isNotEmpty() && textColor != 0L && cardColor != 0L) { + return if (name.isNotEmpty() && textColor != 0L) { Wallpaper( name = name, textColor = textColor, - cardColor = cardColor, + cardColorLight = null, + cardColorDark = null, collection = DefaultCollection, thumbnailFileState = ImageFileState.Downloaded, assetsFileState = ImageFileState.Downloaded, diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperFileManager.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperFileManager.kt index 5bd3bb1200..5b6ba4301b 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperFileManager.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperFileManager.kt @@ -36,7 +36,8 @@ class WallpaperFileManager( name = name, collection = Wallpaper.DefaultCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Downloaded, assetsFileState = Wallpaper.ImageFileState.Downloaded, ) diff --git a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcher.kt b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcher.kt index 1b04ced954..781773daab 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcher.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcher.kt @@ -81,7 +81,8 @@ class WallpaperMetadataFetcher( Wallpaper( name = getString("id"), textColor = getArgbValueAsLong("text-color"), - cardColor = getArgbValueAsLong("card-color"), + cardColorLight = getArgbValueAsLong("card-color-light"), + cardColorDark = getArgbValueAsLong("card-color-dark"), collection = collection, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Unavailable, 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 d5c104c7ab..6f96672ef8 100644 --- a/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt +++ b/app/src/main/java/org/mozilla/fenix/wallpapers/WallpapersUseCases.kt @@ -185,7 +185,8 @@ class WallpapersUseCases( name = Wallpaper.amethystName, collection = firefoxClassicCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ), @@ -193,7 +194,8 @@ class WallpapersUseCases( name = Wallpaper.ceruleanName, collection = firefoxClassicCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ), @@ -201,7 +203,8 @@ class WallpapersUseCases( name = Wallpaper.sunriseName, collection = firefoxClassicCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ), @@ -211,7 +214,8 @@ class WallpapersUseCases( name = Wallpaper.twilightHillsName, collection = firefoxClassicCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ), @@ -219,7 +223,8 @@ class WallpapersUseCases( name = Wallpaper.beachVibeName, collection = firefoxClassicCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, ), @@ -454,7 +459,6 @@ class WallpapersUseCases( override suspend fun invoke(wallpaper: Wallpaper): Wallpaper.ImageFileState { settings.currentWallpaperName = wallpaper.name settings.currentWallpaperTextColor = wallpaper.textColor ?: 0 - settings.currentWallpaperCardColor = wallpaper.cardColor ?: 0 store.dispatch(AppAction.WallpaperAction.UpdateCurrentWallpaper(wallpaper)) return Wallpaper.ImageFileState.Downloaded } diff --git a/app/src/main/res/values/preference_keys.xml b/app/src/main/res/values/preference_keys.xml index cc96aead2d..6f18756194 100644 --- a/app/src/main/res/values/preference_keys.xml +++ b/app/src/main/res/values/preference_keys.xml @@ -205,7 +205,6 @@ pref_key_wallpapers pref_key_current_wallpaper pref_key_current_wallpaper_text_color - pref_key_current_wallpaper_card_color pref_key_wallpapers_onboarding pref_key_should_migrate_wallpaper diff --git a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt index 5255535bf5..7a70c91912 100644 --- a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt @@ -1357,7 +1357,8 @@ class DefaultSessionControlControllerTest { learnMoreUrl = null, ), textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = thumbnailFileState, assetsFileState = Wallpaper.ImageFileState.Unavailable, ) diff --git a/app/src/test/java/org/mozilla/fenix/settings/wallpaper/ExtensionsTest.kt b/app/src/test/java/org/mozilla/fenix/settings/wallpaper/ExtensionsTest.kt index 3738e44fbc..9ce65835bc 100644 --- a/app/src/test/java/org/mozilla/fenix/settings/wallpaper/ExtensionsTest.kt +++ b/app/src/test/java/org/mozilla/fenix/settings/wallpaper/ExtensionsTest.kt @@ -172,7 +172,8 @@ class ExtensionsTest { private fun generateClassicFirefoxWallpaper(name: String) = Wallpaper( name = name, textColor = 0L, - cardColor = 0L, + cardColorLight = 0L, + cardColorDark = 0L, thumbnailFileState = Wallpaper.ImageFileState.Downloaded, assetsFileState = Wallpaper.ImageFileState.Downloaded, collection = classicCollection, @@ -195,7 +196,8 @@ class ExtensionsTest { ) = Wallpaper( name = wallpaperName, textColor = 0L, - cardColor = 0L, + cardColorLight = 0L, + cardColorDark = 0L, thumbnailFileState = thumbnailState, assetsFileState = Wallpaper.ImageFileState.Downloaded, collection = getSeasonalCollection(collectionName), diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManagerTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManagerTest.kt index 890403a4a8..0798794494 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManagerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/LegacyWallpaperFileManagerTest.kt @@ -97,7 +97,8 @@ class LegacyWallpaperFileManagerTest { private fun generateWallpaper(name: String) = Wallpaper( name = name, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Downloaded, collection = Wallpaper.Collection( diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperDownloaderTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperDownloaderTest.kt index 66b19a4621..e43faf60d5 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperDownloaderTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperDownloaderTest.kt @@ -128,7 +128,8 @@ class WallpaperDownloaderTest { name = name, collection = wallpaperCollection, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Unavailable, ) diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperFileManagerTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperFileManagerTest.kt index 51833a9387..a0013ba0ad 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperFileManagerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperFileManagerTest.kt @@ -154,7 +154,8 @@ class WallpaperFileManagerTest { private fun generateWallpaper(name: String) = Wallpaper( name = name, textColor = null, - cardColor = null, + cardColorLight = null, + cardColorDark = null, thumbnailFileState = Wallpaper.ImageFileState.Downloaded, assetsFileState = Wallpaper.ImageFileState.Downloaded, collection = Wallpaper.DefaultCollection, diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcherTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcherTest.kt index 52504603b1..341ce38fea 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcherTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpaperMetadataFetcherTest.kt @@ -52,12 +52,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -70,11 +72,13 @@ class WallpaperMetadataFetcherTest { with(wallpapers[0]) { assertEquals(0xFFFBFBFE, textColor) - assertEquals(0xFF15141A, cardColor) + assertEquals(0xFFFFFFFF, cardColorLight) + assertEquals(0xFF000000, cardColorDark) } with(wallpapers[1]) { assertEquals(0xFF15141A, textColor) - assertEquals(0xFFFBFBFE, cardColor) + assertEquals(0xFFFFFFFF, cardColorLight) + assertEquals(0xFF000000, cardColorDark) } } @@ -91,12 +95,14 @@ class WallpaperMetadataFetcherTest { "wallpapers": [ { "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -123,12 +129,14 @@ class WallpaperMetadataFetcherTest { "wallpapers": [ { "id": "beach-vibes", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -160,7 +168,8 @@ class WallpaperMetadataFetcherTest { { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -189,12 +198,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -239,12 +250,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -280,12 +293,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -323,12 +338,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } @@ -364,12 +381,14 @@ class WallpaperMetadataFetcherTest { { "id": "beach-vibes", "text-color": "FBFBFE", - "card-color": "15141A" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" }, { "id": "sunrise", "text-color": "15141A", - "card-color": "FBFBFE" + "card-color-light": "FFFFFF", + "card-color-dark": "000000" } ] } diff --git a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt index b5bea55e49..5e96665ffc 100644 --- a/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt +++ b/app/src/test/java/org/mozilla/fenix/wallpapers/WallpapersUseCasesTest.kt @@ -41,8 +41,6 @@ class WallpapersUseCasesTest { private val mockSettings = mockk { every { currentWallpaperTextColor } returns 0L every { currentWallpaperTextColor = any() } just Runs - every { currentWallpaperCardColor } returns 0L - every { currentWallpaperCardColor = any() } just Runs every { shouldMigrateLegacyWallpaper } returns false every { shouldMigrateLegacyWallpaper = any() } just Runs } @@ -525,7 +523,6 @@ class WallpapersUseCasesTest { verify { mockSettings.currentWallpaperName = selectedWallpaper.name } verify { mockSettings.currentWallpaperTextColor = selectedWallpaper.textColor!! } - verify { mockSettings.currentWallpaperCardColor = selectedWallpaper.cardColor!! } assertEquals(selectedWallpaper, appStore.state.wallpaperState.currentWallpaper) assertEquals(wallpaperFileState, Wallpaper.ImageFileState.Downloaded) } @@ -677,7 +674,8 @@ class WallpapersUseCasesTest { learnMoreUrl = null, ), textColor = Random.nextLong(), - cardColor = Random.nextLong(), + cardColorLight = Random.nextLong(), + cardColorDark = Random.nextLong(), thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Unavailable, ) @@ -694,7 +692,8 @@ class WallpapersUseCasesTest { learnMoreUrl = null, ), textColor = Random.nextLong(), - cardColor = Random.nextLong(), + cardColorLight = Random.nextLong(), + cardColorDark = Random.nextLong(), thumbnailFileState = Wallpaper.ImageFileState.Unavailable, assetsFileState = Wallpaper.ImageFileState.Unavailable, )