From 012485b8e385a09f67a6500072682efbd258e456 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Thu, 30 Jun 2022 16:18:19 +0100 Subject: [PATCH] lifting the live location sharing build flag to the config along with debug toggle --- vector-config/src/main/java/im/vector/app/config/Config.kt | 2 ++ vector/build.gradle | 1 - .../features/debug/features/DebugFeaturesStateFactory.kt | 5 +++++ .../app/features/debug/features/DebugVectorFeatures.kt | 3 +++ .../src/main/java/im/vector/app/features/VectorFeatures.kt | 2 ++ .../app/features/home/room/detail/TimelineFragment.kt | 7 ++++--- 6 files changed, 16 insertions(+), 4 deletions(-) diff --git a/vector-config/src/main/java/im/vector/app/config/Config.kt b/vector-config/src/main/java/im/vector/app/config/Config.kt index 70ccc5bd5e..384dc2e7f7 100644 --- a/vector-config/src/main/java/im/vector/app/config/Config.kt +++ b/vector-config/src/main/java/im/vector/app/config/Config.kt @@ -37,6 +37,8 @@ object Config { */ const val ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS = true + const val ENABLE_LOCATION_SHARING = true + /** * The maximum length of voice messages in milliseconds. */ diff --git a/vector/build.gradle b/vector/build.gradle index 3d6f50ed93..a3b228b0af 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -160,7 +160,6 @@ android { // This *must* only be set in trusted environments. buildConfigField "Boolean", "handleCallAssertedIdentityEvents", "false" - buildConfigField "Boolean", "enableLocationSharing", "true" buildConfigField "String", "mapTilerKey", "\"fU3vlMsMn4Jb6dnEIFsx\"" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt index 8fe65bd387..d7e402c4dc 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugFeaturesStateFactory.kt @@ -70,6 +70,11 @@ class DebugFeaturesStateFactory @Inject constructor( key = DebugFeatureKeys.allowExternalUnifiedPushDistributors, factory = VectorFeatures::allowExternalUnifiedPushDistributors ), + createBooleanFeature( + label = "Enable Live Location Sharing", + key = DebugFeatureKeys.liveLocationSharing, + factory = VectorFeatures::isLocationSharingEnabled + ), createBooleanFeature( label = "Force usage of OpusEncoder library", key = DebugFeatureKeys.forceUsageOfOpusEncoder, diff --git a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt index c03a0a8663..031ff11d59 100644 --- a/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt +++ b/vector/src/debug/java/im/vector/app/features/debug/features/DebugVectorFeatures.kt @@ -67,6 +67,9 @@ class DebugVectorFeatures( override fun isScreenSharingEnabled(): Boolean = read(DebugFeatureKeys.screenSharing) ?: vectorFeatures.isScreenSharingEnabled() + override fun isLocationSharingEnabled(): Boolean = read(DebugFeatureKeys.liveLocationSharing) + ?: vectorFeatures.isLocationSharingEnabled() + override fun forceUsageOfOpusEncoder(): Boolean = read(DebugFeatureKeys.forceUsageOfOpusEncoder) ?: vectorFeatures.forceUsageOfOpusEncoder() 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 592f568835..290d21879d 100644 --- a/vector/src/main/java/im/vector/app/features/VectorFeatures.kt +++ b/vector/src/main/java/im/vector/app/features/VectorFeatures.kt @@ -30,6 +30,7 @@ interface VectorFeatures { fun isOnboardingCombinedLoginEnabled(): Boolean fun allowExternalUnifiedPushDistributors(): Boolean fun isScreenSharingEnabled(): Boolean + fun isLocationSharingEnabled(): Boolean fun forceUsageOfOpusEncoder(): Boolean fun shouldStartDmOnFirstMessage(): Boolean fun isNewAppLayoutEnabled(): Boolean @@ -45,6 +46,7 @@ class DefaultVectorFeatures : VectorFeatures { override fun isOnboardingCombinedLoginEnabled() = true override fun allowExternalUnifiedPushDistributors(): Boolean = Config.ALLOW_EXTERNAL_UNIFIED_PUSH_DISTRIBUTORS override fun isScreenSharingEnabled(): Boolean = true + override fun isLocationSharingEnabled() = Config.ENABLE_LOCATION_SHARING override fun forceUsageOfOpusEncoder(): Boolean = false override fun shouldStartDmOnFirstMessage(): Boolean = false override fun isNewAppLayoutEnabled(): Boolean = false diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt index 7acc77a686..727791c540 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/TimelineFragment.kt @@ -67,7 +67,6 @@ import com.airbnb.mvrx.fragmentViewModel import com.airbnb.mvrx.withState import com.google.android.material.dialog.MaterialAlertDialogBuilder import com.vanniktech.emoji.EmojiPopup -import im.vector.app.BuildConfig import im.vector.app.R import im.vector.app.core.animations.play import im.vector.app.core.dialogs.ConfirmationDialogBuilder @@ -125,6 +124,7 @@ import im.vector.app.core.utils.startInstallFromSourceIntent import im.vector.app.core.utils.toast import im.vector.app.databinding.DialogReportContentBinding import im.vector.app.databinding.FragmentTimelineBinding +import im.vector.app.features.VectorFeatures import im.vector.app.features.analytics.extensions.toAnalyticsInteraction import im.vector.app.features.analytics.plan.Interaction import im.vector.app.features.analytics.plan.MobileScreen @@ -275,7 +275,8 @@ class TimelineFragment @Inject constructor( private val callManager: WebRtcCallManager, private val audioMessagePlaybackTracker: AudioMessagePlaybackTracker, private val shareIntentHandler: ShareIntentHandler, - private val clock: Clock + private val clock: Clock, + private val vectorFeatures: VectorFeatures, ) : VectorBaseFragment(), TimelineEventController.Callback, @@ -1559,7 +1560,7 @@ class TimelineFragment @Inject constructor( attachmentTypeSelector = AttachmentTypeSelectorView(vectorBaseActivity, vectorBaseActivity.layoutInflater, this@TimelineFragment) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.LOCATION, - BuildConfig.enableLocationSharing + vectorFeatures.isLocationSharingEnabled(), ) attachmentTypeSelector.setAttachmentVisibility( AttachmentTypeSelectorView.Type.POLL, !isThreadTimeLine()