voice messages that are played for at least a threshold are coloured differently

Signed-off-by: Giacomo Pacini <giacomopacini98@gmail.com>
This commit is contained in:
Giacomo Pacini 2024-12-15 22:18:10 +01:00
parent c754ce48d4
commit c0948ba478
No known key found for this signature in database
GPG Key ID: 2FBC97406B43D889
9 changed files with 24 additions and 7 deletions

View File

@ -50,7 +50,8 @@ public class IncomingPreviewMessageViewHolder extends PreviewMessageViewHolder {
message,
true,
viewThemeUtils);
viewThemeUtils.talk.themeIncomingMessageBubble(binding.incomingPreviewMessageBubble, true, false);
viewThemeUtils.talk.themeIncomingMessageBubble(binding.incomingPreviewMessageBubble, true, false,
false);
}
if (processedMessageText != null) {

View File

@ -279,7 +279,7 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
}
private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted)
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted, message.wasPlayedVoiceMessage)
}
@Suppress("Detekt.TooGenericExceptionCaught")

View File

@ -50,7 +50,8 @@ public class OutcomingPreviewMessageViewHolder extends PreviewMessageViewHolder
message,
false,
viewThemeUtils);
viewThemeUtils.talk.themeOutgoingMessageBubble(binding.outgoingPreviewMessageBubble, true, false);
viewThemeUtils.talk.themeOutgoingMessageBubble(binding.outgoingPreviewMessageBubble, true, false,
false);
}
if (processedMessageText != null) {

View File

@ -342,7 +342,7 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
}
private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeOutgoingMessageBubble(bubble, message.isGrouped, message.isDeleted)
viewThemeUtils.talk.themeOutgoingMessageBubble(bubble, message.isGrouped, message.isDeleted, message.wasPlayedVoiceMessage)
}
fun assignVoiceMessageInterface(voiceMessageInterface: VoiceMessageInterface) {

View File

@ -1644,6 +1644,11 @@ class ChatActivity :
lastRecordMediaPosition = mediaPlayer!!.currentPosition
message.voiceMessagePlayedSeconds = pos
message.voiceMessageSeekbarProgress = mediaPlayer!!.currentPosition
if(mediaPlayer!!.currentPosition * 20 > mediaPlayer!!.duration){
// a voice message is marked as played when the mediaplayer position
// is at least at 5% of its duration
message.wasPlayedVoiceMessage = true
}
adapter?.update(message)
} else {
message.resetVoiceMessage = true

View File

@ -91,6 +91,8 @@ data class ChatMessage(
var isPlayingVoiceMessage: Boolean = false,
var wasPlayedVoiceMessage : Boolean = false,
var voiceMessageDuration: Int = 0,
var voiceMessagePlayedSeconds: Int = 0,

View File

@ -70,7 +70,7 @@ class TalkSpecificViewThemeUtils @Inject constructor(
) :
ViewThemeUtilsBase(schemes) {
private val dynamicColor = MaterialDynamicColors()
fun themeIncomingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) {
fun themeIncomingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean, isPlayed: Boolean = false) {
val resources = bubble.resources
var bubbleResource = R.drawable.shape_incoming_message
@ -81,6 +81,8 @@ class TalkSpecificViewThemeUtils @Inject constructor(
val bgBubbleColor = if (deleted) {
resources.getColor(R.color.bg_message_list_incoming_bubble_deleted, null)
} else if(isPlayed){
resources.getColor(R.color.bg_message_list_incoming_bubble_audio_played, null)
} else {
resources.getColor(R.color.bg_message_list_incoming_bubble, null)
}
@ -93,11 +95,13 @@ class TalkSpecificViewThemeUtils @Inject constructor(
ViewCompat.setBackground(bubble, bubbleDrawable)
}
fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean) {
fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean, isPlayed : Boolean = false) {
withScheme(bubble) { scheme ->
val bgBubbleColor = if (deleted) {
ColorUtils.setAlphaComponent(dynamicColor.surfaceVariant().getArgb(scheme), HALF_ALPHA_INT)
} else {
} else if(isPlayed){
ContextCompat.getColor(bubble.context, R.color.bg_message_list_outgoing_bubble_audio_played)
}else {
dynamicColor.surfaceVariant().getArgb(scheme)
}

View File

@ -45,6 +45,8 @@
<color name="bg_bottom_sheet">#121212</color>
<color name="bg_message_list_incoming_bubble">#2A2A2A</color>
<color name="bg_message_list_incoming_bubble_deleted">#14FFFFFF</color>
<color name="bg_message_list_incoming_bubble_audio_played">#3F3F73</color>
<color name="bg_message_list_outgoing_bubble_audio_played">#313B75</color>
<color name="textColorMaxContrast">#8c8c8c</color>

View File

@ -64,6 +64,8 @@
<color name="bg_message_list_incoming_bubble">#EFEFEF</color>
<color name="bg_message_list_incoming_bubble_deleted">#66EFEFEF</color>
<color name="bg_message_list_incoming_bubble_audio_played">#AFAFAF</color>
<color name="bg_message_list_outgoing_bubble_audio_played">#D3CFCF</color>
<color name="bg_bottom_sheet">#FFFFFF</color>
<color name="bg_call_screen_dialog">#121212</color>