Display internal id of a room section in room profile, with copy to clipboard action, only in developer mode

This commit is contained in:
Benoit Marty 2020-02-25 12:03:14 +01:00
parent 68400cce03
commit cfe9c4bb41
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.StringProvider
import im.vector.riotx.core.ui.list.genericFooterItem
import im.vector.riotx.features.settings.VectorPreferences
import javax.inject.Inject
class RoomProfileController @Inject constructor(
private val stringProvider: StringProvider,
private val vectorPreferences: VectorPreferences,
colorProvider: ColorProvider
) : TypedEpoxyController<RoomProfileViewState>() {
@ -43,6 +45,7 @@ class RoomProfileController @Inject constructor(
fun onUploadsClicked()
fun onSettingsClicked()
fun onLeaveRoomClicked()
fun onRoomIdClicked()
}
override fun buildModels(data: RoomProfileViewState?) {
@ -105,5 +108,19 @@ class RoomProfileController @Inject constructor(
editable = false,
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.setTextOrHide
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.features.crypto.util.toImageRes
import im.vector.riotx.features.home.AvatarRenderer
@ -203,6 +204,10 @@ class RoomProfileFragment @Inject constructor(
.show()
}
override fun onRoomIdClicked() {
copyToClipboard(requireContext(), roomProfileArgs.roomId)
}
private fun onShareRoomProfile(permalink: String) {
startSharePlainTextIntent(fragment = this, chooserTitle = null, text = permalink)
}