1
0
Fork 0

For #141 - wires up toolbar and awesomebar

master
Jeff Boek 2019-01-24 12:10:16 -08:00 committed by Emily Kager
parent 480ae93a72
commit 560aea9b56
8 changed files with 49 additions and 5 deletions

View File

@ -77,6 +77,7 @@ dependencies {
implementation Deps.mozilla_browser_session
implementation Deps.mozilla_browser_toolbar
implementation Deps.mozilla_feature_awesomebar
implementation Deps.mozilla_feature_intent
implementation Deps.mozilla_feature_session
implementation Deps.mozilla_feature_toolbar

View File

@ -36,7 +36,6 @@ class BrowserFragment : Fragment() {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
val sessionManager = requireComponents.core.sessionManager
val sessionId = "1"

View File

@ -5,6 +5,7 @@ import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.session.SessionManager
import mozilla.components.feature.search.SearchUseCases
import mozilla.components.feature.session.SessionUseCases
import mozilla.components.feature.tabs.TabsUseCases
/**
* 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 sessionUseCases by lazy { SessionUseCases(sessionManager) }
val sessionUseCases by lazy { SessionUseCases(sessionManager) };
val tabsUseCases by lazy { TabsUseCases(sessionManager) }
}

View File

@ -9,11 +9,16 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.core.content.ContextCompat
import androidx.core.view.ViewCompat
import androidx.fragment.app.Fragment
import androidx.navigation.Navigation
import androidx.navigation.fragment.FragmentNavigator
import kotlinx.android.synthetic.main.fragment_search.*
import mozilla.components.browser.domains.autocomplete.ShippedDomainsProvider
import mozilla.components.feature.awesomebar.AwesomeBarFeature
import org.mozilla.fenix.R
import org.mozilla.fenix.components.toolbar.ToolbarIntegration
import org.mozilla.fenix.ext.requireComponents
class SearchFragment : Fragment() {
override fun onCreateView(
@ -44,6 +49,15 @@ class SearchFragment : Fragment() {
"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.apply {
textColor = ContextCompat.getColor(context, R.color.searchText)
@ -52,4 +66,11 @@ class SearchFragment : Fragment() {
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)
}
}

View File

@ -5,6 +5,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:mozac="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".search.SearchFragment">
@ -37,7 +38,18 @@
</FrameLayout>
<mozilla.components.browser.awesomebar.BrowserAwesomeBar
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/toolbar_wrapper" />
android:id="@+id/awesomeBar"
android:layout_width="0dp"
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>

View File

@ -10,10 +10,12 @@
/>
<action android:id="@+id/action_homeFragment_to_browserFragment" app:destination="@id/browserFragment"/>
</fragment>
<fragment android:id="@+id/searchFragment" android:name="org.mozilla.fenix.search.SearchFragment"
android:label="fragment_search" tools:layout="@layout/fragment_search">
<action android:id="@+id/action_searchFragment_to_browserFragment" app:destination="@id/browserFragment"/>
</fragment>
<fragment android:id="@+id/browserFragment" android:name="org.mozilla.fenix.browser.BrowserFragment"
android:label="fragment_browser" tools:layout="@layout/fragment_browser"/>
</navigation>

View File

@ -30,3 +30,9 @@ allprojects {
task clean(type: Delete) {
delete rootProject.buildDir
}
task showMeCache << {
configurations.compile.each { println it }
}

View File

@ -41,6 +41,7 @@ object Deps {
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_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_session = "org.mozilla.components:feature-session:${Versions.mozilla_android_components}"
const val mozilla_feature_storage = "org.mozilla.components:feature-storage:${Versions.mozilla_android_components}"