Merge pull request #2808 from vector-im/feature/bma/room_settings_ux

Room settings ux
This commit is contained in:
Benoit Marty 2021-02-11 22:01:12 +01:00 committed by GitHub
commit e098ed6627
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 80 additions and 61 deletions

View File

@ -6,6 +6,7 @@ Features ✨:
Improvements 🙌:
- VoIP : new tiles in timeline
- Improve room profile UX
- Upgrade Jitsi library from 2.9.3 to 3.1.0
Bugfix 🐛:

View File

@ -277,8 +277,23 @@ class UiAllScreensSanityTest {
assertDisplayed(R.id.roomProfileAvatarView)
// Leave
// Room addresses
clickListItem(R.id.matrixProfileRecyclerView, 13)
onView(isRoot()).perform(waitForView(withText(R.string.room_alias_published_alias_title)))
pressBack()
// Room permissions
clickListItem(R.id.matrixProfileRecyclerView, 15)
onView(isRoot()).perform(waitForView(withText(R.string.room_permissions_title)))
clickOn(R.string.room_permissions_change_room_avatar)
clickDialogNegativeButton()
// Toggle
clickOn(R.string.show_advanced)
clickOn(R.string.hide_advanced)
pressBack()
// Leave
clickListItem(R.id.matrixProfileRecyclerView, 17)
clickDialogNegativeButton()
// Menu share
@ -289,27 +304,12 @@ class UiAllScreensSanityTest {
}
private fun navigateToRoomParameters() {
// Room addresses
clickListItem(R.id.roomSettingsRecyclerView, 4)
onView(isRoot()).perform(waitForView(withText(R.string.room_alias_published_alias_title)))
pressBack()
// Room permissions
clickListItem(R.id.roomSettingsRecyclerView, 6)
onView(isRoot()).perform(waitForView(withText(R.string.room_permissions_title)))
clickOn(R.string.room_permissions_change_room_avatar)
clickDialogNegativeButton()
// Toggle
clickOn(R.string.show_advanced)
clickOn(R.string.hide_advanced)
pressBack()
// Room history readability
clickListItem(R.id.roomSettingsRecyclerView, 8)
clickListItem(R.id.roomSettingsRecyclerView, 4)
pressBack()
// Room access
clickListItem(R.id.roomSettingsRecyclerView, 10)
clickListItem(R.id.roomSettingsRecyclerView, 6)
pressBack()
}

View File

@ -54,6 +54,8 @@ class RoomProfileController @Inject constructor(
fun createShortcut()
fun onSettingsClicked()
fun onLeaveRoomClicked()
fun onRoomAliasesClicked()
fun onRoomPermissionsClicked()
fun onRoomIdClicked()
fun onUrlInTopicLongClicked(url: String)
}
@ -174,8 +176,29 @@ class RoomProfileController @Inject constructor(
)
// Advanced
buildProfileSection(stringProvider.getString(R.string.room_settings_category_advanced_title))
buildProfileAction(
id = "alias",
title = stringProvider.getString(R.string.room_settings_alias_title),
subtitle = stringProvider.getString(R.string.room_settings_alias_subtitle),
dividerColor = dividerColor,
divider = true,
editable = true,
action = { callback?.onRoomAliasesClicked() }
)
buildProfileAction(
id = "permissions",
title = stringProvider.getString(R.string.room_settings_permissions_title),
subtitle = stringProvider.getString(R.string.room_settings_permissions_subtitle),
dividerColor = dividerColor,
divider = true,
editable = true,
action = { callback?.onRoomPermissionsClicked() }
)
if (vectorPreferences.developerMode()) {
buildProfileSection(stringProvider.getString(R.string.room_settings_category_advanced_title))
buildProfileAction(
id = "roomId",
title = stringProvider.getString(R.string.room_settings_room_internal_id),

View File

@ -52,7 +52,6 @@ import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedA
import im.vector.app.features.home.room.list.actions.RoomListQuickActionsSharedActionViewModel
import kotlinx.parcelize.Parcelize
import org.matrix.android.sdk.api.session.room.notification.RoomNotificationState
import org.matrix.android.sdk.api.util.MatrixItem
import org.matrix.android.sdk.api.util.toMatrixItem
import timber.log.Timber
import javax.inject.Inject
@ -116,6 +115,7 @@ class RoomProfileFragment @Inject constructor(
.observe()
.subscribe { handleQuickActions(it) }
.disposeOnDestroyView()
setupClicks()
setupLongClicks()
}
@ -124,6 +124,29 @@ class RoomProfileFragment @Inject constructor(
views.waitingView.waitingStatusText.isVisible = true
}
private fun setupClicks() {
// Shortcut to room settings
setOf(
headerViews.roomProfileNameView,
views.matrixProfileToolbarTitleView
).forEach {
it.setOnClickListener {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomSettings)
}
}
// Shortcut to room alias
headerViews.roomProfileAliasView.setOnClickListener {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomAliasesSettings)
}
// Open Avatar
setOf(
headerViews.roomProfileAvatarView,
views.matrixProfileToolbarAvatarImageView
).forEach { view ->
view.setOnClickListener { onAvatarClicked(view) }
}
}
private fun setupLongClicks() {
headerViews.roomProfileNameView.copyOnLongClick()
headerViews.roomProfileAliasView.copyOnLongClick()
@ -170,7 +193,7 @@ class RoomProfileFragment @Inject constructor(
override fun invalidate() = withState(roomProfileViewModel) { state ->
views.waitingView.root.isVisible = state.isLoading
state.roomSummary()?.also {
state.roomSummary()?.let {
if (it.membership.isLeft()) {
Timber.w("The room has been left")
activity?.finish()
@ -184,13 +207,6 @@ class RoomProfileFragment @Inject constructor(
headerViews.roomProfileDecorationImageView.isVisible = it.roomEncryptionTrustLevel != null
headerViews.roomProfileDecorationImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
views.matrixProfileDecorationToolbarAvatarImageView.setImageResource(it.roomEncryptionTrustLevel.toImageRes())
headerViews.roomProfileAvatarView.setOnClickListener { view ->
onAvatarClicked(view, matrixItem)
}
views.matrixProfileToolbarAvatarImageView.setOnClickListener { view ->
onAvatarClicked(view, matrixItem)
}
}
}
roomProfileController.setData(state)
@ -269,6 +285,14 @@ class RoomProfileFragment @Inject constructor(
}
}
override fun onRoomAliasesClicked() {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomAliasesSettings)
}
override fun onRoomPermissionsClicked() {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomPermissionsSettings)
}
override fun onRoomIdClicked() {
copyToClipboard(requireContext(), roomProfileArgs.roomId)
}
@ -286,7 +310,9 @@ class RoomProfileFragment @Inject constructor(
)
}
private fun onAvatarClicked(view: View, matrixItem: MatrixItem.RoomItem) {
navigator.openBigImageViewer(requireActivity(), view, matrixItem)
private fun onAvatarClicked(view: View) = withState(roomProfileViewModel) { state ->
state.roomSummary()?.toMatrixItem()?.let { matrixItem ->
navigator.openBigImageViewer(requireActivity(), view, matrixItem)
}
}
}

View File

@ -45,8 +45,6 @@ class RoomSettingsController @Inject constructor(
fun onNameChanged(name: String)
fun onTopicChanged(topic: String)
fun onHistoryVisibilityClicked()
fun onRoomAliasesClicked()
fun onRoomPermissionsClicked()
fun onJoinRuleClicked()
}
@ -106,26 +104,6 @@ class RoomSettingsController @Inject constructor(
}
}
buildProfileAction(
id = "alias",
title = stringProvider.getString(R.string.room_settings_alias_title),
subtitle = stringProvider.getString(R.string.room_settings_alias_subtitle),
dividerColor = dividerColor,
divider = true,
editable = true,
action = { callback?.onRoomAliasesClicked() }
)
buildProfileAction(
id = "permissions",
title = stringProvider.getString(R.string.room_settings_permissions_title),
subtitle = stringProvider.getString(R.string.room_settings_permissions_subtitle),
dividerColor = dividerColor,
divider = true,
editable = true,
action = { callback?.onRoomPermissionsClicked() }
)
buildProfileAction(
id = "historyReadability",
title = stringProvider.getString(R.string.room_settings_room_read_history_rules_pref_title),

View File

@ -41,7 +41,6 @@ import im.vector.app.core.utils.toast
import im.vector.app.databinding.FragmentRoomSettingGenericBinding
import im.vector.app.features.home.AvatarRenderer
import im.vector.app.features.roomprofile.RoomProfileArgs
import im.vector.app.features.roomprofile.RoomProfileSharedAction
import im.vector.app.features.roomprofile.RoomProfileSharedActionViewModel
import im.vector.app.features.roomprofile.settings.historyvisibility.RoomHistoryVisibilitySharedActionViewModel
import im.vector.app.features.roomprofile.settings.historyvisibility.RoomHistoryVisibilityBottomSheet
@ -174,14 +173,6 @@ class RoomSettingsFragment @Inject constructor(
.show(childFragmentManager, "RoomHistoryVisibilityBottomSheet")
}
override fun onRoomAliasesClicked() {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomAliasesSettings)
}
override fun onRoomPermissionsClicked() {
roomProfileSharedActionViewModel.post(RoomProfileSharedAction.OpenRoomPermissionsSettings)
}
override fun onJoinRuleClicked() = withState(viewModel) { state ->
val currentJoinRule = state.newRoomJoinRules.newJoinRules ?: state.currentRoomJoinRules
val currentGuestAccess = state.newRoomJoinRules.newGuestAccess ?: state.currentGuestAccess