mirror of
https://github.com/nextcloud/talk-android
synced 2025-06-19 11:39:42 +01:00
replace CharSequence with String for sendChatMessage
Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
parent
0f53244652
commit
ec466e58f0
@ -14,7 +14,6 @@ import android.util.Log
|
||||
import android.util.TypedValue
|
||||
import android.view.View
|
||||
import androidx.core.content.res.ResourcesCompat
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import autodagger.AutoInjector
|
||||
import coil.load
|
||||
import com.google.android.flexbox.FlexboxLayout
|
||||
@ -73,6 +72,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
layoutParams.isWrapBefore = false
|
||||
var textSize = context.resources.getDimension(R.dimen.chat_text_size)
|
||||
viewThemeUtils.platform.colorTextView(binding.messageTime, ColorRole.ON_SURFACE_VARIANT)
|
||||
|
||||
var processedMessageText = messageUtils.enrichChatMessageText(
|
||||
binding.messageText.context,
|
||||
message,
|
||||
@ -121,18 +121,20 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
|
||||
|
||||
CoroutineScope(Dispatchers.Main).launch {
|
||||
if (message.sendingFailed) {
|
||||
updateStatus(
|
||||
R.drawable.baseline_report_problem_24,
|
||||
"failed"
|
||||
)
|
||||
} else if (message.isTempMessage && !networkMonitor.isOnline.first()) {
|
||||
// if (message.sendingFailed) {
|
||||
// updateStatus(
|
||||
// R.drawable.baseline_report_problem_24,
|
||||
// "failed"
|
||||
// )
|
||||
// } else
|
||||
|
||||
if (message.isTempMessage && !networkMonitor.isOnline.first()) {
|
||||
updateStatus(
|
||||
R.drawable.ic_signal_wifi_off_white_24dp,
|
||||
"offline"
|
||||
)
|
||||
} else if (message.isTempMessage) {
|
||||
updateSendingStatus()
|
||||
showSendingSpinner()
|
||||
} else if(message.readStatus == ReadStatus.READ){
|
||||
updateStatus(R.drawable.ic_check_all, context.resources?.getString(R.string.nc_message_read))
|
||||
} else if(message.readStatus == ReadStatus.SENT) {
|
||||
@ -165,7 +167,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
|
||||
binding.checkMark.contentDescription = description
|
||||
}
|
||||
|
||||
private fun updateSendingStatus() {
|
||||
private fun showSendingSpinner() {
|
||||
binding.sendingProgress.visibility = View.VISIBLE
|
||||
binding.checkMark.visibility = View.GONE
|
||||
|
||||
|
@ -128,7 +128,7 @@ interface NcApiCoroutines {
|
||||
suspend fun sendChatMessage(
|
||||
@Header("Authorization") authorization: String,
|
||||
@Url url: String,
|
||||
@Field("message") message: CharSequence,
|
||||
@Field("message") message: String,
|
||||
@Field("actorDisplayName") actorDisplayName: String,
|
||||
@Field("replyTo") replyTo: Int,
|
||||
@Field("silent") sendWithoutNotification: Boolean,
|
||||
|
@ -867,7 +867,7 @@ class MessageInputFragment : Fragment() {
|
||||
.findViewById<RelativeLayout>(R.id.quotedChatMessageView)?.tag as Int? ?: 0
|
||||
|
||||
sendMessage(
|
||||
editable,
|
||||
editable.toString(),
|
||||
replyMessageId,
|
||||
sendWithoutNotification
|
||||
)
|
||||
@ -875,7 +875,7 @@ class MessageInputFragment : Fragment() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun sendMessage(message: CharSequence, replyTo: Int?, sendWithoutNotification: Boolean) {
|
||||
private fun sendMessage(message: String, replyTo: Int?, sendWithoutNotification: Boolean) {
|
||||
chatActivity.messageInputViewModel.sendChatMessage(
|
||||
conversationInternalId,
|
||||
chatActivity.conversationUser!!.getCredentials(),
|
||||
|
@ -82,7 +82,7 @@ interface ChatMessageRepository : LifecycleAwareManager {
|
||||
suspend fun sendChatMessage(
|
||||
credentials: String,
|
||||
url: String,
|
||||
message: CharSequence,
|
||||
message: String,
|
||||
displayName: String,
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean,
|
||||
|
@ -53,7 +53,7 @@ interface ChatNetworkDataSource {
|
||||
suspend fun sendChatMessage(
|
||||
credentials: String,
|
||||
url: String,
|
||||
message: CharSequence,
|
||||
message: String,
|
||||
displayName: String,
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean,
|
||||
|
@ -13,6 +13,10 @@ import android.util.Log
|
||||
import com.nextcloud.talk.chat.ChatActivity
|
||||
import com.nextcloud.talk.chat.data.ChatMessageRepository
|
||||
import com.nextcloud.talk.chat.data.model.ChatMessage
|
||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel
|
||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel.Companion
|
||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel.SendChatMessageErrorState
|
||||
import com.nextcloud.talk.chat.viewmodels.MessageInputViewModel.SendChatMessageSuccessState
|
||||
import com.nextcloud.talk.data.database.dao.ChatBlocksDao
|
||||
import com.nextcloud.talk.data.database.dao.ChatMessagesDao
|
||||
import com.nextcloud.talk.data.database.mappers.asEntity
|
||||
@ -185,7 +189,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
limit
|
||||
)
|
||||
if (list.isNotEmpty()) {
|
||||
updateUiMessages(
|
||||
handleNewAndTempMessages(
|
||||
receivedChatMessages = list,
|
||||
lookIntoFuture = false,
|
||||
showUnreadMessagesMarker = false
|
||||
@ -307,7 +311,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
val weHaveMessagesFromOurself = chatMessages.any { it.actorId == currentUser.userId }
|
||||
showUnreadMessagesMarker = showUnreadMessagesMarker && !weHaveMessagesFromOurself
|
||||
|
||||
updateUiMessages(
|
||||
handleNewAndTempMessages(
|
||||
receivedChatMessages = chatMessages,
|
||||
lookIntoFuture = true,
|
||||
showUnreadMessagesMarker = showUnreadMessagesMarker
|
||||
@ -334,7 +338,33 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
private suspend fun updateUiMessages(
|
||||
// TODO replace with WorkManager?
|
||||
// private suspend fun tryToSendPendingMessages() {
|
||||
// val tempMessages = chatDao.getTempMessagesForConversation(internalConversationId).first()
|
||||
//
|
||||
// tempMessages.forEach {
|
||||
// Log.d(TAG, "Sending chat message ${it.message} another time!!")
|
||||
//
|
||||
// sendChatMessage(
|
||||
// credentials,
|
||||
// urlForChatting,
|
||||
// it.message,
|
||||
// it.actorDisplayName,
|
||||
// it.parentMessageId?.toInt() ?: 0,
|
||||
// false,
|
||||
// it.referenceId ?: ""
|
||||
// ).collect { result ->
|
||||
// if (result.isSuccess) {
|
||||
// Log.d(TAG, "success. received ref id: " + (result.getOrNull()?.referenceId ?: "none"))
|
||||
//
|
||||
// } else {
|
||||
// Log.d(TAG, "fail. received ref id: " + (result.getOrNull()?.referenceId ?: "none"))
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
private suspend fun handleNewAndTempMessages(
|
||||
receivedChatMessages : List<ChatMessage>,
|
||||
lookIntoFuture: Boolean,
|
||||
showUnreadMessagesMarker: Boolean
|
||||
@ -792,7 +822,7 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
override suspend fun sendChatMessage(
|
||||
credentials: String,
|
||||
url: String,
|
||||
message: CharSequence,
|
||||
message: String,
|
||||
displayName: String,
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean,
|
||||
@ -820,11 +850,11 @@ class OfflineFirstChatRepository @Inject constructor(
|
||||
failedMessage.sendingFailed = true
|
||||
chatDao.updateChatMessage(failedMessage)
|
||||
|
||||
val failedMessageModel = failedMessage.asModel()
|
||||
_removeMessageFlow.emit(failedMessageModel)
|
||||
|
||||
val tripleChatMessages = Triple(true, false, listOf(failedMessageModel))
|
||||
_messageFlow.emit(tripleChatMessages)
|
||||
// val failedMessageModel = failedMessage.asModel()
|
||||
// _removeMessageFlow.emit(failedMessageModel)
|
||||
//
|
||||
// val tripleChatMessages = Triple(true, false, listOf(failedMessageModel))
|
||||
// _messageFlow.emit(tripleChatMessages)
|
||||
|
||||
emit(Result.failure(e))
|
||||
}
|
||||
|
@ -144,7 +144,7 @@ class RetrofitChatNetwork(
|
||||
override suspend fun sendChatMessage(
|
||||
credentials: String,
|
||||
url: String,
|
||||
message: CharSequence,
|
||||
message: String,
|
||||
displayName: String,
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean,
|
||||
|
@ -146,7 +146,7 @@ class MessageInputViewModel @Inject constructor(
|
||||
internalId: String,
|
||||
credentials: String,
|
||||
url: String,
|
||||
message: CharSequence,
|
||||
message: String,
|
||||
displayName: String,
|
||||
replyTo: Int,
|
||||
sendWithoutNotification: Boolean
|
||||
|
@ -79,13 +79,6 @@
|
||||
android:textIsSelectable="false"
|
||||
tools:text="Talk to you later!" />
|
||||
|
||||
<!-- <com.google.android.material.textfield.TextInputEditText-->
|
||||
<!-- android:id="@+id/message_edit"-->
|
||||
<!-- android:layout_width="match_parent"-->
|
||||
<!-- android:layout_height="wrap_content"-->
|
||||
<!-- android:visibility="gone"-->
|
||||
<!-- tools:visibility="visible"/>-->
|
||||
|
||||
<TextView
|
||||
android:id="@id/messageTime"
|
||||
android:layout_width="wrap_content"
|
||||
|
Loading…
Reference in New Issue
Block a user