Labs flag added for enabling live location sharing.

This commit is contained in:
Onuray Sahin 2022-05-19 12:01:42 +03:00
parent 5260e729ac
commit 51ac6f22d7
7 changed files with 16 additions and 13 deletions

View File

@ -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
),
)
)
}

View File

@ -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()

View File

@ -26,7 +26,6 @@ interface VectorFeatures {
fun isOnboardingUseCaseEnabled(): Boolean
fun isOnboardingPersonalizeEnabled(): Boolean
fun isOnboardingCombinedRegisterEnabled(): Boolean
fun isLiveLocationEnabled(): Boolean
fun isScreenSharingEnabled(): Boolean
enum class OnboardingVariant {
@ -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
}

View File

@ -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
@ -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 {
@ -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)

View File

@ -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"
@ -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.
*/

View File

@ -3022,6 +3022,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>

View File

@ -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>