mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 09:55:40 +03:00
Adding the rename and signout actions in the menu
This commit is contained in:
parent
b8ab1b5620
commit
bbc756136c
2 changed files with 44 additions and 20 deletions
|
@ -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,15 +358,28 @@ class VectorSettingsDevicesFragment :
|
|||
|
||||
private fun renderCurrentSessionView(currentDeviceInfo: DeviceFullInfo?, hasOtherDevices: Boolean) {
|
||||
currentDeviceInfo?.let {
|
||||
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 = it
|
||||
deviceFullInfo = currentDeviceInfo
|
||||
)
|
||||
views.deviceListCurrentSession.render(viewState, dateFormatter, drawableProvider, colorProvider, stringProvider)
|
||||
views.deviceListCurrentSession.debouncedClicks {
|
||||
|
@ -368,12 +388,6 @@ class VectorSettingsDevicesFragment :
|
|||
views.deviceListCurrentSession.viewDetailsButton.debouncedClicks {
|
||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||
}
|
||||
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
||||
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
||||
}
|
||||
} ?: run {
|
||||
hideCurrentSessionView()
|
||||
}
|
||||
}
|
||||
|
||||
private fun navigateToSessionOverview(deviceId: String) {
|
||||
|
|
|
@ -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 a new issue