mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-26 19:36:08 +03:00
decoupling the flipper proxy from the vector module
This commit is contained in:
parent
8156a646a1
commit
02286b96b0
12 changed files with 85 additions and 28 deletions
|
@ -26,6 +26,8 @@ import dagger.hilt.components.SingletonComponent
|
|||
import im.vector.app.core.debug.DebugReceiver
|
||||
import im.vector.app.features.debug.DebugMenuActivity
|
||||
import im.vector.app.core.debug.DebugNavigator
|
||||
import im.vector.app.core.debug.FlipperProxy
|
||||
import im.vector.app.flipper.VectorFlipperProxy
|
||||
import im.vector.app.receivers.VectorDebugReceiver
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
@ -44,4 +46,8 @@ abstract class DebugModule {
|
|||
|
||||
@Binds
|
||||
abstract fun bindsDebugReceiver(receiver: VectorDebugReceiver): DebugReceiver
|
||||
|
||||
@Binds
|
||||
abstract fun bindsFlipperProxy(flipperProxy: VectorFlipperProxy): FlipperProxy
|
||||
|
||||
}
|
||||
|
|
|
@ -29,19 +29,19 @@ import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPl
|
|||
import com.facebook.soloader.SoLoader
|
||||
import com.kgurgul.flipper.RealmDatabaseDriver
|
||||
import com.kgurgul.flipper.RealmDatabaseProvider
|
||||
import im.vector.app.core.debug.FlipperProxy
|
||||
import io.realm.RealmConfiguration
|
||||
import okhttp3.Interceptor
|
||||
import org.matrix.android.sdk.api.Matrix
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@Singleton
|
||||
class FlipperProxy @Inject constructor(
|
||||
class VectorFlipperProxy @Inject constructor(
|
||||
private val context: Context,
|
||||
) {
|
||||
) : FlipperProxy {
|
||||
private val networkFlipperPlugin = NetworkFlipperPlugin()
|
||||
|
||||
fun init(matrix: Matrix) {
|
||||
override fun init(matrix: Matrix) {
|
||||
SoLoader.init(context, false)
|
||||
|
||||
if (FlipperUtils.shouldEnableFlipper(context)) {
|
||||
|
@ -65,8 +65,5 @@ class FlipperProxy @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
@Suppress("RedundantNullableReturnType")
|
||||
fun getNetworkInterceptor(): Interceptor? {
|
||||
return FlipperOkhttpInterceptor(networkFlipperPlugin)
|
||||
}
|
||||
override fun networkInterceptor() = FlipperOkhttpInterceptor(networkFlipperPlugin)
|
||||
}
|
|
@ -23,6 +23,7 @@ import dagger.hilt.InstallIn
|
|||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.core.services.GuardServiceStarter
|
||||
import im.vector.app.fdroid.service.FDroidGuardServiceStarter
|
||||
import im.vector.app.features.home.NightlyProxy
|
||||
import im.vector.app.features.settings.VectorPreferences
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
|
@ -33,4 +34,11 @@ object FlavorModule {
|
|||
fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter {
|
||||
return FDroidGuardServiceStarter(preferences, appContext)
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun provideNightlyProxy() = object : NightlyProxy {
|
||||
override fun onHomeResumed() {
|
||||
// no op
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,18 +16,26 @@
|
|||
|
||||
package im.vector.app.di
|
||||
|
||||
import dagger.Binds
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.core.services.GuardServiceStarter
|
||||
import im.vector.app.features.home.NightlyProxy
|
||||
import im.vector.app.nightly.FirebaseNightlyProxy
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
object FlavorModule {
|
||||
abstract class FlavorModule {
|
||||
|
||||
@Provides
|
||||
fun provideGuardServiceStarter(): GuardServiceStarter {
|
||||
return object : GuardServiceStarter {}
|
||||
companion object {
|
||||
@Provides
|
||||
fun provideGuardServiceStarter(): GuardServiceStarter {
|
||||
return object : GuardServiceStarter {}
|
||||
}
|
||||
}
|
||||
|
||||
@Binds
|
||||
abstract fun bindsNightlyProxy(nightlyProxy: FirebaseNightlyProxy): NightlyProxy
|
||||
}
|
||||
|
|
|
@ -23,15 +23,17 @@ import com.google.firebase.appdistribution.FirebaseAppDistributionException
|
|||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.core.di.DefaultPreferences
|
||||
import im.vector.app.core.time.Clock
|
||||
import im.vector.app.features.home.NightlyProxy
|
||||
import timber.log.Timber
|
||||
import javax.inject.Inject
|
||||
|
||||
class NightlyProxy @Inject constructor(
|
||||
class FirebaseNightlyProxy @Inject constructor(
|
||||
private val clock: Clock,
|
||||
@DefaultPreferences
|
||||
private val sharedPreferences: SharedPreferences,
|
||||
) {
|
||||
fun onHomeResumed() {
|
||||
) : NightlyProxy {
|
||||
|
||||
override fun onHomeResumed() {
|
||||
if (!canDisplayPopup()) return
|
||||
val firebaseAppDistribution = FirebaseAppDistribution.getInstance()
|
||||
firebaseAppDistribution.updateIfNewReleaseAvailable()
|
|
@ -41,6 +41,7 @@ import com.vanniktech.emoji.EmojiManager
|
|||
import com.vanniktech.emoji.google.GoogleEmojiProvider
|
||||
import dagger.hilt.android.HiltAndroidApp
|
||||
import im.vector.app.config.Config
|
||||
import im.vector.app.core.debug.FlipperProxy
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.resources.BuildMeta
|
||||
import im.vector.app.features.analytics.VectorAnalytics
|
||||
|
@ -59,7 +60,6 @@ import im.vector.app.features.settings.VectorLocale
|
|||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import im.vector.app.features.version.VersionProvider
|
||||
import im.vector.app.flipper.FlipperProxy
|
||||
import im.vector.app.push.fcm.FcmHelper
|
||||
import org.jitsi.meet.sdk.log.JitsiMeetDefaultLogHandler
|
||||
import org.matrix.android.sdk.api.Matrix
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
/*
|
||||
* Copyright (c) 2022 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
|
||||
*
|
||||
* 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 im.vector.app.core.debug
|
||||
|
||||
import okhttp3.Interceptor
|
||||
import org.matrix.android.sdk.api.Matrix
|
||||
|
||||
interface FlipperProxy {
|
||||
fun init(matrix: Matrix)
|
||||
fun networkInterceptor(): Interceptor?
|
||||
}
|
|
@ -34,6 +34,7 @@ import im.vector.app.EmojiSpanify
|
|||
import im.vector.app.SpaceStateHandler
|
||||
import im.vector.app.SpaceStateHandlerImpl
|
||||
import im.vector.app.config.Config
|
||||
import im.vector.app.core.debug.FlipperProxy
|
||||
import im.vector.app.core.dispatchers.CoroutineDispatchers
|
||||
import im.vector.app.core.error.DefaultErrorFormatter
|
||||
import im.vector.app.core.error.ErrorFormatter
|
||||
|
@ -57,7 +58,6 @@ import im.vector.app.features.settings.FontScalePreferencesImpl
|
|||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.ui.SharedPreferencesUiStateRepository
|
||||
import im.vector.app.features.ui.UiStateRepository
|
||||
import im.vector.app.flipper.FlipperProxy
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.DelicateCoroutinesApi
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
@ -144,7 +144,7 @@ object VectorStaticModule {
|
|||
roomDisplayNameFallbackProvider = vectorRoomDisplayNameFallbackProvider,
|
||||
threadMessagesEnabledDefault = vectorPreferences.areThreadMessagesEnabled(),
|
||||
networkInterceptors = listOfNotNull(
|
||||
flipperProxy.getNetworkInterceptor(),
|
||||
flipperProxy.networkInterceptor(),
|
||||
)
|
||||
)
|
||||
}
|
||||
|
|
|
@ -55,6 +55,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|||
import com.google.android.material.snackbar.Snackbar
|
||||
import dagger.hilt.android.EntryPointAccessors
|
||||
import im.vector.app.R
|
||||
import im.vector.app.core.debug.DebugReceiver
|
||||
import im.vector.app.core.di.ActiveSessionHolder
|
||||
import im.vector.app.core.di.ActivityEntryPoint
|
||||
import im.vector.app.core.dialogs.DialogLocker
|
||||
|
@ -91,7 +92,6 @@ import im.vector.app.features.settings.FontScalePreferencesImpl
|
|||
import im.vector.app.features.settings.VectorPreferences
|
||||
import im.vector.app.features.themes.ActivityOtherThemes
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import im.vector.app.receivers.VectorDebugReceiver
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
import org.matrix.android.sdk.api.extensions.orFalse
|
||||
|
@ -160,8 +160,9 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
|
|||
@Inject lateinit var rageShake: RageShake
|
||||
@Inject lateinit var buildMeta: BuildMeta
|
||||
@Inject lateinit var fontScalePreferences: FontScalePreferences
|
||||
|
||||
// For debug only
|
||||
@Inject lateinit var debugReceiver: VectorDebugReceiver
|
||||
@Inject lateinit var debugReceiver: DebugReceiver
|
||||
|
||||
@Inject
|
||||
lateinit var vectorFeatures: VectorFeatures
|
||||
|
|
|
@ -79,7 +79,6 @@ import im.vector.app.features.spaces.invite.SpaceInviteBottomSheet
|
|||
import im.vector.app.features.spaces.share.ShareSpaceBottomSheet
|
||||
import im.vector.app.features.themes.ThemeUtils
|
||||
import im.vector.app.features.workers.signout.ServerBackupStatusViewModel
|
||||
import im.vector.app.nightly.NightlyProxy
|
||||
import im.vector.app.push.fcm.FcmHelper
|
||||
import kotlinx.coroutines.flow.launchIn
|
||||
import kotlinx.coroutines.flow.onEach
|
||||
|
|
|
@ -14,10 +14,8 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.nightly
|
||||
package im.vector.app.features.home
|
||||
|
||||
import javax.inject.Inject
|
||||
|
||||
class NightlyProxy @Inject constructor() {
|
||||
fun onHomeResumed() = Unit
|
||||
interface NightlyProxy {
|
||||
fun onHomeResumed()
|
||||
}
|
|
@ -14,14 +14,18 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package im.vector.app.features.debug.di
|
||||
package im.vector.app.core.di
|
||||
|
||||
import dagger.Binds
|
||||
import android.content.Context
|
||||
import dagger.Module
|
||||
import dagger.Provides
|
||||
import dagger.hilt.InstallIn
|
||||
import dagger.hilt.components.SingletonComponent
|
||||
import im.vector.app.core.debug.DebugNavigator
|
||||
import im.vector.app.core.debug.DebugReceiver
|
||||
import im.vector.app.core.debug.FlipperProxy
|
||||
import okhttp3.Interceptor
|
||||
import org.matrix.android.sdk.api.Matrix
|
||||
|
||||
@InstallIn(SingletonComponent::class)
|
||||
@Module
|
||||
|
@ -44,4 +48,13 @@ object DebugModule {
|
|||
// no op
|
||||
}
|
||||
}
|
||||
|
||||
@Provides
|
||||
fun providesFlipperProxy() = object : FlipperProxy {
|
||||
override fun init(matrix: Matrix) {
|
||||
// no op
|
||||
}
|
||||
|
||||
override fun networkInterceptor(): Interceptor? = null
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue