Merge pull request #5661 from vector-im/feature/mna/5581-live-location-feature-flag

#5581: live location sharing feature flag
This commit is contained in:
Maxime NATUREL 2022-03-31 14:11:07 +02:00 committed by GitHub
commit d05d697831
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 22 additions and 9 deletions

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

@ -0,0 +1 @@
Live location sharing: adding way to override feature activation in debug

View File

@ -54,6 +54,11 @@ class DebugFeaturesStateFactory @Inject constructor(
key = DebugFeatureKeys.onboardingPersonalize,
factory = VectorFeatures::isOnboardingPersonalizeEnabled
),
createBooleanFeature(
label = "Live location sharing",
key = DebugFeatureKeys.liveLocationSharing,
factory = VectorFeatures::isLiveLocationEnabled
),
))
}

View File

@ -54,6 +54,9 @@ class DebugVectorFeatures(
override fun isOnboardingPersonalizeEnabled(): Boolean = read(DebugFeatureKeys.onboardingPersonalize)
?: vectorFeatures.isOnboardingPersonalizeEnabled()
override fun isLiveLocationEnabled(): Boolean = read(DebugFeatureKeys.liveLocationSharing)
?: vectorFeatures.isLiveLocationEnabled()
fun <T> override(value: T?, key: Preferences.Key<T>) = updatePreferences {
if (value == null) {
it.remove(key)
@ -106,4 +109,5 @@ object DebugFeatureKeys {
val onboardingSplashCarousel = booleanPreferencesKey("onboarding-splash-carousel")
val onboardingUseCase = booleanPreferencesKey("onbboarding-splash-carousel")
val onboardingPersonalize = booleanPreferencesKey("onbboarding-personalize")
val liveLocationSharing = booleanPreferencesKey("live-location-sharing")
}

View File

@ -68,8 +68,8 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
when (action) {
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
is SetDisplayNameCapabilityOverride -> handSetDisplayNameCapabilityOverride(action)
is SetAvatarCapabilityOverride -> handSetAvatarCapabilityOverride(action)
is SetDisplayNameCapabilityOverride -> handleSetDisplayNameCapabilityOverride(action)
is SetAvatarCapabilityOverride -> handleSetAvatarCapabilityOverride(action)
}
}
@ -85,14 +85,14 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
}
}
private fun handSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
private fun handleSetDisplayNameCapabilityOverride(action: SetDisplayNameCapabilityOverride) {
viewModelScope.launch {
val forceDisplayName = action.option.toBoolean()
debugVectorOverrides.setHomeserverCapabilities { copy(canChangeDisplayName = forceDisplayName) }
}
}
private fun handSetAvatarCapabilityOverride(action: SetAvatarCapabilityOverride) {
private fun handleSetAvatarCapabilityOverride(action: SetAvatarCapabilityOverride) {
viewModelScope.launch {
val forceAvatar = action.option.toBoolean()
debugVectorOverrides.setHomeserverCapabilities { copy(canChangeAvatar = forceAvatar) }

View File

@ -25,6 +25,7 @@ interface VectorFeatures {
fun isOnboardingSplashCarouselEnabled(): Boolean
fun isOnboardingUseCaseEnabled(): Boolean
fun isOnboardingPersonalizeEnabled(): Boolean
fun isLiveLocationEnabled(): Boolean
enum class OnboardingVariant {
LEGACY,
@ -39,4 +40,5 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isOnboardingSplashCarouselEnabled() = true
override fun isOnboardingUseCaseEnabled() = true
override fun isOnboardingPersonalizeEnabled() = false
override fun isLiveLocationEnabled(): Boolean = BuildConfig.ENABLE_LIVE_LOCATION_SHARING
}

View File

@ -29,7 +29,6 @@ import com.airbnb.mvrx.fragmentViewModel
import com.airbnb.mvrx.withState
import com.google.android.material.dialog.MaterialAlertDialogBuilder
import com.mapbox.mapboxsdk.maps.MapView
import im.vector.app.BuildConfig
import im.vector.app.R
import im.vector.app.core.platform.VectorBaseFragment
import im.vector.app.core.utils.PERMISSIONS_FOR_BACKGROUND_LOCATION_SHARING
@ -37,6 +36,7 @@ import im.vector.app.core.utils.PERMISSIONS_FOR_FOREGROUND_LOCATION_SHARING
import im.vector.app.core.utils.checkPermissions
import im.vector.app.core.utils.registerForPermissionsResult
import im.vector.app.databinding.FragmentLocationSharingBinding
import im.vector.app.features.VectorFeatures
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.home.room.detail.timeline.helper.MatrixItemColorProvider
import im.vector.app.features.location.option.LocationSharingOption
@ -50,7 +50,8 @@ import javax.inject.Inject
class LocationSharingFragment @Inject constructor(
private val urlMapProvider: UrlMapProvider,
private val avatarRenderer: AvatarRenderer,
private val matrixItemColorProvider: MatrixItemColorProvider
private val matrixItemColorProvider: MatrixItemColorProvider,
private val vectorFeatures: VectorFeatures,
) : VectorBaseFragment<FragmentLocationSharingBinding>(), LocationTargetChangeListener {
private val viewModel: LocationSharingViewModel by fragmentViewModel()
@ -243,7 +244,7 @@ class LocationSharingFragment @Inject constructor(
// first, update the options view
val options: Set<LocationSharingOption> = when (state.areTargetAndUserLocationEqual) {
true -> {
if (BuildConfig.ENABLE_LIVE_LOCATION_SHARING) {
if (vectorFeatures.isLiveLocationEnabled()) {
setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE)
} else {
setOf(LocationSharingOption.USER_CURRENT)

View File

@ -48,7 +48,7 @@ class LocationSharingViewModel @AssistedInject constructor(
private val locationTracker: LocationTracker,
private val locationPinProvider: LocationPinProvider,
private val session: Session,
private val compareLocationsUseCase: CompareLocationsUseCase
private val compareLocationsUseCase: CompareLocationsUseCase,
) : VectorViewModel<LocationSharingViewState, LocationSharingAction, LocationSharingViewEvents>(initialState), LocationTracker.Callback {
private val room = session.getRoom(initialState.roomId)!!

View File

@ -39,7 +39,7 @@ data class LocationSharingViewState(
constructor(locationSharingArgs: LocationSharingArgs) : this(
roomId = locationSharingArgs.roomId,
mode = locationSharingArgs.mode
mode = locationSharingArgs.mode,
)
}