diff --git a/app/src/main/java/org/futo/circles/feature/room/well_known/RoomWellKnownDialogFragment.kt b/app/src/main/java/org/futo/circles/feature/room/well_known/RoomWellKnownDialogFragment.kt index 70ffa836dbb7f7425de6eb32f9461815abd6e697..4559d3e1a515df535cf8321170e2ba8680e38962 100644 --- a/app/src/main/java/org/futo/circles/feature/room/well_known/RoomWellKnownDialogFragment.kt +++ b/app/src/main/java/org/futo/circles/feature/room/well_known/RoomWellKnownDialogFragment.kt @@ -14,6 +14,7 @@ import org.futo.circles.core.extensions.observeResponse import org.futo.circles.core.extensions.onBackPressed import org.futo.circles.core.extensions.setIsVisible import org.futo.circles.core.extensions.showSuccess +import org.futo.circles.core.model.ShareUrlTypeArg import org.futo.circles.databinding.DialogFragmentRoomWellKnownBinding import org.futo.circles.model.RoomPublicInfo import org.futo.circles.model.isProfile @@ -69,26 +70,18 @@ class RoomWellKnownDialogFragment : binding.tvRoomName.text = message } - private fun bindGeneralData( - url: String?, - name: String, - membership: Membership - ) { - with(binding) { - ivCover.setIsVisible(!url.isNullOrBlank()) - url?.let { ivCover.loadProfileIcon(url, name) } - tvRoomName.text = name - btnRequest.setIsVisible(shouldShowKnockButton(membership)) - } - } private fun bindRoomData(roomInfo: RoomPublicInfo) { with(binding) { - bindGeneralData( - roomInfo.avatarUrl, - roomInfo.displayName, - roomInfo.membership - ) + ivCover.apply { + setIsVisible(roomInfo.avatarUrl != null || roomInfo.name != null) + loadProfileIcon(roomInfo.avatarUrl, roomInfo.name ?: "") + } + tvRoomName.apply { + setIsVisible(roomInfo.name != null) + text = roomInfo.name + } + btnRequest.setIsVisible(shouldShowKnockButton(roomInfo.membership)) binding.tvRoomId.text = roomInfo.id tvMembersCount.apply { setIsVisible(roomInfo.memberCount > 0) @@ -98,8 +91,14 @@ class RoomWellKnownDialogFragment : ) } btnRequest.setText(getString(if (roomInfo.isProfile()) R.string.request_to_follow else R.string.request_to_join)) - tvTopic.setIsVisible(roomInfo.topic?.isNotEmpty() == true) - tvTopic.text = roomInfo.topic ?: "" + tvTopic.apply { + setIsVisible(roomInfo.topic?.isNotEmpty() == true) + text = getString(R.string.topic_format, roomInfo.topic ?: "") + } + tvType.apply { + setIsVisible(roomInfo.type != ShareUrlTypeArg.ROOM) + text = getString(R.string.room_type_format, roomInfo.type.typeKey) + } tvMembersip.text = getString( when (roomInfo.membership) { Membership.NONE, diff --git a/app/src/main/java/org/futo/circles/model/RoomPublicInfo.kt b/app/src/main/java/org/futo/circles/model/RoomPublicInfo.kt index 076e4244bb9e8666e9fe6043f5bbc76b0375cdfe..c0bf84cd48aad785fd0206d34fa026873f9ecc42 100644 --- a/app/src/main/java/org/futo/circles/model/RoomPublicInfo.kt +++ b/app/src/main/java/org/futo/circles/model/RoomPublicInfo.kt @@ -8,7 +8,7 @@ import org.matrix.android.sdk.api.session.room.peeking.PeekResult data class RoomPublicInfo( val id: String, - val displayName: String, + val name: String?, val avatarUrl: String?, val topic: String?, val memberCount: Int, @@ -20,7 +20,7 @@ fun RoomPublicInfo.isProfile() = type == ShareUrlTypeArg.PROFILE fun RoomSummary.toRoomPublicInfo(urlType: ShareUrlTypeArg) = RoomPublicInfo( id = roomId, - displayName = nameOrId(), + name = name, avatarUrl = avatarUrl, topic = topic, memberCount = joinedMembersCount ?: 0, @@ -30,7 +30,7 @@ fun RoomSummary.toRoomPublicInfo(urlType: ShareUrlTypeArg) = RoomPublicInfo( fun PeekResult.Success.toRoomPublicInfo(urlType: ShareUrlTypeArg) = RoomPublicInfo( id = roomId, - displayName = name?.takeIf { it.isNotEmpty() } ?: roomId, + name = name, avatarUrl = avatarUrl, topic = topic, memberCount = numJoinedMembers ?: 0, @@ -40,7 +40,7 @@ fun PeekResult.Success.toRoomPublicInfo(urlType: ShareUrlTypeArg) = RoomPublicIn fun RoomUrlData.toRoomPublicInfo() = RoomPublicInfo( id = roomId, - displayName = type.typeKey, + name = null, avatarUrl = null, topic = null, memberCount = 0, diff --git a/app/src/main/res/layout/dialog_fragment_room_well_known.xml b/app/src/main/res/layout/dialog_fragment_room_well_known.xml index 783701331f5d4d9098d39ee0627372a5511f13a5..a5d65439daffe2dc9022c1dce7f3aba21b45de3a 100644 --- a/app/src/main/res/layout/dialog_fragment_room_well_known.xml +++ b/app/src/main/res/layout/dialog_fragment_room_well_known.xml @@ -14,8 +14,8 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" app:navigationIcon="?attr/homeAsUpIndicator" - app:titleCentered="true" - app:title="URL info" /> + app:title="URL info" + app:titleCentered="true" /> <View @@ -74,6 +74,19 @@ app:layout_constraintTop_toBottomOf="@id/tvRoomName" tools:text="Aasdsadasdsaf" /> + <TextView + android:id="@+id/tvType" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginHorizontal="36dp" + android:layout_marginTop="8dp" + android:gravity="center" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toBottomOf="@id/tvRoomId" + tools:text="Type: " + tools:visibility="visible" /> + <TextView android:id="@+id/tvTopic" android:layout_width="0dp" @@ -84,7 +97,7 @@ android:visibility="gone" app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toBottomOf="@id/tvRoomId" + app:layout_constraintTop_toBottomOf="@id/tvType" tools:text="Topic: " tools:visibility="visible" /> diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 8bd9821ae14c70b0c54cb27eae0f172f66c6e9f1..2f413c5cb3b5fa8210db98dc4ca7b2de1379874e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -30,6 +30,8 @@ <string name="log_out">Log out</string> <string name="others">Others</string> <string name="following_format">Following %d</string> + <string name="room_type_format">Room type: %s</string> + <string name="topic_format">Topic: %s</string> <string name="followed_by_format">Followed by %d</string> <string name="requests_format">Requests %d</string> <string name="create_post">Create post</string>