Distinguish user location and pinned location sharing
This commit is contained in:
parent
8d1822da96
commit
04405c7970
@ -21,6 +21,15 @@ import com.squareup.moshi.JsonClass
|
||||
|
||||
@JsonClass(generateAdapter = false)
|
||||
enum class LocationAssetType {
|
||||
/**
|
||||
*
|
||||
**/
|
||||
@Json(name = "m.self")
|
||||
SELF
|
||||
SELF,
|
||||
|
||||
/**
|
||||
*
|
||||
**/
|
||||
@Json(name = "m.pin")
|
||||
PIN
|
||||
}
|
||||
|
@ -142,8 +142,9 @@ interface SendService {
|
||||
* @param latitude required latitude of the location
|
||||
* @param longitude required longitude of the location
|
||||
* @param uncertainty Accuracy of the location in meters
|
||||
* @param isUserLocation indicates whether the location data corresponds to the user location or not
|
||||
*/
|
||||
fun sendLocation(latitude: Double, longitude: Double, uncertainty: Double?): Cancelable
|
||||
fun sendLocation(latitude: Double, longitude: Double, uncertainty: Double?, isUserLocation: Boolean): Cancelable
|
||||
|
||||
/**
|
||||
* Remove this failed message from the timeline
|
||||
|
@ -128,8 +128,8 @@ internal class DefaultSendService @AssistedInject constructor(
|
||||
.let { sendEvent(it) }
|
||||
}
|
||||
|
||||
override fun sendLocation(latitude: Double, longitude: Double, uncertainty: Double?): Cancelable {
|
||||
return localEchoEventFactory.createLocationEvent(roomId, latitude, longitude, uncertainty)
|
||||
override fun sendLocation(latitude: Double, longitude: Double, uncertainty: Double?, isUserLocation: Boolean): Cancelable {
|
||||
return localEchoEventFactory.createLocationEvent(roomId, latitude, longitude, uncertainty, isUserLocation)
|
||||
.also { createLocalEcho(it) }
|
||||
.let { sendEvent(it) }
|
||||
}
|
||||
|
@ -227,13 +227,15 @@ internal class LocalEchoEventFactory @Inject constructor(
|
||||
fun createLocationEvent(roomId: String,
|
||||
latitude: Double,
|
||||
longitude: Double,
|
||||
uncertainty: Double?): Event {
|
||||
uncertainty: Double?,
|
||||
isUserLocation: Boolean): Event {
|
||||
val geoUri = buildGeoUri(latitude, longitude, uncertainty)
|
||||
val assetType = if (isUserLocation) LocationAssetType.SELF else LocationAssetType.PIN
|
||||
val content = MessageLocationContent(
|
||||
geoUri = geoUri,
|
||||
body = geoUri,
|
||||
unstableLocationInfo = LocationInfo(geoUri = geoUri, description = geoUri),
|
||||
unstableLocationAsset = LocationAsset(type = LocationAssetType.SELF),
|
||||
unstableLocationAsset = LocationAsset(type = assetType),
|
||||
unstableTs = TimeUnit.MILLISECONDS.toSeconds(System.currentTimeMillis()),
|
||||
unstableText = geoUri
|
||||
)
|
||||
|
@ -155,8 +155,6 @@ class LocationSharingFragment @Inject constructor(
|
||||
|
||||
private fun initOptionsPicker() {
|
||||
// TODO
|
||||
// changes in the event sent when this is a pinned location
|
||||
// changes in the parsing of events when receiving pinned location: since we may present a different UI
|
||||
// unit tests
|
||||
// set no option at start
|
||||
views.shareLocationOptionsPicker.render()
|
||||
|
@ -123,20 +123,20 @@ class LocationSharingViewModel @AssistedInject constructor(
|
||||
}
|
||||
|
||||
private fun handleCurrentUserLocationSharingAction() = withState { state ->
|
||||
shareLocation(state.lastKnownUserLocation)
|
||||
shareLocation(state.lastKnownUserLocation, isUserLocation = true)
|
||||
}
|
||||
|
||||
private fun handlePinnedLocationSharingAction(action: LocationSharingAction.PinnedLocationSharingAction) {
|
||||
// TODO confirm how to differentiate the user location and pinned location events?
|
||||
shareLocation(action.locationData)
|
||||
shareLocation(action.locationData, isUserLocation = false)
|
||||
}
|
||||
|
||||
private fun shareLocation(locationData: LocationData?) {
|
||||
private fun shareLocation(locationData: LocationData?, isUserLocation: Boolean) {
|
||||
locationData?.let { location ->
|
||||
room.sendLocation(
|
||||
latitude = location.latitude,
|
||||
longitude = location.longitude,
|
||||
uncertainty = location.uncertainty
|
||||
uncertainty = location.uncertainty,
|
||||
isUserLocation = isUserLocation
|
||||
)
|
||||
_viewEvents.post(LocationSharingViewEvents.Close)
|
||||
} ?: run {
|
||||
|
Loading…
x
Reference in New Issue
Block a user