Add toggle ip address menu option.
This commit is contained in:
parent
45050e8216
commit
456762a464
@ -3350,6 +3350,8 @@
|
|||||||
<item quantity="one">Sign out of %1$d session</item>
|
<item quantity="one">Sign out of %1$d session</item>
|
||||||
<item quantity="other">Sign out of %1$d sessions</item>
|
<item quantity="other">Sign out of %1$d sessions</item>
|
||||||
</plurals>
|
</plurals>
|
||||||
|
<string name="device_manager_other_sessions_show_ip_address">Show IP address</string>
|
||||||
|
<string name="device_manager_other_sessions_hide_ip_address">Hide IP address</string>
|
||||||
<string name="device_manager_session_overview_signout">Sign out of this session</string>
|
<string name="device_manager_session_overview_signout">Sign out of this session</string>
|
||||||
<string name="device_manager_session_details_title">Session details</string>
|
<string name="device_manager_session_details_title">Session details</string>
|
||||||
<string name="device_manager_session_details_description">Application, device, and activity information.</string>
|
<string name="device_manager_session_details_description">Application, device, and activity information.</string>
|
||||||
|
@ -29,4 +29,5 @@ sealed class DevicesAction : VectorViewModelAction {
|
|||||||
object VerifyCurrentSession : DevicesAction()
|
object VerifyCurrentSession : DevicesAction()
|
||||||
data class MarkAsManuallyVerified(val cryptoDeviceInfo: CryptoDeviceInfo) : DevicesAction()
|
data class MarkAsManuallyVerified(val cryptoDeviceInfo: CryptoDeviceInfo) : DevicesAction()
|
||||||
object MultiSignoutOtherSessions : DevicesAction()
|
object MultiSignoutOtherSessions : DevicesAction()
|
||||||
|
object ToggleIpAddressVisibility : DevicesAction()
|
||||||
}
|
}
|
||||||
|
@ -116,9 +116,15 @@ class DevicesViewModel @AssistedInject constructor(
|
|||||||
is DevicesAction.VerifyCurrentSession -> handleVerifyCurrentSessionAction()
|
is DevicesAction.VerifyCurrentSession -> handleVerifyCurrentSessionAction()
|
||||||
is DevicesAction.MarkAsManuallyVerified -> handleMarkAsManuallyVerifiedAction()
|
is DevicesAction.MarkAsManuallyVerified -> handleMarkAsManuallyVerifiedAction()
|
||||||
DevicesAction.MultiSignoutOtherSessions -> handleMultiSignoutOtherSessions()
|
DevicesAction.MultiSignoutOtherSessions -> handleMultiSignoutOtherSessions()
|
||||||
|
DevicesAction.ToggleIpAddressVisibility -> handleToggleIpAddressVisibility()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleToggleIpAddressVisibility() = withState { state ->
|
||||||
|
val isShowingIpAddress = state.isShowingIpAddress
|
||||||
|
setState { copy(isShowingIpAddress = !isShowingIpAddress) }
|
||||||
|
}
|
||||||
|
|
||||||
private fun handleVerifyCurrentSessionAction() {
|
private fun handleVerifyCurrentSessionAction() {
|
||||||
viewModelScope.launch {
|
viewModelScope.launch {
|
||||||
val currentSessionCanBeVerified = checkIfCurrentSessionCanBeVerifiedUseCase.execute()
|
val currentSessionCanBeVerified = checkIfCurrentSessionCanBeVerifiedUseCase.execute()
|
||||||
|
@ -27,4 +27,5 @@ data class DevicesViewState(
|
|||||||
val unverifiedSessionsCount: Int = 0,
|
val unverifiedSessionsCount: Int = 0,
|
||||||
val inactiveSessionsCount: Int = 0,
|
val inactiveSessionsCount: Int = 0,
|
||||||
val isLoading: Boolean = false,
|
val isLoading: Boolean = false,
|
||||||
|
val isShowingIpAddress: Boolean = false,
|
||||||
) : MavericksState
|
) : MavericksState
|
||||||
|
@ -146,11 +146,19 @@ class VectorSettingsDevicesFragment :
|
|||||||
confirmMultiSignoutOtherSessions()
|
confirmMultiSignoutOtherSessions()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
R.id.otherSessionsHeaderToggleIpAddress -> {
|
||||||
|
handleToggleIpAddressVisibility()
|
||||||
|
true
|
||||||
|
}
|
||||||
else -> false
|
else -> false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun handleToggleIpAddressVisibility() {
|
||||||
|
viewModel.handle(DevicesAction.ToggleIpAddressVisibility)
|
||||||
|
}
|
||||||
|
|
||||||
private fun confirmMultiSignoutOtherSessions() {
|
private fun confirmMultiSignoutOtherSessions() {
|
||||||
activity?.let {
|
activity?.let {
|
||||||
buildConfirmSignoutDialogUseCase.execute(it, this::multiSignoutOtherSessions)
|
buildConfirmSignoutDialogUseCase.execute(it, this::multiSignoutOtherSessions)
|
||||||
@ -240,7 +248,7 @@ class VectorSettingsDevicesFragment :
|
|||||||
|
|
||||||
renderSecurityRecommendations(state.inactiveSessionsCount, state.unverifiedSessionsCount, isCurrentSessionVerified)
|
renderSecurityRecommendations(state.inactiveSessionsCount, state.unverifiedSessionsCount, isCurrentSessionVerified)
|
||||||
renderCurrentDevice(currentDeviceInfo)
|
renderCurrentDevice(currentDeviceInfo)
|
||||||
renderOtherSessionsView(otherDevices)
|
renderOtherSessionsView(otherDevices, state.isShowingIpAddress)
|
||||||
} else {
|
} else {
|
||||||
hideSecurityRecommendations()
|
hideSecurityRecommendations()
|
||||||
hideCurrentSessionView()
|
hideCurrentSessionView()
|
||||||
@ -297,7 +305,7 @@ class VectorSettingsDevicesFragment :
|
|||||||
hideInactiveSessionsRecommendation()
|
hideInactiveSessionsRecommendation()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun renderOtherSessionsView(otherDevices: List<DeviceFullInfo>?) {
|
private fun renderOtherSessionsView(otherDevices: List<DeviceFullInfo>?, isShowingIpAddress: Boolean) {
|
||||||
if (otherDevices.isNullOrEmpty()) {
|
if (otherDevices.isNullOrEmpty()) {
|
||||||
hideOtherSessionsView()
|
hideOtherSessionsView()
|
||||||
} else {
|
} else {
|
||||||
@ -313,7 +321,12 @@ class VectorSettingsDevicesFragment :
|
|||||||
totalNumberOfDevices = otherDevices.size,
|
totalNumberOfDevices = otherDevices.size,
|
||||||
showViewAll = otherDevices.size > NUMBER_OF_OTHER_DEVICES_TO_RENDER
|
showViewAll = otherDevices.size > NUMBER_OF_OTHER_DEVICES_TO_RENDER
|
||||||
)
|
)
|
||||||
}
|
views.deviceListHeaderOtherSessions.menu.findItem(R.id.otherSessionsHeaderToggleIpAddress).title = if (isShowingIpAddress) {
|
||||||
|
stringProvider.getString(R.string.device_manager_other_sessions_hide_ip_address)
|
||||||
|
} else {
|
||||||
|
stringProvider.getString(R.string.device_manager_other_sessions_show_ip_address)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun hideOtherSessionsView() {
|
private fun hideOtherSessionsView() {
|
||||||
|
@ -4,6 +4,11 @@
|
|||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:ignore="AlwaysShowAction">
|
tools:ignore="AlwaysShowAction">
|
||||||
|
|
||||||
|
<item
|
||||||
|
android:id="@+id/otherSessionsHeaderToggleIpAddress"
|
||||||
|
android:title="@string/device_manager_other_sessions_show_ip_address"
|
||||||
|
app:showAsAction="withText|never" />
|
||||||
|
|
||||||
<item
|
<item
|
||||||
android:id="@+id/otherSessionsHeaderMultiSignout"
|
android:id="@+id/otherSessionsHeaderMultiSignout"
|
||||||
android:title="@plurals/device_manager_other_sessions_multi_signout_all"
|
android:title="@plurals/device_manager_other_sessions_multi_signout_all"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user