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,11 +197,14 @@ 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()
}
}

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)
}
}