mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2024-11-22 17:35:54 +03:00
Using the override setting in the LocationSharing screen
This commit is contained in:
parent
424f70bc58
commit
cfce144b61
3 changed files with 16 additions and 4 deletions
|
@ -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
|
||||
|
@ -243,7 +242,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 (state.isLiveLocationSharingEnabled) {
|
||||
setOf(LocationSharingOption.USER_CURRENT, LocationSharingOption.USER_LIVE)
|
||||
} else {
|
||||
setOf(LocationSharingOption.USER_CURRENT)
|
||||
|
|
|
@ -21,9 +21,11 @@ import com.airbnb.mvrx.MavericksViewModelFactory
|
|||
import dagger.assisted.Assisted
|
||||
import dagger.assisted.AssistedFactory
|
||||
import dagger.assisted.AssistedInject
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.core.di.MavericksAssistedViewModelFactory
|
||||
import im.vector.app.core.di.hiltMavericksViewModelFactory
|
||||
import im.vector.app.core.platform.VectorViewModel
|
||||
import im.vector.app.features.VectorOverrides
|
||||
import im.vector.app.features.home.room.detail.timeline.helper.LocationPinProvider
|
||||
import im.vector.app.features.location.domain.usecase.CompareLocationsUseCase
|
||||
import kotlinx.coroutines.flow.MutableSharedFlow
|
||||
|
@ -48,7 +50,8 @@ class LocationSharingViewModel @AssistedInject constructor(
|
|||
private val locationTracker: LocationTracker,
|
||||
private val locationPinProvider: LocationPinProvider,
|
||||
private val session: Session,
|
||||
private val compareLocationsUseCase: CompareLocationsUseCase
|
||||
private val compareLocationsUseCase: CompareLocationsUseCase,
|
||||
private val vectorOverrides: VectorOverrides
|
||||
) : VectorViewModel<LocationSharingViewState, LocationSharingAction, LocationSharingViewEvents>(initialState), LocationTracker.Callback {
|
||||
|
||||
private val room = session.getRoom(initialState.roomId)!!
|
||||
|
@ -68,6 +71,7 @@ class LocationSharingViewModel @AssistedInject constructor(
|
|||
setUserItem()
|
||||
updatePin()
|
||||
compareTargetAndUserLocation()
|
||||
observeVectorOverrides()
|
||||
}
|
||||
|
||||
private fun setUserItem() {
|
||||
|
@ -109,6 +113,12 @@ class LocationSharingViewModel @AssistedInject constructor(
|
|||
?.let { userLocation -> compareLocationsUseCase.execute(userLocation, targetLocation) }
|
||||
}
|
||||
|
||||
private fun observeVectorOverrides() {
|
||||
vectorOverrides.forceEnableLiveLocationSharing.setOnEach { forceLiveLocation ->
|
||||
copy(isLiveLocationSharingEnabled = forceLiveLocation || BuildConfig.ENABLE_LIVE_LOCATION_SHARING)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCleared() {
|
||||
super.onCleared()
|
||||
locationTracker.removeCallback(this)
|
||||
|
|
|
@ -19,6 +19,7 @@ package im.vector.app.features.location
|
|||
import android.graphics.drawable.Drawable
|
||||
import androidx.annotation.StringRes
|
||||
import com.airbnb.mvrx.MavericksState
|
||||
import im.vector.app.BuildConfig
|
||||
import im.vector.app.R
|
||||
import org.matrix.android.sdk.api.extensions.orTrue
|
||||
import org.matrix.android.sdk.api.util.MatrixItem
|
||||
|
@ -31,6 +32,7 @@ enum class LocationSharingMode(@StringRes val titleRes: Int) {
|
|||
data class LocationSharingViewState(
|
||||
val roomId: String,
|
||||
val mode: LocationSharingMode,
|
||||
val isLiveLocationSharingEnabled: Boolean,
|
||||
val userItem: MatrixItem.UserItem? = null,
|
||||
val areTargetAndUserLocationEqual: Boolean? = null,
|
||||
val lastKnownUserLocation: LocationData? = null,
|
||||
|
@ -39,7 +41,8 @@ data class LocationSharingViewState(
|
|||
|
||||
constructor(locationSharingArgs: LocationSharingArgs) : this(
|
||||
roomId = locationSharingArgs.roomId,
|
||||
mode = locationSharingArgs.mode
|
||||
mode = locationSharingArgs.mode,
|
||||
isLiveLocationSharingEnabled = BuildConfig.ENABLE_LIVE_LOCATION_SHARING
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue