Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable-20.1] Feature/4378/add temporary messages while sending #4593

Closed
wants to merge 30 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
275ff1a
add referenceId for "normal" sending of chat message
mahibi Nov 6, 2024
d332e4d
use repository in MessageInputViewModel instead datasource
mahibi Nov 6, 2024
781f3a0
fixes after some wrong merge after merge conflict
mahibi Nov 21, 2024
e5972e6
WIP add temporary message
mahibi Nov 22, 2024
5a48422
temp message is added (values are still wrong)
mahibi Dec 4, 2024
f6bc459
WIP temp messages are replaced when same refId received from sever
mahibi Dec 4, 2024
4ac4c1c
update temp messages also for initial pull of messages
mahibi Dec 9, 2024
679bdc1
show x when sending failed
mahibi Dec 10, 2024
2e48ef7
works okay (no resend logic yet, offline message mode not reworked)
mahibi Dec 11, 2024
3db4e23
prepare to replace no-internet-connection message handling (sorry Jul…
mahibi Dec 11, 2024
79de729
replace CharSequence with String for sendChatMessage
mahibi Dec 15, 2024
8978e43
WIP add options to temp messages
mahibi Dec 20, 2024
4b56f47
fix after merge conflicts
mahibi Dec 27, 2024
7fdba91
resend queued messages when connection gained
mahibi Dec 27, 2024
c32ac1b
delete temp messages
mahibi Dec 27, 2024
4cf1395
add manual resend button
mahibi Dec 27, 2024
7d80059
add retry logic for sending messages, hide resend button when offline
mahibi Jan 2, 2025
1f128d6
revert ReadStatus SENDING and FAILED
mahibi Jan 2, 2025
2a7283a
simplify "sent messages are queued" hint
mahibi Jan 2, 2025
03c4cd5
Skip to send message when device is offline
mahibi Jan 2, 2025
202df6e
simplify to refresh message
mahibi Jan 2, 2025
320c9ee
adjust some pixels to avoid jump of message list
mahibi Jan 2, 2025
acbe840
delete roomId comments
mahibi Jan 2, 2025
86e4473
add logging for unread messages popup bug
mahibi Jan 3, 2025
fdbd394
fix to not accidentally show unread messages popup
mahibi Jan 3, 2025
0b0fee8
Fix duplicate "Today"-bug
mahibi Jan 3, 2025
8218151
resolve codacy/ktlint warnings
mahibi Jan 3, 2025
909e927
resolve warnings
mahibi Jan 3, 2025
9aa2c08
comment in opHelperFactory
mahibi Jan 6, 2025
94c7998
resolve detekt warnings
mahibi Jan 6, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
743 changes: 743 additions & 0 deletions app/schemas/com.nextcloud.talk.data.source.local.TalkDatabase/13.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import com.nextcloud.talk.application.NextcloudTalkApplication
import com.nextcloud.talk.application.NextcloudTalkApplication.Companion.sharedApplication
import com.nextcloud.talk.chat.ChatActivity
import com.nextcloud.talk.chat.data.model.ChatMessage
import com.nextcloud.talk.data.network.NetworkMonitor
import com.nextcloud.talk.databinding.ItemCustomOutcomingTextMessageBinding
import com.nextcloud.talk.models.json.chat.ReadStatus
import com.nextcloud.talk.ui.theme.ViewThemeUtils
Expand Down Expand Up @@ -58,8 +59,12 @@ class OutcomingTextMessageViewHolder(itemView: View) :
@Inject
lateinit var dateUtils: DateUtils

@Inject
lateinit var networkMonitor: NetworkMonitor

lateinit var commonMessageInterface: CommonMessageInterface

@Suppress("Detekt.LongMethod")
override fun onBind(message: ChatMessage) {
super.onBind(message)
sharedApplication!!.componentApplication.inject(this)
Expand All @@ -68,6 +73,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,
Expand Down Expand Up @@ -114,7 +120,28 @@ class OutcomingTextMessageViewHolder(itemView: View) :
binding.messageQuote.quotedChatMessageView.visibility = View.GONE
}

setReadStatus(message.readStatus)
CoroutineScope(Dispatchers.Main).launch {
if (message.isTemporary && !networkMonitor.isOnline.first()) {
updateStatus(
R.drawable.ic_signal_wifi_off_white_24dp,
"offline"
)
} else if (message.sendingFailed) {
updateStatus(
R.drawable.baseline_report_problem_24,
"failed"
)
binding.bubble.setOnClickListener {
commonMessageInterface.onOpenMessageActionsDialog(message)
}
} else if (message.isTemporary) {
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) {
updateStatus(R.drawable.ic_check, context.resources?.getString(R.string.nc_message_sent))
}
}

itemView.setTag(R.string.replyable_message_view_tag, message.replyable)

Expand All @@ -129,27 +156,23 @@ class OutcomingTextMessageViewHolder(itemView: View) :
)
}

private fun setReadStatus(readStatus: Enum<ReadStatus>) {
val readStatusDrawableInt = when (readStatus) {
ReadStatus.READ -> R.drawable.ic_check_all
ReadStatus.SENT -> R.drawable.ic_check
else -> null
}

val readStatusContentDescriptionString = when (readStatus) {
ReadStatus.READ -> context.resources?.getString(R.string.nc_message_read)
ReadStatus.SENT -> context.resources?.getString(R.string.nc_message_sent)
else -> null
}

readStatusDrawableInt?.let { drawableInt ->
private fun updateStatus(readStatusDrawableInt: Int, description: String?) {
binding.sendingProgress.visibility = View.GONE
binding.checkMark.visibility = View.VISIBLE
readStatusDrawableInt.let { drawableInt ->
ResourcesCompat.getDrawable(context.resources, drawableInt, null)?.let {
binding.checkMark.setImageDrawable(it)
viewThemeUtils.talk.themeMessageCheckMark(binding.checkMark)
}
}
binding.checkMark.contentDescription = description
}

private fun showSendingSpinner() {
binding.sendingProgress.visibility = View.VISIBLE
binding.checkMark.visibility = View.GONE

binding.checkMark.contentDescription = readStatusContentDescriptionString
viewThemeUtils.material.colorProgressBar(binding.sendingProgress)
}

private fun longClickOnReaction(chatMessage: ChatMessage) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,6 @@ public void onBindViewHolder(ViewHolder holder, int position) {
} else if (holder instanceof SystemMessageViewHolder holderInstance) {
holderInstance.assignSystemMessageInterface(chatActivity);

} else if (holder instanceof TemporaryMessageViewHolder holderInstance) {
holderInstance.assignTemporaryMessageInterface(chatActivity);

} else if (holder instanceof IncomingDeckCardViewHolder holderInstance) {
holderInstance.assignCommonMessageInterface(chatActivity);
} else if (holder instanceof OutcomingDeckCardViewHolder holderInstance) {
Expand Down

This file was deleted.

This file was deleted.

12 changes: 4 additions & 8 deletions app/src/main/java/com/nextcloud/talk/api/NcApi.java
Original file line number Diff line number Diff line change
Expand Up @@ -344,18 +344,14 @@ Observable<Response<ChatOverall>> pullChatMessages(@Header("Authorization") Stri

@FormUrlEncoded
@POST
Observable<GenericOverall> sendChatMessage(@Header("Authorization") String authorization,
Observable<ChatOverallSingleMessage> sendChatMessage(@Header("Authorization") String authorization,
@Url String url,
@Field("message") CharSequence message,
@Field("actorDisplayName") String actorDisplayName,
@Field("replyTo") Integer replyTo,
@Field("silent") Boolean sendWithoutNotification);

@FormUrlEncoded
@PUT
Observable<ChatOverallSingleMessage> editChatMessage(@Header("Authorization") String authorization,
@Url String url,
@Field("message") String message);
@Field("silent") Boolean sendWithoutNotification,
@Field("referenceId") String referenceId
);

@GET
Observable<Response<ChatShareOverall>> getSharedItems(
Expand Down
23 changes: 23 additions & 0 deletions app/src/main/java/com/nextcloud/talk/api/NcApiCoroutines.kt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
package com.nextcloud.talk.api

import com.nextcloud.talk.models.json.autocomplete.AutocompleteOverall
import com.nextcloud.talk.models.json.chat.ChatOverallSingleMessage
import com.nextcloud.talk.models.json.conversations.RoomOverall
import com.nextcloud.talk.models.json.generic.GenericOverall
import com.nextcloud.talk.models.json.participants.AddParticipantOverall
Expand All @@ -29,6 +30,7 @@ import retrofit2.http.Query
import retrofit2.http.QueryMap
import retrofit2.http.Url

@Suppress("TooManyFunctions")
interface NcApiCoroutines {
@GET
@JvmSuppressWildcards
Expand Down Expand Up @@ -121,6 +123,27 @@ interface NcApiCoroutines {
@DELETE
suspend fun unarchiveConversation(@Header("Authorization") authorization: String, @Url url: String): GenericOverall

@Suppress("LongParameterList")
@FormUrlEncoded
@POST
suspend fun sendChatMessage(
@Header("Authorization") authorization: String,
@Url url: String,
@Field("message") message: String,
@Field("actorDisplayName") actorDisplayName: String,
@Field("replyTo") replyTo: Int,
@Field("silent") sendWithoutNotification: Boolean,
@Field("referenceId") referenceId: String
): ChatOverallSingleMessage

@FormUrlEncoded
@PUT
suspend fun editChatMessage(
@Header("Authorization") authorization: String,
@Url url: String,
@Field("message") message: String
): ChatOverallSingleMessage

@FormUrlEncoded
@POST
suspend fun banActor(
Expand Down
Loading