From 1d0cc1ad529eee95a5098f31670f7e5e141adeff Mon Sep 17 00:00:00 2001 From: mike a Date: Fri, 8 Mar 2024 21:58:19 -0800 Subject: [PATCH] =?UTF-8?q?Bug=201884487=20=E2=80=93=20simplify=20NavbarIn?= =?UTF-8?q?tegration=20by=20removing=20viewLifecycleOwner?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/org/mozilla/fenix/browser/BaseBrowserFragment.kt | 1 - .../fenix/components/toolbar/navbar/NavbarIntegration.kt | 6 ++---- app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt | 1 - .../fenix/components/toolbar/NavbarIntegrationTest.kt | 1 - 4 files changed, 2 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt index 576a57958..bb437233f 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BaseBrowserFragment.kt @@ -480,7 +480,6 @@ abstract class BaseBrowserFragment : toolbar = bottomToolbarContainerView.toolbarContainerView, store = requireComponents.core.store, appStore = requireComponents.appStore, - viewLifecycleOwner = viewLifecycleOwner, bottomToolbarContainerView = bottomToolbarContainerView, sessionId = customTabSessionId, ), diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/navbar/NavbarIntegration.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/navbar/NavbarIntegration.kt index bdeaad456..e7e1ab101 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/navbar/NavbarIntegration.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/navbar/NavbarIntegration.kt @@ -6,7 +6,6 @@ package org.mozilla.fenix.components.toolbar.navbar import androidx.annotation.VisibleForTesting import androidx.core.view.isVisible -import androidx.lifecycle.LifecycleOwner import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.cancel import kotlinx.coroutines.flow.distinctUntilChangedBy @@ -26,19 +25,18 @@ class NavbarIntegration( val toolbar: ScrollableToolbar, val store: BrowserStore, val appStore: AppStore, - val viewLifecycleOwner: LifecycleOwner, val bottomToolbarContainerView: BottomToolbarContainerView, sessionId: String?, ) : LifecycleAwareFeature { @VisibleForTesting(otherwise = VisibleForTesting.PRIVATE) var toolbarController = ToolbarBehaviorController(toolbar, store, sessionId) - var scope: CoroutineScope? = null + private var scope: CoroutineScope? = null override fun start() { toolbarController.start() - scope = appStore.flowScoped(viewLifecycleOwner) { flow -> + scope = appStore.flowScoped { flow -> flow.distinctUntilChangedBy { it.isSearchDialogVisible } .collect { state -> bottomToolbarContainerView.composeView.isVisible = !state.isSearchDialogVisible diff --git a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt index 42baeb3f2..a847f7508 100644 --- a/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt @@ -476,7 +476,6 @@ class HomeFragment : Fragment() { toolbar = bottomToolbarContainerView.toolbarContainerView, store = requireComponents.core.store, appStore = requireComponents.appStore, - viewLifecycleOwner = viewLifecycleOwner, bottomToolbarContainerView = bottomToolbarContainerView, sessionId = null, ), diff --git a/app/src/test/java/org/mozilla/fenix/components/toolbar/NavbarIntegrationTest.kt b/app/src/test/java/org/mozilla/fenix/components/toolbar/NavbarIntegrationTest.kt index a620417fa..a402cdbfa 100644 --- a/app/src/test/java/org/mozilla/fenix/components/toolbar/NavbarIntegrationTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/toolbar/NavbarIntegrationTest.kt @@ -22,7 +22,6 @@ class NavbarIntegrationTest { toolbar = mockk(), store = mockk(), appStore = mockk(), - viewLifecycleOwner = mockk(), bottomToolbarContainerView = mockk(), sessionId = null, ).apply {