From 320915e0a1186d7908cf543b9f5e03179ca8924f Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 28 Jun 2022 14:52:01 +0300 Subject: [PATCH] Code review fixes. --- .../features/location/LocationSharingFragment.kt | 13 ++++++++----- .../app/features/settings/VectorPreferences.kt | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt index 84034c6461..1deb9fade2 100644 --- a/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt +++ b/vector/src/main/java/im/vector/app/features/location/LocationSharingFragment.kt @@ -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() } } diff --git a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt index d389c76dfa..8fd520e883 100755 --- a/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt +++ b/vector/src/main/java/im/vector/app/features/settings/VectorPreferences.kt @@ -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) } }