mirror of
https://github.com/element-hq/element-android
synced 2024-11-23 18:05:36 +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()
|
initWaitingView()
|
||||||
initCurrentSessionHeaderView()
|
initCurrentSessionHeaderView()
|
||||||
|
initCurrentSessionListView()
|
||||||
initOtherSessionsHeaderView()
|
initOtherSessionsHeaderView()
|
||||||
initOtherSessionsView()
|
initOtherSessionsView()
|
||||||
initSecurityRecommendationsView()
|
initSecurityRecommendationsView()
|
||||||
|
@ -153,6 +154,12 @@ class VectorSettingsDevicesFragment :
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun initCurrentSessionListView() {
|
||||||
|
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
||||||
|
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private fun initOtherSessionsHeaderView() {
|
private fun initOtherSessionsHeaderView() {
|
||||||
views.deviceListHeaderOtherSessions.setOnMenuItemClickListener { menuItem ->
|
views.deviceListHeaderOtherSessions.setOnMenuItemClickListener { menuItem ->
|
||||||
when (menuItem.itemId) {
|
when (menuItem.itemId) {
|
||||||
|
@ -351,15 +358,28 @@ class VectorSettingsDevicesFragment :
|
||||||
|
|
||||||
private fun renderCurrentSessionView(currentDeviceInfo: DeviceFullInfo?, hasOtherDevices: Boolean) {
|
private fun renderCurrentSessionView(currentDeviceInfo: DeviceFullInfo?, hasOtherDevices: Boolean) {
|
||||||
currentDeviceInfo?.let {
|
currentDeviceInfo?.let {
|
||||||
|
renderCurrentSessionHeaderView(hasOtherDevices)
|
||||||
|
renderCurrentSessionListView(it)
|
||||||
|
} ?: run {
|
||||||
|
hideCurrentSessionView()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderCurrentSessionHeaderView(hasOtherDevices: Boolean) {
|
||||||
views.deviceListHeaderCurrentSession.isVisible = true
|
views.deviceListHeaderCurrentSession.isVisible = true
|
||||||
val colorDestructive = colorProvider.getColorFromAttribute(R.attr.colorError)
|
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)
|
val signoutOtherSessionsItem = views.deviceListHeaderCurrentSession.menu.findItem(R.id.currentSessionHeaderSignoutOtherSessions)
|
||||||
signoutOtherSessionsItem.setTextColor(colorDestructive)
|
signoutOtherSessionsItem.setTextColor(colorDestructive)
|
||||||
signoutOtherSessionsItem.isVisible = hasOtherDevices
|
signoutOtherSessionsItem.isVisible = hasOtherDevices
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun renderCurrentSessionListView(currentDeviceInfo: DeviceFullInfo) {
|
||||||
views.deviceListCurrentSession.isVisible = true
|
views.deviceListCurrentSession.isVisible = true
|
||||||
val viewState = SessionInfoViewState(
|
val viewState = SessionInfoViewState(
|
||||||
isCurrentSession = true,
|
isCurrentSession = true,
|
||||||
deviceFullInfo = it
|
deviceFullInfo = currentDeviceInfo
|
||||||
)
|
)
|
||||||
views.deviceListCurrentSession.render(viewState, dateFormatter, drawableProvider, colorProvider, stringProvider)
|
views.deviceListCurrentSession.render(viewState, dateFormatter, drawableProvider, colorProvider, stringProvider)
|
||||||
views.deviceListCurrentSession.debouncedClicks {
|
views.deviceListCurrentSession.debouncedClicks {
|
||||||
|
@ -368,12 +388,6 @@ class VectorSettingsDevicesFragment :
|
||||||
views.deviceListCurrentSession.viewDetailsButton.debouncedClicks {
|
views.deviceListCurrentSession.viewDetailsButton.debouncedClicks {
|
||||||
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
currentDeviceInfo.deviceInfo.deviceId?.let { deviceId -> navigateToSessionOverview(deviceId) }
|
||||||
}
|
}
|
||||||
views.deviceListCurrentSession.viewVerifyButton.debouncedClicks {
|
|
||||||
viewModel.handle(DevicesAction.VerifyCurrentSession)
|
|
||||||
}
|
|
||||||
} ?: run {
|
|
||||||
hideCurrentSessionView()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun navigateToSessionOverview(deviceId: String) {
|
private fun navigateToSessionOverview(deviceId: String) {
|
||||||
|
|
|
@ -4,6 +4,16 @@
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
tools:ignore="AlwaysShowAction">
|
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
|
<item
|
||||||
android:id="@+id/currentSessionHeaderSignoutOtherSessions"
|
android:id="@+id/currentSessionHeaderSignoutOtherSessions"
|
||||||
android:title="@string/device_manager_signout_all_other_sessions"
|
android:title="@string/device_manager_signout_all_other_sessions"
|
||||||
|
|
Loading…
Reference in a new issue