Skip to content

Commit

Permalink
Merge pull request #6098 from vector-im/live_location_labs_flag
Browse files Browse the repository at this point in the history
Labs flag for enabling live location sharing (PSF-799)
  • Loading branch information
onurays authored May 19, 2022
2 parents a30912f + 2e2dffd commit c518f59
Show file tree
Hide file tree
Showing 8 changed files with 17 additions and 13 deletions.
1 change: 1 addition & 0 deletions changelog.d/6098.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Labs flag for enabling live location sharing
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,6 @@ class DebugFeaturesStateFactory @Inject constructor(
key = DebugFeatureKeys.onboardingCombinedRegister,
factory = VectorFeatures::isOnboardingCombinedRegisterEnabled
),
createBooleanFeature(
label = "Live location sharing",
key = DebugFeatureKeys.liveLocationSharing,
factory = VectorFeatures::isLiveLocationEnabled
),
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,6 @@ class DebugVectorFeatures(
override fun isOnboardingCombinedRegisterEnabled(): Boolean = read(DebugFeatureKeys.onboardingCombinedRegister)
?: vectorFeatures.isOnboardingCombinedRegisterEnabled()

override fun isLiveLocationEnabled(): Boolean = read(DebugFeatureKeys.liveLocationSharing)
?: vectorFeatures.isLiveLocationEnabled()

override fun isScreenSharingEnabled(): Boolean = read(DebugFeatureKeys.screenSharing)
?: vectorFeatures.isScreenSharingEnabled()

Expand Down
2 changes: 0 additions & 2 deletions vector/src/main/java/im/vector/app/features/VectorFeatures.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ interface VectorFeatures {
fun isOnboardingUseCaseEnabled(): Boolean
fun isOnboardingPersonalizeEnabled(): Boolean
fun isOnboardingCombinedRegisterEnabled(): Boolean
fun isLiveLocationEnabled(): Boolean
fun isScreenSharingEnabled(): Boolean

enum class OnboardingVariant {
Expand All @@ -43,6 +42,5 @@ class DefaultVectorFeatures : VectorFeatures {
override fun isOnboardingUseCaseEnabled() = true
override fun isOnboardingPersonalizeEnabled() = false
override fun isOnboardingCombinedRegisterEnabled() = false
override fun isLiveLocationEnabled(): Boolean = false
override fun isScreenSharingEnabled(): Boolean = true
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@ 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.live.duration.ChooseLiveDurationBottomSheet
import im.vector.app.features.location.option.LocationSharingOption
import im.vector.app.features.settings.VectorPreferences
import org.matrix.android.sdk.api.util.MatrixItem
import java.lang.ref.WeakReference
import javax.inject.Inject
Expand All @@ -53,7 +53,7 @@ class LocationSharingFragment @Inject constructor(
private val urlMapProvider: UrlMapProvider,
private val avatarRenderer: AvatarRenderer,
private val matrixItemColorProvider: MatrixItemColorProvider,
private val vectorFeatures: VectorFeatures,
private val vectorPreferences: VectorPreferences,
) : VectorBaseFragment<FragmentLocationSharingBinding>(),
LocationTargetChangeListener,
VectorBaseBottomSheetDialogFragment.ResultListener {
Expand Down Expand Up @@ -255,7 +255,7 @@ class LocationSharingFragment @Inject constructor(
// first, update the options view
val options: Set<LocationSharingOption> = when (state.areTargetAndUserLocationEqual) {
true -> {
if (vectorFeatures.isLiveLocationEnabled()) {
if (vectorPreferences.labsEnableLiveLocation()) {
setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE)
} else {
setOf(LocationSharingOption.USER_CURRENT)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ class VectorPreferences @Inject constructor(
private const val TAKE_PHOTO_VIDEO_MODE = "TAKE_PHOTO_VIDEO_MODE"

private const val SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE = "SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE"
private const val SETTINGS_LABS_ENABLE_LIVE_LOCATION = "SETTINGS_LABS_ENABLE_LIVE_LOCATION"

// This key will be used to identify clients with the old thread support enabled io.element.thread
const val SETTINGS_LABS_ENABLE_THREAD_MESSAGES_OLD_CLIENTS = "SETTINGS_LABS_ENABLE_THREAD_MESSAGES"
Expand Down Expand Up @@ -1041,6 +1042,10 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE, true)
}

fun labsEnableLiveLocation(): Boolean {
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, false)
}

/**
* Indicates whether or not thread messages are enabled.
*/
Expand Down
2 changes: 2 additions & 0 deletions vector/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3035,6 +3035,8 @@
<string name="location_share_live_remaining_time">%1$s left</string>
<string name="live_location_sharing_notification_title">${app_name} Live Location</string>
<string name="live_location_sharing_notification_description">Location sharing is in progress</string>
<string name="labs_enable_live_location">Enable Live Location Sharing</string>
<string name="labs_enable_live_location_summary">Temporary implementation: locations persist in room history</string>

<string name="message_bubbles">Show Message bubbles</string>

Expand Down
6 changes: 6 additions & 0 deletions vector/src/main/res/xml/vector_settings_labs.xml
Original file line number Diff line number Diff line change
Expand Up @@ -69,4 +69,10 @@
android:key="SETTINGS_LABS_RENDER_LOCATIONS_IN_TIMELINE"
android:title="@string/labs_render_locations_in_timeline" />

<im.vector.app.core.preference.VectorSwitchPreference
android:defaultValue="false"
android:key="SETTINGS_LABS_ENABLE_LIVE_LOCATION"
android:summary="@string/labs_enable_live_location_summary"
android:title="@string/labs_enable_live_location" />

</androidx.preference.PreferenceScreen>

0 comments on commit c518f59

Please sign in to comment.