mirror of
https://github.com/element-hq/element-android
synced 2024-11-27 03:48:12 +03:00
Toggle ip address on other sessions screen.
This commit is contained in:
parent
eed2a74d07
commit
b5e8375592
5 changed files with 33 additions and 3 deletions
|
@ -33,4 +33,5 @@ sealed class OtherSessionsAction : VectorViewModelAction {
|
|||
object SelectAll : OtherSessionsAction()
|
||||
object DeselectAll : OtherSessionsAction()
|
||||
object MultiSignout : OtherSessionsAction()
|
||||
object ToggleIpAddressVisibility: OtherSessionsAction()
|
||||
}
|
||||
|
|
|
@ -85,6 +85,12 @@ class OtherSessionsFragment :
|
|||
menu.findItem(R.id.otherSessionsSelectAll).isVisible = isSelectModeEnabled
|
||||
menu.findItem(R.id.otherSessionsDeselectAll).isVisible = isSelectModeEnabled
|
||||
menu.findItem(R.id.otherSessionsSelect).isVisible = !isSelectModeEnabled && state.devices()?.isNotEmpty().orFalse()
|
||||
menu.findItem(R.id.otherSessionsToggleIpAddress).isVisible = !isSelectModeEnabled
|
||||
menu.findItem(R.id.otherSessionsToggleIpAddress).title = if (state.isShowingIpAddress) {
|
||||
getString(R.string.device_manager_other_sessions_hide_ip_address)
|
||||
} else {
|
||||
getString(R.string.device_manager_other_sessions_show_ip_address)
|
||||
}
|
||||
updateMultiSignoutMenuItem(menu, state)
|
||||
}
|
||||
}
|
||||
|
@ -130,10 +136,18 @@ class OtherSessionsFragment :
|
|||
confirmMultiSignout()
|
||||
true
|
||||
}
|
||||
R.id.otherSessionsToggleIpAddress -> {
|
||||
toggleIpAddressVisibility()
|
||||
true
|
||||
}
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
private fun toggleIpAddressVisibility() {
|
||||
viewModel.handle(OtherSessionsAction.ToggleIpAddressVisibility)
|
||||
}
|
||||
|
||||
private fun confirmMultiSignout() {
|
||||
activity?.let {
|
||||
buildConfirmSignoutDialogUseCase.execute(it, this::multiSignout)
|
||||
|
@ -213,7 +227,7 @@ class OtherSessionsFragment :
|
|||
updateLoading(state.isLoading)
|
||||
if (state.devices is Success) {
|
||||
val devices = state.devices.invoke()
|
||||
renderDevices(devices, state.currentFilter)
|
||||
renderDevices(devices, state.currentFilter, state.isShowingIpAddress)
|
||||
updateToolbar(devices, state.isSelectModeEnabled)
|
||||
}
|
||||
}
|
||||
|
@ -237,7 +251,7 @@ class OtherSessionsFragment :
|
|||
toolbar?.title = title
|
||||
}
|
||||
|
||||
private fun renderDevices(devices: List<DeviceFullInfo>, currentFilter: DeviceManagerFilterType) {
|
||||
private fun renderDevices(devices: List<DeviceFullInfo>, currentFilter: DeviceManagerFilterType, isShowingIpAddress: Boolean) {
|
||||
views.otherSessionsFilterBadgeImageView.isVisible = currentFilter != DeviceManagerFilterType.ALL_SESSIONS
|
||||
views.otherSessionsSecurityRecommendationView.isVisible = currentFilter != DeviceManagerFilterType.ALL_SESSIONS
|
||||
views.deviceListHeaderOtherSessions.isVisible = currentFilter == DeviceManagerFilterType.ALL_SESSIONS
|
||||
|
@ -296,7 +310,8 @@ class OtherSessionsFragment :
|
|||
} else {
|
||||
views.deviceListOtherSessions.isVisible = true
|
||||
views.otherSessionsNotFoundLayout.isVisible = false
|
||||
views.deviceListOtherSessions.render(devices = devices, totalNumberOfDevices = devices.size, showViewAll = false)
|
||||
val mappedDevices = if (isShowingIpAddress) devices else devices.map { it.copy(deviceInfo = it.deviceInfo.copy(lastSeenIp = null)) }
|
||||
views.deviceListOtherSessions.render(devices = mappedDevices, totalNumberOfDevices = mappedDevices.size, showViewAll = false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -91,6 +91,14 @@ class OtherSessionsViewModel @AssistedInject constructor(
|
|||
OtherSessionsAction.DeselectAll -> handleDeselectAll()
|
||||
OtherSessionsAction.SelectAll -> handleSelectAll()
|
||||
OtherSessionsAction.MultiSignout -> handleMultiSignout()
|
||||
OtherSessionsAction.ToggleIpAddressVisibility -> handleToggleIpAddressVisibility()
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleToggleIpAddressVisibility() = withState { state ->
|
||||
val isShowingIpAddress = state.isShowingIpAddress
|
||||
setState {
|
||||
copy(isShowingIpAddress = !isShowingIpAddress)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ data class OtherSessionsViewState(
|
|||
val excludeCurrentDevice: Boolean = false,
|
||||
val isSelectModeEnabled: Boolean = false,
|
||||
val isLoading: Boolean = false,
|
||||
val isShowingIpAddress: Boolean = false,
|
||||
) : MavericksState {
|
||||
|
||||
constructor(args: OtherSessionsArgs) : this(excludeCurrentDevice = args.excludeCurrentDevice)
|
||||
|
|
|
@ -9,6 +9,11 @@
|
|||
android:title="@string/device_manager_other_sessions_select"
|
||||
app:showAsAction="withText|never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/otherSessionsToggleIpAddress"
|
||||
android:title="@string/device_manager_other_sessions_show_ip_address"
|
||||
app:showAsAction="withText|never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/otherSessionsMultiSignout"
|
||||
android:title="@plurals/device_manager_other_sessions_multi_signout_all"
|
||||
|
|
Loading…
Reference in a new issue