1
0
Fork 0

For #3869 - Uses RegionSearchLocalizationProvider in the search engine provider

master
Jeff Boek 2020-01-16 13:12:54 -08:00
parent 2b0a5086d5
commit a8746320d7
5 changed files with 37 additions and 3 deletions

1
.gitignore vendored
View File

@ -84,6 +84,7 @@ gen-external-apklibs
.adjust_token
.sentry_token
.digital_asset_links_token
.mls_token
# Python Byte-compiled / optimized / DLL files

View File

@ -356,6 +356,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 {
@ -429,6 +444,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

View File

@ -17,7 +17,10 @@ import mozilla.components.browser.search.provider.AssetsSearchEngineProvider
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
@ -26,15 +29,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) &&

View File

@ -135,6 +135,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}"

View File

@ -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"] = [[
@ -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"),
)]