From b3068c017da17d07f040c8060f9e3d8b369917db Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Fri, 23 Sep 2022 16:20:20 +0200 Subject: [PATCH] Inject ErrorFormatter in the parent Activity (often used) --- .../java/im/vector/app/core/platform/VectorBaseActivity.kt | 3 ++- vector/src/main/java/im/vector/app/features/MainActivity.kt | 5 ----- .../im/vector/app/features/call/dialpad/PstnDialActivity.kt | 2 -- .../app/features/call/transfer/CallTransferActivity.kt | 4 ---- .../app/features/createdirect/CreateDirectRoomActivity.kt | 3 --- .../features/crypto/quads/SharedSecureStorageActivity.kt | 3 --- .../vector/app/features/invite/InviteUsersToRoomActivity.kt | 3 --- .../java/im/vector/app/features/link/LinkHandlerActivity.kt | 2 -- .../roomprofile/settings/joinrule/RoomJoinRuleActivity.kt | 5 ----- .../vector/app/features/signout/soft/SoftLogoutActivity.kt | 2 -- .../app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt | 6 +----- .../im/vector/app/features/terms/ReviewTermsActivity.kt | 4 ---- 12 files changed, 3 insertions(+), 39 deletions(-) diff --git a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt index 413249e79c..4e5116eda9 100644 --- a/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt +++ b/vector/src/main/java/im/vector/app/core/platform/VectorBaseActivity.kt @@ -56,6 +56,7 @@ import im.vector.app.core.di.ActiveSessionHolder import im.vector.app.core.di.ActivityEntryPoint import im.vector.app.core.dialogs.DialogLocker import im.vector.app.core.dialogs.UnrecognizedCertificateDialog +import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.error.fatalError import im.vector.app.core.extensions.observeEvent import im.vector.app.core.extensions.observeNotNull @@ -161,11 +162,11 @@ abstract class VectorBaseActivity : AppCompatActivity(), Maver @Inject lateinit var navigator: Navigator @Inject lateinit var activeSessionHolder: ActiveSessionHolder @Inject lateinit var vectorPreferences: VectorPreferences + @Inject lateinit var errorFormatter: ErrorFormatter // For debug only @Inject lateinit var debugReceiver: DebugReceiver - // Filter for multiple invalid token error private var mainActivityStarted = false diff --git a/vector/src/main/java/im/vector/app/features/MainActivity.kt b/vector/src/main/java/im/vector/app/features/MainActivity.kt index 1040727722..c197cfccf3 100644 --- a/vector/src/main/java/im/vector/app/features/MainActivity.kt +++ b/vector/src/main/java/im/vector/app/features/MainActivity.kt @@ -30,8 +30,6 @@ import com.bumptech.glide.Glide import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.di.ActiveSessionHolder -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.startSyncing import im.vector.app.core.extensions.vectorStore import im.vector.app.core.platform.VectorBaseActivity @@ -42,13 +40,11 @@ import im.vector.app.features.analytics.plan.ViewRoom import im.vector.app.features.home.HomeActivity import im.vector.app.features.home.ShortcutsHandler import im.vector.app.features.notifications.NotificationDrawerManager -import im.vector.app.features.pin.PinLocker import im.vector.app.features.pin.UnlockedActivity import im.vector.app.features.pin.lockscreen.crypto.LockScreenKeyRepository import im.vector.app.features.pin.lockscreen.pincode.PinCodeHelper import im.vector.app.features.popup.PopupAlertManager import im.vector.app.features.session.VectorSessionStore -import im.vector.app.features.settings.VectorPreferences import im.vector.app.features.signout.hard.SignedOutActivity import im.vector.app.features.start.StartAppAction import im.vector.app.features.start.StartAppAndroidService @@ -131,7 +127,6 @@ class MainActivity : VectorBaseActivity(), UnlockedActivity private lateinit var args: MainActivityArgs @Inject lateinit var notificationDrawerManager: NotificationDrawerManager - @Inject lateinit var errorFormatter: ErrorFormatter @Inject lateinit var uiStateRepository: UiStateRepository @Inject lateinit var shortcutsHandler: ShortcutsHandler @Inject lateinit var pinCodeHelper: PinCodeHelper diff --git a/vector/src/main/java/im/vector/app/features/call/dialpad/PstnDialActivity.kt b/vector/src/main/java/im/vector/app/features/call/dialpad/PstnDialActivity.kt index 251195ddc4..1a7571598e 100644 --- a/vector/src/main/java/im/vector/app/features/call/dialpad/PstnDialActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/dialpad/PstnDialActivity.kt @@ -23,7 +23,6 @@ import androidx.lifecycle.lifecycleScope import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.addFragment import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.features.call.webrtc.WebRtcCallManager @@ -39,7 +38,6 @@ class PstnDialActivity : SimpleFragmentActivity() { @Inject lateinit var callManager: WebRtcCallManager @Inject lateinit var directRoomHelper: DirectRoomHelper @Inject lateinit var session: Session - @Inject lateinit var errorFormatter: ErrorFormatter private var progress: AppCompatDialog? = null diff --git a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt index 25bfb6c0e9..ae168c5f92 100644 --- a/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt +++ b/vector/src/main/java/im/vector/app/features/call/transfer/CallTransferActivity.kt @@ -25,12 +25,10 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.tabs.TabLayoutMediator import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivityCallTransferBinding import im.vector.lib.core.utils.compat.getParcelableCompat import kotlinx.parcelize.Parcelize -import javax.inject.Inject @Parcelize data class CallTransferArgs(val callId: String) : Parcelable @@ -40,8 +38,6 @@ private const val USER_LIST_FRAGMENT_TAG = "USER_LIST_FRAGMENT_TAG" @AndroidEntryPoint class CallTransferActivity : VectorBaseActivity() { - @Inject lateinit var errorFormatter: ErrorFormatter - private lateinit var sectionsPagerAdapter: CallTransferPagerAdapter private val callTransferViewModel: CallTransferViewModel by viewModel() diff --git a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt index fd28235a51..acaf24dca7 100644 --- a/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/createdirect/CreateDirectRoomActivity.kt @@ -32,7 +32,6 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.platform.SimpleFragmentActivity @@ -58,7 +57,6 @@ import kotlinx.coroutines.flow.onEach import org.matrix.android.sdk.api.failure.Failure import org.matrix.android.sdk.api.session.room.failure.CreateRoomFailure import java.net.HttpURLConnection -import javax.inject.Inject @AndroidEntryPoint class CreateDirectRoomActivity : SimpleFragmentActivity() { @@ -67,7 +65,6 @@ class CreateDirectRoomActivity : SimpleFragmentActivity() { private val qrViewModel: QrCodeScannerViewModel by viewModel() private lateinit var sharedActionViewModel: UserListSharedActionViewModel - @Inject lateinit var errorFormatter: ErrorFormatter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt index b39992256d..d393636a8e 100644 --- a/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt +++ b/vector/src/main/java/im/vector/app/features/crypto/quads/SharedSecureStorageActivity.kt @@ -30,13 +30,11 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.app.core.platform.VectorBaseBottomSheetDialogFragment import im.vector.app.features.crypto.recover.SetupMode import kotlinx.parcelize.Parcelize -import javax.inject.Inject import kotlin.reflect.KClass @AndroidEntryPoint @@ -54,7 +52,6 @@ class SharedSecureStorageActivity : ) : Parcelable private val viewModel: SharedSecureStorageViewModel by viewModel() - @Inject lateinit var errorFormatter: ErrorFormatter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt index 86f061849b..7f514d2ad2 100644 --- a/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt +++ b/vector/src/main/java/im/vector/app/features/invite/InviteUsersToRoomActivity.kt @@ -27,7 +27,6 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.addFragmentToBackstack import im.vector.app.core.platform.SimpleFragmentActivity @@ -47,7 +46,6 @@ import kotlinx.coroutines.flow.onEach import kotlinx.parcelize.Parcelize import org.matrix.android.sdk.api.failure.Failure import java.net.HttpURLConnection -import javax.inject.Inject @Parcelize data class InviteUsersToRoomArgs(val roomId: String) : Parcelable @@ -57,7 +55,6 @@ class InviteUsersToRoomActivity : SimpleFragmentActivity() { private val viewModel: InviteUsersToRoomViewModel by viewModel() private lateinit var sharedActionViewModel: UserListSharedActionViewModel - @Inject lateinit var errorFormatter: ErrorFormatter override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) diff --git a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt index 2526dc6ed7..1ca67e1fb7 100644 --- a/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt +++ b/vector/src/main/java/im/vector/app/features/link/LinkHandlerActivity.kt @@ -24,7 +24,6 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.registerStartForActivityResult import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.core.utils.toast @@ -45,7 +44,6 @@ import javax.inject.Inject @AndroidEntryPoint class LinkHandlerActivity : VectorBaseActivity() { - @Inject lateinit var errorFormatter: ErrorFormatter @Inject lateinit var permalinkHandler: PermalinkHandler private val startAppViewModel: StartAppViewModel by viewModel() diff --git a/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt b/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt index 205fb86377..818300ac72 100644 --- a/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt +++ b/vector/src/main/java/im/vector/app/features/roomprofile/settings/joinrule/RoomJoinRuleActivity.kt @@ -29,7 +29,6 @@ import com.airbnb.mvrx.viewModel import com.airbnb.mvrx.withState import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.addFragment import im.vector.app.core.extensions.commitTransaction import im.vector.app.core.extensions.toMvRxBundle @@ -44,7 +43,6 @@ import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRul import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedState import im.vector.app.features.roomprofile.settings.joinrule.advanced.RoomJoinRuleChooseRestrictedViewModel import im.vector.lib.core.utils.compat.getParcelableCompat -import javax.inject.Inject @AndroidEntryPoint class RoomJoinRuleActivity : VectorBaseActivity() { @@ -53,9 +51,6 @@ class RoomJoinRuleActivity : VectorBaseActivity() { private lateinit var roomProfileArgs: RoomProfileArgs - @Inject - lateinit var errorFormatter: ErrorFormatter - val viewModel: RoomJoinRuleChooseRestrictedViewModel by viewModel() override fun initUiAndData() { diff --git a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt index 729bd2541e..15a86c869b 100644 --- a/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt +++ b/vector/src/main/java/im/vector/app/features/signout/soft/SoftLogoutActivity.kt @@ -25,7 +25,6 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.replaceFragment import im.vector.app.features.MainActivity import im.vector.app.features.MainActivityArgs @@ -45,7 +44,6 @@ class SoftLogoutActivity : LoginActivity() { private val softLogoutViewModel: SoftLogoutViewModel by viewModel() @Inject lateinit var session: Session - @Inject lateinit var errorFormatter: ErrorFormatter override fun initUiAndData() { super.initUiAndData() diff --git a/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt b/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt index 80959c61a1..6f9aef401d 100644 --- a/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt +++ b/vector/src/main/java/im/vector/app/features/spaces/leave/SpaceLeaveAdvancedActivity.kt @@ -29,7 +29,6 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.hideKeyboard import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.extensions.setTextOrHide @@ -37,16 +36,13 @@ import im.vector.app.core.platform.VectorBaseActivity import im.vector.app.databinding.ActivitySimpleLoadingBinding import im.vector.app.features.spaces.SpaceBottomSheetSettingsArgs import im.vector.lib.core.utils.compat.getParcelableExtraCompat -import javax.inject.Inject @AndroidEntryPoint class SpaceLeaveAdvancedActivity : VectorBaseActivity() { override fun getBinding(): ActivitySimpleLoadingBinding = ActivitySimpleLoadingBinding.inflate(layoutInflater) - val leaveViewModel: SpaceLeaveAdvancedViewModel by viewModel() - - @Inject lateinit var errorFormatter: ErrorFormatter + private val leaveViewModel: SpaceLeaveAdvancedViewModel by viewModel() override fun showWaitingView(text: String?) { hideKeyboard() diff --git a/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt b/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt index d261a8d160..6e34113012 100644 --- a/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt +++ b/vector/src/main/java/im/vector/app/features/terms/ReviewTermsActivity.kt @@ -22,18 +22,14 @@ import com.airbnb.mvrx.viewModel import com.google.android.material.dialog.MaterialAlertDialogBuilder import dagger.hilt.android.AndroidEntryPoint import im.vector.app.R -import im.vector.app.core.error.ErrorFormatter import im.vector.app.core.extensions.replaceFragment import im.vector.app.core.platform.SimpleFragmentActivity import im.vector.lib.core.utils.compat.getParcelableExtraCompat import org.matrix.android.sdk.api.session.terms.TermsService -import javax.inject.Inject @AndroidEntryPoint class ReviewTermsActivity : SimpleFragmentActivity() { - @Inject lateinit var errorFormatter: ErrorFormatter - private val reviewTermsViewModel: ReviewTermsViewModel by viewModel() override fun initUiAndData() {