From f7367af3f7b49ba0f1ef19b262c3b07a95254d01 Mon Sep 17 00:00:00 2001 From: Alexandru2909 Date: Fri, 24 Feb 2023 18:39:42 +0200 Subject: [PATCH] Bug 1818774 - Navigate to search dialog when interacting with homescreen private browsing button (cherry picked from commit ee94e6fed9e6bff88b75b5f3d6f455934a9b542d) --- .../home/sessioncontrol/SessionControlController.kt | 9 +++++++++ .../fenix/home/DefaultSessionControlControllerTest.kt | 11 +++++++++++ 2 files changed, 20 insertions(+) diff --git a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt index 46f5453f21..855a5613c0 100644 --- a/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt +++ b/app/src/main/java/org/mozilla/fenix/home/sessioncontrol/SessionControlController.kt @@ -41,6 +41,7 @@ import org.mozilla.fenix.GleanMetrics.TopSites import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R import org.mozilla.fenix.browser.BrowserAnimator +import org.mozilla.fenix.browser.BrowserFragmentDirections import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.collections.SaveCollectionStep import org.mozilla.fenix.components.AppStore @@ -627,6 +628,14 @@ class DefaultSessionControlController( appStore.dispatch( AppAction.ModeChange(Mode.fromBrowsingMode(newMode)), ) + + if (navController.currentDestination?.id == R.id.searchDialogFragment) { + navController.navigate( + BrowserFragmentDirections.actionGlobalSearchDialog( + sessionId = null, + ), + ) + } } } diff --git a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt index 080706c357..9b4d25c182 100644 --- a/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt +++ b/app/src/test/java/org/mozilla/fenix/home/DefaultSessionControlControllerTest.kt @@ -59,6 +59,7 @@ import org.mozilla.fenix.GleanMetrics.RecentTabs import org.mozilla.fenix.GleanMetrics.TopSites import org.mozilla.fenix.HomeActivity import org.mozilla.fenix.R +import org.mozilla.fenix.browser.BrowserFragmentDirections import org.mozilla.fenix.browser.browsingmode.BrowsingMode import org.mozilla.fenix.components.Analytics import org.mozilla.fenix.components.AppStore @@ -1099,6 +1100,11 @@ class DefaultSessionControlControllerTest { verify { settings.incrementNumTimesPrivateModeOpened() AppAction.ModeChange(Mode.fromBrowsingMode(newMode)) + navController.navigate( + BrowserFragmentDirections.actionGlobalSearchDialog( + sessionId = null, + ), + ) } } @@ -1129,6 +1135,11 @@ class DefaultSessionControlControllerTest { appStore.dispatch( AppAction.ModeChange(Mode.fromBrowsingMode(newMode)), ) + navController.navigate( + BrowserFragmentDirections.actionGlobalSearchDialog( + sessionId = null, + ), + ) } }