1
0
Fork 0

For #7559 - allows changing locale even after setting theme with

AppCompatDelegate.setDefaultNightMode(mode). The override is necessary because the uiMode needs
to be manually updated after changing theme
master
Mihai Branescu 2020-01-27 15:33:57 +02:00 committed by Jeff Boek
parent eb2eed1c9c
commit 1b7cb117ca
1 changed files with 11 additions and 1 deletions

View File

@ -6,6 +6,7 @@ package org.mozilla.fenix
import android.content.Context
import android.content.Intent
import android.content.res.Configuration
import android.os.Bundle
import android.util.AttributeSet
import android.view.View
@ -21,7 +22,7 @@ import androidx.navigation.NavDirections
import androidx.navigation.fragment.NavHostFragment
import androidx.navigation.ui.AppBarConfiguration
import androidx.navigation.ui.NavigationUI
import kotlinx.android.synthetic.main.activity_home.*
import kotlinx.android.synthetic.main.activity_home.navigationToolbarStub
import kotlinx.coroutines.launch
import mozilla.components.browser.search.SearchEngine
import mozilla.components.browser.session.Session
@ -91,6 +92,15 @@ open class HomeActivity : LocaleAwareAppCompatActivity() {
)
}
override fun applyOverrideConfiguration(overrideConfiguration: Configuration?) {
if (overrideConfiguration != null) {
val uiMode = overrideConfiguration.uiMode
overrideConfiguration.setTo(baseContext.resources.configuration)
overrideConfiguration.uiMode = uiMode
}
super.applyOverrideConfiguration(overrideConfiguration)
}
final override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)