Code review fixes.

This commit is contained in:
Onuray Sahin 2022-06-28 14:52:01 +03:00
parent ab34bb6df7
commit 320915e0a1
2 changed files with 10 additions and 7 deletions

View file

@ -197,12 +197,15 @@ class LocationSharingFragment @Inject constructor(
private val liveLocationLabsFlagPromotionListener = object : VectorBaseBottomSheetDialogFragment.ResultListener {
override fun onBottomSheetResult(resultCode: Int, data: Any?) {
// Check if the user wants to enable the labs flag
if (resultCode == VectorBaseBottomSheetDialogFragment.ResultListener.RESULT_OK && (data as? Boolean) == true) {
vectorPreferences.setLiveLocationLabsEnabled()
startLiveLocationSharing()
handleLiveLocationLabsFlagPromotionResult(resultCode, data)
}
}
private fun handleLiveLocationLabsFlagPromotionResult(resultCode: Int, data: Any?) {
if (resultCode == VectorBaseBottomSheetDialogFragment.ResultListener.RESULT_OK && (data as? Boolean) == true) {
vectorPreferences.setLiveLocationLabsEnabled(isEnabled = true)
startLiveLocationSharing()
}
}
private fun tryStartLiveLocationSharing() {

View file

@ -1047,9 +1047,9 @@ class VectorPreferences @Inject constructor(
return defaultPrefs.getBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, false)
}
fun setLiveLocationLabsEnabled() {
fun setLiveLocationLabsEnabled(isEnabled: Boolean) {
defaultPrefs.edit {
putBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, true)
putBoolean(SETTINGS_LABS_ENABLE_LIVE_LOCATION, isEnabled)
}
}