Skip to content

Commit

Permalink
added ui
Browse files Browse the repository at this point in the history
Signed-off-by: rapterjet2004 <[email protected]>
  • Loading branch information
rapterjet2004 committed Sep 19, 2024
1 parent 1c55439 commit b4bd162
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
10 changes: 10 additions & 0 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -529,6 +529,16 @@ class ChatActivity :
private fun initObservers() {
Log.d(TAG, "initObservers Called")

messageInputViewModel.messageQueueFlow.observe(this) { message ->
// TODO shouldn't be able save state
val temporaryChatMessage = ChatMessage()
temporaryChatMessage.jsonMessageId = -3
temporaryChatMessage.actorId = "-3"
temporaryChatMessage.timestamp = (adapter?.items?.get(0)?.item as ChatMessage).timestamp
temporaryChatMessage.message = message
adapter?.addToStart(temporaryChatMessage, true)
}

this.lifecycleScope.launch {
chatViewModel.getConversationFlow
.onEach { conversationModel ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@ class MessageInputViewModel @Inject constructor(
val messageQueueSizeFlow: LiveData<Int>
get() = _messageQueueSizeFlow.asLiveData()

private val _messageQueueFlow: MutableLiveData<String> = MutableLiveData()
val messageQueueFlow: LiveData<String>
get() = _messageQueueFlow

@Suppress("LongParameterList")
fun sendChatMessage(
roomToken: String,
Expand All @@ -138,6 +142,7 @@ class MessageInputViewModel @Inject constructor(
messageQueue.add(QueuedMessage(message, displayName, replyTo, sendWithoutNotification))
dataStore.saveMessageQueue(roomToken, messageQueue)
_messageQueueSizeFlow.update { messageQueue.size }
_messageQueueFlow.postValue(message.toString())
return
}

Expand Down Expand Up @@ -274,6 +279,6 @@ class MessageInputViewModel @Inject constructor(

companion object {
private val TAG = MessageInputViewModel::class.java.simpleName
private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 100
private const val DELAY_BETWEEN_QUEUED_MESSAGES: Long = 500
}
}
8 changes: 8 additions & 0 deletions app/src/main/res/layout/item_temporary_message.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
android:layout_marginRight="16dp"
android:layout_marginBottom="2dp">

<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/ic_signal_wifi_off_white_24dp"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/standard_margin"
app:tint="@color/hwSecurityRed" />

<com.google.android.flexbox.FlexboxLayout
android:id="@id/bubble"
android:layout_width="wrap_content"
Expand Down

0 comments on commit b4bd162

Please sign in to comment.