Skip to content
This repository has been archived by the owner on Feb 20, 2023. It is now read-only.

Commit

Permalink
Upgrade to android-components 0.11
Browse files Browse the repository at this point in the history
  • Loading branch information
csadilek committed Jun 25, 2018
1 parent 5596105 commit e53678a
Show file tree
Hide file tree
Showing 7 changed files with 180 additions and 38 deletions.
104 changes: 90 additions & 14 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,21 @@ android {
lintConfig file("${rootDir}/config/lint.xml")
}

flavorDimensions "abi"
flavorDimensions "channel", "abi"

productFlavors {
// GeckoView release channels
nightly {
dimension "channel"
}
beta {
dimension "channel"
}
production {
dimension "channel"
}

// Processor architecture
x86 {
dimension "abi"
}
Expand All @@ -49,30 +61,84 @@ android {
}

repositories {
// GeckoView ARM
////////////////////////////////////////////////////////////////////////////////////////////
// GeckoView Nightly
////////////////////////////////////////////////////////////////////////////////////////////

// ARM
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.nightly.${geckoNightly['nightlyDate']}.revision.${geckoNightly['revision']}.mobile.android-api-16-opt/artifacts/public/android/maven"
}

// x86
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.nightly.${geckoNightly['nightlyDate']}.revision.${geckoNightly['revision']}.mobile.android-x86-opt/artifacts/public/android/maven"
}

// aarch64
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"
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.nightly.${geckoNightly['nightlyDate']}.revision.${geckoNightly['revision']}.mobile.android-aarch64-opt/artifacts/public/android/maven"
}

// GeckoView x86
////////////////////////////////////////////////////////////////////////////////////////////
// GeckoView Beta
////////////////////////////////////////////////////////////////////////////////////////////

// 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-x86-opt/artifacts/public/android/maven"
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-beta.revision.${geckoBeta['revision']}.mobile.android-api-16-opt/artifacts/public/android/maven"
}

// GeckoView aarch64
// x86
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-central.nightly.${rootProject.ext.gecko['nightlyDate']}.revision.${rootProject.ext.gecko['revision']}.mobile.android-aarch64-opt/artifacts/public/android/maven"
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-beta.revision.${geckoBeta['revision']}.mobile.android-x86-opt/artifacts/public/android/maven"
}

// aarch64
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-beta.revision.${geckoBeta['revision']}.mobile.android-aarch64-opt/artifacts/public/android/maven"
}

////////////////////////////////////////////////////////////////////////////////////////////
// GeckoView Release (60.0.2)
////////////////////////////////////////////////////////////////////////////////////////////

// ARM
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-release.revision.${geckoRelease['revision']}.mobile.android-api-16-opt/artifacts/public/android/maven"
}

// x86
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-release.revision.${geckoRelease['revision']}.mobile.android-x86-opt/artifacts/public/android/maven"
}

// aarch64
maven {
url "https://index.taskcluster.net/v1/task/gecko.v2.mozilla-release.revision.${geckoRelease['revision']}.mobile.android-aarch64-opt/artifacts/public/android/maven"
}
}


configurations {
nightlyArmImplementation {}
nightlyX86Implementation {}
nightlyAarch64Implementation {}

betaArmImplementation {}
betaX86Implementation {}
betaAarch64Implementation {}

productionArmImplementation {}
productionX86Implementation {}
productionAarch64Implementation {}
}

dependencies {
implementation "io.sentry:sentry-android:${rootProject.ext.dependencies['sentry']}"

implementation "org.mozilla.components:engine:${rootProject.ext.dependencies['mozillaComponents']}"
implementation "org.mozilla.components:engine-gecko:${rootProject.ext.dependencies['mozillaComponents']}"

implementation "org.mozilla.components:search:${rootProject.ext.dependencies['mozillaComponents']}"

implementation "org.mozilla.components:session:${rootProject.ext.dependencies['mozillaComponents']}"

implementation "org.mozilla.components:abstract-toolbar:${rootProject.ext.dependencies['mozillaComponents']}"
Expand All @@ -89,17 +155,27 @@ dependencies {
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']}"
nightlyImplementation "org.mozilla.components:engine-gecko-nightly:${rootProject.ext.dependencies['mozillaComponents']}"
nightlyArmImplementation "org.mozilla:geckoview-nightly-armeabi-v7a:${rootProject.ext.geckoNightly['version']}"
nightlyX86Implementation "org.mozilla:geckoview-nightly-x86:${rootProject.ext.geckoNightly['version']}"
nightlyAarch64Implementation "org.mozilla:geckoview-nightly-arm64-v8a:${rootProject.ext.geckoNightly['version']}"

betaImplementation "org.mozilla.components:engine-gecko-beta:${rootProject.ext.dependencies['mozillaComponents']}"
betaArmImplementation "org.mozilla:geckoview-beta-armeabi-v7a:61.0.20180614135649"
betaX86Implementation "org.mozilla:geckoview-beta-x86:61.0.20180614135649"
betaAarch64Implementation "org.mozilla:geckoview-beta-arm64-v8a:61.0.20180614135649"

productionImplementation "org.mozilla.components:engine-gecko:${rootProject.ext.dependencies['mozillaComponents']}"
productionArmImplementation "org.mozilla:geckoview-release-armeabi-v7a:60.0.2"
productionX86Implementation "org.mozilla:geckoview-release-x86:60.0.2"
productionAarch64Implementation "org.mozilla:geckoview-release-arm64-v8a:60.0.2"

implementation "com.android.support:appcompat-v7:${rootProject.ext.dependencies['supportLibraries']}"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${rootProject.ext.dependencies['kotlin']}"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:${rootProject.ext.dependencies['coroutines']}"
implementation "com.android.support.constraint:constraint-layout:${rootProject.ext.dependencies['constraintLayout']}"

testImplementation "junit:junit:${rootProject.ext.dependencies['junit']}"

}

// -------------------------------------------------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions app/src/beta/java/org/mozilla/samples/browser/EngineProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.samples.browser

import android.content.Context
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.concept.engine.Engine
import org.mozilla.geckoview.GeckoRuntime

object EngineProvider {
fun createEngine(applicationContext: Context): Engine {
val runtime = GeckoRuntime.getDefault(applicationContext)
return GeckoEngine(runtime)
}
}
8 changes: 4 additions & 4 deletions app/src/main/java/mozilla/fenix/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ class MainActivity : AppCompatActivity() {

toolbarFeature = ToolbarFeature(
toolbar,
components.sessionProvider.sessionManager,
components.sessionManager,
components.sessionUseCases.loadUrl,
components.defaultSearchUseCase)

sessionFeature = SessionFeature(
components.sessionProvider,
components.sessionManager,
components.sessionUseCases,
components.engine,
engineView)
engineView,
components.sessionStorage)

lifecycle.addObserver(FeatureLifecycleObserver(sessionFeature, toolbarFeature))
}
Expand Down
32 changes: 18 additions & 14 deletions app/src/main/java/mozilla/fenix/components/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,45 +5,49 @@
package mozilla.fenix.components

