Code review fixes.

This commit is contained in:
Onuray Sahin 2022-11-22 18:02:48 +03:00
parent 5eb786b55f
commit abea9b686a
8 changed files with 10 additions and 9 deletions

View File

@ -51,12 +51,13 @@
<bool name="settings_labs_rich_text_editor_default">false</bool>
<bool name="settings_labs_enable_voice_broadcast_visible">true</bool>
<bool name="settings_labs_enable_voice_broadcast_default">false</bool>
<bool name="settings_device_manager_show_ip_address">false</bool>
<!-- Level 1: Advanced settings -->
<!-- Level 1: Help and about -->
<!-- Level 1: Legals -->
<!-- Level 3: Security & Privacy, Sessions -->
<bool name="settings_session_manager_show_ip_address">false</bool>
</resources>

View File

@ -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) {

View File

@ -88,7 +88,7 @@ class DevicesViewModel @AssistedInject constructor(
}
private fun refreshIpAddressVisibility() {
val shouldShowIpAddress = vectorPreferences.showIpAddressInDeviceManagerScreens()
val shouldShowIpAddress = vectorPreferences.showIpAddressInSessionManagerScreens()
setState {
copy(isShowingIpAddress = shouldShowIpAddress)
}

View File

@ -24,7 +24,7 @@ class ToggleIpAddressVisibilityUseCase @Inject constructor(
) {
fun execute() {
val currentVisibility = vectorPreferences.showIpAddressInDeviceManagerScreens()
val currentVisibility = vectorPreferences.showIpAddressInSessionManagerScreens()
vectorPreferences.setIpAddressVisibilityInDeviceManagerScreens(!currentVisibility)
}
}

View File

@ -81,7 +81,7 @@ class OtherSessionsViewModel @AssistedInject constructor(
}
private fun refreshIpAddressVisibility() {
val shouldShowIpAddress = vectorPreferences.showIpAddressInDeviceManagerScreens()
val shouldShowIpAddress = vectorPreferences.showIpAddressInSessionManagerScreens()
setState {
copy(isShowingIpAddress = shouldShowIpAddress)
}

View File

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

View File

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

View File

@ -54,6 +54,6 @@ class FakeVectorPreferences {
}
fun givenSessionManagerShowIpAddress(showIpAddress: Boolean) {
every { instance.showIpAddressInDeviceManagerScreens() } returns showIpAddress
every { instance.showIpAddressInSessionManagerScreens() } returns showIpAddress
}
}