mirror of
https://github.com/vector-im/element-android.git
synced 2024-11-26 15:18:19 +08:00
Hilt: replace the VectorComponent
This commit is contained in:
parent
7ec0872b78
commit
ff53cf4db9
@ -17,6 +17,7 @@ buildscript {
|
||||
// https://developer.android.com/studio/releases/gradle-plugin
|
||||
classpath libs.gradle.gradlePlugin
|
||||
classpath libs.gradle.kotlinPlugin
|
||||
classpath libs.gradle.hiltPlugin
|
||||
classpath 'com.google.gms:google-services:4.3.10'
|
||||
classpath 'org.sonarsource.scanner.gradle:sonarqube-gradle-plugin:3.3'
|
||||
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.4'
|
||||
|
@ -34,7 +34,9 @@ def androidxTest = "1.4.0"
|
||||
ext.libs = [
|
||||
gradle : [
|
||||
'gradlePlugin' : "com.android.tools.build:gradle:$gradle",
|
||||
'kotlinPlugin' : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin"
|
||||
'kotlinPlugin' : "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin",
|
||||
'hiltPlugin' : "com.google.dagger:hilt-android-gradle-plugin:$dagger"
|
||||
|
||||
],
|
||||
jetbrains : [
|
||||
'kotlinStdlibJdk7' : "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin",
|
||||
@ -74,7 +76,9 @@ ext.libs = [
|
||||
],
|
||||
dagger : [
|
||||
'dagger' : "com.google.dagger:dagger:$dagger",
|
||||
'daggerCompiler' : "com.google.dagger:dagger-compiler:$dagger"
|
||||
'daggerCompiler' : "com.google.dagger:dagger-compiler:$dagger",
|
||||
'hilt' : "com.google.dagger:hilt-android:$dagger",
|
||||
'hiltCompiler' : "com.google.dagger:hilt-compiler:$dagger"
|
||||
],
|
||||
squareup : [
|
||||
'moshi' : "com.squareup.moshi:moshi-adapters:$moshi",
|
||||
|
@ -6,6 +6,7 @@ apply plugin: 'kotlin-android'
|
||||
apply plugin: 'kotlin-parcelize'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
apply plugin: 'placeholder-resolver'
|
||||
apply plugin: 'dagger.hilt.android.plugin'
|
||||
|
||||
kapt {
|
||||
correctErrorTypes = true
|
||||
@ -457,8 +458,8 @@ dependencies {
|
||||
implementation 'nl.dionsegijn:konfetti:1.3.2'
|
||||
implementation 'com.github.jetradarmobile:android-snowfall:1.2.1'
|
||||
// DI
|
||||
implementation libs.dagger.dagger
|
||||
kapt libs.dagger.daggerCompiler
|
||||
implementation libs.dagger.hilt
|
||||
kapt libs.dagger.hiltCompiler
|
||||
|
||||
// gplay flavor only
|
||||
gplayImplementation('com.google.firebase:firebase-messaging:22.0.0') {
|
||||
|
@ -39,10 +39,11 @@ import com.facebook.stetho.Stetho
|
||||
import com.gabrielittner.threetenbp.LazyThreeTen
|
||||
import com.vanniktech.emoji.EmojiManager
|
||||
import com.vanniktech.emoji.google.GoogleEmojiProvider
|
||||
import dagger.hilt.EntryPoints
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DaggerVectorComponent
|
||||
import im.vector.app.core.di.AggregatorEntryPoint
|
||||
import im.vector.app.core.di.HasVectorInjector
|
||||
import im.vector.app.core.di.VectorComponent
|
||||
import im.vector.app.core.extensions.configureAndStart
|
||||
import im.vector.app.core.extensions.startSyncing
|
||||
import im.vector.app.core.rx.RxConfig
|
||||
@ -75,6 +76,7 @@ import java.util.concurrent.Executors
|
||||
import javax.inject.Inject
|
||||
import androidx.work.Configuration as WorkConfiguration
|
||||
|
||||
@HiltAndroidApp
|
||||
class VectorApplication :
|
||||
Application(),
|
||||
HasVectorInjector,
|
||||
@ -100,8 +102,6 @@ class VectorApplication :
|
||||
@Inject lateinit var callManager: WebRtcCallManager
|
||||
@Inject lateinit var invitesAcceptor: InvitesAcceptor
|
||||
|
||||
lateinit var vectorComponent: VectorComponent
|
||||
|
||||
// font thread handler
|
||||
private var fontThreadHandler: Handler? = null
|
||||
|
||||
@ -114,12 +114,15 @@ class VectorApplication :
|
||||
}
|
||||
}
|
||||
|
||||
fun component(): AggregatorEntryPoint {
|
||||
// Use EntryPoints to get an instance of the AggregatorEntryPoint.
|
||||
return EntryPoints.get(this, AggregatorEntryPoint::class.java)
|
||||
}
|
||||
|
||||
override fun onCreate() {
|
||||
enableStrictModeIfNeeded()
|
||||
super.onCreate()
|
||||
appContext = this
|
||||
vectorComponent = DaggerVectorComponent.factory().create(this)
|
||||
vectorComponent.inject(this)
|
||||
invitesAcceptor.initialize()
|
||||
vectorUncaughtExceptionHandler.activate(this)
|
||||
rxConfig.setupRxPlugin()
|
||||
@ -132,7 +135,7 @@ class VectorApplication :
|
||||
if (BuildConfig.DEBUG) {
|
||||
Timber.plant(Timber.DebugTree())
|
||||
}
|
||||
Timber.plant(vectorComponent.vectorFileLogger())
|
||||
Timber.plant(component().vectorFileLogger())
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
Stetho.initializeWithDefaults(this)
|
||||
@ -236,8 +239,8 @@ class VectorApplication :
|
||||
.build()
|
||||
}
|
||||
|
||||
override fun injector(): VectorComponent {
|
||||
return vectorComponent
|
||||
override fun injector(): AggregatorEntryPoint {
|
||||
return component()
|
||||
}
|
||||
|
||||
private fun logInfo() {
|
||||
|
@ -1,11 +1,11 @@
|
||||
/*
|
||||
* Copyright 2019 New Vector Ltd
|
||||
* Copyright (c) 2021 New Vector Ltd
|
||||
*
|
||||
* 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
|
||||
* 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,
|
||||
@ -18,13 +18,13 @@ package im.vector.app.core.di
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.hilt.EntryPoint
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.AppStateHandler
|
||||
import im.vector.app.EmojiCompatFontProvider
|
||||
import im.vector.app.EmojiCompatWrapper
|
||||
import im.vector.app.VectorApplication
|
||||
import im.vector.app.core.dialogs.UnrecognizedCertificateDialog
|
||||
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
@ -47,7 +47,6 @@ import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.login.ReAuthHelper
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.app.features.notifications.NotifiableEventResolver
|
||||
import im.vector.app.features.notifications.NotificationBroadcastReceiver
|
||||
import im.vector.app.features.notifications.NotificationDrawerManager
|
||||
import im.vector.app.features.notifications.NotificationUtils
|
||||
import im.vector.app.features.notifications.PushRuleTriggerListener
|
||||
@ -68,15 +67,10 @@ import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||
import org.matrix.android.sdk.api.auth.HomeServerHistoryService
|
||||
import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Component(modules = [VectorModule::class])
|
||||
@Singleton
|
||||
interface VectorComponent {
|
||||
|
||||
fun inject(notificationBroadcastReceiver: NotificationBroadcastReceiver)
|
||||
|
||||
fun inject(vectorApplication: VectorApplication)
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@EntryPoint
|
||||
interface AggregatorEntryPoint {
|
||||
|
||||
fun matrix(): Matrix
|
||||
|
||||
@ -175,9 +169,4 @@ interface VectorComponent {
|
||||
fun coroutineDispatchers(): CoroutineDispatchers
|
||||
|
||||
fun jitsiActiveConferenceHolder(): JitsiActiveConferenceHolder
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
fun create(@BindsInstance context: Context): VectorComponent
|
||||
}
|
||||
}
|
@ -21,6 +21,7 @@ import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentFactory
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.migration.DisableInstallInCheck
|
||||
import dagger.multibindings.IntoMap
|
||||
import im.vector.app.features.attachments.preview.AttachmentsPreviewFragment
|
||||
import im.vector.app.features.contactsbook.ContactsBookFragment
|
||||
@ -157,6 +158,7 @@ import im.vector.app.features.usercode.ShowUserCodeFragment
|
||||
import im.vector.app.features.userdirectory.UserListFragment
|
||||
import im.vector.app.features.widgets.WidgetFragment
|
||||
|
||||
@DisableInstallInCheck
|
||||
@Module
|
||||
interface FragmentModule {
|
||||
/**
|
||||
|
@ -18,5 +18,5 @@ package im.vector.app.core.di
|
||||
|
||||
interface HasVectorInjector {
|
||||
|
||||
fun injector(): VectorComponent
|
||||
fun injector(): AggregatorEntryPoint
|
||||
}
|
||||
|
@ -16,58 +16,93 @@
|
||||
|
||||
package im.vector.app.core.di
|
||||
|
||||
import android.content.Context
|
||||
import android.content.res.Resources
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.FragmentFactory
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import dagger.BindsInstance
|
||||
import dagger.Component
|
||||
import dagger.hilt.EntryPoint
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.ActiveSessionDataSource
|
||||
import im.vector.app.AppStateHandler
|
||||
import im.vector.app.EmojiCompatFontProvider
|
||||
import im.vector.app.EmojiCompatWrapper
|
||||
import im.vector.app.core.dialogs.UnrecognizedCertificateDialog
|
||||
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.network.WifiDetector
|
||||
import im.vector.app.core.preference.UserAvatarPreference
|
||||
import im.vector.app.core.pushers.PushersManager
|
||||
import im.vector.app.core.utils.AssetReader
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import im.vector.app.features.MainActivity
|
||||
import im.vector.app.features.auth.ReAuthActivity
|
||||
import im.vector.app.features.call.CallControlsBottomSheet
|
||||
import im.vector.app.features.call.VectorCallActivity
|
||||
import im.vector.app.features.call.conference.JitsiActiveConferenceHolder
|
||||
import im.vector.app.features.call.conference.VectorJitsiActivity
|
||||
import im.vector.app.features.call.transfer.CallTransferActivity
|
||||
import im.vector.app.features.call.webrtc.WebRtcCallManager
|
||||
import im.vector.app.features.configuration.VectorConfiguration
|
||||
import im.vector.app.features.createdirect.CreateDirectRoomActivity
|
||||
import im.vector.app.features.crypto.keysbackup.settings.KeysBackupManageActivity
|
||||
import im.vector.app.features.crypto.keysbackup.setup.KeysBackupSetupActivity
|
||||
import im.vector.app.features.crypto.keysrequest.KeyRequestHandler
|
||||
import im.vector.app.features.crypto.quads.SharedSecureStorageActivity
|
||||
import im.vector.app.features.crypto.recover.BootstrapBottomSheet
|
||||
import im.vector.app.features.crypto.verification.IncomingVerificationRequestHandler
|
||||
import im.vector.app.features.crypto.verification.VerificationBottomSheet
|
||||
import im.vector.app.features.debug.DebugMenuActivity
|
||||
import im.vector.app.features.devtools.RoomDevToolActivity
|
||||
import im.vector.app.features.home.AvatarRenderer
|
||||
import im.vector.app.features.home.CurrentSpaceSuggestedRoomListDataSource
|
||||
import im.vector.app.features.home.HomeActivity
|
||||
import im.vector.app.features.home.HomeModule
|
||||
import im.vector.app.features.home.room.detail.JoinReplacementRoomBottomSheet
|
||||
import im.vector.app.features.home.room.detail.RoomDetailActivity
|
||||
import im.vector.app.features.home.room.detail.RoomDetailPendingActionStore
|
||||
import im.vector.app.features.home.room.detail.readreceipts.DisplayReadReceiptsBottomSheet
|
||||
import im.vector.app.features.home.room.detail.search.SearchActivity
|
||||
import im.vector.app.features.home.room.detail.timeline.action.MessageActionsBottomSheet
|
||||
import im.vector.app.features.home.room.detail.timeline.edithistory.ViewEditHistoryBottomSheet
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
|
||||
import im.vector.app.features.home.room.detail.timeline.reactions.ViewReactionsBottomSheet
|
||||
import im.vector.app.features.home.room.detail.upgrade.MigrateRoomBottomSheet
|
||||
import im.vector.app.features.home.room.detail.widget.RoomWidgetsBottomSheet
|
||||
import im.vector.app.features.home.room.filtered.FilteredRoomsActivity
|
||||
import im.vector.app.features.home.room.list.RoomListModule
|
||||
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsBottomSheet
|
||||
import im.vector.app.features.html.EventHtmlRenderer
|
||||
import im.vector.app.features.html.VectorHtmlCompressor
|
||||
import im.vector.app.features.invite.AutoAcceptInvites
|
||||
import im.vector.app.features.invite.InviteUsersToRoomActivity
|
||||
import im.vector.app.features.invite.VectorInviteView
|
||||
import im.vector.app.features.link.LinkHandlerActivity
|
||||
import im.vector.app.features.login.LoginActivity
|
||||
import im.vector.app.features.login.ReAuthHelper
|
||||
import im.vector.app.features.login2.LoginActivity2
|
||||
import im.vector.app.features.matrixto.MatrixToBottomSheet
|
||||
import im.vector.app.features.media.BigImageViewerActivity
|
||||
import im.vector.app.features.media.VectorAttachmentViewerActivity
|
||||
import im.vector.app.features.navigation.Navigator
|
||||
import im.vector.app.features.notifications.NotifiableEventResolver
|
||||
import im.vector.app.features.notifications.NotificationDrawerManager
|
||||
import im.vector.app.features.notifications.NotificationUtils
|
||||
import im.vector.app.features.notifications.PushRuleTriggerListener
|
||||
import im.vector.app.features.pin.PinCodeStore
|
||||
import im.vector.app.features.pin.PinLocker
|
||||
import im.vector.app.features.popup.PopupAlertManager
|
||||
import im.vector.app.features.qrcode.QrCodeScannerActivity
|
||||
import im.vector.app.features.rageshake.BugReportActivity
|
||||
import im.vector.app.features.rageshake.BugReporter
|
||||
import im.vector.app.features.rageshake.RageShake
|
||||
import im.vector.app.features.rageshake.VectorFileLogger
|
||||
import im.vector.app.features.rageshake.VectorUncaughtExceptionHandler
|
||||
import im.vector.app.features.reactions.EmojiReactionPickerActivity
|
||||
import im.vector.app.features.reactions.data.EmojiDataSource
|
||||
import im.vector.app.features.reactions.widget.ReactionButton
|
||||
import im.vector.app.features.roomdirectory.RoomDirectoryActivity
|
||||
import im.vector.app.features.roomdirectory.createroom.CreateRoomActivity
|
||||
@ -78,6 +113,9 @@ import im.vector.app.features.roomprofile.alias.detail.RoomAliasBottomSheet
|
||||
import im.vector.app.features.roomprofile.settings.historyvisibility.RoomHistoryVisibilityBottomSheet
|
||||
import im.vector.app.features.roomprofile.settings.joinrule.RoomJoinRuleActivity
|
||||
import im.vector.app.features.roomprofile.settings.joinrule.RoomJoinRuleBottomSheet
|
||||
import im.vector.app.features.session.SessionListener
|
||||
import im.vector.app.features.settings.VectorDataStore
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.settings.VectorSettingsActivity
|
||||
import im.vector.app.features.settings.devices.DeviceVerificationInfoBottomSheet
|
||||
import im.vector.app.features.share.IncomingShareActivity
|
||||
@ -98,10 +136,118 @@ import im.vector.app.features.widgets.WidgetActivity
|
||||
import im.vector.app.features.widgets.permissions.RoomWidgetPermissionBottomSheet
|
||||
import im.vector.app.features.workers.signout.SignOutBottomSheetDialogFragment
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import org.matrix.android.sdk.api.Matrix
|
||||
import org.matrix.android.sdk.api.auth.AuthenticationService
|
||||
import org.matrix.android.sdk.api.auth.HomeServerHistoryService
|
||||
import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@EntryPoint
|
||||
interface ScreenComponentDependencies {
|
||||
fun matrix(): Matrix
|
||||
|
||||
fun matrixItemColorProvider(): MatrixItemColorProvider
|
||||
|
||||
fun sessionListener(): SessionListener
|
||||
|
||||
fun currentSession(): Session
|
||||
|
||||
fun notificationUtils(): NotificationUtils
|
||||
|
||||
fun notificationDrawerManager(): NotificationDrawerManager
|
||||
|
||||
fun appContext(): Context
|
||||
|
||||
fun resources(): Resources
|
||||
|
||||
fun assetReader(): AssetReader
|
||||
|
||||
fun dimensionConverter(): DimensionConverter
|
||||
|
||||
fun vectorConfiguration(): VectorConfiguration
|
||||
|
||||
fun avatarRenderer(): AvatarRenderer
|
||||
|
||||
fun activeSessionHolder(): ActiveSessionHolder
|
||||
|
||||
fun unrecognizedCertificateDialog(): UnrecognizedCertificateDialog
|
||||
|
||||
fun emojiCompatFontProvider(): EmojiCompatFontProvider
|
||||
|
||||
fun emojiCompatWrapper(): EmojiCompatWrapper
|
||||
|
||||
fun eventHtmlRenderer(): EventHtmlRenderer
|
||||
|
||||
fun vectorHtmlCompressor(): VectorHtmlCompressor
|
||||
|
||||
fun navigator(): Navigator
|
||||
|
||||
fun errorFormatter(): ErrorFormatter
|
||||
|
||||
fun appStateHandler(): AppStateHandler
|
||||
|
||||
fun currentSpaceSuggestedRoomListDataSource(): CurrentSpaceSuggestedRoomListDataSource
|
||||
|
||||
fun roomDetailPendingActionStore(): RoomDetailPendingActionStore
|
||||
|
||||
fun activeSessionObservableStore(): ActiveSessionDataSource
|
||||
|
||||
fun incomingVerificationRequestHandler(): IncomingVerificationRequestHandler
|
||||
|
||||
fun incomingKeyRequestHandler(): KeyRequestHandler
|
||||
|
||||
fun authenticationService(): AuthenticationService
|
||||
|
||||
fun rawService(): RawService
|
||||
|
||||
fun homeServerHistoryService(): HomeServerHistoryService
|
||||
|
||||
fun bugReporter(): BugReporter
|
||||
|
||||
fun vectorUncaughtExceptionHandler(): VectorUncaughtExceptionHandler
|
||||
|
||||
fun pushRuleTriggerListener(): PushRuleTriggerListener
|
||||
|
||||
fun pusherManager(): PushersManager
|
||||
|
||||
fun notifiableEventResolver(): NotifiableEventResolver
|
||||
|
||||
fun vectorPreferences(): VectorPreferences
|
||||
|
||||
fun vectorDataStore(): VectorDataStore
|
||||
|
||||
fun wifiDetector(): WifiDetector
|
||||
|
||||
fun vectorFileLogger(): VectorFileLogger
|
||||
|
||||
fun uiStateRepository(): UiStateRepository
|
||||
|
||||
fun pinCodeStore(): PinCodeStore
|
||||
|
||||
fun emojiDataSource(): EmojiDataSource
|
||||
|
||||
fun alertManager(): PopupAlertManager
|
||||
|
||||
fun reAuthHelper(): ReAuthHelper
|
||||
|
||||
fun pinLocker(): PinLocker
|
||||
|
||||
fun autoAcceptInvites(): AutoAcceptInvites
|
||||
|
||||
fun webRtcCallManager(): WebRtcCallManager
|
||||
|
||||
fun appCoroutineScope(): CoroutineScope
|
||||
|
||||
fun coroutineDispatchers(): CoroutineDispatchers
|
||||
|
||||
fun jitsiActiveConferenceHolder(): JitsiActiveConferenceHolder
|
||||
|
||||
}
|
||||
|
||||
@Component(
|
||||
dependencies = [
|
||||
VectorComponent::class
|
||||
ScreenComponentDependencies::class
|
||||
],
|
||||
modules = [
|
||||
ViewModelModule::class,
|
||||
@ -218,7 +364,7 @@ interface ScreenComponent {
|
||||
|
||||
@Component.Factory
|
||||
interface Factory {
|
||||
fun create(vectorComponent: VectorComponent,
|
||||
fun create(deps: ScreenComponentDependencies,
|
||||
@BindsInstance context: AppCompatActivity
|
||||
): ScreenComponent
|
||||
}
|
||||
|
@ -20,9 +20,11 @@ import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.migration.DisableInstallInCheck
|
||||
import im.vector.app.core.glide.GlideApp
|
||||
|
||||
@Module
|
||||
@DisableInstallInCheck
|
||||
object ScreenModule {
|
||||
|
||||
@Provides
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
package im.vector.app.core.di
|
||||
|
||||
import android.app.Application
|
||||
import android.content.Context
|
||||
import android.content.Context.MODE_PRIVATE
|
||||
import android.content.SharedPreferences
|
||||
@ -23,6 +24,8 @@ import android.content.res.Resources
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||
import im.vector.app.core.error.DefaultErrorFormatter
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
@ -45,74 +48,9 @@ import org.matrix.android.sdk.api.raw.RawService
|
||||
import org.matrix.android.sdk.api.session.Session
|
||||
import javax.inject.Singleton
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
abstract class VectorModule {
|
||||
|
||||
@Module
|
||||
companion object {
|
||||
|
||||
@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)
|
||||
}
|
||||
}
|
||||
abstract class VectorBindModule {
|
||||
|
||||
@Binds
|
||||
abstract fun bindNavigator(navigator: DefaultNavigator): Navigator
|
||||
@ -129,3 +67,76 @@ abstract class VectorModule {
|
||||
@Binds
|
||||
abstract fun bindAutoAcceptInvites(autoAcceptInvites: CompileTimeAutoAcceptInvites): AutoAcceptInvites
|
||||
}
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
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)
|
||||
}
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.migration.DisableInstallInCheck
|
||||
import dagger.multibindings.IntoMap
|
||||
import im.vector.app.core.platform.ConfigurationViewModel
|
||||
import im.vector.app.features.call.SharedKnownCallsViewModel
|
||||
@ -42,6 +43,7 @@ import im.vector.app.features.spaces.SpacePreviewSharedActionViewModel
|
||||
import im.vector.app.features.spaces.people.SpacePeopleSharedActionViewModel
|
||||
import im.vector.app.features.userdirectory.UserListSharedActionViewModel
|
||||
|
||||
@DisableInstallInCheck
|
||||
@Module
|
||||
interface ViewModelModule {
|
||||
|
||||
|
@ -17,10 +17,10 @@
|
||||
package im.vector.app.core.extensions
|
||||
|
||||
import android.content.Context
|
||||
import im.vector.app.core.di.AggregatorEntryPoint
|
||||
import im.vector.app.core.di.HasVectorInjector
|
||||
import im.vector.app.core.di.VectorComponent
|
||||
|
||||
fun Context.vectorComponent(): VectorComponent {
|
||||
fun Context.vectorComponent(): AggregatorEntryPoint {
|
||||
val appContext = applicationContext
|
||||
if (appContext is HasVectorInjector) {
|
||||
return appContext.injector()
|
||||
|
@ -45,14 +45,16 @@ import com.bumptech.glide.util.Util
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.jakewharton.rxbinding3.view.clicks
|
||||
import dagger.hilt.EntryPoints
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.AggregatorEntryPoint
|
||||
import im.vector.app.core.di.DaggerScreenComponent
|
||||
import im.vector.app.core.di.HasScreenInjector
|
||||
import im.vector.app.core.di.HasVectorInjector
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.di.VectorComponent
|
||||
import im.vector.app.core.di.ScreenComponentDependencies
|
||||
import im.vector.app.core.dialogs.DialogLocker
|
||||
import im.vector.app.core.dialogs.UnrecognizedCertificateDialog
|
||||
import im.vector.app.core.extensions.exhaustive
|
||||
@ -188,7 +190,10 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), HasSc
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
Timber.i("onCreate Activity ${javaClass.simpleName}")
|
||||
val vectorComponent = getVectorComponent()
|
||||
screenComponent = DaggerScreenComponent.factory().create(vectorComponent, this)
|
||||
val screenComponentDeps = EntryPoints.get(
|
||||
applicationContext,
|
||||
ScreenComponentDependencies::class.java)
|
||||
screenComponent = DaggerScreenComponent.factory().create(screenComponentDeps, this)
|
||||
val timeForInjection = measureTimeMillis {
|
||||
injectWith(screenComponent)
|
||||
}
|
||||
@ -419,7 +424,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), HasSc
|
||||
* PRIVATE METHODS
|
||||
* ========================================================================================== */
|
||||
|
||||
internal fun getVectorComponent(): VectorComponent {
|
||||
internal fun getVectorComponent(): AggregatorEntryPoint {
|
||||
return (application as HasVectorInjector).injector()
|
||||
}
|
||||
|
||||
|
@ -33,8 +33,10 @@ import com.google.android.material.bottomsheet.BottomSheetBehavior
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialog
|
||||
import com.google.android.material.bottomsheet.BottomSheetDialogFragment
|
||||
import com.jakewharton.rxbinding3.view.clicks
|
||||
import dagger.hilt.EntryPoints
|
||||
import im.vector.app.core.di.DaggerScreenComponent
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.di.ScreenComponentDependencies
|
||||
import im.vector.app.core.utils.DimensionConverter
|
||||
import io.reactivex.android.schedulers.AndroidSchedulers
|
||||
import io.reactivex.disposables.CompositeDisposable
|
||||
@ -122,7 +124,10 @@ abstract class VectorBaseBottomSheetDialogFragment<VB : ViewBinding> : BottomShe
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
screenComponent = DaggerScreenComponent.factory().create(vectorBaseActivity.getVectorComponent(), vectorBaseActivity)
|
||||
val screenComponentDeps = EntryPoints.get(
|
||||
vectorBaseActivity.applicationContext,
|
||||
ScreenComponentDependencies::class.java)
|
||||
screenComponent = DaggerScreenComponent.factory().create(screenComponentDeps, vectorBaseActivity)
|
||||
viewModelFactory = screenComponent.viewModelFactory()
|
||||
super.onAttach(context)
|
||||
injectWith(screenComponent)
|
||||
|
@ -35,10 +35,12 @@ import com.bumptech.glide.util.Util.assertMainThread
|
||||
import com.google.android.material.appbar.MaterialToolbar
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import com.jakewharton.rxbinding3.view.clicks
|
||||
import dagger.hilt.EntryPoints
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.DaggerScreenComponent
|
||||
import im.vector.app.core.di.HasScreenInjector
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.di.ScreenComponentDependencies
|
||||
import im.vector.app.core.dialogs.UnrecognizedCertificateDialog
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.extensions.toMvRxBundle
|
||||
@ -95,7 +97,10 @@ abstract class VectorBaseFragment<VB : ViewBinding> : Fragment(), MavericksView,
|
||||
* ========================================================================================== */
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
screenComponent = DaggerScreenComponent.factory().create(vectorBaseActivity.getVectorComponent(), vectorBaseActivity)
|
||||
val screenComponentDeps = EntryPoints.get(
|
||||
vectorBaseActivity.applicationContext,
|
||||
ScreenComponentDependencies::class.java)
|
||||
screenComponent = DaggerScreenComponent.factory().create(screenComponentDeps, vectorBaseActivity)
|
||||
navigator = screenComponent.navigator()
|
||||
errorFormatter = screenComponent.errorFormatter()
|
||||
unrecognizedCertificateDialog = screenComponent.unrecognizedCertificateDialog()
|
||||
|
@ -19,9 +19,11 @@ package im.vector.app.features.home
|
||||
import android.os.Handler
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.migration.DisableInstallInCheck
|
||||
import im.vector.app.features.home.room.detail.timeline.TimelineEventControllerHandler
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.TimelineAsyncHelper
|
||||
|
||||
@DisableInstallInCheck
|
||||
@Module
|
||||
object HomeModule {
|
||||
|
||||
|
@ -18,7 +18,9 @@ package im.vector.app.features.home.room.list
|
||||
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.hilt.migration.DisableInstallInCheck
|
||||
|
||||
@DisableInstallInCheck
|
||||
@Module
|
||||
abstract class RoomListModule {
|
||||
|
||||
|
@ -30,12 +30,9 @@ import androidx.core.view.isInvisible
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import androidx.transition.Transition
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.DaggerScreenComponent
|
||||
import im.vector.app.core.di.HasVectorInjector
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.di.VectorComponent
|
||||
import im.vector.app.core.intent.getMimeTypeFromUri
|
||||
import im.vector.app.core.utils.shareMedia
|
||||
import im.vector.app.features.themes.ActivityOtherThemes
|
||||
@ -48,8 +45,8 @@ import kotlinx.coroutines.withContext
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
import kotlin.system.measureTimeMillis
|
||||
|
||||
@AndroidEntryPoint
|
||||
class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmentProvider.InteractionListener {
|
||||
|
||||
@Parcelize
|
||||
@ -61,14 +58,11 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
||||
|
||||
@Inject
|
||||
lateinit var sessionHolder: ActiveSessionHolder
|
||||
|
||||
@Inject
|
||||
lateinit var dataSourceFactory: AttachmentProviderFactory
|
||||
|
||||
@Inject
|
||||
lateinit var imageContentRenderer: ImageContentRenderer
|
||||
|
||||
private lateinit var screenComponent: ScreenComponent
|
||||
|
||||
private var initialIndex = 0
|
||||
private var isAnimatingOut = false
|
||||
@ -78,12 +72,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
Timber.i("onCreate Activity ${javaClass.simpleName}")
|
||||
val vectorComponent = getVectorComponent()
|
||||
screenComponent = DaggerScreenComponent.factory().create(vectorComponent, this)
|
||||
val timeForInjection = measureTimeMillis {
|
||||
screenComponent.inject(this)
|
||||
}
|
||||
Timber.v("Injecting dependencies into ${javaClass.simpleName} took $timeForInjection ms")
|
||||
ThemeUtils.setActivityTheme(this, getOtherThemes())
|
||||
|
||||
val args = args() ?: throw IllegalArgumentException("Missing arguments")
|
||||
@ -220,10 +208,6 @@ class VectorAttachmentViewerActivity : AttachmentViewerActivity(), BaseAttachmen
|
||||
|
||||
private fun args() = intent.getParcelableExtra<Args>(EXTRA_ARGS)
|
||||
|
||||
private fun getVectorComponent(): VectorComponent {
|
||||
return (application as HasVectorInjector).injector()
|
||||
}
|
||||
|
||||
private fun scheduleStartPostponedTransition(sharedElement: View) {
|
||||
sharedElement.viewTreeObserver.addOnPreDrawListener(
|
||||
object : ViewTreeObserver.OnPreDrawListener {
|
||||
|
@ -20,6 +20,7 @@ import android.content.BroadcastReceiver
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.core.app.RemoteInput
|
||||
import dagger.hilt.android.AndroidEntryPoint
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.extensions.vectorComponent
|
||||
@ -36,6 +37,7 @@ import javax.inject.Inject
|
||||
/**
|
||||
* Receives actions broadcast by notification (on click, on dismiss, inline replies, etc.)
|
||||
*/
|
||||
@AndroidEntryPoint
|
||||
class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||
|
||||
@Inject lateinit var notificationDrawerManager: NotificationDrawerManager
|
||||
@ -44,7 +46,6 @@ class NotificationBroadcastReceiver : BroadcastReceiver() {
|
||||
override fun onReceive(context: Context?, intent: Intent?) {
|
||||
if (intent == null || context == null) return
|
||||
Timber.v("NotificationBroadcastReceiver received : $intent")
|
||||
context.vectorComponent().inject(this)
|
||||
when (intent.action) {
|
||||
NotificationUtils.SMART_REPLY_ACTION ->
|
||||
handleSmartReply(intent, context)
|
||||
|
@ -22,10 +22,12 @@ import android.view.View
|
||||
import androidx.annotation.CallSuper
|
||||
import androidx.preference.PreferenceFragmentCompat
|
||||
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
||||
import dagger.hilt.EntryPoints
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.di.DaggerScreenComponent
|
||||
import im.vector.app.core.di.HasScreenInjector
|
||||
import im.vector.app.core.di.ScreenComponent
|
||||
import im.vector.app.core.di.ScreenComponentDependencies
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
import im.vector.app.core.platform.VectorBaseActivity
|
||||
import im.vector.app.core.utils.toast
|
||||
@ -56,7 +58,10 @@ abstract class VectorSettingsBaseFragment : PreferenceFragmentCompat(), HasScree
|
||||
}
|
||||
|
||||
override fun onAttach(context: Context) {
|
||||
screenComponent = DaggerScreenComponent.factory().create(vectorActivity.getVectorComponent(), vectorActivity)
|
||||
val screenComponentDeps = EntryPoints.get(
|
||||
vectorActivity.applicationContext,
|
||||
ScreenComponentDependencies::class.java)
|
||||
screenComponent = DaggerScreenComponent.factory().create(screenComponentDeps, vectorActivity)
|
||||
super.onAttach(context)
|
||||
session = screenComponent.activeSessionHolder().getActiveSession()
|
||||
errorFormatter = screenComponent.errorFormatter()
|
||||
|
Loading…
Reference in New Issue
Block a user