Code review fixes.

This commit is contained in:
Onuray Sahin 2022-07-19 13:41:00 +03:00
parent 5fb10ab287
commit 493dc57a29
3 changed files with 9 additions and 12 deletions

View File

@ -175,9 +175,7 @@ class LocationSharingFragment @Inject constructor(
MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.live_location_not_enough_permission_dialog_title)
.setMessage(R.string.live_location_not_enough_permission_dialog_description)
.setPositiveButton(R.string.ok) { dialogInterface, _ ->
dialogInterface.dismiss()
}
.setPositiveButton(R.string.ok, null)
.show()
}

View File

@ -75,22 +75,21 @@ class LocationSharingViewModel @AssistedInject constructor(
setUserItem()
updatePin()
compareTargetAndUserLocation()
checkPowerLevelsForLiveLocationSharing()
observePowerLevelsForLiveLocationSharing()
}
private fun checkPowerLevelsForLiveLocationSharing() {
private fun observePowerLevelsForLiveLocationSharing() {
PowerLevelsFlowFactory(room).createFlow()
.distinctUntilChanged()
.onEach {
.setOnEach {
val powerLevelsHelper = PowerLevelsHelper(it)
val canShareLiveLocation = EventType.STATE_ROOM_BEACON_INFO
.map { beaconInfoType ->
.all { beaconInfoType ->
powerLevelsHelper.isUserAllowedToSend(session.myUserId, true, beaconInfoType)
}
.all { isUserAllowed -> isUserAllowed }
setState { copy(canShareLiveLocation = canShareLiveLocation) }
}.launchIn(viewModelScope)
copy(canShareLiveLocation = canShareLiveLocation)
}
}
private fun initLocationTracking() {

View File

@ -3054,8 +3054,8 @@
<!-- TODO remove key -->
<string name="live_location_bottom_sheet_stop_sharing" tools:ignore="UnusedResources">Stop sharing</string>
<string name="live_location_bottom_sheet_last_updated_at">Updated %1$s ago</string>
<string name="live_location_not_enough_permission_dialog_title">You dont have permission to share locations</string>
<string name="live_location_not_enough_permission_dialog_description">You need to have the right permissions in order to share locations in this room.</string>
<string name="live_location_not_enough_permission_dialog_title">You dont have permission to share live location</string>
<string name="live_location_not_enough_permission_dialog_description">You need to have the right permissions in order to share live location in this room.</string>
<string name="message_bubbles">Show Message bubbles</string>