Skip to content

Commit

Permalink
For mozilla-mobile#3869 - Uses RegionSearchLocalizationProvider in th…
Browse files Browse the repository at this point in the history
…e search engine provider
  • Loading branch information
boek committed Jan 16, 2020
1 parent f4b583f commit cffa7c2
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ gen-external-apklibs
.adjust_token
.sentry_token
.digital_asset_links_token
.mls_token


# Python Byte-compiled / optimized / DLL files
Expand Down
17 changes: 17 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,21 @@ android.applicationVariants.all { variant ->
buildConfigField 'String', 'DIGITAL_ASSET_LINKS_TOKEN', 'null'
println("X_X")
}

// -------------------------------------------------------------------------------------------------
// MLS: Read token from local file if it exists
// -------------------------------------------------------------------------------------------------

print("MLS token: ")

try {
def token = new File("${rootDir}/.mls_token").text.trim()
buildConfigField 'String', 'MLS_TOKEN', '"' + token + '"'
println "(Added from .mls_token file)"
} catch (FileNotFoundException ignored) {
buildConfigField 'String', 'MLS_TOKEN', '""'
println("X_X")
}
}

androidExtensions {
Expand Down Expand Up @@ -422,6 +437,8 @@ dependencies {
implementation Deps.mozilla_service_firefox_accounts
implementation Deps.mozilla_service_glean
implementation Deps.mozilla_service_experiments
implementation Deps.mozilla_service_location


implementation Deps.mozilla_support_base
implementation Deps.mozilla_support_ktx
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import mozilla.components.browser.search.provider.SearchEngineList
import mozilla.components.browser.search.provider.SearchEngineProvider
import mozilla.components.browser.search.provider.filter.SearchEngineFilter
import mozilla.components.browser.search.provider.localization.LocaleSearchLocalizationProvider
import mozilla.components.service.location.MozillaLocationService
import mozilla.components.service.location.search.RegionSearchLocalizationProvider
import org.mozilla.fenix.BuildConfig
import org.mozilla.fenix.ext.components
import org.mozilla.fenix.ext.settings
import java.util.Locale

Expand All @@ -26,15 +30,25 @@ open class FenixSearchEngineProvider(
private val context: Context
) : SearchEngineProvider, CoroutineScope by CoroutineScope(Job() + Dispatchers.IO) {
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)

private val localizationProvider =
RegionSearchLocalizationProvider(
MozillaLocationService(
context,
context.components.core.client,
BuildConfig.MLS_TOKEN
)
)

open val baseSearchEngines = async {
AssetsSearchEngineProvider(LocaleSearchLocalizationProvider()).loadSearchEngines(context)
AssetsSearchEngineProvider(localizationProvider).loadSearchEngines(context)
}

@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
open val bundledSearchEngines = async {
val defaultEngineIdentifiers = baseSearchEngines.await().list.map { it.identifier }.toSet()
AssetsSearchEngineProvider(
LocaleSearchLocalizationProvider(),
localizationProvider,
filters = listOf(object : SearchEngineFilter {
override fun filter(context: Context, searchEngine: SearchEngine): Boolean {
return BUNDLED_SEARCH_ENGINES.contains(searchEngine.identifier) &&
Expand Down
1 change: 1 addition & 0 deletions buildSrc/src/main/java/Dependencies.kt
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ object Deps {
const val mozilla_service_glean = "org.mozilla.components:service-glean:${Versions.mozilla_android_components}"
const val mozilla_service_glean_forUnitTests = "org.mozilla.telemetry:glean-forUnitTests:${Versions.mozilla_glean}"
const val mozilla_service_experiments = "org.mozilla.components:service-experiments:${Versions.mozilla_android_components}"
const val mozilla_service_location = "org.mozilla.components:service-location:${Versions.mozilla_android_components}"

const val mozilla_ui_colors = "org.mozilla.components:ui-colors:${Versions.mozilla_android_components}"
const val mozilla_ui_icons = "org.mozilla.components:ui-icons:${Versions.mozilla_android_components}"
Expand Down
2 changes: 2 additions & 0 deletions taskcluster/fenix_taskgraph/transforms/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ def add_shippable_secrets(config, tasks):
('digital_asset_links', '.digital_asset_links_token'),
('leanplum', '.leanplum_token'),
('sentry_dsn', '.sentry_token'),
('mls', '.mls_token'),
)])
else:
task["run"]["pre-gradlew"] = [[
Expand All @@ -55,6 +56,7 @@ def add_shippable_secrets(config, tasks):
("--", ".adjust_token"),
("", ".digital_asset_links_token"),
("-:-", ".leanplum_token"),
("", ".mls_token"),
("https://fake@sentry.prod.mozaws.net/368", ".sentry_token"),
)]

Expand Down

0 comments on commit cffa7c2

Please sign in to comment.