Merge pull request #6783 from vector-im/feature/adm/decouple-variants

Decouple `:vector` variants/build types
This commit is contained in:
Adam Brown 2022-08-11 10:59:42 +01:00 committed by GitHub
commit 616c16f8c6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
37 changed files with 434 additions and 143 deletions

1
changelog.d/6783.misc Normal file
View File

@ -0,0 +1 @@
Decouples the variant logic from the vector module

View File

@ -307,7 +307,6 @@ android {
isDefault = true
versionName "${versionMajor}.${versionMinor}.${versionPatch}${getGplayVersionSuffix()}"
resValue "bool", "isGplay", "true"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"G\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"GooglePlay\""
}
@ -317,7 +316,6 @@ android {
versionName "${versionMajor}.${versionMinor}.${versionPatch}${getFdroidVersionSuffix()}"
resValue "bool", "isGplay", "false"
buildConfigField "String", "SHORT_FLAVOR_DESCRIPTION", "\"F\""
buildConfigField "String", "FLAVOR_DESCRIPTION", "\"FDroid\""
}

View File

@ -9,6 +9,7 @@
<activity android:name=".features.debug.settings.DebugPrivateSettingsActivity" />
<activity android:name=".features.debug.sas.DebugSasEmojiActivity" />
<activity android:name=".features.debug.features.DebugFeaturesSettingsActivity" />
<activity android:name=".features.debug.DebugMenuActivity" />
<activity
android:name="com.facebook.flipper.android.diagnostics.FlipperDiagnosticActivity"

View File

