mirror of
https://github.com/element-hq/element-android
synced 2024-11-24 02:15:35 +03:00
Stop live location sharing.
This commit is contained in:
parent
4ee7332973
commit
33e735cbdd
5 changed files with 35 additions and 1 deletions
|
@ -111,4 +111,7 @@ sealed class RoomDetailAction : VectorViewModelAction {
|
|||
|
||||
// Poll
|
||||
data class EndPoll(val eventId: String) : RoomDetailAction()
|
||||
|
||||
// Live Location
|
||||
object StopLiveLocationSharing : RoomDetailAction()
|
||||
}
|
||||
|
|
|
@ -385,6 +385,7 @@ class TimelineFragment @Inject constructor(
|
|||
setupEmojiButton()
|
||||
setupRemoveJitsiWidgetView()
|
||||
setupVoiceMessageView()
|
||||
setupLiveLocationIndicator()
|
||||
|
||||
views.includeRoomToolbar.roomToolbarContentView.debouncedClicks {
|
||||
navigator.openRoomProfile(requireActivity(), timelineArgs.roomId)
|
||||
|
@ -810,6 +811,12 @@ class TimelineFragment @Inject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun setupLiveLocationIndicator() {
|
||||
views.locationLiveStatusIndicator.stopButton.debouncedClicks {
|
||||
timelineViewModel.handle(RoomDetailAction.StopLiveLocationSharing)
|
||||
}
|
||||
}
|
||||
|
||||
private fun joinJitsiRoom(jitsiWidget: Widget, enableVideo: Boolean) {
|
||||
navigator.openRoomWidget(requireContext(), timelineArgs.roomId, jitsiWidget, mapOf(JitsiCallViewModel.ENABLE_VIDEO_OPTION to enableVideo))
|
||||
}
|
||||
|
|
|
@ -444,6 +444,7 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
_viewEvents.post(RoomDetailViewEvents.OpenRoom(action.replacementRoomId, closeCurrentRoom = true))
|
||||
}
|
||||
is RoomDetailAction.EndPoll -> handleEndPoll(action.eventId)
|
||||
RoomDetailAction.StopLiveLocationSharing -> handleStopLiveLocationSharing()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1093,6 +1094,23 @@ class TimelineViewModel @AssistedInject constructor(
|
|||
}
|
||||
}
|
||||
|
||||
private fun handleStopLiveLocationSharing() {
|
||||
viewModelScope.launch {
|
||||
EventType
|
||||
.STATE_ROOM_BEACON_INFO
|
||||
.mapNotNull {
|
||||
room.getStateEvent(it, QueryStringValue.Equals(session.myUserId))
|
||||
}
|
||||
.firstOrNull()
|
||||
?.let { beaconInfoEvent ->
|
||||
room.stopLiveLocation(beaconInfoEvent)
|
||||
}
|
||||
?.also {
|
||||
locationSharingServiceConnection.stopLiveLocationSharing(room.roomId)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun observeRoomSummary() {
|
||||
room.flow().liveRoomSummary()
|
||||
.unwrap()
|
||||
|
|
|
@ -129,7 +129,7 @@ class LocationSharingService : VectorService(), LocationTracker.Callback {
|
|||
}
|
||||
}
|
||||
|
||||
private fun stopSharingLocation(roomId: String) {
|
||||
fun stopSharingLocation(roomId: String) {
|
||||
Timber.i("### LocationSharingService.stopSharingLocation for $roomId")
|
||||
synchronized(roomArgsList) {
|
||||
roomArgsList.removeAll { it.roomId == roomId }
|
||||
|
|
|
@ -34,6 +34,7 @@ class LocationSharingServiceConnection @Inject constructor(
|
|||
|
||||
private var callback: Callback? = null
|
||||
private var isBound = false
|
||||
private var locationSharingService: LocationSharingService? = null
|
||||
|
||||
fun bind(callback: Callback) {
|
||||
this.callback = callback
|
||||
|
@ -51,7 +52,12 @@ class LocationSharingServiceConnection @Inject constructor(
|
|||
callback = null
|
||||
}
|
||||
|
||||
fun stopLiveLocationSharing(roomId: String) {
|
||||
locationSharingService?.stopSharingLocation(roomId)
|
||||
}
|
||||
|
||||
override fun onServiceConnected(className: ComponentName, binder: IBinder) {
|
||||
locationSharingService = (binder as LocationSharingService.LocalBinder).getService()
|
||||
isBound = true
|
||||
callback?.onLocationServiceRunning()
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue