mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Only set the engine's theme when it is instantiated
This commit is contained in:
parent
b1cc487f14
commit
6d50cc22a0
@ -65,7 +65,6 @@ open class HomeActivity : AppCompatActivity() {
|
||||
DefaultThemeManager.applyStatusBarTheme(window, themeManager, this)
|
||||
browsingModeManager = DefaultBrowsingModeManager(this)
|
||||
|
||||
components.core.setEnginePreferredColorScheme()
|
||||
setContentView(R.layout.activity_home)
|
||||
|
||||
val appBarConfiguration = AppBarConfiguration.Builder(setOf(R.id.libraryFragment)).build()
|
||||
|
@ -62,7 +62,8 @@ class Core(private val context: Context) {
|
||||
remoteDebuggingEnabled = Settings.getInstance(context).isRemoteDebuggingEnabled,
|
||||
testingModeEnabled = false,
|
||||
trackingProtectionPolicy = createTrackingProtectionPolicy(),
|
||||
historyTrackingDelegate = HistoryDelegate(historyStorage)
|
||||
historyTrackingDelegate = HistoryDelegate(historyStorage),
|
||||
preferredColorScheme = getPreferredColorScheme()
|
||||
)
|
||||
|
||||
GeckoEngine(context, defaultSettings, runtime)
|
||||
@ -153,11 +154,11 @@ class Core(private val context: Context) {
|
||||
/**
|
||||
* Sets Preferred Color scheme based on Dark/Light Theme Settings or Current Configuration
|
||||
*/
|
||||
fun setEnginePreferredColorScheme() {
|
||||
fun getPreferredColorScheme(): PreferredColorScheme {
|
||||
val inDark =
|
||||
(context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) ==
|
||||
Configuration.UI_MODE_NIGHT_YES
|
||||
engine.settings.preferredColorScheme = when {
|
||||
return when {
|
||||
Settings.getInstance(context).shouldUseDarkTheme -> PreferredColorScheme.Dark
|
||||
Settings.getInstance(context).shouldUseLightTheme -> PreferredColorScheme.Light
|
||||
inDark -> PreferredColorScheme.Dark
|
||||
|
@ -100,6 +100,9 @@ class ThemeFragment : PreferenceFragmentCompat() {
|
||||
private fun setNewTheme(mode: Int) {
|
||||
AppCompatDelegate.setDefaultNightMode(mode)
|
||||
activity?.recreate()
|
||||
with(requireComponents.core) {
|
||||
engine.settings.preferredColorScheme = getPreferredColorScheme()
|
||||
}
|
||||
requireComponents.useCases.sessionUseCases.reload.invoke()
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user