For #141 - wires up toolbar and awesomebar
parent
480ae93a72
commit
560aea9b56
|
@ -77,6 +77,7 @@ dependencies {
|
||||||
implementation Deps.mozilla_browser_session
|
implementation Deps.mozilla_browser_session
|
||||||
implementation Deps.mozilla_browser_toolbar
|
implementation Deps.mozilla_browser_toolbar
|
||||||
|
|
||||||
|
implementation Deps.mozilla_feature_awesomebar
|
||||||
implementation Deps.mozilla_feature_intent
|
implementation Deps.mozilla_feature_intent
|
||||||
implementation Deps.mozilla_feature_session
|
implementation Deps.mozilla_feature_session
|
||||||
implementation Deps.mozilla_feature_toolbar
|
implementation Deps.mozilla_feature_toolbar
|
||||||
|
|
|
@ -36,7 +36,6 @@ class BrowserFragment : Fragment() {
|
||||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||||
super.onViewCreated(view, savedInstanceState)
|
super.onViewCreated(view, savedInstanceState)
|
||||||
|
|
||||||
|
|
||||||
val sessionManager = requireComponents.core.sessionManager
|
val sessionManager = requireComponents.core.sessionManager
|
||||||
val sessionId = "1"
|
val sessionId = "1"
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ import mozilla.components.browser.search.SearchEngineManager
|
||||||
import mozilla.components.browser.session.SessionManager
|
import mozilla.components.browser.session.SessionManager
|
||||||
import mozilla.components.feature.search.SearchUseCases
|
import mozilla.components.feature.search.SearchUseCases
|
||||||
import mozilla.components.feature.session.SessionUseCases
|
import mozilla.components.feature.session.SessionUseCases
|
||||||
|
import mozilla.components.feature.tabs.TabsUseCases
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Component group for all use cases. Use cases are provided by feature
|
* Component group for all use cases. Use cases are provided by feature
|
||||||
|
@ -17,5 +18,6 @@ class UseCases(
|
||||||
) {
|
) {
|
||||||
|
|
||||||
val searchUseCases by lazy { SearchUseCases(context, searchEngineManager, sessionManager) }
|
val searchUseCases by lazy { SearchUseCases(context, searchEngineManager, sessionManager) }
|
||||||
val sessionUseCases by lazy { SessionUseCases(sessionManager) }
|
val sessionUseCases by lazy { SessionUseCases(sessionManager) };
|
||||||
|
val tabsUseCases by lazy { TabsUseCases(sessionManager) }
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,11 +9,16 @@ import android.view.LayoutInflater
|
||||||
import android.view.View
|
import android.view.View
|
||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import androidx.core.content.ContextCompat
|
import androidx.core.content.ContextCompat
|
||||||
|
import androidx.core.view.ViewCompat
|
||||||
import androidx.fragment.app.Fragment
|
import androidx.fragment.app.Fragment
|
||||||
|
import androidx.navigation.Navigation
|
||||||
|
import androidx.navigation.fragment.FragmentNavigator
|
||||||
import kotlinx.android.synthetic.main.fragment_search.*
|
import kotlinx.android.synthetic.main.fragment_search.*
|
||||||
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
|
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
|
||||||
|
import mozilla.components.feature.awesomebar.AwesomeBarFeature
|
||||||
import org.mozilla.fenix.R
|
import org.mozilla.fenix.R
|
||||||
import org.mozilla.fenix.components.toolbar.ToolbarIntegration
|
import org.mozilla.fenix.components.toolbar.ToolbarIntegration
|
||||||
|
import org.mozilla.fenix.ext.requireComponents
|
||||||
|
|
||||||
class SearchFragment : Fragment() {
|
class SearchFragment : Fragment() {
|
||||||
override fun onCreateView(
|
override fun onCreateView(
|
||||||
|
@ -44,6 +49,15 @@ class SearchFragment : Fragment() {
|
||||||
"1")
|
"1")
|
||||||
)
|
)
|
||||||
|
|
||||||
|
AwesomeBarFeature(awesomeBar, toolbar, null, onEditComplete = ::didActivateSearch)
|
||||||
|
.addSearchProvider(
|
||||||
|
requireComponents.search.searchEngineManager.getDefaultSearchEngine(requireContext()),
|
||||||
|
requireComponents.useCases.searchUseCases.defaultSearch)
|
||||||
|
.addSessionProvider(
|
||||||
|
requireComponents.core.sessionManager,
|
||||||
|
requireComponents.useCases.tabsUseCases.selectTab)
|
||||||
|
|
||||||
|
|
||||||
toolbar_wrapper.clipToOutline = false
|
toolbar_wrapper.clipToOutline = false
|
||||||
toolbar.apply {
|
toolbar.apply {
|
||||||
textColor = ContextCompat.getColor(context, R.color.searchText)
|
textColor = ContextCompat.getColor(context, R.color.searchText)
|
||||||
|
@ -52,4 +66,11 @@ class SearchFragment : Fragment() {
|
||||||
hintColor = ContextCompat.getColor(context, R.color.searchText)
|
hintColor = ContextCompat.getColor(context, R.color.searchText)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun didActivateSearch() {
|
||||||
|
val extras = FragmentNavigator.Extras.Builder().addSharedElement(
|
||||||
|
toolbar_wrapper, ViewCompat.getTransitionName(toolbar_wrapper)!!
|
||||||
|
).build()
|
||||||
|
Navigation.findNavController(toolbar).navigate(R.id.action_searchFragment_to_browserFragment, null, null, extras)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
|
xmlns:mozac="http://schemas.android.com/apk/res-auto"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".search.SearchFragment">
|
tools:context=".search.SearchFragment">
|
||||||
|
@ -37,7 +38,18 @@
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
|
|
||||||
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/awesomeBar"
|
||||||
android:layout_height="wrap_content"
|
android:layout_width="0dp"
|
||||||
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />
|
android:layout_height="0dp"
|
||||||
|
android:padding="4dp"
|
||||||
|
android:visibility="gone"
|
||||||
|
android:layout_marginTop="16dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
mozac:awesomeBarTitleTextColor="#ffffff"
|
||||||
|
mozac:awesomeBarDescriptionTextColor="#dddddd"
|
||||||
|
mozac:awesomeBarChipTextColor="#ffffff"
|
||||||
|
mozac:awesomeBarChipBackgroundColor="#444444" />
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
@ -10,10 +10,12 @@
|
||||||
/>
|
/>
|
||||||
<action android:id="@+id/action_homeFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
<action android:id="@+id/action_homeFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<fragment android:id="@+id/searchFragment" android:name="org.mozilla.fenix.search.SearchFragment"
|
<fragment android:id="@+id/searchFragment" android:name="org.mozilla.fenix.search.SearchFragment"
|
||||||
android:label="fragment_search" tools:layout="@layout/fragment_search">
|
android:label="fragment_search" tools:layout="@layout/fragment_search">
|
||||||
<action android:id="@+id/action_searchFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
<action android:id="@+id/action_searchFragment_to_browserFragment" app:destination="@id/browserFragment"/>
|
||||||
</fragment>
|
</fragment>
|
||||||
|
|
||||||
<fragment android:id="@+id/browserFragment" android:name="org.mozilla.fenix.browser.BrowserFragment"
|
<fragment android:id="@+id/browserFragment" android:name="org.mozilla.fenix.browser.BrowserFragment"
|
||||||
android:label="fragment_browser" tools:layout="@layout/fragment_browser"/>
|
android:label="fragment_browser" tools:layout="@layout/fragment_browser"/>
|
||||||
</navigation>
|
</navigation>
|
|
@ -30,3 +30,9 @@ allprojects {
|
||||||
task clean(type: Delete) {
|
task clean(type: Delete) {
|
||||||
delete rootProject.buildDir
|
delete rootProject.buildDir
|
||||||
}
|
}
|
||||||
|
|
||||||
|
task showMeCache << {
|
||||||
|
configurations.compile.each { println it }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,7 @@ object Deps {
|
||||||
const val mozilla_browser_session = "org.mozilla.components:browser-session:${Versions.mozilla_android_components}"
|
const val mozilla_browser_session = "org.mozilla.components:browser-session:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_browser_toolbar = "org.mozilla.components:browser-toolbar:${Versions.mozilla_android_components}"
|
const val mozilla_browser_toolbar = "org.mozilla.components:browser-toolbar:${Versions.mozilla_android_components}"
|
||||||
|
|
||||||
|
const val mozilla_feature_awesomebar = "org.mozilla.components:feature-awesomebar:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_feature_intent = "org.mozilla.components:feature-intent:${Versions.mozilla_android_components}"
|
const val mozilla_feature_intent = "org.mozilla.components:feature-intent:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_feature_session = "org.mozilla.components:feature-session:${Versions.mozilla_android_components}"
|
const val mozilla_feature_session = "org.mozilla.components:feature-session:${Versions.mozilla_android_components}"
|
||||||
const val mozilla_feature_storage = "org.mozilla.components:feature-storage:${Versions.mozilla_android_components}"
|
const val mozilla_feature_storage = "org.mozilla.components:feature-storage:${Versions.mozilla_android_components}"
|
||||||
|
|
Loading…
Reference in New Issue