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()) MaterialAlertDialogBuilder(requireActivity())
.setTitle(R.string.live_location_not_enough_permission_dialog_title) .setTitle(R.string.live_location_not_enough_permission_dialog_title)
.setMessage(R.string.live_location_not_enough_permission_dialog_description) .setMessage(R.string.live_location_not_enough_permission_dialog_description)
.setPositiveButton(R.string.ok) { dialogInterface, _ -> .setPositiveButton(R.string.ok, null)
dialogInterface.dismiss()
}
.show() .show()
} }

View file

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

View file

@ -3054,8 +3054,8 @@
<!-- TODO remove key --> <!-- TODO remove key -->
<string name="live_location_bottom_sheet_stop_sharing" tools:ignore="UnusedResources">Stop sharing</string> <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_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_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 locations in this room.</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> <string name="message_bubbles">Show Message bubbles</string>