Refactor code

Signed-off-by: sowjanyakch <sowjanya.kch@gmail.com>
This commit is contained in:
sowjanyakch 2024-05-10 11:18:02 +02:00 committed by Marcel Hibbe
parent f0670f9f15
commit ed5a12b7da
No known key found for this signature in database
GPG key ID: C793F8B59F43CE7B
2 changed files with 17 additions and 22 deletions

View file

@ -3474,41 +3474,36 @@ class ChatActivity :
"" ""
} }
val statusMessageView = binding.chatToolbar.findViewById<TextView>(R.id.chat_toolbar_status_message)
if (currentConversation?.type == ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) { if (currentConversation?.type == ConversationType.ROOM_TYPE_ONE_TO_ONE_CALL) {
var statusMessage = "" var statusMessage = ""
if (currentConversation?.statusIcon != null) { if (currentConversation?.statusIcon != null) {
statusMessage += currentConversation?.statusIcon statusMessage += currentConversation?.statusIcon
} }
if (currentConversation?.statusMessage != null) { if (currentConversation?.statusMessage != null) {
statusMessage += currentConversation?.statusMessage statusMessage += currentConversation?.statusMessage
} }
statusMessageViewContents(statusMessage)
if (statusMessage.isNotEmpty()) {
viewThemeUtils.platform.colorTextView(statusMessageView, ColorRole.ON_SURFACE)
statusMessageView.text = statusMessage
statusMessageView.visibility = View.VISIBLE
} else { } else {
statusMessageView.visibility = View.GONE
}
} else {
var descriptionMessage = ""
if (currentConversation?.type == ConversationType.ROOM_GROUP_CALL || if (currentConversation?.type == ConversationType.ROOM_GROUP_CALL ||
currentConversation?.type == ConversationType.ROOM_PUBLIC_CALL currentConversation?.type == ConversationType.ROOM_PUBLIC_CALL
) { ) {
var descriptionMessage = ""
descriptionMessage += currentConversation?.description descriptionMessage += currentConversation?.description
statusMessageViewContents(descriptionMessage)
}
}
}
if (descriptionMessage.isNotEmpty()) { private fun statusMessageViewContents(statusMessageContent: String) {
val statusMessageView = binding.chatToolbar.findViewById<TextView>(R.id.chat_toolbar_status_message)
if (statusMessageContent.isNotEmpty()) {
viewThemeUtils.platform.colorTextView(statusMessageView, ColorRole.ON_SURFACE) viewThemeUtils.platform.colorTextView(statusMessageView, ColorRole.ON_SURFACE)
statusMessageView.text = descriptionMessage statusMessageView.text = statusMessageContent
statusMessageView.visibility = View.VISIBLE statusMessageView.visibility = View.VISIBLE
} else { } else {
statusMessageView.visibility = View.GONE statusMessageView.visibility = View.GONE
} }
} }
}
}
public override fun onDestroy() { public override fun onDestroy() {
super.onDestroy() super.onDestroy()

View file

@ -40,13 +40,13 @@
android:lines="1" android:lines="1"
android:textAlignment="viewStart" android:textAlignment="viewStart"
android:textColor="@color/low_emphasis_text" android:textColor="@color/low_emphasis_text"
android:textSize="14sp" android:textSize="13sp"
tools:text="Jane Doe" /> tools:text="Jane Doe" />
<ImageView <ImageView
android:id="@+id/avatar_view" android:id="@+id/avatar_view"
android:layout_width="60dp" android:layout_width="52dp"
android:layout_height="60dp" android:layout_height="52dp"
android:layout_centerVertical="true" android:layout_centerVertical="true"
android:layout_marginEnd="@dimen/standard_margin" android:layout_marginEnd="@dimen/standard_margin"
android:contentDescription="@string/avatar" /> android:contentDescription="@string/avatar" />