From abea9b686a3407eea3e343061ae7dd5ab96ca38a Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Tue, 22 Nov 2022 18:02:48 +0300 Subject: [PATCH] Code review fixes. --- vector-config/src/main/res/values/config-settings.xml | 3 ++- .../java/im/vector/app/features/settings/VectorPreferences.kt | 4 ++-- .../app/features/settings/devices/v2/DevicesViewModel.kt | 2 +- .../settings/devices/v2/ToggleIpAddressVisibilityUseCase.kt | 2 +- .../devices/v2/othersessions/OtherSessionsViewModel.kt | 2 +- .../settings/devices/v2/overview/SessionOverviewViewModel.kt | 2 +- .../app/features/settings/devices/v2/DevicesViewModelTest.kt | 2 +- .../java/im/vector/app/test/fakes/FakeVectorPreferences.kt | 2 +- 8 files changed, 10 insertions(+), 9 deletions(-) diff --git a/vector-config/src/main/res/values/config-settings.xml b/vector-config/src/main/res/values/config-settings.xml index ef9695a080..ad9c16c214 100755 --- a/vector-config/src/main/res/values/config-settings.xml +++ b/vector-config/src/main/res/values/config-settings.xml @@ -51,12 +51,13 @@ false true false - false + + false 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 30b5ef9131..447038d768 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 @@ -1232,8 +1232,8 @@ class VectorPreferences @Inject constructor( defaultPrefs.getBoolean(SETTINGS_LABS_VOICE_BROADCAST_KEY, getDefault(R.bool.settings_labs_enable_voice_broadcast_default)) } - fun showIpAddressInDeviceManagerScreens(): Boolean { - return defaultPrefs.getBoolean(SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, getDefault(R.bool.settings_device_manager_show_ip_address)) + fun showIpAddressInSessionManagerScreens(): Boolean { + return defaultPrefs.getBoolean(SETTINGS_SESSION_MANAGER_SHOW_IP_ADDRESS, getDefault(R.bool.settings_session_manager_show_ip_address)) } fun setIpAddressVisibilityInDeviceManagerScreens(isVisible: Boolean) { diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt index 236237ddbb..f42d5af398 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/DevicesViewModel.kt @@ -88,7 +88,7 @@ class DevicesViewModel @AssistedInject constructor( } private fun refreshIpAddressVisibility() { - val shouldShowIpAddress = vectorPreferences.showIpAddressInDeviceManagerScreens() + val shouldShowIpAddress = vectorPreferences.showIpAddressInSessionManagerScreens() setState { copy(isShowingIpAddress = shouldShowIpAddress) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/ToggleIpAddressVisibilityUseCase.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/ToggleIpAddressVisibilityUseCase.kt index ef99d3489a..1e1dc19c96 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/ToggleIpAddressVisibilityUseCase.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/ToggleIpAddressVisibilityUseCase.kt @@ -24,7 +24,7 @@ class ToggleIpAddressVisibilityUseCase @Inject constructor( ) { fun execute() { - val currentVisibility = vectorPreferences.showIpAddressInDeviceManagerScreens() + val currentVisibility = vectorPreferences.showIpAddressInSessionManagerScreens() vectorPreferences.setIpAddressVisibilityInDeviceManagerScreens(!currentVisibility) } } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewModel.kt index bd6e31dd4d..a5282e7ba2 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/othersessions/OtherSessionsViewModel.kt @@ -81,7 +81,7 @@ class OtherSessionsViewModel @AssistedInject constructor( } private fun refreshIpAddressVisibility() { - val shouldShowIpAddress = vectorPreferences.showIpAddressInDeviceManagerScreens() + val shouldShowIpAddress = vectorPreferences.showIpAddressInSessionManagerScreens() setState { copy(isShowingIpAddress = shouldShowIpAddress) } diff --git a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt index d423d4a743..472e0a4269 100644 --- a/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt +++ b/vector/src/main/java/im/vector/app/features/settings/devices/v2/overview/SessionOverviewViewModel.kt @@ -92,7 +92,7 @@ class SessionOverviewViewModel @AssistedInject constructor( super.onCleared() } private fun refreshIpAddressVisibility() { - val shouldShowIpAddress = vectorPreferences.showIpAddressInDeviceManagerScreens() + val shouldShowIpAddress = vectorPreferences.showIpAddressInSessionManagerScreens() setState { copy(isShowingIpAddress = shouldShowIpAddress) } diff --git a/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt b/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt index 16ccaab37f..03177aac47 100644 --- a/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt +++ b/vector/src/test/java/im/vector/app/features/settings/devices/v2/DevicesViewModelTest.kt @@ -368,7 +368,7 @@ class DevicesViewModelTest { val viewModelTest = viewModel.test() every { toggleIpAddressVisibilityUseCase.execute() } just runs every { fakeVectorPreferences.instance.setIpAddressVisibilityInDeviceManagerScreens(true) } just runs - every { fakeVectorPreferences.instance.showIpAddressInDeviceManagerScreens() } returns true + every { fakeVectorPreferences.instance.showIpAddressInSessionManagerScreens() } returns true viewModel.handle(DevicesAction.ToggleIpAddressVisibility) viewModel.onSharedPreferenceChanged(null, null) diff --git a/vector/src/test/java/im/vector/app/test/fakes/FakeVectorPreferences.kt b/vector/src/test/java/im/vector/app/test/fakes/FakeVectorPreferences.kt index f05f5f1493..d89764a77e 100644 --- a/vector/src/test/java/im/vector/app/test/fakes/FakeVectorPreferences.kt +++ b/vector/src/test/java/im/vector/app/test/fakes/FakeVectorPreferences.kt @@ -54,6 +54,6 @@ class FakeVectorPreferences { } fun givenSessionManagerShowIpAddress(showIpAddress: Boolean) { - every { instance.showIpAddressInDeviceManagerScreens() } returns showIpAddress + every { instance.showIpAddressInSessionManagerScreens() } returns showIpAddress } }