From 4fac7d12532fc994e618c9ce8bdcd3a58e77088f Mon Sep 17 00:00:00 2001 From: Aitor Viana Date: Sat, 4 Dec 2021 21:00:04 +0000 Subject: [PATCH] Added sugar over multibindings that helps with Kotlin wildcards --- .../duckduckgo/app/di/StubStatisticsModule.kt | 3 ++- .../app/flipper/FlipperPluginPoint.kt | 7 ++++--- .../state/BrowserApplicationStateInfo.kt | 3 ++- .../com/duckduckgo/app/di/MigrationsModule.kt | 3 ++- .../com/duckduckgo/app/di/StatisticsModule.kt | 5 +++-- .../app/global/ActivityLifecycleCallbacks.kt | 5 +++-- .../app/global/DuckDuckGoApplication.kt | 3 ++- .../app/global/api/ApiInterceptorPlugin.kt | 7 ++++--- .../app/global/api/PixelInterceptorPlugin.kt | 7 ++++--- .../plugin/LifecycleObserverPluginPoint.kt | 5 +++-- .../extension/InternalFeaturePlugin.kt | 7 ++++--- .../plugins/migrations/MigrationPlugin.kt | 3 ++- .../view_model/ViewModelFactoryPlugin.kt | 3 ++- .../plugins/worker/WorkerInjectorPlugin.kt | 3 ++- .../java/com/duckduckgo/di/DaggerTypes.kt | 21 +++++++++++++++++++ .../toggles/impl/RealFeatureTogglesImpl.kt | 3 ++- .../toggles/impl/di/FeatureTogglesModules.kt | 5 +++-- .../config/impl/di/PrivacyConfigModule.kt | 5 +++-- .../impl/plugins/PrivacyFeaturePlugin.kt | 3 ++- .../api/RefreshRetentionAtbPlugin.kt | 5 +++-- .../vpn/bugreport/VpnStateCollector.kt | 7 ++++--- ...pnTrackerDetectorInterceptorPluginPoint.kt | 7 ++++--- .../vpn/service/VpnMemoryCollectorPlugin.kt | 7 ++++--- .../service/VpnServiceCallbacksPluginPoint.kt | 7 ++++--- 24 files changed, 89 insertions(+), 45 deletions(-) create mode 100644 di/src/main/java/com/duckduckgo/di/DaggerTypes.kt diff --git a/app/src/androidTest/java/com/duckduckgo/app/di/StubStatisticsModule.kt b/app/src/androidTest/java/com/duckduckgo/app/di/StubStatisticsModule.kt index caea4c52594d..c3c1faae5d64 100644 --- a/app/src/androidTest/java/com/duckduckgo/app/di/StubStatisticsModule.kt +++ b/app/src/androidTest/java/com/duckduckgo/app/di/StubStatisticsModule.kt @@ -27,6 +27,7 @@ import com.duckduckgo.app.statistics.api.StatisticsService import com.duckduckgo.app.statistics.api.StatisticsUpdater import com.duckduckgo.app.statistics.pixels.Pixel import com.duckduckgo.app.statistics.store.StatisticsDataStore +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -95,7 +96,7 @@ class StubStatisticsModule { @AppCoroutineScope appCoroutineScope: CoroutineScope, statisticsDataStore: StatisticsDataStore, statisticsUpdater: StatisticsUpdater, - listeners: Set<@JvmSuppressWildcards AtbInitializerListener> + listeners: DaggerSet ): LifecycleObserver { return AtbInitializer(appCoroutineScope, statisticsDataStore, statisticsUpdater, listeners) } diff --git a/app/src/internal/java/com/duckduckgo/app/flipper/FlipperPluginPoint.kt b/app/src/internal/java/com/duckduckgo/app/flipper/FlipperPluginPoint.kt index 07a8ed031afc..52d6ef11db57 100644 --- a/app/src/internal/java/com/duckduckgo/app/flipper/FlipperPluginPoint.kt +++ b/app/src/internal/java/com/duckduckgo/app/flipper/FlipperPluginPoint.kt @@ -17,6 +17,7 @@ package com.duckduckgo.app.flipper import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.facebook.flipper.core.FlipperPlugin import com.squareup.anvil.annotations.ContributesTo @@ -26,7 +27,7 @@ import dagger.multibindings.Multibinds import dagger.SingleInstanceIn private class FlipperPluginPluginPoint( - private val plugins: Set<@JvmSuppressWildcards FlipperPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins @@ -37,7 +38,7 @@ private class FlipperPluginPluginPoint( @ContributesTo(AppScope::class) abstract class FlipperPluginModule { @Multibinds - abstract fun bindEmptySettingInternalFeaturePlugins(): Set<@JvmSuppressWildcards FlipperPlugin> + abstract fun bindEmptySettingInternalFeaturePlugins(): DaggerSet @Module @ContributesTo(AppScope::class) @@ -45,7 +46,7 @@ abstract class FlipperPluginModule { @Provides @SingleInstanceIn(AppScope::class) fun provideSettingInternalFeaturePlugins( - plugins: Set<@JvmSuppressWildcards FlipperPlugin> + plugins: DaggerSet ): PluginPoint { return FlipperPluginPluginPoint(plugins) } diff --git a/app/src/main/java/com/duckduckgo/app/browser/state/BrowserApplicationStateInfo.kt b/app/src/main/java/com/duckduckgo/app/browser/state/BrowserApplicationStateInfo.kt index 524cfe521259..3eaf0d94cdd2 100644 --- a/app/src/main/java/com/duckduckgo/app/browser/state/BrowserApplicationStateInfo.kt +++ b/app/src/main/java/com/duckduckgo/app/browser/state/BrowserApplicationStateInfo.kt @@ -21,6 +21,7 @@ import android.os.Bundle import com.duckduckgo.app.browser.BrowserActivity import com.duckduckgo.app.global.ActivityLifecycleCallbacks import com.duckduckgo.browser.api.BrowserLifecycleObserver +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesMultibinding import dagger.SingleInstanceIn @@ -29,7 +30,7 @@ import javax.inject.Inject @ContributesMultibinding(AppScope::class) @SingleInstanceIn(AppScope::class) class BrowserApplicationStateInfo @Inject constructor( - private val observers: Set<@JvmSuppressWildcards BrowserLifecycleObserver> + private val observers: DaggerSet ) : ActivityLifecycleCallbacks { private var created = 0 private var started = 0 diff --git a/app/src/main/java/com/duckduckgo/app/di/MigrationsModule.kt b/app/src/main/java/com/duckduckgo/app/di/MigrationsModule.kt index 19fbb0b1948c..164bb9d740a1 100644 --- a/app/src/main/java/com/duckduckgo/app/di/MigrationsModule.kt +++ b/app/src/main/java/com/duckduckgo/app/di/MigrationsModule.kt @@ -19,6 +19,7 @@ package com.duckduckgo.app.di import com.duckduckgo.app.global.plugins.PluginPoint import com.duckduckgo.app.global.plugins.migrations.MigrationPlugin import com.duckduckgo.app.global.plugins.migrations.MigrationPluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Binds @@ -31,7 +32,7 @@ import dagger.SingleInstanceIn abstract class MigrationsPluginProviderModule { // we use multibinds as the list of plugins can be empty @Multibinds - abstract fun provideMigrationsPlugins(): Set<@JvmSuppressWildcards MigrationPlugin> + abstract fun provideMigrationsPlugins(): DaggerSet @Binds @SingleInstanceIn(AppScope::class) diff --git a/app/src/main/java/com/duckduckgo/app/di/StatisticsModule.kt b/app/src/main/java/com/duckduckgo/app/di/StatisticsModule.kt index c790ec3aa81b..4fe0c3c44454 100644 --- a/app/src/main/java/com/duckduckgo/app/di/StatisticsModule.kt +++ b/app/src/main/java/com/duckduckgo/app/di/StatisticsModule.kt @@ -32,6 +32,7 @@ import com.duckduckgo.app.statistics.pixels.Pixel import com.duckduckgo.app.statistics.store.OfflinePixelCountDataStore import com.duckduckgo.app.statistics.store.PendingPixelDao import com.duckduckgo.app.statistics.store.StatisticsDataStore +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -54,7 +55,7 @@ class StatisticsModule { statisticsDataStore: StatisticsDataStore, statisticsService: StatisticsService, variantManager: VariantManager, - plugins: Set<@JvmSuppressWildcards RefreshRetentionAtbPlugin>, + plugins: DaggerSet, ): StatisticsUpdater { return StatisticsRequester( statisticsDataStore, statisticsService, variantManager, RefreshRetentionAtbPluginPoint(plugins) @@ -107,7 +108,7 @@ class StatisticsModule { @AppCoroutineScope appCoroutineScope: CoroutineScope, statisticsDataStore: StatisticsDataStore, statisticsUpdater: StatisticsUpdater, - listeners: Set<@JvmSuppressWildcards AtbInitializerListener> + listeners: DaggerSet ): LifecycleObserver { return AtbInitializer(appCoroutineScope, statisticsDataStore, statisticsUpdater, listeners) } diff --git a/app/src/main/java/com/duckduckgo/app/global/ActivityLifecycleCallbacks.kt b/app/src/main/java/com/duckduckgo/app/global/ActivityLifecycleCallbacks.kt index b6538c5435ed..3974c3e0a377 100644 --- a/app/src/main/java/com/duckduckgo/app/global/ActivityLifecycleCallbacks.kt +++ b/app/src/main/java/com/duckduckgo/app/global/ActivityLifecycleCallbacks.kt @@ -20,6 +20,7 @@ import android.app.Activity import android.app.Application import android.os.Bundle import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -43,7 +44,7 @@ interface ActivityLifecycleCallbacks : Application.ActivityLifecycleCallbacks { } private class ActivityLifecycleCallbacksPluginPoint( - private val plugins: Set<@JvmSuppressWildcards ActivityLifecycleCallbacks> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins.sortedBy { it.javaClass.simpleName } @@ -56,6 +57,6 @@ class ActivityLifecycleCallbacksModule { @Provides @SingleInstanceIn(AppScope::class) fun provideActivityLifecycleCallbacksPluginPoint( - plugins: Set<@JvmSuppressWildcards ActivityLifecycleCallbacks> + plugins: DaggerSet ): PluginPoint = ActivityLifecycleCallbacksPluginPoint(plugins) } diff --git a/app/src/main/java/com/duckduckgo/app/global/DuckDuckGoApplication.kt b/app/src/main/java/com/duckduckgo/app/global/DuckDuckGoApplication.kt index 105a3a7a6676..23d530f4d914 100644 --- a/app/src/main/java/com/duckduckgo/app/global/DuckDuckGoApplication.kt +++ b/app/src/main/java/com/duckduckgo/app/global/DuckDuckGoApplication.kt @@ -36,6 +36,7 @@ import com.duckduckgo.app.process.ProcessDetector.DuckDuckGoProcess import com.duckduckgo.app.process.ProcessDetector.DuckDuckGoProcess.VpnProcess import com.duckduckgo.app.referral.AppInstallationReferrerStateListener import com.duckduckgo.app.statistics.pixels.Pixel +import com.duckduckgo.di.DaggerMap import com.duckduckgo.mobile.android.vpn.service.VpnUncaughtExceptionHandler import com.jakewharton.threetenabp.AndroidThreeTen import dagger.android.AndroidInjector @@ -76,7 +77,7 @@ open class DuckDuckGoApplication : HasDaggerInjector, Application(), LifecycleOb lateinit var appCoroutineScope: CoroutineScope @Inject - lateinit var injectorFactoryMap: Map<@JvmSuppressWildcards Class<*>, @JvmSuppressWildcards AndroidInjector.Factory<*>> + lateinit var injectorFactoryMap: DaggerMap, AndroidInjector.Factory<*>> private val processDetector = ProcessDetector() diff --git a/app/src/main/java/com/duckduckgo/app/global/api/ApiInterceptorPlugin.kt b/app/src/main/java/com/duckduckgo/app/global/api/ApiInterceptorPlugin.kt index 99e9945d6a54..4de329d61d36 100644 --- a/app/src/main/java/com/duckduckgo/app/global/api/ApiInterceptorPlugin.kt +++ b/app/src/main/java/com/duckduckgo/app/global/api/ApiInterceptorPlugin.kt @@ -17,6 +17,7 @@ package com.duckduckgo.app.global.api import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -30,7 +31,7 @@ interface ApiInterceptorPlugin { } private class ApiInterceptorPluginPoint( - private val plugins: Set<@JvmSuppressWildcards ApiInterceptorPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins @@ -41,7 +42,7 @@ private class ApiInterceptorPluginPoint( @ContributesTo(AppScope::class) abstract class ApiInterceptorPluginModule { @Multibinds - abstract fun bindEmptyApiInterceptorPlugins(): Set<@JvmSuppressWildcards ApiInterceptorPlugin> + abstract fun bindEmptyApiInterceptorPlugins(): DaggerSet @Module @ContributesTo(AppScope::class) @@ -49,7 +50,7 @@ abstract class ApiInterceptorPluginModule { @Provides @SingleInstanceIn(AppScope::class) fun provideApiInterceptorPlugins( - plugins: Set<@JvmSuppressWildcards ApiInterceptorPlugin> + plugins: DaggerSet ): PluginPoint { return ApiInterceptorPluginPoint(plugins) } diff --git a/app/src/main/java/com/duckduckgo/app/global/api/PixelInterceptorPlugin.kt b/app/src/main/java/com/duckduckgo/app/global/api/PixelInterceptorPlugin.kt index a70672002e98..bd28ab2c2f77 100644 --- a/app/src/main/java/com/duckduckgo/app/global/api/PixelInterceptorPlugin.kt +++ b/app/src/main/java/com/duckduckgo/app/global/api/PixelInterceptorPlugin.kt @@ -18,6 +18,7 @@ package com.duckduckgo.app.global.api import com.duckduckgo.app.global.plugins.PluginPoint import com.duckduckgo.app.global.plugins.pixel.PixelInterceptorPlugin +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -26,7 +27,7 @@ import dagger.multibindings.Multibinds import dagger.SingleInstanceIn private class PixelInterceptorPluginPoint( - private val plugins: Set<@JvmSuppressWildcards PixelInterceptorPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins.sortedBy { it.javaClass.simpleName } @@ -37,7 +38,7 @@ private class PixelInterceptorPluginPoint( @ContributesTo(AppScope::class) abstract class PixelInterceptorPluginModule { @Multibinds - abstract fun bindEmptyPixelInterceptorPlugins(): Set<@JvmSuppressWildcards PixelInterceptorPlugin> + abstract fun bindEmptyPixelInterceptorPlugins(): DaggerSet @Module @ContributesTo(AppScope::class) @@ -45,7 +46,7 @@ abstract class PixelInterceptorPluginModule { @Provides @SingleInstanceIn(AppScope::class) fun providePixelInterceptorPlugins( - plugins: Set<@JvmSuppressWildcards PixelInterceptorPlugin> + plugins: DaggerSet ): PluginPoint { return PixelInterceptorPluginPoint(plugins) } diff --git a/app/src/main/java/com/duckduckgo/app/global/plugin/LifecycleObserverPluginPoint.kt b/app/src/main/java/com/duckduckgo/app/global/plugin/LifecycleObserverPluginPoint.kt index 47ac3675a083..5b21b13d8cc6 100644 --- a/app/src/main/java/com/duckduckgo/app/global/plugin/LifecycleObserverPluginPoint.kt +++ b/app/src/main/java/com/duckduckgo/app/global/plugin/LifecycleObserverPluginPoint.kt @@ -18,6 +18,7 @@ package com.duckduckgo.app.global.plugin import androidx.lifecycle.LifecycleObserver import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Binds @@ -31,7 +32,7 @@ import dagger.SingleInstanceIn abstract class LifecycleObserverPluginProviderModule { // we use multibinds as the list of plugins can be empty @Multibinds - abstract fun provideLifecycleObserverPlugins(): Set<@JvmSuppressWildcards LifecycleObserver> + abstract fun provideLifecycleObserverPlugins(): DaggerSet @Binds @SingleInstanceIn(AppScope::class) @@ -42,7 +43,7 @@ abstract class LifecycleObserverPluginProviderModule { @SingleInstanceIn(AppScope::class) class LifecycleObserverPluginPoint @Inject constructor( - private val plugins: Set<@JvmSuppressWildcards LifecycleObserver> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Set { return plugins diff --git a/app/src/main/java/com/duckduckgo/app/settings/extension/InternalFeaturePlugin.kt b/app/src/main/java/com/duckduckgo/app/settings/extension/InternalFeaturePlugin.kt index 0b3d1e9aed69..b99262d4be45 100644 --- a/app/src/main/java/com/duckduckgo/app/settings/extension/InternalFeaturePlugin.kt +++ b/app/src/main/java/com/duckduckgo/app/settings/extension/InternalFeaturePlugin.kt @@ -18,6 +18,7 @@ package com.duckduckgo.app.settings.extension import android.content.Context import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -41,7 +42,7 @@ interface InternalFeaturePlugin { } private class SettingsInternalFeaturePluginPoint( - private val plugins: Set<@JvmSuppressWildcards InternalFeaturePlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins.sortedBy { it.internalFeatureTitle() } @@ -52,7 +53,7 @@ private class SettingsInternalFeaturePluginPoint( @ContributesTo(AppScope::class) abstract class SettingInternalFeaturePluginModule { @Multibinds - abstract fun bindEmptySettingInternalFeaturePlugins(): Set<@JvmSuppressWildcards InternalFeaturePlugin> + abstract fun bindEmptySettingInternalFeaturePlugins(): DaggerSet @Module @ContributesTo(AppScope::class) @@ -60,7 +61,7 @@ abstract class SettingInternalFeaturePluginModule { @Provides @SingleInstanceIn(AppScope::class) fun provideSettingInternalFeaturePlugins( - plugins: Set<@JvmSuppressWildcards InternalFeaturePlugin> + plugins: DaggerSet ): PluginPoint { return SettingsInternalFeaturePluginPoint(plugins) } diff --git a/common/src/main/java/com/duckduckgo/app/global/plugins/migrations/MigrationPlugin.kt b/common/src/main/java/com/duckduckgo/app/global/plugins/migrations/MigrationPlugin.kt index c4f0b2d84a0b..a96ff10b6d51 100644 --- a/common/src/main/java/com/duckduckgo/app/global/plugins/migrations/MigrationPlugin.kt +++ b/common/src/main/java/com/duckduckgo/app/global/plugins/migrations/MigrationPlugin.kt @@ -17,6 +17,7 @@ package com.duckduckgo.app.global.plugins.migrations import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import javax.inject.Inject import dagger.SingleInstanceIn @@ -28,7 +29,7 @@ interface MigrationPlugin { @SingleInstanceIn(AppScope::class) class MigrationPluginPoint @Inject constructor( - private val injectorPlugins: Set<@JvmSuppressWildcards MigrationPlugin> + private val injectorPlugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return injectorPlugins diff --git a/common/src/main/java/com/duckduckgo/app/global/plugins/view_model/ViewModelFactoryPlugin.kt b/common/src/main/java/com/duckduckgo/app/global/plugins/view_model/ViewModelFactoryPlugin.kt index 55afb1e7d4bf..2315d21e55a9 100644 --- a/common/src/main/java/com/duckduckgo/app/global/plugins/view_model/ViewModelFactoryPlugin.kt +++ b/common/src/main/java/com/duckduckgo/app/global/plugins/view_model/ViewModelFactoryPlugin.kt @@ -18,6 +18,7 @@ package com.duckduckgo.app.global.plugins.view_model import androidx.lifecycle.ViewModel import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import javax.inject.Inject import dagger.SingleInstanceIn @@ -28,7 +29,7 @@ interface ViewModelFactoryPlugin { @SingleInstanceIn(AppScope::class) class ViewModelFactoryPluginPoint @Inject constructor( - private val injectorPlugins: Set<@JvmSuppressWildcards ViewModelFactoryPlugin> + private val injectorPlugins: DaggerSet ) : PluginPoint { override fun getPlugins(): List { return injectorPlugins.toList() diff --git a/common/src/main/java/com/duckduckgo/app/global/plugins/worker/WorkerInjectorPlugin.kt b/common/src/main/java/com/duckduckgo/app/global/plugins/worker/WorkerInjectorPlugin.kt index 29ccd3d7bbae..e84c46098ae0 100644 --- a/common/src/main/java/com/duckduckgo/app/global/plugins/worker/WorkerInjectorPlugin.kt +++ b/common/src/main/java/com/duckduckgo/app/global/plugins/worker/WorkerInjectorPlugin.kt @@ -18,6 +18,7 @@ package com.duckduckgo.app.global.plugins.worker import androidx.work.ListenableWorker import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import javax.inject.Inject import dagger.SingleInstanceIn @@ -31,7 +32,7 @@ interface WorkerInjectorPlugin { @SingleInstanceIn(AppScope::class) class WorkerInjectorPluginPoint @Inject constructor( - private val injectorPlugins: Set<@JvmSuppressWildcards WorkerInjectorPlugin> + private val injectorPlugins: DaggerSet ) : PluginPoint { override fun getPlugins(): List { return injectorPlugins.toList() diff --git a/di/src/main/java/com/duckduckgo/di/DaggerTypes.kt b/di/src/main/java/com/duckduckgo/di/DaggerTypes.kt new file mode 100644 index 000000000000..dc6301340b4f --- /dev/null +++ b/di/src/main/java/com/duckduckgo/di/DaggerTypes.kt @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2021 DuckDuckGo + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.duckduckgo.di + +/** Sugar over multibindings that helps with Kotlin wildcards. */ +typealias DaggerSet = Set<@JvmSuppressWildcards T> +typealias DaggerMap = Map<@JvmSuppressWildcards K, @JvmSuppressWildcards V> diff --git a/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/RealFeatureTogglesImpl.kt b/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/RealFeatureTogglesImpl.kt index 3bd7cb0b45ab..5a31a0c40b91 100644 --- a/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/RealFeatureTogglesImpl.kt +++ b/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/RealFeatureTogglesImpl.kt @@ -17,6 +17,7 @@ package com.duckduckgo.feature.toggles.impl import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.feature.toggles.api.FeatureToggle import com.duckduckgo.feature.toggles.api.FeatureTogglesPlugin @@ -39,7 +40,7 @@ class RealFeatureToggleImpl @Inject constructor(private val featureTogglesPlugin } class FeatureCustomConfigPluginPoint( - private val toggles: Set<@JvmSuppressWildcards FeatureTogglesPlugin> + private val toggles: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return toggles diff --git a/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/di/FeatureTogglesModules.kt b/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/di/FeatureTogglesModules.kt index e8ec4386a3ac..5589c0243a67 100644 --- a/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/di/FeatureTogglesModules.kt +++ b/feature-toggles/feature-toggles-impl/src/main/java/com/duckduckgo/feature/toggles/impl/di/FeatureTogglesModules.kt @@ -17,6 +17,7 @@ package com.duckduckgo.feature.toggles.impl.di import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.feature.toggles.api.FeatureTogglesPlugin import com.duckduckgo.feature.toggles.impl.FeatureCustomConfigPluginPoint @@ -31,7 +32,7 @@ import dagger.SingleInstanceIn abstract class FeatureTogglesBindingModule { @Multibinds - abstract fun provideFeatureTogglesPlugins(): Set<@JvmSuppressWildcards FeatureTogglesPlugin> + abstract fun provideFeatureTogglesPlugins(): DaggerSet } @@ -41,7 +42,7 @@ class FeatureTogglesModule { @Provides @SingleInstanceIn(AppScope::class) - fun provideFeatureTogglesPluginPoint(toggles: Set<@JvmSuppressWildcards FeatureTogglesPlugin>): PluginPoint { + fun provideFeatureTogglesPluginPoint(toggles: DaggerSet): PluginPoint { return FeatureCustomConfigPluginPoint(toggles) } } diff --git a/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/di/PrivacyConfigModule.kt b/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/di/PrivacyConfigModule.kt index 60e45dfbbecd..211666fb2be8 100644 --- a/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/di/PrivacyConfigModule.kt +++ b/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/di/PrivacyConfigModule.kt @@ -22,6 +22,7 @@ import com.duckduckgo.app.di.AppCoroutineScope import com.duckduckgo.app.global.AppUrl import com.duckduckgo.app.global.DispatcherProvider import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.duckduckgo.privacy.config.impl.network.JSONObjectAdapter import com.duckduckgo.privacy.config.impl.network.PrivacyConfigService @@ -66,7 +67,7 @@ import dagger.SingleInstanceIn abstract class PrivacyFeaturesBindingModule { @Multibinds - abstract fun providePrivacyFeatureStorePlugins(): Set<@JvmSuppressWildcards PrivacyFeaturePlugin> + abstract fun providePrivacyFeatureStorePlugins(): DaggerSet } @@ -89,7 +90,7 @@ class NetworkModule { @Provides @SingleInstanceIn(AppScope::class) - fun providePrivacyFeaturePluginPoint(customConfigs: Set<@JvmSuppressWildcards PrivacyFeaturePlugin>): PluginPoint { + fun providePrivacyFeaturePluginPoint(customConfigs: DaggerSet): PluginPoint { return PrivacyFeaturePluginPoint(customConfigs) } } diff --git a/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/plugins/PrivacyFeaturePlugin.kt b/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/plugins/PrivacyFeaturePlugin.kt index 491c04dbeeb3..0763b9e26248 100644 --- a/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/plugins/PrivacyFeaturePlugin.kt +++ b/privacy-config/privacy-config-impl/src/main/java/com/duckduckgo/privacy/config/impl/plugins/PrivacyFeaturePlugin.kt @@ -17,6 +17,7 @@ package com.duckduckgo.privacy.config.impl.plugins import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.privacy.config.api.PrivacyFeatureName interface PrivacyFeaturePlugin { @@ -25,7 +26,7 @@ interface PrivacyFeaturePlugin { } class PrivacyFeaturePluginPoint( - private val privacyFeatures: Set<@JvmSuppressWildcards PrivacyFeaturePlugin> + private val privacyFeatures: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return privacyFeatures diff --git a/statistics/src/main/java/com/duckduckgo/app/statistics/api/RefreshRetentionAtbPlugin.kt b/statistics/src/main/java/com/duckduckgo/app/statistics/api/RefreshRetentionAtbPlugin.kt index 31b6e3029a97..46222368d479 100644 --- a/statistics/src/main/java/com/duckduckgo/app/statistics/api/RefreshRetentionAtbPlugin.kt +++ b/statistics/src/main/java/com/duckduckgo/app/statistics/api/RefreshRetentionAtbPlugin.kt @@ -17,6 +17,7 @@ package com.duckduckgo.app.statistics.api import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.AppScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -34,7 +35,7 @@ interface RefreshRetentionAtbPlugin { } class RefreshRetentionAtbPluginPoint( - private val plugins: Set<@JvmSuppressWildcards RefreshRetentionAtbPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins.sortedBy { it.javaClass.simpleName } @@ -45,5 +46,5 @@ class RefreshRetentionAtbPluginPoint( @ContributesTo(AppScope::class) abstract class RefreshRetentionAtbPluginModule { @Multibinds - abstract fun bindRefreshRetentionAtbPlugins(): Set<@JvmSuppressWildcards RefreshRetentionAtbPlugin> + abstract fun bindRefreshRetentionAtbPlugins(): DaggerSet } diff --git a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/bugreport/VpnStateCollector.kt b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/bugreport/VpnStateCollector.kt index d874b962bca8..73de63d89ecd 100644 --- a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/bugreport/VpnStateCollector.kt +++ b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/bugreport/VpnStateCollector.kt @@ -18,6 +18,7 @@ package com.duckduckgo.mobile.android.vpn.bugreport import com.duckduckgo.app.global.DispatcherProvider import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.VpnScope import com.duckduckgo.mobile.android.vpn.state.VpnStateCollector import com.duckduckgo.mobile.android.vpn.state.VpnStateCollectorPlugin @@ -54,7 +55,7 @@ class RealVpnStateCollector @Inject constructor( } private class VpnStateCollectorPluginPoint( - private val plugins: Set<@JvmSuppressWildcards VpnStateCollectorPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins.sortedBy { it.collectorName } @@ -67,7 +68,7 @@ abstract class VpnStateCollectorProviderModule { @Multibinds @SingleInstanceIn(VpnScope::class) - abstract fun bindVpnStateCollectorEmptyPlugins(): Set<@JvmSuppressWildcards VpnStateCollectorPlugin> + abstract fun bindVpnStateCollectorEmptyPlugins(): DaggerSet @Module @ContributesTo(VpnScope::class) @@ -75,7 +76,7 @@ abstract class VpnStateCollectorProviderModule { @Provides @SingleInstanceIn(VpnScope::class) fun bindVpnMemoryCollectorPluginPoint( - plugins: Set<@JvmSuppressWildcards VpnStateCollectorPlugin> + plugins: DaggerSet ): PluginPoint { return VpnStateCollectorPluginPoint(plugins) } diff --git a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/processor/tcp/tracker/VpnTrackerDetectorInterceptorPluginPoint.kt b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/processor/tcp/tracker/VpnTrackerDetectorInterceptorPluginPoint.kt index 1fe3c5ef8fcb..8153191ceb04 100644 --- a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/processor/tcp/tracker/VpnTrackerDetectorInterceptorPluginPoint.kt +++ b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/processor/tcp/tracker/VpnTrackerDetectorInterceptorPluginPoint.kt @@ -17,6 +17,7 @@ package com.duckduckgo.mobile.android.vpn.processor.tcp.tracker import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.VpnScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -25,7 +26,7 @@ import dagger.SingleInstanceIn import dagger.multibindings.Multibinds private class VpnTrackerDetectorInterceptorPluginPoint( - private val requestInterceptors: Set<@JvmSuppressWildcards VpnTrackerDetectorInterceptor> + private val requestInterceptors: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return requestInterceptors @@ -36,7 +37,7 @@ private class VpnTrackerDetectorInterceptorPluginPoint( @ContributesTo(VpnScope::class) abstract class VpnTrackerDetectorInterceptorModule { @Multibinds - abstract fun bindVpnTrackerDetectorInterceptorPlugins(): Set<@JvmSuppressWildcards VpnTrackerDetectorInterceptor> + abstract fun bindVpnTrackerDetectorInterceptorPlugins(): DaggerSet @Module @ContributesTo(VpnScope::class) @@ -44,7 +45,7 @@ abstract class VpnTrackerDetectorInterceptorModule { @Provides @SingleInstanceIn(VpnScope::class) fun provideVpnTrackerDetectorInterceptorPluginPoint( - plugins: Set<@JvmSuppressWildcards VpnTrackerDetectorInterceptor> + plugins: DaggerSet ): PluginPoint { return VpnTrackerDetectorInterceptorPluginPoint(plugins) } diff --git a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnMemoryCollectorPlugin.kt b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnMemoryCollectorPlugin.kt index 5632f525db8d..875f5da2496b 100644 --- a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnMemoryCollectorPlugin.kt +++ b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnMemoryCollectorPlugin.kt @@ -17,6 +17,7 @@ package com.duckduckgo.mobile.android.vpn.service import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.VpnScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -36,7 +37,7 @@ interface VpnMemoryCollectorPlugin { } private class VpnMemoryCollectorPluginPoint( - private val plugins: Set<@JvmSuppressWildcards VpnMemoryCollectorPlugin> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { return plugins @@ -49,7 +50,7 @@ abstract class VpnMemoryCollectorProviderModule { @Multibinds @SingleInstanceIn(VpnScope::class) - abstract fun bindVpnMemoryCollectorPlugins(): Set<@JvmSuppressWildcards VpnMemoryCollectorPlugin> + abstract fun bindVpnMemoryCollectorPlugins(): DaggerSet @Module @ContributesTo(VpnScope::class) @@ -57,7 +58,7 @@ abstract class VpnMemoryCollectorProviderModule { @Provides @SingleInstanceIn(VpnScope::class) fun bindVpnMemoryCollectorPluginPoint( - plugins: Set<@JvmSuppressWildcards VpnMemoryCollectorPlugin> + plugins: DaggerSet ): PluginPoint { return VpnMemoryCollectorPluginPoint(plugins) } diff --git a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnServiceCallbacksPluginPoint.kt b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnServiceCallbacksPluginPoint.kt index 3594e6b179d0..6c77392120b8 100644 --- a/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnServiceCallbacksPluginPoint.kt +++ b/vpn/src/main/java/com/duckduckgo/mobile/android/vpn/service/VpnServiceCallbacksPluginPoint.kt @@ -17,6 +17,7 @@ package com.duckduckgo.mobile.android.vpn.service import com.duckduckgo.app.global.plugins.PluginPoint +import com.duckduckgo.di.DaggerSet import com.duckduckgo.di.scopes.VpnScope import com.squareup.anvil.annotations.ContributesTo import dagger.Module @@ -25,7 +26,7 @@ import dagger.SingleInstanceIn import dagger.multibindings.Multibinds private class VpnServiceCallbacksPluginPoint( - private val plugins: Set<@JvmSuppressWildcards VpnServiceCallbacks> + private val plugins: DaggerSet ) : PluginPoint { override fun getPlugins(): Collection { // not that it matters but sorting adds predictability here @@ -38,7 +39,7 @@ private class VpnServiceCallbacksPluginPoint( abstract class VpnServiceCallbacksProviderModule { @Multibinds @SingleInstanceIn(VpnScope::class) - abstract fun provideVpnServiceCallbacksPlugins(): Set<@JvmSuppressWildcards VpnServiceCallbacks> + abstract fun provideVpnServiceCallbacksPlugins(): DaggerSet @Module @ContributesTo(VpnScope::class) @@ -46,7 +47,7 @@ abstract class VpnServiceCallbacksProviderModule { @Provides @SingleInstanceIn(VpnScope::class) fun bindVpnServiceCallbacksPluginPoint( - plugins: Set<@JvmSuppressWildcards VpnServiceCallbacks> + plugins: DaggerSet ): PluginPoint { return VpnServiceCallbacksPluginPoint(plugins) }