diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt b/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt index 6948adc8b4..0a18214038 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/di/FeaturesModule.kt @@ -23,6 +23,7 @@ import dagger.Provides import dagger.hilt.InstallIn import dagger.hilt.components.SingletonComponent import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.DefaultVectorFeatures import im.vector.app.features.DefaultVectorOverrides import im.vector.app.features.VectorFeatures @@ -43,8 +44,8 @@ interface FeaturesModule { companion object { @Provides - fun providesDefaultVectorFeatures(booleanProvider: BooleanProvider): DefaultVectorFeatures { - return DefaultVectorFeatures(booleanProvider) + fun providesDefaultVectorFeatures(stringArrayProvider: StringArrayProvider, booleanProvider: BooleanProvider): DefaultVectorFeatures { + return DefaultVectorFeatures(stringArrayProvider, booleanProvider) } @Provides diff --git a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index f4be52ce1c..684a284418 100644 --- a/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector-app/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -40,7 +40,7 @@ class DebugVectorFeatures( private val dataStore = context.dataStore - override fun tchapIsVoipSupported() = vectorFeatures.tchapIsVoipSupported() + override fun tchapIsVoipSupported(homeServerUrl: String) = vectorFeatures.tchapIsVoipSupported(homeServerUrl) override fun tchapIsCrossSigningEnabled() = vectorFeatures.tchapIsCrossSigningEnabled() diff --git a/vector-config/src/btchap/res/values/config-features.xml b/vector-config/src/btchap/res/values/config-features.xml index f6fda74684..e30415e59d 100755 --- a/vector-config/src/btchap/res/values/config-features.xml +++ b/vector-config/src/btchap/res/values/config-features.xml @@ -3,4 +3,6 @@ true true false + + diff --git a/vector-config/src/devTchap/res/values/config-features.xml b/vector-config/src/devTchap/res/values/config-features.xml index f6fda74684..e30415e59d 100755 --- a/vector-config/src/devTchap/res/values/config-features.xml +++ b/vector-config/src/devTchap/res/values/config-features.xml @@ -3,4 +3,6 @@ true true false + + diff --git a/vector-config/src/tchap/res/values/config-features.xml b/vector-config/src/tchap/res/values/config-features.xml index f6fda74684..f9439b9f00 100755 --- a/vector-config/src/tchap/res/values/config-features.xml +++ b/vector-config/src/tchap/res/values/config-features.xml @@ -3,4 +3,8 @@ true true false + + + agent.dinum.tchap.gouv.fr + diff --git a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt index a364398449..209c0fba3c 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -20,12 +20,13 @@ import im.vector.app.R import im.vector.app.config.Config import im.vector.app.config.OnboardingVariant import im.vector.app.core.resources.BooleanProvider +import im.vector.app.core.resources.StringArrayProvider import im.vector.app.features.settings.VectorPreferences import javax.inject.Inject interface VectorFeatures { - fun tchapIsVoipSupported(): Boolean + fun tchapIsVoipSupported(homeServerUrl: String): Boolean fun tchapIsCrossSigningEnabled(): Boolean fun tchapIsKeyBackupEnabled(): Boolean fun tchapIsThreadEnabled(): Boolean @@ -55,9 +56,13 @@ interface VectorFeatures { } class DefaultVectorFeatures @Inject constructor( + private val stringArrayProvider: StringArrayProvider, private val booleanProvider: BooleanProvider ) : VectorFeatures { - override fun tchapIsVoipSupported() = booleanProvider.getBoolean(R.bool.tchap_is_voip_supported) + override fun tchapIsVoipSupported(homeServerUrl: String) = booleanProvider.getBoolean(R.bool.tchap_is_voip_supported) && + stringArrayProvider.getStringArray(R.array.tchap_is_voip_supported_homeservers).let { homeServerUrls -> + homeServerUrls.isEmpty() || homeServerUrls.any { homeServerUrl.contains(it) } + } override fun tchapIsCrossSigningEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_cross_signing_enabled) override fun tchapIsKeyBackupEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_key_backup_enabled) override fun tchapIsThreadEnabled() = booleanProvider.getBoolean(R.bool.tchap_is_thread_enabled) diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt index a6983a3948..413c1ca502 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineViewModel.kt @@ -855,11 +855,11 @@ class TimelineViewModel @AssistedInject constructor( R.id.invite -> state.canInvite R.id.open_matrix_apps -> false // Tchap: there are no matrix apps // Tchap: check if voip is enabled - R.id.video_call -> vectorPreferences.developerMode() && vectorFeatures.tchapIsVoipSupported() - R.id.voice_call -> (session.sessionParams.homeServerUrl.contains("agent.dinum.tchap.gouv.fr") || vectorPreferences.developerMode()) && - vectorFeatures.tchapIsVoipSupported() && (state.isCallOptionAvailable() || state.hasActiveElementCallWidget()) + R.id.video_call -> vectorPreferences.developerMode() && vectorFeatures.tchapIsVoipSupported(session.sessionParams.homeServerUrl) + R.id.voice_call -> vectorFeatures.tchapIsVoipSupported(session.sessionParams.homeServerUrl) && + (state.isCallOptionAvailable() || state.hasActiveElementCallWidget()) // Show Join conference button only if there is an active conf id not joined. Otherwise fallback to default video disabled. ^ - R.id.join_conference -> vectorFeatures.tchapIsVoipSupported() && !state.isCallOptionAvailable() && + R.id.join_conference -> vectorFeatures.tchapIsVoipSupported(session.sessionParams.homeServerUrl) && !state.isCallOptionAvailable() && state.jitsiState.confId != null && !state.jitsiState.hasJoined R.id.search -> state.isSearchAvailable() R.id.menu_timeline_thread_list -> vectorPreferences.areThreadMessagesEnabled() diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt index 35f5af2e44..5ea450ba32 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/CallItemFactory.kt @@ -147,7 +147,7 @@ class CallItemFactory @Inject constructor( val userOfInterest = roomSummary.toMatrixItem() val attributes = messageItemAttributesFactory.create(null, informationData, callback, reactionsSummaryEvents).let { CallTileTimelineItem.Attributes( - isVoipSupported = vectorFeatures.tchapIsVoipSupported(), + isVoipSupported = vectorFeatures.tchapIsVoipSupported(session.sessionParams.homeServerUrl), callId = callId, callKind = callKind, callStatus = callStatus, diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt index 8477c16d8f..b8dc6be9fc 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/factory/WidgetItemFactory.kt @@ -26,6 +26,7 @@ import im.vector.app.features.home.room.detail.timeline.helper.JitsiWidgetEvents import im.vector.app.features.home.room.detail.timeline.helper.MessageInformationDataFactory import im.vector.app.features.home.room.detail.timeline.item.CallTileTimelineItem import im.vector.app.features.home.room.detail.timeline.item.CallTileTimelineItem_ +import org.matrix.android.sdk.api.session.Session import org.matrix.android.sdk.api.session.events.model.toModel import org.matrix.android.sdk.api.session.widgets.model.WidgetContent import org.matrix.android.sdk.api.session.widgets.model.WidgetType @@ -34,6 +35,7 @@ import javax.inject.Inject class WidgetItemFactory @Inject constructor( private val vectorFeatures: VectorFeatures, + private val session: Session, private val informationDataFactory: MessageInformationDataFactory, private val noticeItemFactory: NoticeItemFactory, private val avatarSizeProvider: AvatarSizeProvider, @@ -78,7 +80,7 @@ class WidgetItemFactory @Inject constructor( CallTileTimelineItem.CallStatus.ENDED } val attributes = CallTileTimelineItem.Attributes( - isVoipSupported = vectorFeatures.tchapIsVoipSupported(), + isVoipSupported = vectorFeatures.tchapIsVoipSupported(session.sessionParams.homeServerUrl), callId = jitsiWidgetEventsGroup.callId, callKind = CallTileTimelineItem.CallKind.CONFERENCE, callStatus = callStatus,