diff --git a/vector/build.gradle b/vector/build.gradle index 2d9c097da8..8eda029472 100644 --- a/vector/build.gradle +++ b/vector/build.gradle @@ -229,6 +229,7 @@ android { buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false" // Set to true if you want to enable strict mode in debug buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" + buildConfigField "Boolean", "ENABLE_LIVE_LOCATION_SHARING", "true" signingConfig signingConfigs.debug } @@ -238,6 +239,7 @@ android { buildConfigField "boolean", "LOW_PRIVACY_LOG_ENABLE", "false" buildConfigField "boolean", "ENABLE_STRICT_MODE_LOGS", "false" + buildConfigField "Boolean", "ENABLE_LIVE_LOCATION_SHARING", "false" postprocessing { removeUnusedCode true diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index e9e96e676c..399f8e4419 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -27,6 +27,7 @@ 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.extensions.exhaustive import im.vector.app.core.platform.VectorBaseFragment @@ -170,16 +171,19 @@ class LocationSharingFragment @Inject constructor( private fun updateMap(state: LocationSharingViewState) { // first, update the options view - when (state.areTargetAndUserLocationEqual) { - // TODO activate USER_LIVE option when implemented - true -> views.shareLocationOptionsPicker.render( - LocationSharingOption.USER_CURRENT - ) - false -> views.shareLocationOptionsPicker.render( - LocationSharingOption.PINNED - ) - else -> views.shareLocationOptionsPicker.render() + val options: Set = when (state.areTargetAndUserLocationEqual) { + true -> { + if (BuildConfig.ENABLE_LIVE_LOCATION_SHARING) { + setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE) + } else { + setOf(LocationSharingOption.USER_CURRENT) + } + } + false -> setOf(LocationSharingOption.PINNED) + else -> emptySet() } + views.shareLocationOptionsPicker.render(options) + // then, update the map using the height of the options view after it has been rendered views.shareLocationOptionsPicker.post { val mapState = state diff --git a/vector/src/main/java/im/vector/app/features/location/option/LocationSharingOptionPickerView.kt b/vector/src/main/java/im/vector/app/features/location/option/LocationSharingOptionPickerView.kt index 1aea1ff613..8a603a1a56 100644 --- a/vector/src/main/java/im/vector/app/features/location/option/LocationSharingOptionPickerView.kt +++ b/vector/src/main/java/im/vector/app/features/location/option/LocationSharingOptionPickerView.kt @@ -58,7 +58,7 @@ class LocationSharingOptionPickerView @JvmOverloads constructor( applyBackground() } - fun render(vararg options: LocationSharingOption) { + fun render(options: Set = emptySet()) { val optionsNumber = options.toSet().size val isPinnedVisible = options.contains(LocationSharingOption.PINNED) val isUserCurrentVisible = options.contains(LocationSharingOption.USER_CURRENT)