Adding the rename and signout actions in the menu
This commit is contained in:
parent
b8ab1b5620
commit
bbc756136c
|
@ -101,6 +101,7 @@ class VectorSettingsDevicesFragment :
|
|||
|
||||
initWaitingView()
|
||||
initCurrentSessionHeaderView()
|
||||
initCurrentSessionListView()
|
||||
initOtherSessionsHeaderView()
|
||||
initOtherSessionsView()
|
||||
initSecurityRecommendationsView()
|
||||
|
@ -153,6 +154,12 @@ class VectorSettingsDevicesFragment :
|
|||
}
|
||||
}
|
||||
|
||||
private fun initCurrentSessionListView() {
|
||||
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
||||
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
||||
}
|
||||
}
|
||||
|
||||
private fun initOtherSessionsHeaderView() {
|
||||
views.deviceListHeaderOtherSessions.setOnMenuItemClickListener { menuItem ->
|
||||
when (menuItem.itemId) {
|
||||
|
@ -351,31 +358,38 @@ class VectorSettingsDevicesFragment :
|
|||
|
||||
private fun renderCurrentSessionView(currentDeviceInfo: DeviceFullInfo?, hasOtherDevices: Boolean) {
|
||||
currentDeviceInfo?.let {
|
||||
views.deviceListHeaderCurrentSession.isVisible = true
|
||||
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
|
||||
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
|
||||
signoutOtherSessionsItem.setTextColor(colorDestructive)
|
||||
signoutOtherSessionsItem.isVisible = hasOtherDevices
|
||||
views.deviceListCurrentSession.isVisible = true
|
||||
val viewState = SessionInfoViewState(
|
||||
isCurrentSession = true,
|
||||
deviceFullInfo = it
|
||||
)
|
||||
views.deviceListCurrentSession.render(viewState, dateFormatter, drawableProvider, colorProvider, stringProvider)
|
||||
views.deviceListCurrentSession.debouncedClicks {
|
||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||
}
|
||||
views.deviceListCurrentSession.viewDetailsButton.debouncedClicks {
|
||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||
}
|
||||
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
||||
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
||||
}
|
||||
renderCurrentSessionHeaderView(hasOtherDevices)
|
||||
renderCurrentSessionListView(it)
|
||||
} ?: run {
|
||||
hideCurrentSessionView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun renderCurrentSessionHeaderView(hasOtherDevices: Boolean) {
|
||||
views.deviceListHeaderCurrentSession.isVisible = true
|
||||
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
|
||||
val signoutSessionItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignout)
|
||||
signoutSessionItem.setTextColor(colorDestructive)
|
||||
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
|
||||
signoutOtherSessionsItem.setTextColor(colorDestructive)
|
||||
signoutOtherSessionsItem.isVisible = hasOtherDevices
|
||||
}
|
||||
|
||||
private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) {
|
||||
views.deviceListCurrentSession.isVisible = true
|
||||
val viewState = SessionInfoViewState(
|
||||
isCurrentSession = true,
|
||||
deviceFullInfo = currentDeviceInfo
|
||||
)
|
||||
views.deviceListCurrentSession.render(viewState, dateFormatter, drawableProvider, colorProvider, stringProvider)
|
||||
views.deviceListCurrentSession.debouncedClicks {
|
||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||
}
|
||||
views.deviceListCurrentSession.viewDetailsButton.debouncedClicks {
|
||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToSessionOverview(deviceId: String) {
|
||||
viewNavigator.navigateToSessionOverview(
|
||||
context = requireActivity(),
|
||||
|
|
|
@ -4,6 +4,16 @@
|
|||
xmlns:tools="http://schemas.android.com/tools"
|
||||
tools:ignore="AlwaysShowAction">
|
||||
|
||||
<item
|
||||
android:id="@+id/currentSessionHeaderRename"
|
||||
android:title="@string/device_manager_session_rename"
|
||||
app:showAsAction="withText|never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/currentSessionHeaderSignout"
|
||||
android:title="@string/logout"
|
||||
app:showAsAction="withText|never" />
|
||||
|
||||
<item
|
||||
android:id="@+id/currentSessionHeaderSignoutOtherSessions"
|
||||
android:title="@string/device_manager_signout_all_other_sessions"
|
||||
|
|
Loading…
Reference in New Issue