For #23440,#23441,#23442 remove adapting themes after switching wallpapers

This commit is contained in:
Arturo Mejia 2022-01-31 15:33:45 -05:00 committed by mergify[bot]
parent 7a51dcc304
commit 2533c91da5

View File

@ -14,11 +14,9 @@ import android.graphics.drawable.BitmapDrawable
import android.os.Handler
import android.os.Looper
import android.view.View
import androidx.appcompat.app.AppCompatDelegate
import mozilla.components.support.base.log.logger.Logger
import mozilla.components.support.ktx.android.content.getColorFromAttr
import org.mozilla.fenix.R
import org.mozilla.fenix.ext.asActivity
import org.mozilla.fenix.utils.Settings
/**
@ -53,42 +51,6 @@ class WallpaperManager(
wallpaperContainer.background = BitmapDrawable(context.resources, bitmap)
}
currentWallpaper = newWallpaper
adjustTheme(wallpaperContainer.context)
}
private fun adjustTheme(context: Context) {
val mode = if (currentWallpaper != defaultWallpaper) {
if (currentWallpaper.isDark) {
updateThemePreference(useDarkTheme = true)
logger.info("theme changed to useDarkTheme")
AppCompatDelegate.MODE_NIGHT_YES
} else {
logger.info("theme changed to useLightTheme")
updateThemePreference(useLightTheme = true)
AppCompatDelegate.MODE_NIGHT_NO
}
} else {
// For the default wallpaper, there is not need to adjust the theme,
// as we want to allow users decide which theme they want to have.
// The default wallpaper adapts to whichever theme the user has.
return
}
if (AppCompatDelegate.getDefaultNightMode() != mode) {
AppCompatDelegate.setDefaultNightMode(mode)
logger.info("theme updated activity recreated")
context.asActivity()?.recreate()
}
}
private fun updateThemePreference(
useDarkTheme: Boolean = false,
useLightTheme: Boolean = false
) {
settings.shouldUseDarkTheme = useDarkTheme
settings.shouldUseLightTheme = useLightTheme
settings.shouldFollowDeviceTheme = false
}
/**