From 8495b385bca2d6c9a95bf97933fe44697baf6ad6 Mon Sep 17 00:00:00 2001 From: Sebastian Kaspari Date: Thu, 3 May 2018 15:17:00 +0200 Subject: [PATCH] Issue #35: Integrate "browser-toolbar" component. --- app/build.gradle | 11 +++++++++++ app/src/main/AndroidManifest.xml | 3 +++ app/src/main/java/mozilla/fenix/MainActivity.kt | 16 +++++++++++++--- .../fenix/components/FeatureLifecycleObserver.kt | 8 ++++++-- app/src/main/res/layout/activity_main.xml | 6 ++++++ app/src/main/res/values/styles.xml | 2 +- 6 files changed, 40 insertions(+), 6 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index e11ec024d9bf..efb6fb168c29 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -49,6 +49,11 @@ android { } repositories { + maven { + // Temporary solution until all required packages are on JCenter + url "https://dl.bintray.com/pocmo/Mozilla-Mobile/" + } + // GeckoView ARM maven { url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.nightly.${rootProject.ext.gecko['nightlyDate']}.revision.${rootProject.ext.gecko['revision']}.mobile.android-api-16-opt/artifacts/public/android/maven" @@ -75,8 +80,14 @@ dependencies { implementation "org.mozilla.components:toolbar:${rootProject.ext.dependencies['mozillaComponents']}" implementation "org.mozilla.components:feature-session:${rootProject.ext.dependencies['mozillaComponents']}" implementation "org.mozilla.components:feature-toolbar:${rootProject.ext.dependencies['mozillaComponents']}" + + implementation "org.mozilla.components:autocomplete:${rootProject.ext.dependencies['mozillaComponents']}" implementation "org.mozilla.components:ktx:${rootProject.ext.dependencies['mozillaComponents']}" + implementation "org.mozilla.photon:colors:${rootProject.ext.dependencies['mozillaComponents']}" + implementation "org.mozilla.photon:icons:${rootProject.ext.dependencies['mozillaComponents']}" + implementation "org.mozilla.photon:progress:${rootProject.ext.dependencies['mozillaComponents']}" + armImplementation "org.mozilla:geckoview-nightly-armeabi-v7a:${rootProject.ext.gecko['version']}" x86Implementation "org.mozilla:geckoview-nightly-x86:${rootProject.ext.gecko['version']}" aarch64Implementation "org.mozilla:geckoview-nightly-arm64-v8a:${rootProject.ext.gecko['version']}" diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 3b2911df1e41..aeb23c5a1429 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,4 +1,7 @@ + diff --git a/app/src/main/java/mozilla/fenix/MainActivity.kt b/app/src/main/java/mozilla/fenix/MainActivity.kt index 9d6f98cef244..149dc9b95d28 100644 --- a/app/src/main/java/mozilla/fenix/MainActivity.kt +++ b/app/src/main/java/mozilla/fenix/MainActivity.kt @@ -12,6 +12,7 @@ import android.view.View import kotlinx.android.synthetic.main.activity_main.* import mozilla.components.concept.engine.EngineView import mozilla.components.feature.session.SessionFeature +import mozilla.components.feature.toolbar.ToolbarFeature import mozilla.fenix.components.FeatureLifecycleObserver import mozilla.fenix.ext.components @@ -21,10 +22,19 @@ class MainActivity : AppCompatActivity() { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) - val sessionFeature = SessionFeature(components.sessionManager, components.sessionUseCases, - components.engine, engineView, components.sessionMapping) + val toolbarFeature = ToolbarFeature( + components.sessionManager, + components.sessionUseCases.loadUrl, + toolbar) - lifecycle.addObserver(FeatureLifecycleObserver(sessionFeature)) + val sessionFeature = SessionFeature( + components.sessionManager, + components.sessionUseCases, + components.engine, + engineView, + components.sessionMapping) + + lifecycle.addObserver(FeatureLifecycleObserver(sessionFeature, toolbarFeature)) } override fun onCreateView(parent: View?, name: String?, context: Context?, attrs: AttributeSet?): View? { diff --git a/app/src/main/java/mozilla/fenix/components/FeatureLifecycleObserver.kt b/app/src/main/java/mozilla/fenix/components/FeatureLifecycleObserver.kt index 5bc426071356..beb1ae304d82 100644 --- a/app/src/main/java/mozilla/fenix/components/FeatureLifecycleObserver.kt +++ b/app/src/main/java/mozilla/fenix/components/FeatureLifecycleObserver.kt @@ -8,20 +8,24 @@ import android.arch.lifecycle.Lifecycle import android.arch.lifecycle.LifecycleObserver import android.arch.lifecycle.OnLifecycleEvent import mozilla.components.feature.session.SessionFeature +import mozilla.components.feature.toolbar.ToolbarFeature /** * LifecycleObserver implementation that will forward lifecycle callbacks to "feature" components. */ class FeatureLifecycleObserver( - private val sessionFeature: SessionFeature + private val sessionFeature: SessionFeature, + private val toolbarFeature: ToolbarFeature ): LifecycleObserver { @OnLifecycleEvent(Lifecycle.Event.ON_START) fun startFeatures() { sessionFeature.start() + toolbarFeature.start() } @OnLifecycleEvent(Lifecycle.Event.ON_STOP) fun stopFeatures() { sessionFeature.stop() + toolbarFeature.stop() } -} \ No newline at end of file +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index dd4bb32d98de..1b55499a4b24 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -9,6 +9,12 @@ android:orientation="vertical" tools:context=".MainActivity"> + + -