[fenix] For mozilla-mobilehttps://github.com/mozilla-mobile/fenix/issues/27282: delete WallpaperManager

pull/600/head
Meiirbek Baimuratov 2 years ago committed by mergify[bot]
parent 8870a14690
commit 8d822f9ab1

@ -93,7 +93,7 @@ import org.mozilla.fenix.telemetry.TelemetryLifecycleObserver
import org.mozilla.fenix.utils.BrowsersCache
import org.mozilla.fenix.utils.Settings
import org.mozilla.fenix.utils.Settings.Companion.TOP_SITES_PROVIDER_MAX_THRESHOLD
import org.mozilla.fenix.wallpapers.WallpaperManager
import org.mozilla.fenix.wallpapers.Wallpaper
import java.util.UUID
import java.util.concurrent.TimeUnit
@ -696,7 +696,10 @@ open class FenixApplication : LocaleAwareApplication(), Provider {
}
installSource.set(installSourcePackage.orEmpty())
defaultWallpaper.set(WallpaperManager.isDefaultTheCurrentWallpaper(settings))
val isDefaultTheCurrentWallpaper =
Wallpaper.nameIsDefault(settings.currentWallpaperName)
defaultWallpaper.set(isDefaultTheCurrentWallpaper)
}
with(AndroidAutofill) {

@ -8,7 +8,6 @@ import android.annotation.SuppressLint
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.StrictMode
import androidx.compose.runtime.Composable
import androidx.compose.ui.platform.LocalContext
import androidx.core.net.toUri
@ -46,7 +45,6 @@ import org.mozilla.fenix.perf.StrictModeManager
import org.mozilla.fenix.perf.lazyMonitored
import org.mozilla.fenix.utils.ClipboardHandler
import org.mozilla.fenix.utils.Settings
import org.mozilla.fenix.wallpapers.WallpaperManager
import org.mozilla.fenix.wifi.WifiConnectionMonitor
import java.util.concurrent.TimeUnit
@ -164,14 +162,6 @@ class Components(private val context: Context) {
val wifiConnectionMonitor by lazyMonitored { WifiConnectionMonitor(context as Application) }
val strictMode by lazyMonitored { StrictModeManager(Config, this) }
val wallpaperManager by lazyMonitored {
strictMode.resetAfter(StrictMode.allowThreadDiskReads()) {
WallpaperManager(
appStore,
)
}
}
val settings by lazyMonitored { Settings(context) }
val reviewPromptController by lazyMonitored {

@ -1,33 +0,0 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
package org.mozilla.fenix.wallpapers
import mozilla.components.support.base.log.logger.Logger
import org.mozilla.fenix.components.AppStore
import org.mozilla.fenix.utils.Settings
/**
* Provides access to available wallpapers and manages their states.
*/
@Suppress("TooManyFunctions")
class WallpaperManager(
private val appStore: AppStore,
) {
val logger = Logger("WallpaperManager")
val wallpapers get() = appStore.state.wallpaperState.availableWallpapers
val currentWallpaper: Wallpaper get() = appStore.state.wallpaperState.currentWallpaper
companion object {
/**
* Get whether the default wallpaper should be used.
*/
fun isDefaultTheCurrentWallpaper(settings: Settings): Boolean = with(settings.currentWallpaperName) {
return isEmpty() || equals(defaultWallpaper.name)
}
val defaultWallpaper = Wallpaper.Default
}
}

@ -1,40 +0,0 @@
package org.mozilla.fenix.wallpapers
import io.mockk.every
import io.mockk.mockk
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Test
import org.mozilla.fenix.utils.Settings
class WallpaperManagerTest {
private val mockSettings: Settings = mockk()
@Test
fun `GIVEN no custom wallpaper set WHEN checking whether the current wallpaper should be default THEN return true`() {
every { mockSettings.currentWallpaperName } returns ""
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
assertTrue(result)
}
@Test
fun `GIVEN the default wallpaper is set to be shown WHEN checking whether the current wallpaper should be default THEN return true`() {
every { mockSettings.currentWallpaperName } returns WallpaperManager.defaultWallpaper.name
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
assertTrue(result)
}
@Test
fun `GIVEN a custom wallpaper is set to be shown WHEN checking whether the current wallpaper should be default THEN return false`() {
every { mockSettings.currentWallpaperName } returns "test"
val result = WallpaperManager.isDefaultTheCurrentWallpaper(mockSettings)
assertFalse(result)
}
}
Loading…
Cancel
Save