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

Commit

Permalink
Fix deprecation errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jonalmeida committed Jul 24, 2021
1 parent 70f7b5e commit 1f4173d
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 8 deletions.
1 change: 1 addition & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,7 @@ tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all {
kotlinOptions {
allWarningsAsErrors = true
freeCompilerArgs += "-Xuse-experimental=kotlinx.coroutines.ExperimentalCoroutinesApi"
freeCompilerArgs += "-Xopt-in=kotlin.RequiresOptIn"
jvmTarget = '1.8'
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.mozilla.focus.ext.components
import org.mozilla.focus.ext.requireComponents
import org.mozilla.focus.state.AppAction
import org.mozilla.focus.telemetry.TelemetryWrapper
import kotlin.collections.forEach as withEach

class ExceptionsRemoveFragment : ExceptionsListFragment() {

Expand All @@ -43,7 +44,7 @@ class ExceptionsRemoveFragment : ExceptionsListFragment() {
val domains = exceptions.map { it.url.tryGetHostFromUrl() }
ExceptionDomains.remove(context, domains)
}
exceptions.forEach { exception ->
exceptions.withEach { exception ->
context.components.trackingProtectionUseCases.removeException(exception)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import mozilla.components.support.base.log.logger.Logger
import org.mozilla.geckoview.GeckoRuntime
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.ContentPermission.VALUE_ALLOW
import org.mozilla.geckoview.GeckoSession.PermissionDelegate.PERMISSION_TRACKING
import kotlin.collections.forEach as withEach

/**
* Migrate preference based Focus tracking protection exceptions to gecko based exceptions.
Expand All @@ -29,7 +30,7 @@ class GeckoExceptionsMigrator(
val exceptions = fetchExceptions(context)

withContext(Dispatchers.Main) {
exceptions.forEach { migrate(it) }
exceptions.withEach { migrate(it) }
}

logger.info("Finished tracking protection exceptions migration")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import androidx.preference.PreferenceManager
import com.google.android.material.appbar.AppBarLayout
import com.google.android.material.snackbar.Snackbar
import kotlinx.android.synthetic.main.fragment_browser.*
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -319,6 +320,7 @@ class BrowserFragment :
promptFeature.withFeature { it.onActivityResult(requestCode, data, resultCode) }
}

@OptIn(DelicateCoroutinesApi::class)
private fun showCrashReporter(crash: Crash) {
val fragmentManager = requireActivity().supportFragmentManager

Expand All @@ -333,6 +335,7 @@ class BrowserFragment :
crashReporterFragment.onCloseTabPressed = { sendCrashReport ->
if (sendCrashReport) {
val crashReporter = requireComponents.crashReporter

GlobalScope.launch(Dispatchers.IO) { crashReporter.submitReport(crash) }
}
erase()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.mozilla.focus.settings.SettingsFragment
import org.mozilla.focus.state.Screen
import org.mozilla.focus.utils.FeatureFlags
import org.mozilla.focus.utils.ViewUtils
import kotlin.collections.forEach as withEach

/**
* Class performing the actual navigation in [MainActivity] by performing fragment transactions if
Expand Down Expand Up @@ -158,7 +159,7 @@ class MainActivityNavigation(
val transaction = fragmentManager
.beginTransaction()

fragmentManager.fragments.forEach { fragment ->
fragmentManager.fragments.withEach { fragment ->
transaction.remove(fragment)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ class SearchSuggestionsFetcher(

fun requestSuggestions(query: String) {
if (query.isBlank()) { _results.value = SuggestionResult(query, listOf()); return }
fetchChannel.offer(query)
fetchChannel.trySend(query)
}

fun updateSearchEngine(searchEngine: SearchEngine?) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import org.mozilla.focus.search.RadioSearchEngineListPreference
import org.mozilla.focus.state.AppAction
import org.mozilla.focus.state.Screen
import org.mozilla.focus.telemetry.TelemetryWrapper
import kotlin.collections.forEach as withEach

class InstalledSearchEnginesSettingsFragment : BaseSettingsFragment() {
override fun onCreatePreferences(p0: Bundle?, p1: String?) {
Expand Down Expand Up @@ -112,6 +113,6 @@ private fun SearchState.hasDefaultSearchEnginesOnly(): Boolean {
}

private fun restoreSearchDefaults(store: BrowserStore, useCases: SearchUseCases) {
store.state.search.customSearchEngines.forEach { searchEngine -> useCases.removeSearchEngine(searchEngine) }
store.state.search.hiddenSearchEngines.forEach { searchEngine -> useCases.addSearchEngine(searchEngine) }
store.state.search.customSearchEngines.withEach { searchEngine -> useCases.removeSearchEngine(searchEngine) }
store.state.search.hiddenSearchEngines.withEach { searchEngine -> useCases.addSearchEngine(searchEngine) }
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package org.mozilla.focus.telemetry

import android.content.Context
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.Dispatchers.IO
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.async
Expand Down Expand Up @@ -36,6 +37,7 @@ class GleanMetricsService(context: Context) : MetricsService {

private val activationPing = ActivationPing(context)

@OptIn(DelicateCoroutinesApi::class)
override fun initialize(context: Context) {
val components = context.components
val settings = Settings.getInstance(context)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import mozilla.components.browser.state.state.CustomTabSessionState
import mozilla.components.browser.state.state.SessionState
import mozilla.components.lib.state.Middleware
import mozilla.components.lib.state.MiddlewareContext
import kotlin.collections.forEach as withEach

class TelemetryMiddleware : Middleware<BrowserState, BrowserAction> {
override fun invoke(
Expand All @@ -23,7 +24,7 @@ class TelemetryMiddleware : Middleware<BrowserState, BrowserAction> {

when (action) {
is TabListAction.AddTabAction -> collectTelemetry(action.tab)
is TabListAction.AddMultipleTabsAction -> action.tabs.forEach { collectTelemetry(it) }
is TabListAction.AddMultipleTabsAction -> action.tabs.withEach { collectTelemetry(it) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package org.mozilla.telemetry.measurement

import org.json.JSONObject
import kotlin.collections.forEach as withEach

private const val FIELD_NAME = "experiments"

Expand All @@ -15,7 +16,7 @@ class ExperimentsMapMeasurement : TelemetryMeasurement(FIELD_NAME) {
private val map = JSONObject()

fun setExperiments(experiments: Map<String, Boolean>) {
experiments.forEach { entry ->
experiments.withEach { entry ->
map.put(entry.key, if (entry.value) VALUE_BRANCH else VALUE_CONTROL)
}
}
Expand Down

0 comments on commit 1f4173d

Please sign in to comment.