mirror of
https://github.com/fork-maintainers/iceraven-browser
synced 2024-11-15 18:12:54 +00:00
[fenix] Issue https://github.com/mozilla-mobile/fenix/issues/24740: Use unified search bar in bookmark search
This commit is contained in:
parent
143d60ebac
commit
56d367f4fd
@ -25,6 +25,7 @@ import org.mozilla.fenix.ext.bookmarkStorage
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.ext.nav
|
||||
import org.mozilla.fenix.ext.navigateSafe
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
/**
|
||||
* [BookmarkFragment] controller.
|
||||
@ -76,7 +77,8 @@ class DefaultBookmarkController(
|
||||
private val showSnackbar: (String) -> Unit,
|
||||
private val deleteBookmarkNodes: (Set<BookmarkNode>, BookmarkRemoveType) -> Unit,
|
||||
private val deleteBookmarkFolder: (Set<BookmarkNode>) -> Unit,
|
||||
private val showTabTray: () -> Unit
|
||||
private val showTabTray: () -> Unit,
|
||||
private val settings: Settings,
|
||||
) : BookmarkController {
|
||||
|
||||
private val resources: Resources = activity.resources
|
||||
@ -195,8 +197,12 @@ class DefaultBookmarkController(
|
||||
}
|
||||
|
||||
override fun handleSearch() {
|
||||
val directions =
|
||||
val directions = if (settings.showUnifiedSearchFeature) {
|
||||
BookmarkFragmentDirections.actionGlobalSearchDialog(sessionId = null)
|
||||
} else {
|
||||
BookmarkFragmentDirections.actionBookmarkFragmentToBookmarkSearchDialogFragment()
|
||||
}
|
||||
|
||||
navController.navigateSafe(R.id.bookmarkFragment, directions)
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,8 @@ class BookmarkFragment : LibraryPageFragment<BookmarkNode>(), UserInteractionHan
|
||||
showSnackbar = ::showSnackBarWithText,
|
||||
deleteBookmarkNodes = ::deleteMulti,
|
||||
deleteBookmarkFolder = ::showRemoveFolderDialog,
|
||||
showTabTray = ::showTabTray
|
||||
showTabTray = ::showTabTray,
|
||||
settings = requireComponents.settings,
|
||||
)
|
||||
)
|
||||
|
||||
|
@ -72,6 +72,7 @@ import org.mozilla.fenix.GleanMetrics.Awesomebar
|
||||
import org.mozilla.fenix.GleanMetrics.VoiceSearch
|
||||
import org.mozilla.fenix.HomeActivity
|
||||
import org.mozilla.fenix.R
|
||||
import org.mozilla.fenix.components.Core.Companion.BOOKMARKS_SEARCH_ENGINE_ID
|
||||
import org.mozilla.fenix.components.Core.Companion.HISTORY_SEARCH_ENGINE_ID
|
||||
import org.mozilla.fenix.components.toolbar.ToolbarPosition
|
||||
import org.mozilla.fenix.databinding.FragmentSearchDialogBinding
|
||||
@ -268,6 +269,13 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
||||
store.dispatch(SearchFragmentAction.SearchHistoryEngineSelected(searchEngine))
|
||||
}
|
||||
}
|
||||
R.id.bookmarkFragment -> {
|
||||
requireComponents.core.store.state.search.searchEngines.firstOrNull { searchEngine ->
|
||||
searchEngine.id == BOOKMARKS_SEARCH_ENGINE_ID
|
||||
}?.let { searchEngine ->
|
||||
store.dispatch(SearchFragmentAction.SearchBookmarksEngineSelected(searchEngine))
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
|
||||
@ -300,7 +308,7 @@ class SearchDialogFragment : AppCompatDialogFragment(), UserInteractionHandler {
|
||||
false
|
||||
}
|
||||
}
|
||||
R.id.historyFragment -> {
|
||||
R.id.historyFragment, R.id.bookmarkFragment -> {
|
||||
binding.searchWrapper.setOnTouchListener { _, _ ->
|
||||
dismissAllowingStateLoss()
|
||||
true
|
||||
|
@ -273,12 +273,6 @@
|
||||
app:popUpTo="@id/historySearchDialogFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_global_search_dialog"
|
||||
app:destination="@id/searchDialogFragment"
|
||||
app:popUpTo="@id/searchDialogFragment"
|
||||
app:popUpToInclusive="true" />
|
||||
|
||||
<action
|
||||
android:id="@+id/action_historyFragment_to_syncedHistoryFragment"
|
||||
app:destination="@id/syncedHistoryFragment" />
|
||||
|
@ -41,6 +41,7 @@ import org.mozilla.fenix.browser.browsingmode.BrowsingMode
|
||||
import org.mozilla.fenix.components.Services
|
||||
import org.mozilla.fenix.ext.bookmarkStorage
|
||||
import org.mozilla.fenix.ext.components
|
||||
import org.mozilla.fenix.utils.Settings
|
||||
|
||||
@Suppress("TooManyFunctions", "LargeClass")
|
||||
class BookmarkControllerTest {
|
||||
@ -60,6 +61,7 @@ class BookmarkControllerTest {
|
||||
private val addNewTabUseCase: TabsUseCases.AddNewTabUseCase = mockk(relaxed = true)
|
||||
private val navBackStackEntry: NavBackStackEntry = mockk(relaxed = true)
|
||||
private val navDestination: NavDestination = mockk(relaxed = true)
|
||||
private val settings: Settings = mockk(relaxed = true)
|
||||
|
||||
private val item =
|
||||
BookmarkNode(BookmarkNodeType.ITEM, "456", "123", 0u, "Mozilla", "http://mozilla.org", 0, null)
|
||||
@ -220,6 +222,17 @@ class BookmarkControllerTest {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `WHEN handling search THEN navigate to the search dialog fragment`() {
|
||||
createController().handleSearch()
|
||||
|
||||
verify {
|
||||
navController.navigate(
|
||||
BookmarkFragmentDirections.actionBookmarkFragmentToBookmarkSearchDialogFragment()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `handleBookmarkSelected dispatches Select action when selecting a non-root folder`() {
|
||||
createController().handleBookmarkSelected(item)
|
||||
@ -424,7 +437,8 @@ class BookmarkControllerTest {
|
||||
showSnackbar = showSnackbar,
|
||||
deleteBookmarkNodes = deleteBookmarkNodes,
|
||||
deleteBookmarkFolder = deleteBookmarkFolder,
|
||||
showTabTray = showTabTray
|
||||
showTabTray = showTabTray,
|
||||
settings = settings,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user