Merge pull request #1067 from vector-im/feature/roomId

Display internal id of a room section in room profile
This commit is contained in:
Benoit Marty 2020-02-25 12:22:14 +01:00 committed by GitHub
commit ec0cba2b23
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 0 deletions

View file

@ -25,10 +25,12 @@ import im.vector.riotx.core.epoxy.profiles.buildProfileSection
import im.vector.riotx.core.resources.ColorProvider import im.vector.riotx.core.resources.ColorProvider
import im.vector.riotx.core.resources.StringProvider import im.vector.riotx.core.resources.StringProvider
import im.vector.riotx.core.ui.list.genericFooterItem import im.vector.riotx.core.ui.list.genericFooterItem
import im.vector.riotx.features.settings.VectorPreferences
import javax.inject.Inject import javax.inject.Inject
class RoomProfileController @Inject constructor( class RoomProfileController @Inject constructor(
private val stringProvider: StringProvider, private val stringProvider: StringProvider,
private val vectorPreferences: VectorPreferences,
colorProvider: ColorProvider colorProvider: ColorProvider
) : TypedEpoxyController<RoomProfileViewState>() { ) : TypedEpoxyController<RoomProfileViewState>() {
@ -43,6 +45,7 @@ class RoomProfileController @Inject constructor(
fun onUploadsClicked() fun onUploadsClicked()
fun onSettingsClicked() fun onSettingsClicked()
fun onLeaveRoomClicked() fun onLeaveRoomClicked()
fun onRoomIdClicked()
} }
override fun buildModels(data: RoomProfileViewState?) { override fun buildModels(data: RoomProfileViewState?) {
@ -105,5 +108,19 @@ class RoomProfileController @Inject constructor(
editable = false, editable = false,
action = { callback?.onLeaveRoomClicked() } action = { callback?.onLeaveRoomClicked() }
) )
// Advanced
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),
subtitle = roomSummary.roomId,
dividerColor = dividerColor,
divider = false,
editable = false,
action = { callback?.onRoomIdClicked() }
)
}
} }
} }

View file

@ -36,6 +36,7 @@ import im.vector.riotx.core.extensions.configureWith
import im.vector.riotx.core.extensions.exhaustive import im.vector.riotx.core.extensions.exhaustive
import im.vector.riotx.core.extensions.setTextOrHide import im.vector.riotx.core.extensions.setTextOrHide
import im.vector.riotx.core.platform.VectorBaseFragment import im.vector.riotx.core.platform.VectorBaseFragment
import im.vector.riotx.core.utils.copyToClipboard
import im.vector.riotx.core.utils.startSharePlainTextIntent import im.vector.riotx.core.utils.startSharePlainTextIntent
import im.vector.riotx.features.crypto.util.toImageRes import im.vector.riotx.features.crypto.util.toImageRes
import im.vector.riotx.features.home.AvatarRenderer import im.vector.riotx.features.home.AvatarRenderer
@ -203,6 +204,10 @@ class RoomProfileFragment @Inject constructor(
.show() .show()
} }
override fun onRoomIdClicked() {
copyToClipboard(requireContext(), roomProfileArgs.roomId)
}
private fun onShareRoomProfile(permalink: String) { private fun onShareRoomProfile(permalink: String) {
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink) startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
} }