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

Feature/4378/add temporary messages while sending #4422

Merged
merged 40 commits into from
Jan 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
9cb40d4
add referenceId for "normal" sending of chat message
mahibi Nov 6, 2024
3597cf2
use repository in MessageInputViewModel instead datasource
mahibi Nov 6, 2024
c33bd99
fixes after some wrong merge after merge conflict
mahibi Nov 21, 2024
80d2e75
WIP add temporary message
mahibi Nov 22, 2024
048551e
temp message is added (values are still wrong)
mahibi Dec 4, 2024
0e682ed
WIP temp messages are replaced when same refId received from sever
mahibi Dec 4, 2024
a78c9e1
update temp messages also for initial pull of messages
mahibi Dec 9, 2024
e1c1574
show x when sending failed
mahibi Dec 10, 2024
3f5f2f0
works okay (no resend logic yet, offline message mode not reworked)
mahibi Dec 11, 2024
0f53244
prepare to replace no-internet-connection message handling (sorry Jul…
mahibi Dec 11, 2024
ec466e5
replace CharSequence with String for sendChatMessage
mahibi Dec 15, 2024
1bfb3ba
WIP add options to temp messages
mahibi Dec 20, 2024
f88b1f1
fix after merge conflicts
mahibi Dec 27, 2024
5ac130a
resend queued messages when connection gained
mahibi Dec 27, 2024
e9f3863
delete temp messages
mahibi Dec 27, 2024
2c397ad
add manual resend button
mahibi Dec 27, 2024
06c8509
add retry logic for sending messages, hide resend button when offline
mahibi Jan 2, 2025
656be3f
revert ReadStatus SENDING and FAILED
mahibi Jan 2, 2025
f62941f
simplify "sent messages are queued" hint
mahibi Jan 2, 2025
cca4e69
Skip to send message when device is offline
mahibi Jan 2, 2025
7d9c2fd
simplify to refresh message
mahibi Jan 2, 2025
a5049fb
adjust some pixels to avoid jump of message list
mahibi Jan 2, 2025
b529d13
delete roomId comments
mahibi Jan 2, 2025
29362fa
add logging for unread messages popup bug
mahibi Jan 3, 2025
0356f5a
fix to not accidentally show unread messages popup
mahibi Jan 3, 2025
8f1f22f
Fix duplicate "Today"-bug
mahibi Jan 3, 2025
ab007fc
resolve codacy/ktlint warnings
mahibi Jan 3, 2025
3dca00b
resolve warnings
mahibi Jan 3, 2025
560f955
comment in opHelperFactory
mahibi Jan 6, 2025
a58607b
resolve detekt warnings
mahibi Jan 6, 2025
4c79513
add DB migration
mahibi Jan 6, 2025
3fdaa4b
fix parent message for temp messages
mahibi Jan 6, 2025
f665b1c
save "silent" in chat messages (incl DB)
mahibi Jan 6, 2025
1731ca0
remove flickering of status icons
mahibi Jan 6, 2025
1504e51
add strings for message status icons
mahibi Jan 6, 2025
3094054
change visibility of temp message actions
mahibi Jan 6, 2025
aa5b4d0
remove click listener for failed messages (use default longclick)
mahibi Jan 6, 2025
68065d7
fix lint warning
mahibi Jan 6, 2025
cd09636
change icons for message sending and messages sending failed
mahibi Jan 10, 2025
4f4ac5e
Analysis: update lint results to reflect reduced error/warning count
invalid-email-address Jan 10, 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
749 changes: 749 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 @@ -218,7 +218,6 @@ class IncomingTextMessageViewHolder(itemView: View, payload: Any) :
)

binding.messageQuote.quotedChatMessageView.setOnClickListener {
val chatActivity = commonMessageInterface as ChatActivity
chatActivity.jumpToQuotedMessage(parentChatMessage)
}
} catch (e: Exception) {
Expand Down
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,27 @@ class OutcomingTextMessageViewHolder(itemView: View) :
binding.messageQuote.quotedChatMessageView.visibility = View.GONE
}

setReadStatus(message.readStatus)
binding.checkMark.visibility = View.INVISIBLE
binding.sendingProgress.visibility = View.GONE

if (message.sendingFailed) {
updateStatus(R.drawable.baseline_error_outline_24, context.resources?.getString(R.string.nc_message_failed))
} else if (message.isTemporary) {
updateStatus(R.drawable.baseline_schedule_24, context.resources?.getString(R.string.nc_message_sending))
} 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))
}

CoroutineScope(Dispatchers.Main).launch {
if (message.isTemporary && !networkMonitor.isOnline.first()) {
updateStatus(
R.drawable.ic_signal_wifi_off_white_24dp,
context.resources?.getString(R.string.nc_message_offline)
)
}
}

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

Expand All @@ -129,27 +155,16 @@ 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 = readStatusContentDescriptionString
binding.checkMark.contentDescription = description
}

private fun longClickOnReaction(chatMessage: ChatMessage) {
Expand Down Expand Up @@ -180,7 +195,7 @@ class OutcomingTextMessageViewHolder(itemView: View) :
).first()
}

parentChatMessage!!.activeUser = message.activeUser
parentChatMessage.activeUser = message.activeUser
parentChatMessage.imageUrl?.let {
binding.messageQuote.quotedMessageImage.visibility = View.VISIBLE
binding.messageQuote.quotedMessageImage.load(it) {
Expand All @@ -207,7 +222,6 @@ class OutcomingTextMessageViewHolder(itemView: View) :
viewThemeUtils.talk.colorOutgoingQuoteBackground(binding.messageQuote.quoteColoredView)

binding.messageQuote.quotedChatMessageView.setOnClickListener {
val chatActivity = commonMessageInterface as ChatActivity
chatActivity.jumpToQuotedMessage(parentChatMessage)
}
} catch (e: Exception) {
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
Loading
Loading