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

Commit

Permalink
Issue #35: Integrate search functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
csadilek committed May 25, 2018
1 parent aeeecae commit 0ff3184
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
7 changes: 7 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,15 @@ dependencies {

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']}"
implementation "org.mozilla.components:toolbar:${rootProject.ext.dependencies['mozillaComponents']}"

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

Expand All @@ -89,6 +95,7 @@ dependencies {

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
3 changes: 2 additions & 1 deletion app/src/main/java/mozilla/fenix/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ class MainActivity : AppCompatActivity() {
toolbarFeature = ToolbarFeature(
toolbar,
components.sessionProvider.sessionManager,
components.sessionUseCases.loadUrl)
components.sessionUseCases.loadUrl,
components.defaultSearchUseCase)

sessionFeature = SessionFeature(
components.sessionProvider,
Expand Down
16 changes: 15 additions & 1 deletion app/src/main/java/mozilla/fenix/components/Components.kt
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@
package mozilla.fenix.components

import android.content.Context
import kotlinx.coroutines.experimental.async
import mozilla.components.browser.engine.gecko.GeckoEngine
import mozilla.components.browser.search.SearchEngineManager
import mozilla.components.browser.session.Session
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
Expand All @@ -17,14 +20,25 @@ import org.mozilla.geckoview.GeckoRuntime
* 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) }

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

val sessionUseCases = SessionUseCases(sessionProvider, engine)

// Search
private val searchEngineManager by lazy {
SearchEngineManager().apply {
async { load(applicationContext) }
}
}
private val searchUseCases = SearchUseCases(applicationContext, searchEngineManager, sessionProvider)
val defaultSearchUseCase = { searchTerms: String -> searchUseCases.defaultSearch.invoke(searchTerms) }
}
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
buildscript {
ext.dependencies = [
kotlin: '1.2.40',
coroutines: '0.22.5',
sentry: '1.7.3',
supportLibraries: '27.1.1',
constraintLayout: '1.1.0',
Expand Down Expand Up @@ -46,6 +47,11 @@ allprojects {
repositories {
google()
jcenter()

// Temporary until all modules are synced to JCenter
maven {
url "https://dl.bintray.com/pocmo/Mozilla-Mobile"
}
}
}

Expand Down

0 comments on commit 0ff3184

Please sign in to comment.