mirror of
https://github.com/nextcloud/talk-android
synced 2025-07-16 17:25:01 +01:00
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:
parent
c754ce48d4
commit
c0948ba478
@ -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) {
|
||||
|
@ -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")
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
@ -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
|
||||
|
@ -91,6 +91,8 @@ data class ChatMessage(
|
||||
|
||||
var isPlayingVoiceMessage: Boolean = false,
|
||||
|
||||
var wasPlayedVoiceMessage : Boolean = false,
|
||||
|
||||
var voiceMessageDuration: Int = 0,
|
||||
|
||||
var voiceMessagePlayedSeconds: Int = 0,
|
||||
|
@ -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)
|
||||
}
|
||||
|
||||
|
@ -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>
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
Reference in New Issue
Block a user