@ -0,0 +1,52 @@
/*
* 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.features.debug.di
import android.content.Context
import android.content.Intent
import dagger.Binds
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 im.vector.app.features.debug.DebugMenuActivity
import im.vector.app.flipper.VectorFlipperProxy
import im.vector.app.receivers.VectorDebugReceiver
@InstallIn(SingletonComponent::class)
@Module
abstract class DebugModule {
companion object {
@Provides
fun providesDebugNavigator() = object : DebugNavigator {
override fun openDebugMenu(context: Context) {
context.startActivity(Intent(context, DebugMenuActivity::class.java))
}
}
}
@Binds
abstract fun bindsDebugReceiver(receiver: VectorDebugReceiver): DebugReceiver
@Binds
abstract fun bindsFlipperProxy(flipperProxy: VectorFlipperProxy): FlipperProxy
}

View File

@ -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)
}

View File

@ -22,14 +22,24 @@ import android.content.Intent
import android.content.IntentFilter
import android.content.SharedPreferences
import androidx.core.content.edit
import im.vector.app.core.debug.DebugReceiver
import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.core.utils.lsFiles
import timber.log.Timber
import javax.inject.Inject
/**
* Receiver to handle some command from ADB
*/
class DebugReceiver : BroadcastReceiver() {
class VectorDebugReceiver @Inject constructor() : BroadcastReceiver(), DebugReceiver {
override fun register(context: Context) {
context.registerReceiver(this, getIntentFilter(context))
}
override fun unregister(context: Context) {
context.unregisterReceiver(this)
}
override fun onReceive(context: Context, intent: Intent) {
Timber.v("Received debug action: ${intent.action}")

View File

@ -17,20 +17,46 @@
package im.vector.app.di
import android.content.Context
import dagger.Binds
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
import im.vector.app.core.pushers.FcmHelper
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
import im.vector.app.features.settings.legals.FlavorLegals
import im.vector.app.push.fcm.FdroidFcmHelper
@InstallIn(SingletonComponent::class)
@Module
object FlavorModule {
abstract class FlavorModule {
@Provides
fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter {
return FDroidGuardServiceStarter(preferences, appContext)
companion object {
@Provides
fun provideGuardServiceStarter(preferences: VectorPreferences, appContext: Context): GuardServiceStarter {
return FDroidGuardServiceStarter(preferences, appContext)
}
@Provides
fun provideNightlyProxy() = object : NightlyProxy {
override fun onHomeResumed() {
// no op
}
}
@Provides
fun providesFlavorLegals() = object : FlavorLegals {
override fun hasThirdPartyNotices() = false
override fun navigateToThirdPartyNotices(context: Context) {
// no op
}
}
}
@Binds
abstract fun bindsFcmHelper(fcmHelper: FdroidFcmHelper): FcmHelper
}

View File

@ -0,0 +1,31 @@
/*
* 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.di
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory
import im.vector.app.push.fcm.FdroidNotificationTroubleshootTestManagerFactory
@InstallIn(ActivityComponent::class)
@Module
abstract class NotificationTestModule {
@Binds
abstract fun bindsNotificationTestFactory(factory: FdroidNotificationTroubleshootTestManagerFactory): NotificationTroubleshootTestManagerFactory
}

View File

@ -20,6 +20,7 @@ package im.vector.app.push.fcm
import android.app.Activity
import android.content.Context
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.pushers.PushersManager
import im.vector.app.fdroid.BackgroundSyncStarter
import im.vector.app.fdroid.receiver.AlarmSyncBroadcastReceiver
@ -28,47 +29,32 @@ import javax.inject.Inject
/**
* This class has an alter ego in the gplay variant.
*/
class FcmHelper @Inject constructor(
class FdroidFcmHelper @Inject constructor(
private val context: Context,
private val backgroundSyncStarter: BackgroundSyncStarter,
) {
) : FcmHelper {
fun isFirebaseAvailable(): Boolean = false
override fun isFirebaseAvailable(): Boolean = false
/**
* Retrieves the FCM registration token.
*
* @return the FCM token or null if not received from FCM
*/
fun getFcmToken(): String? {
override fun getFcmToken(): String? {
return null
}
/**
* Store FCM token to the SharedPrefs
*
* @param token the token to store
*/
fun storeFcmToken(token: String?) {
override fun storeFcmToken(token: String?) {
// No op
}
/**
* onNewToken may not be called on application upgrade, so ensure my shared pref is set
*
* @param activity the first launch Activity
*/
fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager, registerPusher: Boolean) {
override fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager, registerPusher: Boolean) {
// No op
}
fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
override fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
// try to stop all regardless of background mode
activeSessionHolder.getSafeActiveSession()?.syncService()?.stopAnyBackgroundSync()
AlarmSyncBroadcastReceiver.cancelAlarm(context)
}
fun onEnterBackground(activeSessionHolder: ActiveSessionHolder) {
override fun onEnterBackground(activeSessionHolder: ActiveSessionHolder) {
backgroundSyncStarter.start(activeSessionHolder)
}
}

View File

@ -21,6 +21,7 @@ import im.vector.app.fdroid.features.settings.troubleshoot.TestAutoStartBoot
import im.vector.app.fdroid.features.settings.troubleshoot.TestBackgroundRestrictions
import im.vector.app.fdroid.features.settings.troubleshoot.TestBatteryOptimization
import im.vector.app.features.VectorFeatures
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
import im.vector.app.features.settings.troubleshoot.TestAccountSettings
import im.vector.app.features.settings.troubleshoot.TestAvailableUnifiedPushDistributors
@ -35,7 +36,7 @@ import im.vector.app.features.settings.troubleshoot.TestUnifiedPushEndpoint
import im.vector.app.features.settings.troubleshoot.TestUnifiedPushGateway
import javax.inject.Inject
class NotificationTroubleshootTestManagerFactory @Inject constructor(
class FdroidNotificationTroubleshootTestManagerFactory @Inject constructor(
private val unifiedPushHelper: UnifiedPushHelper,
private val testSystemSettings: TestSystemSettings,
private val testAccountSettings: TestAccountSettings,
@ -52,9 +53,9 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
private val testBatteryOptimization: TestBatteryOptimization,
private val testNotification: TestNotification,
private val vectorFeatures: VectorFeatures,
) {
) : NotificationTroubleshootTestManagerFactory {
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
override fun create(fragment: Fragment): NotificationTroubleshootTestManager {
val mgr = NotificationTroubleshootTestManager(fragment)
mgr.addTest(testSystemSettings)
mgr.addTest(testAccountSettings)

View File

@ -0,0 +1,33 @@
/*
* 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
import android.content.Context
import android.content.Intent
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
import im.vector.app.features.settings.legals.FlavorLegals
import javax.inject.Inject
class GoogleFlavorLegals @Inject constructor() : FlavorLegals {
override fun hasThirdPartyNotices() = true
override fun navigateToThirdPartyNotices(context: Context) {
// See https://developers.google.com/android/guides/opensource
context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
}
}

View File

@ -16,18 +16,36 @@
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.GoogleFlavorLegals
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.services.GuardServiceStarter
import im.vector.app.features.home.NightlyProxy
import im.vector.app.features.settings.legals.FlavorLegals
import im.vector.app.nightly.FirebaseNightlyProxy
import im.vector.app.push.fcm.GoogleFcmHelper
@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
@Binds
abstract fun bindsFcmHelper(fcmHelper: GoogleFcmHelper): FcmHelper
@Binds
abstract fun bindsFlavorLegals(legals: GoogleFlavorLegals): FlavorLegals
}

View File

@ -0,0 +1,31 @@
/*
* 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.di
import dagger.Binds
import dagger.Module
import dagger.hilt.InstallIn
import dagger.hilt.android.components.ActivityComponent
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory
import im.vector.app.push.fcm.GoogleNotificationTroubleshootTestManagerFactory
@InstallIn(ActivityComponent::class)
@Module
abstract class NotificationTestModule {
@Binds
abstract fun bindsNotificationTestFactory(factory: GoogleNotificationTroubleshootTestManagerFactory): NotificationTroubleshootTestManagerFactory
}

View File

@ -20,10 +20,10 @@ import androidx.activity.result.ActivityResultLauncher
import androidx.fragment.app.FragmentActivity
import com.google.firebase.messaging.FirebaseMessaging
import im.vector.app.R
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.resources.StringProvider
import im.vector.app.core.utils.startAddGoogleAccountIntent
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
import im.vector.app.push.fcm.FcmHelper
import timber.log.Timber
import javax.inject.Inject

View File

@ -23,10 +23,10 @@ import androidx.work.WorkInfo
import androidx.work.WorkManager
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.resources.StringProvider
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
import im.vector.app.push.fcm.FcmHelper
import org.matrix.android.sdk.api.session.pushers.PusherState
import javax.inject.Inject

View File

@ -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()

View File

@ -25,6 +25,7 @@ import com.google.firebase.messaging.FirebaseMessaging
import im.vector.app.R
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.di.DefaultSharedPreferences
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.pushers.PushersManager
import timber.log.Timber
import javax.inject.Inject
@ -33,44 +34,29 @@ import javax.inject.Inject
* This class store the FCM token in SharedPrefs and ensure this token is retrieved.
* It has an alter ego in the fdroid variant.
*/
class FcmHelper @Inject constructor(
class GoogleFcmHelper @Inject constructor(
context: Context,
) {
) : FcmHelper {
companion object {
private const val PREFS_KEY_FCM_TOKEN = "FCM_TOKEN"
}
private val sharedPrefs = DefaultSharedPreferences.getInstance(context)
fun isFirebaseAvailable(): Boolean = true
override fun isFirebaseAvailable(): Boolean = true
/**
* Retrieves the FCM registration token.
*
* @return the FCM token or null if not received from FCM
*/
fun getFcmToken(): String? {
override fun getFcmToken(): String? {
return sharedPrefs.getString(PREFS_KEY_FCM_TOKEN, null)
}
/**
* Store FCM token to the SharedPrefs
* TODO Store in realm
*
* @param token the token to store
*/
fun storeFcmToken(token: String?) {
override fun storeFcmToken(token: String?) {
// TODO Store in realm
sharedPrefs.edit {
putString(PREFS_KEY_FCM_TOKEN, token)
}
}
/**
* onNewToken may not be called on application upgrade, so ensure my shared pref is set
*
* @param activity the first launch Activity
*/
fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager, registerPusher: Boolean) {
override fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager, registerPusher: Boolean) {
// if (TextUtils.isEmpty(getFcmToken(activity))) {
// 'app should always check the device for a compatible Google Play services APK before accessing Google Play services features'
if (checkPlayServices(activity)) {
@ -105,13 +91,11 @@ class FcmHelper @Inject constructor(
return resultCode == ConnectionResult.SUCCESS
}
@Suppress("UNUSED_PARAMETER")
fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
override fun onEnterForeground(activeSessionHolder: ActiveSessionHolder) {
// No op
}
@Suppress("UNUSED_PARAMETER")
fun onEnterBackground(activeSessionHolder: ActiveSessionHolder) {
override fun onEnterBackground(activeSessionHolder: ActiveSessionHolder) {
// No op
}
}

View File

@ -18,6 +18,7 @@ package im.vector.app.push.fcm
import androidx.fragment.app.Fragment
import im.vector.app.core.pushers.UnifiedPushHelper
import im.vector.app.features.VectorFeatures
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
import im.vector.app.features.settings.troubleshoot.TestAccountSettings
import im.vector.app.features.settings.troubleshoot.TestAvailableUnifiedPushDistributors
@ -35,7 +36,7 @@ import im.vector.app.gplay.features.settings.troubleshoot.TestPlayServices
import im.vector.app.gplay.features.settings.troubleshoot.TestTokenRegistration
import javax.inject.Inject
class NotificationTroubleshootTestManagerFactory @Inject constructor(
class GoogleNotificationTroubleshootTestManagerFactory @Inject constructor(
private val unifiedPushHelper: UnifiedPushHelper,
private val testSystemSettings: TestSystemSettings,
private val testAccountSettings: TestAccountSettings,
@ -52,9 +53,9 @@ class NotificationTroubleshootTestManagerFactory @Inject constructor(
private val testPushFromPushGateway: TestPushFromPushGateway,
private val testNotification: TestNotification,
private val vectorFeatures: VectorFeatures,
) {
) : NotificationTroubleshootTestManagerFactory {
fun create(fragment: Fragment): NotificationTroubleshootTestManager {
override fun create(fragment: Fragment): NotificationTroubleshootTestManager {
val mgr = NotificationTroubleshootTestManager(fragment)
mgr.addTest(testSystemSettings)
mgr.addTest(testAccountSettings)

View File

@ -187,7 +187,6 @@
android:name="android.support.PARENT_ACTIVITY"
android:value=".features.home.HomeActivity" />
</activity>
<activity android:name=".features.debug.DebugMenuActivity" />
<activity android:name=".features.createdirect.CreateDirectRoomActivity" />
<activity android:name=".features.invite.InviteUsersToRoomActivity" />
<activity android:name=".features.webview.VectorWebViewActivity" />

View File

@ -45,7 +45,9 @@ 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.pushers.FcmHelper
import im.vector.app.core.resources.BuildMeta
import im.vector.app.features.analytics.VectorAnalytics
import im.vector.app.features.call.webrtc.WebRtcCallManager
@ -63,8 +65,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
import org.matrix.android.sdk.api.auth.AuthenticationService

View File

@ -14,10 +14,10 @@
* limitations under the License.
*/
package im.vector.app.nightly
package im.vector.app.core.debug
import javax.inject.Inject
import android.content.Context
class NightlyProxy @Inject constructor() {
fun onHomeResumed() = Unit
interface DebugNavigator {
fun openDebugMenu(context: Context)
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2020 New Vector Ltd
* 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.
@ -14,9 +14,11 @@
* limitations under the License.
*/
package im.vector.app
package im.vector.app.core.debug
import android.content.Context
// No op
fun openOssLicensesMenuActivity(@Suppress("UNUSED_PARAMETER") context: Context) = Unit
interface DebugReceiver {
fun register(context: Context)
fun unregister(context: Context)
}

View File

@ -14,18 +14,12 @@
* limitations under the License.
*/
package im.vector.app.flipper
package im.vector.app.core.debug
import okhttp3.Interceptor
import org.matrix.android.sdk.api.Matrix
import javax.inject.Inject
/**
* No op version.
*/
@Suppress("UNUSED_PARAMETER")
class FlipperProxy @Inject constructor() {
fun init(matrix: Matrix) {}
fun getNetworkInterceptor(): Interceptor? = null
interface FlipperProxy {
fun init(matrix: Matrix)
fun networkInterceptor(): Interceptor?
}

View File

@ -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(),
)
)
}

View File

@ -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.DebugReceiver
import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach
import org.matrix.android.sdk.api.extensions.orFalse
@ -161,6 +161,9 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
@Inject lateinit var buildMeta: BuildMeta
@Inject lateinit var fontScalePreferences: FontScalePreferences
// For debug only
@Inject lateinit var debugReceiver: DebugReceiver
@Inject
lateinit var vectorFeatures: VectorFeatures
@ -176,9 +179,6 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
private var savedInstanceState: Bundle? = null
// For debug only
private var debugReceiver: DebugReceiver? = null
private val restorables = ArrayList<Restorable>()
override fun attachBaseContext(base: Context) {
@ -418,13 +418,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
if (this !is BugReportActivity && vectorPreferences.useRageshake()) {
rageShake.start()
}
DebugReceiver
.getIntentFilter(this)
.takeIf { buildMeta.isDebug }
?.let {
debugReceiver = DebugReceiver()
registerReceiver(debugReceiver, it)
}
debugReceiver.register(this)
}
private val postResumeScheduledActions = mutableListOf<() -> Unit>()
@ -454,11 +448,7 @@ abstract class VectorBaseActivity<VB : ViewBinding> : AppCompatActivity(), Maver
Timber.i("onPause Activity ${javaClass.simpleName}")
rageShake.stop()
debugReceiver?.let {
unregisterReceiver(debugReceiver)
debugReceiver = null
}
debugReceiver.unregister(this)
}
override fun onWindowFocusChanged(hasFocus: Boolean) {

View File

@ -0,0 +1,51 @@
/*
* 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.pushers
import android.app.Activity
import im.vector.app.core.di.ActiveSessionHolder
interface FcmHelper {
fun isFirebaseAvailable(): Boolean
/**
* Retrieves the FCM registration token.
*
* @return the FCM token or null if not received from FCM.
*/
fun getFcmToken(): String?
/**
* Store FCM token to the SharedPrefs.
*
* @param token the token to store.
*/
fun storeFcmToken(token: String?)
/**
* onNewToken may not be called on application upgrade, so ensure my shared pref is set.
*
* @param activity the first launch Activity.
* @param pushersManager the instance to register the pusher on.
* @param registerPusher whether the pusher should be registered.
*/
fun ensureFcmTokenIsRetrieved(activity: Activity, pushersManager: PushersManager, registerPusher: Boolean)
fun onEnterForeground(activeSessionHolder: ActiveSessionHolder)
fun onEnterBackground(activeSessionHolder: ActiveSessionHolder)
}

View File

@ -28,7 +28,6 @@ import im.vector.app.core.utils.getApplicationLabel
import im.vector.app.features.VectorFeatures
import im.vector.app.features.settings.BackgroundSyncMode
import im.vector.app.features.settings.VectorPreferences
import im.vector.app.push.fcm.FcmHelper
import kotlinx.coroutines.launch
import org.matrix.android.sdk.api.Matrix
import org.matrix.android.sdk.api.cache.CacheStrategy

View File

@ -44,6 +44,7 @@ import im.vector.app.core.extensions.replaceFragment
import im.vector.app.core.extensions.validateBackPressed
import im.vector.app.core.platform.VectorBaseActivity
import im.vector.app.core.platform.VectorMenuProvider
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.pushers.PushersManager
import im.vector.app.core.pushers.UnifiedPushHelper
import im.vector.app.core.utils.startSharePlainTextIntent
@ -79,8 +80,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
import kotlinx.coroutines.launch

View File

@ -1,5 +1,5 @@
/*
* Copyright 2019 New Vector Ltd
* 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.
@ -14,9 +14,8 @@
* limitations under the License.
*/
package im.vector.app.features.debug
package im.vector.app.features.home
import androidx.appcompat.app.AppCompatActivity
// This activity is not accessible
class DebugMenuActivity : AppCompatActivity()
interface NightlyProxy {
fun onHomeResumed()
}

View File

@ -34,6 +34,7 @@ import com.google.android.material.dialog.MaterialAlertDialogBuilder
import im.vector.app.R
import im.vector.app.SpaceStateHandler
import im.vector.app.config.OnboardingVariant
import im.vector.app.core.debug.DebugNavigator
import im.vector.app.core.di.ActiveSessionHolder
import im.vector.app.core.error.fatalError
import im.vector.app.features.VectorFeatures
@ -51,7 +52,6 @@ import im.vector.app.features.crypto.recover.BootstrapBottomSheet
import im.vector.app.features.crypto.recover.SetupMode
import im.vector.app.features.crypto.verification.SupportedVerificationMethodsProvider
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.room.detail.RoomDetailActivity
import im.vector.app.features.home.room.detail.arguments.TimelineArgs
@ -123,7 +123,8 @@ class DefaultNavigator @Inject constructor(
private val spaceStateHandler: SpaceStateHandler,
private val supportedVerificationMethodsProvider: SupportedVerificationMethodsProvider,
private val features: VectorFeatures,
private val analyticsTracker: AnalyticsTracker
private val analyticsTracker: AnalyticsTracker,
private val debugNavigator: DebugNavigator,
) : Navigator {
override fun openLogin(context: Context, loginConfig: LoginConfig?, flags: Int) {
@ -367,7 +368,7 @@ class DefaultNavigator @Inject constructor(
}
override fun openDebug(context: Context) {
context.startActivity(Intent(context, DebugMenuActivity::class.java))
debugNavigator.openDebugMenu(context)
}
override fun openKeysBackupSetup(context: Context, showManualExport: Boolean) {

View File

@ -0,0 +1,24 @@
/*
* 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.features.push
import androidx.fragment.app.Fragment
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
interface NotificationTroubleshootTestManagerFactory {
fun create(fragment: Fragment): NotificationTroubleshootTestManager
}

View File

@ -1,5 +1,5 @@
/*
* Copyright 2020 New Vector Ltd
* 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.
@ -14,10 +14,11 @@
* limitations under the License.
*/
package im.vector.app
package im.vector.app.features.settings.legals
import android.content.Context
import android.content.Intent
import com.google.android.gms.oss.licenses.OssLicensesMenuActivity
fun openOssLicensesMenuActivity(context: Context) = context.startActivity(Intent(context, OssLicensesMenuActivity::class.java))
interface FlavorLegals {
fun hasThirdPartyNotices(): Boolean
fun navigateToThirdPartyNotices(context: Context)
}

View File

@ -38,7 +38,8 @@ class LegalsController @Inject constructor(
private val stringProvider: StringProvider,
private val resources: Resources,
private val elementLegals: ElementLegals,
private val errorFormatter: ErrorFormatter
private val errorFormatter: ErrorFormatter,
private val flavorLegals: FlavorLegals,
) : TypedEpoxyController<LegalsState>() {
var listener: Listener? = null
@ -134,7 +135,7 @@ class LegalsController @Inject constructor(
clickListener { host.listener?.openThirdPartyNotice() }
}
// Only on Gplay
if (resources.getBoolean(R.bool.isGplay)) {
if (flavorLegals.hasThirdPartyNotices()) {
discoveryPolicyItem {
id("eltpn2")
name(host.stringProvider.getString(R.string.settings_other_third_party_notices))

View File

@ -33,11 +33,11 @@ import im.vector.app.databinding.FragmentGenericRecyclerBinding
import im.vector.app.features.analytics.plan.MobileScreen
import im.vector.app.features.discovery.ServerPolicy
import im.vector.app.features.settings.VectorSettingsUrls
import im.vector.app.openOssLicensesMenuActivity
import javax.inject.Inject
class LegalsFragment @Inject constructor(
private val controller: LegalsController
private val controller: LegalsController,
private val flavorLegals: FlavorLegals,
) : VectorBaseFragment<FragmentGenericRecyclerBinding>(),
LegalsController.Listener {
@ -100,8 +100,7 @@ class LegalsFragment @Inject constructor(
override fun openThirdPartyNoticeGplay() {
if (firstThrottler.canHandle() is FirstThrottler.CanHandlerResult.Yes) {
// See https://developers.google.com/android/guides/opensource
openOssLicensesMenuActivity(requireActivity())
flavorLegals.navigateToThirdPartyNotices(requireContext())
}
}
}

View File

@ -35,11 +35,11 @@ import im.vector.app.core.extensions.registerStartForActivityResult
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.databinding.FragmentSettingsNotificationsTroubleshootBinding
import im.vector.app.features.notifications.NotificationActionIds
import im.vector.app.features.push.NotificationTroubleshootTestManagerFactory
import im.vector.app.features.rageshake.BugReporter
import im.vector.app.features.settings.VectorSettingsFragmentInteractionListener
import im.vector.app.features.settings.troubleshoot.NotificationTroubleshootTestManager
import im.vector.app.features.settings.troubleshoot.TroubleshootTest
import im.vector.app.push.fcm.NotificationTroubleshootTestManagerFactory
import org.matrix.android.sdk.api.extensions.orFalse
import org.matrix.android.sdk.api.extensions.tryOrNull
import javax.inject.Inject

View File

@ -19,9 +19,9 @@ package im.vector.app.features.settings.troubleshoot
import android.content.Intent
import androidx.activity.result.ActivityResultLauncher
import im.vector.app.R
import im.vector.app.core.pushers.FcmHelper
import im.vector.app.core.pushers.UnifiedPushHelper
import im.vector.app.core.resources.StringProvider
import im.vector.app.push.fcm.FcmHelper
import javax.inject.Inject
class TestAvailableUnifiedPushDistributors @Inject constructor(

View File

@ -0,0 +1,60 @@
/*
* 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.di
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
object DebugModule {
@Provides
fun providesDebugNavigator() = object : DebugNavigator {
override fun openDebugMenu(context: Context) {
// no op
}
}
@Provides
fun providesDebugReceiver() = object : DebugReceiver {
override fun register(context: Context) {
// no op
}
override fun unregister(context: Context) {
// no op
}
}
@Provides
fun providesFlipperProxy() = object : FlipperProxy {
override fun init(matrix: Matrix) {
// no op
}
override fun networkInterceptor(): Interceptor? = null
}
}