From d80a25feac3c8faba66730ed4ca1074d43680625 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 19 Nov 2021 15:29:11 +0100 Subject: [PATCH] Fix "@JvmStatic used for @Provides function in an object class" Lint warning. See https://github.com/google/dagger/releases/tag/dagger-2.25.2 point 2.ii. : @Module object classes no longer need @JvmStatic on the provides methods. Ensure this warning does not appear again. --- vector/lint.xml | 3 +++ .../fdroid/java/im/vector/app/di/FlavorModule.kt | 14 +++++--------- .../gplay/java/im/vector/app/di/FlavorModule.kt | 12 ++++-------- .../main/java/im/vector/app/core/di/HomeModule.kt | 1 - .../java/im/vector/app/core/di/ScreenModule.kt | 2 -- .../java/im/vector/app/core/di/SingletonModule.kt | 11 ----------- .../java/im/vector/app/features/home/HomeModule.kt | 1 - 7 files changed, 12 insertions(+), 32 deletions(-) diff --git a/vector/lint.xml b/vector/lint.xml index e534bdc355..9d9b208df7 100644 --- a/vector/lint.xml +++ b/vector/lint.xml @@ -84,4 +84,7 @@ + + + diff --git a/vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt b/vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt index 39b5c4a976..1a3348f4c6 100644 --- a/vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt +++ b/vector/src/fdroid/java/im/vector/app/di/FlavorModule.kt @@ -25,16 +25,12 @@ import im.vector.app.core.services.GuardServiceStarter import im.vector.app.fdroid.service.FDroidGuardServiceStarter import im.vector.app.features.settings.VectorPreferences -@Module @InstallIn(SingletonComponent::class) -abstract class FlavorModule { +@Module +object FlavorModule { - companion object { - - @Provides - @JvmStatic - fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter { - return FDroidGuardServiceStarter(preferences, appContext) - } + @Provides + fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter { + return FDroidGuardServiceStarter(preferences, appContext) } } diff --git a/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt b/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt index 61fd476c87..901320be4c 100644 --- a/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt +++ b/vector/src/gplay/java/im/vector/app/di/FlavorModule.kt @@ -24,14 +24,10 @@ import im.vector.app.core.services.GuardServiceStarter @InstallIn(SingletonComponent::class) @Module -abstract class FlavorModule { +object FlavorModule { - companion object { - - @Provides - @JvmStatic - fun provideGuardServiceStarter(): GuardServiceStarter { - return object : GuardServiceStarter {} - } + @Provides + fun provideGuardServiceStarter(): GuardServiceStarter { + return object : GuardServiceStarter {} } } diff --git a/vector/src/main/java/im/vector/app/core/di/HomeModule.kt b/vector/src/main/java/im/vector/app/core/di/HomeModule.kt index 1af67cdc83..b667a12ce8 100644 --- a/vector/src/main/java/im/vector/app/core/di/HomeModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/HomeModule.kt @@ -28,7 +28,6 @@ import im.vector.app.features.home.room.detail.timeline.helper.TimelineAsyncHelp @InstallIn(ActivityComponent::class) object HomeModule { @Provides - @JvmStatic @TimelineEventControllerHandler fun providesTimelineBackgroundHandler(): Handler { return TimelineAsyncHelper.getBackgroundHandler() diff --git a/vector/src/main/java/im/vector/app/core/di/ScreenModule.kt b/vector/src/main/java/im/vector/app/core/di/ScreenModule.kt index 2dab05378c..4ed71039e4 100644 --- a/vector/src/main/java/im/vector/app/core/di/ScreenModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/ScreenModule.kt @@ -30,11 +30,9 @@ import im.vector.app.core.glide.GlideApp object ScreenModule { @Provides - @JvmStatic fun providesGlideRequests(context: AppCompatActivity) = GlideApp.with(context) @Provides - @JvmStatic @ActivityScoped fun providesSharedViewPool() = RecyclerView.RecycledViewPool() } diff --git a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt index a3d8f39b30..429b88be69 100644 --- a/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt +++ b/vector/src/main/java/im/vector/app/core/di/SingletonModule.kt @@ -73,69 +73,58 @@ abstract class VectorBindModule { object VectorStaticModule { @Provides - @JvmStatic fun providesContext(application: Application): Context { return application.applicationContext } @Provides - @JvmStatic fun providesResources(context: Context): Resources { return context.resources } @Provides - @JvmStatic fun providesSharedPreferences(context: Context): SharedPreferences { return context.getSharedPreferences("im.vector.riot", MODE_PRIVATE) } @Provides - @JvmStatic fun providesMatrix(context: Context): Matrix { return Matrix.getInstance(context) } @Provides - @JvmStatic fun providesCurrentSession(activeSessionHolder: ActiveSessionHolder): Session { // TODO: handle session injection better return activeSessionHolder.getActiveSession() } @Provides - @JvmStatic fun providesLegacySessionImporter(matrix: Matrix): LegacySessionImporter { return matrix.legacySessionImporter() } @Provides - @JvmStatic fun providesAuthenticationService(matrix: Matrix): AuthenticationService { return matrix.authenticationService() } @Provides - @JvmStatic fun providesRawService(matrix: Matrix): RawService { return matrix.rawService() } @Provides - @JvmStatic fun providesHomeServerHistoryService(matrix: Matrix): HomeServerHistoryService { return matrix.homeServerHistoryService() } @Provides - @JvmStatic @Singleton fun providesApplicationCoroutineScope(): CoroutineScope { return CoroutineScope(SupervisorJob() + Dispatchers.Main) } @Provides - @JvmStatic fun providesCoroutineDispatchers(): CoroutineDispatchers { return CoroutineDispatchers(io = Dispatchers.IO, computation = Dispatchers.Default) } diff --git a/vector/src/main/java/im/vector/app/features/home/HomeModule.kt b/vector/src/main/java/im/vector/app/features/home/HomeModule.kt index 0782bbb573..d34d3489c5 100644 --- a/vector/src/main/java/im/vector/app/features/home/HomeModule.kt +++ b/vector/src/main/java/im/vector/app/features/home/HomeModule.kt @@ -28,7 +28,6 @@ import im.vector.app.features.home.room.detail.timeline.helper.TimelineAsyncHelp object HomeModule { @Provides - @JvmStatic @TimelineEventControllerHandler fun providesTimelineBackgroundHandler(): Handler { return TimelineAsyncHelper.getBackgroundHandler()