From 8bd4dc98d2c0665435f9e2c9199ee3e8969a62a0 Mon Sep 17 00:00:00 2001 From: Sawyer Blatz Date: Wed, 7 Aug 2019 14:00:53 -0700 Subject: [PATCH] [fenix] For https://github.com/mozilla-mobile/fenix/issues/4508: Treats warnings as errors (https://github.com/mozilla-mobile/fenix/pull/4543) --- app/src/main/java/org/mozilla/fenix/HomeActivity.kt | 4 ++-- .../java/org/mozilla/fenix/browser/BrowserFragment.kt | 9 +++++++-- .../fenix/components/toolbar/BrowserToolbarView.kt | 7 ++----- .../fenix/components/toolbar/ToolbarIntegration.kt | 2 -- .../org/mozilla/fenix/exceptions/ExceptionsFragment.kt | 4 ++++ .../mozilla/fenix/library/bookmarks/BookmarkFragment.kt | 4 ++++ .../org/mozilla/fenix/library/history/HistoryFragment.kt | 4 ++++ .../main/java/org/mozilla/fenix/search/SearchFragment.kt | 4 ++++ app/src/test/java/org/mozilla/fenix/TestApplication.kt | 2 ++ .../org/mozilla/fenix/components/StoreProviderTest.kt | 2 ++ .../java/org/mozilla/fenix/components/TestComponents.kt | 2 ++ .../fenix/components/metrics/ActivationPingTest.kt | 5 ++--- .../fenix/components/metrics/PerformedSearchTest.kt | 2 ++ .../test/java/org/mozilla/fenix/ext/TabCollectionTest.kt | 4 +++- .../fenix/library/bookmarks/BookmarkAdapterTest.kt | 2 ++ .../test/java/org/mozilla/fenix/utils/SettingsTest.kt | 2 ++ build.gradle | 4 ++++ 17 files changed, 48 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt index b9b4c64bd4..400db29958 100644 --- a/app/src/main/java/org/mozilla/fenix/HomeActivity.kt +++ b/app/src/main/java/org/mozilla/fenix/HomeActivity.kt @@ -25,8 +25,8 @@ import kotlinx.coroutines.launch import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.session.Session import mozilla.components.browser.session.SessionManager +import mozilla.components.browser.session.intent.EXTRA_SESSION_ID import mozilla.components.concept.engine.EngineView -import mozilla.components.feature.intent.IntentProcessor import mozilla.components.lib.crash.Crash import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.ktx.kotlin.isUrl @@ -206,7 +206,7 @@ open class HomeActivity : AppCompatActivity(), ShareFragment.TabsSharedCallback var customTabSessionId: String? = null if (isCustomTab) { - customTabSessionId = SafeIntent(intent).getStringExtra(IntentProcessor.ACTIVE_SESSION_ID) + customTabSessionId = SafeIntent(intent).getStringExtra(EXTRA_SESSION_ID) } openToBrowser(BrowserDirection.FromGlobal, customTabSessionId) diff --git a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt index e023e913c1..ff6eaa9d3d 100644 --- a/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/browser/BrowserFragment.kt @@ -21,7 +21,9 @@ import kotlinx.android.synthetic.main.component_search.* import kotlinx.android.synthetic.main.fragment_browser.view.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job +import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.launch import kotlinx.coroutines.withContext import mozilla.appservices.places.BookmarkRoot @@ -29,7 +31,6 @@ import mozilla.components.browser.session.Session import mozilla.components.browser.session.SessionManager import mozilla.components.feature.readerview.ReaderViewFeature import mozilla.components.feature.session.ThumbnailsFeature -import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.support.base.feature.BackHandler import mozilla.components.support.base.feature.ViewBoundFeatureWrapper @@ -46,6 +47,7 @@ import org.mozilla.fenix.customtabs.CustomTabsIntegration import org.mozilla.fenix.ext.nav import org.mozilla.fenix.ext.requireComponents import org.mozilla.fenix.home.sessioncontrol.SessionControlChange +import org.mozilla.fenix.home.sessioncontrol.TabCollection import org.mozilla.fenix.mvi.getManagedEmitter import org.mozilla.fenix.quickactionsheet.DefaultQuickActionSheetController import org.mozilla.fenix.quickactionsheet.QuickActionSheetView @@ -85,12 +87,15 @@ class BrowserFragment : BaseBrowserFragment(), BackHandler { return view } + @Suppress("LongMethod", "ComplexMethod") + @ObsoleteCoroutinesApi + @ExperimentalCoroutinesApi override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val sessionManager = requireComponents.core.sessionManager - getSessionById()?.let { session -> + getSessionById()?.let { quickActionSheetView = QuickActionSheetView(view.nestedScrollQuickAction, browserInteractor) customTabSessionId?.let { customTabSessionId -> diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt index 375fb6b5d7..7917d235b3 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/BrowserToolbarView.kt @@ -39,9 +39,6 @@ class BrowserToolbarView( val toolbarIntegration: ToolbarIntegration init { - // We need access to the customSessionId. We don't directly have access since we aren't passing session id in - // So we need to access it through the store...? - with(container.context) { val sessionManager = components.core.sessionManager val isCustomTabSession = currentSession.isCustomTabSession() @@ -100,7 +97,6 @@ class BrowserToolbarView( toolbarIntegration = ToolbarIntegration( this, view, - container, menuToolbar, ShippedDomainsProvider().also { it.initialize(this) }, components.core.historyStorage, @@ -111,8 +107,9 @@ class BrowserToolbarView( } } + @Suppress("UNUSED_PARAMETER") fun update(state: BrowserState) { - // TODO Leaving this as a stub for now since we don't actually have anything to update ever...? + // Intentionally leaving this as a stub for now since we don't actually want to update currently } companion object { diff --git a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarIntegration.kt b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarIntegration.kt index 1be217f2c0..9d129a65bd 100644 --- a/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarIntegration.kt +++ b/app/src/main/java/org/mozilla/fenix/components/toolbar/ToolbarIntegration.kt @@ -5,7 +5,6 @@ package org.mozilla.fenix.components.toolbar import android.content.Context -import android.view.ViewGroup import androidx.navigation.NavOptions import androidx.navigation.Navigation import mozilla.components.browser.domains.autocomplete.DomainAutocompleteProvider @@ -28,7 +27,6 @@ import org.mozilla.fenix.utils.Settings class ToolbarIntegration( context: Context, toolbar: BrowserToolbar, - browserLayout: ViewGroup, toolbarMenu: ToolbarMenu, domainAutocompleteProvider: DomainAutocompleteProvider, historyStorage: HistoryStorage, diff --git a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt index ba926a5fab..d530e75f3c 100644 --- a/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/exceptions/ExceptionsFragment.kt @@ -14,6 +14,8 @@ import androidx.lifecycle.lifecycleScope import kotlinx.android.synthetic.main.fragment_exceptions.view.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.coroutineScope import kotlinx.coroutines.launch import mozilla.components.lib.state.ext.consumeFrom @@ -53,6 +55,8 @@ class ExceptionsFragment : Fragment() { return view } + @ObsoleteCoroutinesApi + @ExperimentalCoroutinesApi override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) consumeFrom(exceptionsStore) { diff --git a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt index 98b483db8b..7daed4e6d7 100644 --- a/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/bookmarks/BookmarkFragment.kt @@ -23,7 +23,9 @@ import androidx.navigation.fragment.findNavController import kotlinx.android.synthetic.main.fragment_bookmark.view.* import kotlinx.coroutines.Dispatchers.IO import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.ExperimentalCoroutinesApi import kotlinx.coroutines.Job +import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.isActive import kotlinx.coroutines.launch import mozilla.appservices.places.BookmarkRoot @@ -95,6 +97,8 @@ class BookmarkFragment : LibraryPageFragment(), BackHandler, Accou return view } + @ObsoleteCoroutinesApi + @ExperimentalCoroutinesApi override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) consumeFrom(bookmarkStore) { diff --git a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt index a86ff2b3a6..0a155be41d 100644 --- a/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/library/history/HistoryFragment.kt @@ -21,6 +21,8 @@ import androidx.lifecycle.Observer import androidx.lifecycle.lifecycleScope import kotlinx.android.synthetic.main.fragment_history.view.* import kotlinx.coroutines.Dispatchers.Main +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.ObsoleteCoroutinesApi import kotlinx.coroutines.launch import mozilla.components.lib.state.ext.consumeFrom import mozilla.components.support.base.feature.BackHandler @@ -105,6 +107,8 @@ class HistoryFragment : LibraryPageFragment(), BackHandler { } } + @ObsoleteCoroutinesApi + @ExperimentalCoroutinesApi override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt index 5373f8b0b5..296fc5cde5 100644 --- a/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt +++ b/app/src/main/java/org/mozilla/fenix/search/SearchFragment.kt @@ -21,6 +21,8 @@ import androidx.fragment.app.Fragment import androidx.navigation.fragment.findNavController import kotlinx.android.synthetic.main.fragment_search.* import kotlinx.android.synthetic.main.fragment_search.view.* +import kotlinx.coroutines.ExperimentalCoroutinesApi +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.concept.storage.HistoryStorage import mozilla.components.feature.qr.QrFeature import mozilla.components.lib.state.ext.consumeFrom @@ -102,6 +104,8 @@ class SearchFragment : Fragment(), BackHandler { return view } + @ObsoleteCoroutinesApi + @ExperimentalCoroutinesApi override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) diff --git a/app/src/test/java/org/mozilla/fenix/TestApplication.kt b/app/src/test/java/org/mozilla/fenix/TestApplication.kt index 285ad7b305..9aa64f800c 100644 --- a/app/src/test/java/org/mozilla/fenix/TestApplication.kt +++ b/app/src/test/java/org/mozilla/fenix/TestApplication.kt @@ -4,9 +4,11 @@ package org.mozilla.fenix +import kotlinx.coroutines.ObsoleteCoroutinesApi import org.mozilla.fenix.components.Components import org.mozilla.fenix.components.TestComponents +@ObsoleteCoroutinesApi class TestApplication : FenixApplication() { override val components: Components diff --git a/app/src/test/java/org/mozilla/fenix/components/StoreProviderTest.kt b/app/src/test/java/org/mozilla/fenix/components/StoreProviderTest.kt index 20b25fe39a..7932700565 100644 --- a/app/src/test/java/org/mozilla/fenix/components/StoreProviderTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/StoreProviderTest.kt @@ -6,6 +6,7 @@ package org.mozilla.fenix.components import androidx.fragment.app.Fragment import androidx.fragment.app.testing.launchFragmentInContainer +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.lib.state.Action import mozilla.components.lib.state.State import mozilla.components.lib.state.Store @@ -18,6 +19,7 @@ import org.mozilla.fenix.TestApplication import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +@ObsoleteCoroutinesApi @RunWith(RobolectricTestRunner::class) @Config(application = TestApplication::class) class StoreProviderTest { diff --git a/app/src/test/java/org/mozilla/fenix/components/TestComponents.kt b/app/src/test/java/org/mozilla/fenix/components/TestComponents.kt index 755acba93e..0aec887ddd 100644 --- a/app/src/test/java/org/mozilla/fenix/components/TestComponents.kt +++ b/app/src/test/java/org/mozilla/fenix/components/TestComponents.kt @@ -6,7 +6,9 @@ package org.mozilla.fenix.components import android.content.Context import io.mockk.mockk +import kotlinx.coroutines.ObsoleteCoroutinesApi +@ObsoleteCoroutinesApi class TestComponents(private val context: Context) : Components(context) { override val backgroundServices by lazy { mockk(relaxed = true) diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/ActivationPingTest.kt b/app/src/test/java/org/mozilla/fenix/components/metrics/ActivationPingTest.kt index e93ef6af6d..0632417c83 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/ActivationPingTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/metrics/ActivationPingTest.kt @@ -16,10 +16,9 @@ import io.mockk.mockkStatic import io.mockk.slot import io.mockk.spyk import io.mockk.verify -import junit.framework.Assert.assertEquals -import junit.framework.Assert.assertNull - import kotlinx.coroutines.runBlocking +import org.junit.Assert.assertEquals +import org.junit.Assert.assertNull import org.junit.Test import org.mockito.ArgumentMatchers.any import org.mockito.ArgumentMatchers.anyString diff --git a/app/src/test/java/org/mozilla/fenix/components/metrics/PerformedSearchTest.kt b/app/src/test/java/org/mozilla/fenix/components/metrics/PerformedSearchTest.kt index b8220da98d..e805e8de28 100644 --- a/app/src/test/java/org/mozilla/fenix/components/metrics/PerformedSearchTest.kt +++ b/app/src/test/java/org/mozilla/fenix/components/metrics/PerformedSearchTest.kt @@ -4,6 +4,7 @@ package org.mozilla.fenix.components.metrics +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.browser.search.SearchEngine import mozilla.components.browser.search.SearchEngineManager import mozilla.components.browser.search.provider.AssetsSearchEngineProvider @@ -20,6 +21,7 @@ import org.mozilla.fenix.components.FenixLocaleSearchLocalizationProvider import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +@ObsoleteCoroutinesApi @RunWith(RobolectricTestRunner::class) @Config(application = TestApplication::class) class PerformedSearchTest { diff --git a/app/src/test/java/org/mozilla/fenix/ext/TabCollectionTest.kt b/app/src/test/java/org/mozilla/fenix/ext/TabCollectionTest.kt index 1ef5495750..1c075a4099 100644 --- a/app/src/test/java/org/mozilla/fenix/ext/TabCollectionTest.kt +++ b/app/src/test/java/org/mozilla/fenix/ext/TabCollectionTest.kt @@ -5,10 +5,11 @@ package org.mozilla.fenix.ext import androidx.core.content.ContextCompat -import junit.framework.Assert.assertEquals +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.feature.tab.collections.TabCollection import mozilla.components.support.test.mock import mozilla.components.support.test.robolectric.testContext +import org.junit.Assert.assertEquals import org.junit.Assert.assertNotEquals import org.junit.Test import org.junit.runner.RunWith @@ -18,6 +19,7 @@ import org.mozilla.fenix.TestApplication import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +@ObsoleteCoroutinesApi @RunWith(RobolectricTestRunner::class) @Config(application = TestApplication::class) class TabCollectionTest { diff --git a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkAdapterTest.kt b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkAdapterTest.kt index b23e5c8839..46e415b4fa 100644 --- a/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkAdapterTest.kt +++ b/app/src/test/java/org/mozilla/fenix/library/bookmarks/BookmarkAdapterTest.kt @@ -7,6 +7,7 @@ package org.mozilla.fenix.library.bookmarks import io.mockk.mockk import io.mockk.spyk import io.mockk.verifyOrder +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.concept.storage.BookmarkNode import mozilla.components.concept.storage.BookmarkNodeType import org.junit.Before @@ -16,6 +17,7 @@ import org.mozilla.fenix.TestApplication import org.robolectric.RobolectricTestRunner import org.robolectric.annotation.Config +@ObsoleteCoroutinesApi @RunWith(RobolectricTestRunner::class) @Config(application = TestApplication::class) internal class BookmarkAdapterTest { diff --git a/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt b/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt index 84748441e0..d1b124aef9 100644 --- a/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt +++ b/app/src/test/java/org/mozilla/fenix/utils/SettingsTest.kt @@ -5,6 +5,7 @@ package org.mozilla.fenix.utils import androidx.test.ext.junit.runners.AndroidJUnit4 +import kotlinx.coroutines.ObsoleteCoroutinesApi import mozilla.components.feature.sitepermissions.SitePermissionsRules import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.ASK_TO_ALLOW import mozilla.components.feature.sitepermissions.SitePermissionsRules.Action.BLOCKED @@ -19,6 +20,7 @@ import org.mozilla.fenix.TestApplication import org.mozilla.fenix.ext.clearAndCommit import org.robolectric.annotation.Config +@ObsoleteCoroutinesApi @RunWith(AndroidJUnit4::class) @Config(application = TestApplication::class) class SettingsTest { diff --git a/build.gradle b/build.gradle index 3449a0e19b..a8d331f152 100644 --- a/build.gradle +++ b/build.gradle @@ -35,6 +35,10 @@ allprojects { } jcenter() } + tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile).all { + kotlinOptions.allWarningsAsErrors = true + kotlinOptions.freeCompilerArgs += ["-Xuse-experimental=kotlin.Experimental", "-Xskip-runtime-version-check"] + } } task clean(type: Delete) {