import android.content.Context
import android.widget.Toast
import kotlinx.coroutines.experimental.async
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.menu.BrowserMenuBuilder
import mozilla.components.browser.menu.item.BrowserMenuItemToolbar
import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.session.Session
import mozilla.components.browser.session.SessionManager
import mozilla.components.browser.session.storage.DefaultSessionStorage
import mozilla.components.concept.engine.Engine
import mozilla.components.feature.search.SearchUseCases
import mozilla.components.feature.session.DefaultSessionStorage
import mozilla.components.feature.session.SessionProvider
import mozilla.components.feature.session.SessionUseCases
import mozilla.fenix.R
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.samples.browser.EngineProvider

/**
* Helper class for lazily instantiating components needed by the application.
*/
class Components(private val applicationContext: Context) {

// Engine
private val geckoRuntime by lazy {
GeckoRuntime.getDefault(applicationContext)
}
val engine : Engine by lazy { GeckoEngine(geckoRuntime) }
val engine: Engine by lazy { EngineProvider.createEngine(applicationContext) }

// Session
val sessionProvider : SessionProvider by lazy {
SessionProvider(Session("https://www.mozilla.org"), DefaultSessionStorage(applicationContext))
val sessionStorage by lazy { DefaultSessionStorage(applicationContext) }

val sessionManager by lazy {
SessionManager(engine).apply {
sessionStorage.restore(engine, this)

if (size == 0) {
val initialSession = Session("https://www.mozilla.org")
add(initialSession)
}
}
}
val sessionUseCases = SessionUseCases(sessionProvider, engine)

val sessionUseCases = SessionUseCases(sessionManager)

// Search
private val searchEngineManager by lazy {
SearchEngineManager().apply {
async { load(applicationContext) }
}
}
private val searchUseCases = SearchUseCases(applicationContext, searchEngineManager, sessionProvider)
private val searchUseCases = SearchUseCases(applicationContext, searchEngineManager, sessionManager)
val defaultSearchUseCase = { searchTerms: String -> searchUseCases.defaultSearch.invoke(searchTerms) }

// Menu
Expand Down
17 changes: 17 additions & 0 deletions app/src/nightly/java/org/mozilla/samples/browser/EngineProvider.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.samples.browser

import android.content.Context
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.concept.engine.Engine
import org.mozilla.geckoview.GeckoRuntime

object EngineProvider {
fun createEngine(applicationContext: Context): Engine {
val runtime = GeckoRuntime.getDefault(applicationContext)
return GeckoEngine(runtime)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */

package org.mozilla.samples.browser

import android.content.Context
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.concept.engine.Engine

object EngineProvider {
fun createEngine(applicationContext: Context): Engine {
return GeckoEngine(applicationContext)
}
}
25 changes: 19 additions & 6 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,27 @@ buildscript {
// Testing
junit: '4.12',
// Mozilla
mozillaComponents: '0.7'
mozillaComponents: '0.11'
]

ext.gecko = [
// Discover nightly builds: https://tools.taskcluster.net/index/gecko.v2.mozilla-central.nightly
nightlyDate: '2018.05.16',
revision: 'dedd25bfd2794eaba95225361f82c701e49c9339',
version: '62.0.20180516100458'
// Synchronized versions numbers of GeckoView (Nightly) artifacts.
ext.geckoNightly = [
// Discover nightly builds: https://tools.taskcluster.net/index/gecko.v2.mozilla-central.nightly
nightlyDate: '2018.06.21',
revision: 'e834d23a292972ab4250a8be00e6740c43e41db2',
version: '62.0.20180621100051'
]

// Synchronized versions numbers of GeckoView (Beta) artifacts.
ext.geckoBeta = [
// (61.0b14)
revision: '585281dde9604ddd197693ca5330f2b95987a181',
version: '61.0.20180614135649'
]

ext.geckoRelease = [
revision: 'a0b222c551f586904f51228c49149d9b6b7e2a81',
version: '60.0.2'
]

ext.build = [
Expand Down

0 comments on commit e53678a

Please sign in to comment.