Signed-off-by: Giacomo Pacini <giacomopacini98@gmail.com>
This commit is contained in:
Giacomo Pacini 2024-12-19 12:20:30 +01:00
parent 09925699b7
commit 169dac4045
No known key found for this signature in database
GPG Key ID: 2FBC97406B43D889
5 changed files with 18 additions and 12 deletions

View File

@ -155,9 +155,10 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
isBound = true isBound = true
} }
private fun showVoiceMessageDuration(message: ChatMessage){ private fun showVoiceMessageDuration(message: ChatMessage) {
if (message.voiceMessageDuration > 0) { if (message.voiceMessageDuration > 0) {
binding.voiceMessageDuration.text = android.text.format.DateUtils.formatElapsedTime(message.voiceMessageDuration.toLong()) binding.voiceMessageDuration.text = android.text.format.DateUtils.formatElapsedTime(
message.voiceMessageDuration.toLong())
binding.voiceMessageDuration.visibility = View.VISIBLE binding.voiceMessageDuration.visibility = View.VISIBLE
} else { } else {
binding.voiceMessageDuration.visibility = View.INVISIBLE binding.voiceMessageDuration.visibility = View.INVISIBLE
@ -290,7 +291,8 @@ class IncomingVoiceMessageViewHolder(incomingView: View, payload: Any) :
} }
private fun colorizeMessageBubble(message: ChatMessage) { private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped, message.isDeleted, message.wasPlayedVoiceMessage) viewThemeUtils.talk.themeIncomingMessageBubble(bubble, message.isGrouped,
message.isDeleted, message.wasPlayedVoiceMessage)
} }
@Suppress("Detekt.TooGenericExceptionCaught") @Suppress("Detekt.TooGenericExceptionCaught")

View File

@ -196,9 +196,10 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
} }
} }
private fun showVoiceMessageDuration(message: ChatMessage){ private fun showVoiceMessageDuration(message: ChatMessage) {
if (message.voiceMessageDuration > 0) { if (message.voiceMessageDuration > 0) {
binding.voiceMessageDuration.text = android.text.format.DateUtils.formatElapsedTime(message.voiceMessageDuration.toLong()) binding.voiceMessageDuration.text = android.text.format.DateUtils.formatElapsedTime(
message.voiceMessageDuration.toLong())
binding.voiceMessageDuration.visibility = View.VISIBLE binding.voiceMessageDuration.visibility = View.VISIBLE
} else { } else {
binding.voiceMessageDuration.visibility = View.INVISIBLE binding.voiceMessageDuration.visibility = View.INVISIBLE
@ -355,7 +356,8 @@ class OutcomingVoiceMessageViewHolder(outcomingView: View) :
} }
private fun colorizeMessageBubble(message: ChatMessage) { private fun colorizeMessageBubble(message: ChatMessage) {
viewThemeUtils.talk.themeOutgoingMessageBubble(bubble, message.isGrouped, message.isDeleted, message.wasPlayedVoiceMessage) viewThemeUtils.talk.themeOutgoingMessageBubble(bubble, message.isGrouped,
message.isDeleted, message.wasPlayedVoiceMessage)
} }
fun assignVoiceMessageInterface(voiceMessageInterface: VoiceMessageInterface) { fun assignVoiceMessageInterface(voiceMessageInterface: VoiceMessageInterface) {

View File

@ -1205,7 +1205,8 @@ class ChatActivity :
} }
} }
private fun setUpWaveform(message: ChatMessage, thenPlay: Boolean = true, backgroundPlayAllowed : Boolean = false) { private fun setUpWaveform(message: ChatMessage, thenPlay: Boolean = true,
backgroundPlayAllowed: Boolean = false) {
val filename = message.selectedIndividualHashMap!!["name"] val filename = message.selectedIndividualHashMap!!["name"]
val file = File(context.cacheDir, filename!!) val file = File(context.cacheDir, filename!!)
if (file.exists() && message.voiceMessageFloatArray == null) { if (file.exists() && message.voiceMessageFloatArray == null) {
@ -1614,7 +1615,8 @@ class ChatActivity :
} }
} }
private fun startPlayback(message: ChatMessage, doPlay: Boolean = true, backgroundPlayAllowed : Boolean = false) { private fun startPlayback(message: ChatMessage, doPlay: Boolean = true,
backgroundPlayAllowed: Boolean = false) {
if (!active && !backgroundPlayAllowed) { if (!active && !backgroundPlayAllowed) {
// don't begin to play voice message if screen is not visible anymore. // don't begin to play voice message if screen is not visible anymore.
// this situation might happen if file is downloading but user already left the chatview. // this situation might happen if file is downloading but user already left the chatview.

View File

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

View File

@ -81,7 +81,7 @@ class TalkSpecificViewThemeUtils @Inject constructor(
val bgBubbleColor = if (deleted) { val bgBubbleColor = if (deleted) {
resources.getColor(R.color.bg_message_list_incoming_bubble_deleted, null) resources.getColor(R.color.bg_message_list_incoming_bubble_deleted, null)
} else if(isPlayed){ } else if (isPlayed){
resources.getColor(R.color.bg_message_list_incoming_bubble_audio_played, null) resources.getColor(R.color.bg_message_list_incoming_bubble_audio_played, null)
} else { } else {
resources.getColor(R.color.bg_message_list_incoming_bubble, null) resources.getColor(R.color.bg_message_list_incoming_bubble, null)
@ -95,13 +95,13 @@ class TalkSpecificViewThemeUtils @Inject constructor(
ViewCompat.setBackground(bubble, bubbleDrawable) ViewCompat.setBackground(bubble, bubbleDrawable)
} }
fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean, isPlayed : Boolean = false) { fun themeOutgoingMessageBubble(bubble: View, grouped: Boolean, deleted: Boolean, isPlayed: Boolean = false) {
withScheme(bubble) { scheme -> withScheme(bubble) { scheme ->
val bgBubbleColor = if (deleted) { val bgBubbleColor = if (deleted) {
ColorUtils.setAlphaComponent(dynamicColor.surfaceVariant().getArgb(scheme), HALF_ALPHA_INT) ColorUtils.setAlphaComponent(dynamicColor.surfaceVariant().getArgb(scheme), HALF_ALPHA_INT)
} else if(isPlayed){ } else if(isPlayed){
ContextCompat.getColor(bubble.context, R.color.bg_message_list_outgoing_bubble_audio_played) ContextCompat.getColor(bubble.context, R.color.bg_message_list_outgoing_bubble_audio_played)
}else { } else {
dynamicColor.surfaceVariant().getArgb(scheme) dynamicColor.surfaceVariant().getArgb(scheme)
} }