Browse Source

For #4736: Display search shortcuts only from home or search widget

master
Yeon Taek Jeong 2 years ago
committed by Emily Kager
parent
commit
d4c83f9668
  1. 2
      app/src/main/java/org/mozilla/fenix/HomeActivity.kt
  2. 4
      app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt
  3. 6
      app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt
  4. 6
      app/src/main/res/navigation/nav_graph.xml

2
app/src/main/java/org/mozilla/fenix/HomeActivity.kt

@ -192,7 +192,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback
} else if (intent?.extras?.getBoolean(OPEN_TO_SEARCH) == true) {
this.intent.putExtra(OPEN_TO_SEARCH, false)
components.analytics.metrics.track(Event.SearchWidgetNewTabPressed)
navHost.navController.nav(null, NavGraphDirections.actionGlobalSearch(null))
navHost.navController.nav(null, NavGraphDirections.actionGlobalSearch(null, true))
return
} else if (intent?.scheme == "fenix") {
intent.data?.let { handleDeepLink(it) }

4
app/src/main/java/org/mozilla/fenix/home/HomeFragment.kt

@ -245,7 +245,7 @@ class HomeFragment : Fragment(), AccountObserver {
view.toolbar_wrapper.setOnClickListener {
invokePendingDeleteJobs()
onboarding.finish()
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null)
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null, true)
val extras =
FragmentNavigator.Extras.Builder()
.addSharedElement(toolbar_wrapper, "toolbar_wrapper_transition")
@ -396,7 +396,7 @@ class HomeFragment : Fragment(), AccountObserver {
}
is TabAction.Add -> {
invokePendingDeleteJobs()
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null)
val directions = HomeFragmentDirections.actionHomeFragmentToSearchFragment(null, true)
nav(R.id.homeFragment, directions)
}
is TabAction.ShareTabs -> {

6
app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt

@ -74,6 +74,10 @@ class SearchFragment : Fragment(), BackHandler {
?.let { it.sessionId }
?.let(requireComponents.core.sessionManager::findSessionById)
val displayShortcutEnginePicker = arguments
?.let(SearchFragmentArgs.Companion::fromBundle)
?.let { it.showShortcutEnginePicker } ?: false
val view = inflater.inflate(R.layout.fragment_search, container, false)
val url = session?.url ?: ""
val currentSearchEngine = SearchEngineSource.Default(
@ -84,7 +88,7 @@ class SearchFragment : Fragment(), BackHandler {
SearchStore(
SearchState(
query = url,
showShortcutEnginePicker = true,
showShortcutEnginePicker = displayShortcutEnginePicker,
searchEngineSource = currentSearchEngine,
defaultEngineSource = currentSearchEngine,
showSuggestions = Settings.getInstance(requireContext()).showSearchSuggestions,

6
app/src/main/res/navigation/nav_graph.xml

@ -15,7 +15,7 @@
android:id="@+id/action_global_search"
app:destination="@id/searchFragment"
app:popUpTo="@id/nav_graph"
app:popUpToInclusive="true"/>
app:popUpToInclusive="true" />
<action
android:id="@+id/action_global_crash_reporter"
@ -72,6 +72,10 @@
android:name="session_id"
app:argType="string"
app:nullable="true" />
<argument
android:name="showShortcutEnginePicker"
app:argType="boolean"
android:defaultValue="false" />
<action
android:id="@+id/action_searchFragment_to_searchEngineFragment"
app:destination="@id/searchEngineFragment"

Loading…
Cancel
Save