This commit is contained in:
parent
9059575bbc
commit
aa2921d7d7
|
@ -16,6 +16,7 @@ import androidx.navigation.ui.AppBarConfiguration
|
|||
import androidx.navigation.ui.NavigationUI
|
||||
import mozilla.components.browser.search.SearchEngine
|
||||
import mozilla.components.browser.session.Session
|
||||
import mozilla.components.browser.session.SessionManager
|
||||
import mozilla.components.concept.engine.EngineView
|
||||
import mozilla.components.feature.intent.IntentProcessor
|
||||
import mozilla.components.lib.crash.Crash
|
||||
|
@ -35,6 +36,8 @@ import org.mozilla.fenix.settings.SettingsFragmentDirections
|
|||
@SuppressWarnings("TooManyFunctions")
|
||||
open class HomeActivity : AppCompatActivity() {
|
||||
open val isCustomTab = false
|
||||
private var sessionObserver: SessionManager.Observer? = null
|
||||
var allSessionsRemoved = false
|
||||
|
||||
val themeManager = DefaultThemeManager().also {
|
||||
it.onThemeChange = { theme ->
|
||||
|
@ -51,6 +54,7 @@ open class HomeActivity : AppCompatActivity() {
|
|||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
sessionObserver = subscribeToSessions()
|
||||
|
||||
setTheme(themeManager.currentTheme)
|
||||
DefaultThemeManager.applyStatusBarTheme(window, themeManager, this)
|
||||
|
@ -82,9 +86,17 @@ open class HomeActivity : AppCompatActivity() {
|
|||
|
||||
override fun onResume() {
|
||||
super.onResume()
|
||||
// No session or timed out; we should try to pop inclusive to browser if not in private mode
|
||||
if (components.core.sessionStorage.current() == null && !browsingModeManager.isPrivate) {
|
||||
// All sessions have been removed; we should try to pop inclusive to browser if not in private mode
|
||||
if (allSessionsRemoved && !browsingModeManager.isPrivate) {
|
||||
navHost.navController.popBackStack(R.id.browserFragment, true)
|
||||
allSessionsRemoved = false
|
||||
}
|
||||
}
|
||||
|
||||
override fun onDestroy() {
|
||||
super.onDestroy()
|
||||
sessionObserver?.let {
|
||||
components.core.sessionManager.unregister(it)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -190,6 +202,17 @@ open class HomeActivity : AppCompatActivity() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun subscribeToSessions(): SessionManager.Observer {
|
||||
val observer = object : SessionManager.Observer {
|
||||
override fun onAllSessionsRemoved() {
|
||||
super.onAllSessionsRemoved()
|
||||
allSessionsRemoved = true
|
||||
}
|
||||
}
|
||||
components.core.sessionManager.register(observer)
|
||||
return observer
|
||||
}
|
||||
|
||||
companion object {
|
||||
const val OPEN_TO_BROWSER = "open_to_browser"
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user