For #10408: Dismiss menu when navigating away. (#10415)

The menu is dismissed when toolbar view is detached from window.
fennec/production
Mihai Adrian 4 years ago committed by GitHub
parent d2a3613b73
commit 5106134786
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -4,6 +4,7 @@
package org.mozilla.fenix.components.toolbar package org.mozilla.fenix.components.toolbar
import android.view.View
import mozilla.components.browser.session.SelectionAwareSessionObserver import mozilla.components.browser.session.SelectionAwareSessionObserver
import mozilla.components.browser.session.Session import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager import mozilla.components.browser.session.SessionManager
@ -14,10 +15,11 @@ class MenuPresenter(
private val menuToolbar: BrowserToolbar, private val menuToolbar: BrowserToolbar,
sessionManager: SessionManager, sessionManager: SessionManager,
private val sessionId: String? = null private val sessionId: String? = null
) : SelectionAwareSessionObserver(sessionManager) { ) : SelectionAwareSessionObserver(sessionManager), View.OnAttachStateChangeListener {
fun start() { fun start() {
observeIdOrSelected(sessionId) observeIdOrSelected(sessionId)
menuToolbar.addOnAttachStateChangeListener(this)
} }
/** Redraw the refresh/stop button */ /** Redraw the refresh/stop button */
@ -38,4 +40,12 @@ class MenuPresenter(
fun invalidateActions() { fun invalidateActions() {
menuToolbar.invalidateActions() menuToolbar.invalidateActions()
} }
override fun onViewDetachedFromWindow(v: View?) {
menuToolbar.onStop()
}
override fun onViewAttachedToWindow(v: View?) {
// no-op
}
} }

Loading…
Cancel
Save