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

feat: Audio message play in background WPB-11725 #3766

Open
wants to merge 30 commits into
base: develop
Choose a base branch
from
Open
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
88a706f
feat: Audio messages new design
borichellow Nov 29, 2024
25b582b
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Nov 29, 2024
3ffc762
Work in progress
borichellow Nov 29, 2024
3ff7627
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 2, 2024
0e0f03e
Audio messages new design almost ready
borichellow Dec 9, 2024
601ce01
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 9, 2024
0e2dd74
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 9, 2024
c79f7ef
Fixed code style
borichellow Dec 9, 2024
15f3303
Fixed code style and some tests
borichellow Dec 9, 2024
e9ef69c
Fix tests
borichellow Dec 9, 2024
182d04e
Updated tests
borichellow Dec 10, 2024
7260a2b
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 10, 2024
a8ae13c
Code style fixes
borichellow Dec 11, 2024
49c749c
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 16, 2024
b1862e8
Added JumpToPlayingAudio Button
borichellow Dec 16, 2024
9add5f4
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 16, 2024
5fee401
finished JumpToPlayingAudioButton
borichellow Dec 17, 2024
c8149dc
Merge branch 'develop' into feat/audio_messages_new_design
borichellow Dec 17, 2024
6ceb9b2
Review updates
borichellow Dec 17, 2024
6c29136
Code style fix
borichellow Dec 17, 2024
4be2efe
feat: Audio message play in background
borichellow Dec 23, 2024
8711849
Updated kalium
borichellow Dec 23, 2024
5644f0a
Added play control buttons for paginated list too
borichellow Dec 23, 2024
a672a62
Merge develop into feat/audio_messages_play_in_background
borichellow Dec 27, 2024
d0d0ffb
Fix code-style
borichellow Dec 27, 2024
f8dafe2
Fixed some tests
borichellow Jan 2, 2025
849e47b
Merge develop into feat/audio_messages_play_in_background
borichellow Jan 2, 2025
caa70fc
Fixed tests
borichellow Jan 3, 2025
81febf8
Code style fix
borichellow Jan 3, 2025
b0ca7cc
Merge branch 'develop' into feat/audio_messages_play_in_background
yamilmedina 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
32 changes: 29 additions & 3 deletions app/src/main/kotlin/com/wire/android/mapper/ConversationMapper.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
*/
package com.wire.android.mapper

import com.wire.android.media.audiomessage.AudioMediaPlayingState
import com.wire.android.media.audiomessage.PlayingAudioMessage
import com.wire.android.model.ImageAsset.UserAvatarAsset
import com.wire.android.model.NameBasedAvatar
import com.wire.android.model.UserAvatarData
Expand All @@ -25,7 +27,9 @@ import com.wire.android.ui.home.conversationslist.model.BadgeEventType
import com.wire.android.ui.home.conversationslist.model.BlockState
import com.wire.android.ui.home.conversationslist.model.ConversationInfo
import com.wire.android.ui.home.conversationslist.model.ConversationItem
import com.wire.android.ui.home.conversationslist.model.PlayingAudioInConversation
import com.wire.android.ui.home.conversationslist.showLegalHoldIndicator
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationDetails.Connection
import com.wire.kalium.logic.data.conversation.ConversationDetails.Group
import com.wire.kalium.logic.data.conversation.ConversationDetails.OneOne
Expand All @@ -42,7 +46,8 @@ import com.wire.kalium.logic.data.user.UserAvailabilityStatus
fun ConversationDetailsWithEvents.toConversationItem(
userTypeMapper: UserTypeMapper,
searchQuery: String,
selfUserTeamId: TeamId?
selfUserTeamId: TeamId?,
playingAudioMessage: PlayingAudioMessage
): ConversationItem = when (val conversationDetails = this.conversationDetails) {
is Group -> {
ConversationItem.GroupConversation(
Expand All @@ -65,7 +70,8 @@ fun ConversationDetailsWithEvents.toConversationItem(
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus,
hasNewActivitiesToShow = hasNewActivitiesToShow,
searchQuery = searchQuery,
isFavorite = conversationDetails.isFavorite
isFavorite = conversationDetails.isFavorite,
playingAudio = getPlayingAudioInConversation(playingAudioMessage, conversationDetails)
)
}

Expand Down Expand Up @@ -103,7 +109,8 @@ fun ConversationDetailsWithEvents.toConversationItem(
proteusVerificationStatus = conversationDetails.conversation.proteusVerificationStatus,
hasNewActivitiesToShow = hasNewActivitiesToShow,
searchQuery = searchQuery,
isFavorite = conversationDetails.isFavorite
isFavorite = conversationDetails.isFavorite,
playingAudio = getPlayingAudioInConversation(playingAudioMessage, conversationDetails)
)
}

Expand Down Expand Up @@ -140,6 +147,25 @@ fun ConversationDetailsWithEvents.toConversationItem(
}
}

private fun getPlayingAudioInConversation(
playingAudioMessage: PlayingAudioMessage,
conversationDetails: ConversationDetails
): PlayingAudioInConversation? =
if (playingAudioMessage is PlayingAudioMessage.Some
&& playingAudioMessage.conversationId == conversationDetails.conversation.id
) {
if (playingAudioMessage.state.isPlaying()) {
PlayingAudioInConversation(playingAudioMessage.messageId, false)
} else if (playingAudioMessage.state.audioMediaPlayingState is AudioMediaPlayingState.Paused) {
PlayingAudioInConversation(playingAudioMessage.messageId, true)
} else {
// states Fetching, Completed, Stopped, etc. should not be shown in ConversationItem
null
}
} else {
null
}

private fun parseConnectionEventType(connectionState: ConnectionState) =
if (connectionState == ConnectionState.SENT) {
BadgeEventType.SentConnectRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package com.wire.android.media.audiomessage

import androidx.annotation.StringRes
import com.wire.android.R
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.id.ConversationId

data class AudioState(
val audioMediaPlayingState: AudioMediaPlayingState,
Expand All @@ -40,13 +42,27 @@ data class AudioState(
return totalTimeInMs
}

fun isPlaying() = audioMediaPlayingState is AudioMediaPlayingState.Playing
fun isPlayingOrPaused() = audioMediaPlayingState is AudioMediaPlayingState.Playing
|| audioMediaPlayingState is AudioMediaPlayingState.Paused

sealed class TotalTimeInMs {
object NotKnown : TotalTimeInMs()

data class Known(val value: Int) : TotalTimeInMs()
}
}

sealed class PlayingAudioMessage {
data object None : PlayingAudioMessage()
data class Some(
val conversationId: ConversationId,
val messageId: String,
val authorName: UIText,
val state: AudioState
) : PlayingAudioMessage()
}

@Suppress("MagicNumber")
enum class AudioSpeed(val value: Float, @StringRes val titleRes: Int) {
NORMAL(1f, R.string.audio_speed_1),
Expand Down Expand Up @@ -84,27 +100,32 @@ sealed class AudioMediaPlayingState {
}

sealed class AudioMediaPlayerStateUpdate(
open val conversationId: ConversationId,
open val messageId: String
) {
data class AudioMediaPlayingStateUpdate(
override val conversationId: ConversationId,
override val messageId: String,
val audioMediaPlayingState: AudioMediaPlayingState
) : AudioMediaPlayerStateUpdate(messageId)
) : AudioMediaPlayerStateUpdate(conversationId, messageId)

data class PositionChangeUpdate(
override val conversationId: ConversationId,
override val messageId: String,
val position: Int
) : AudioMediaPlayerStateUpdate(messageId)
) : AudioMediaPlayerStateUpdate(conversationId, messageId)

data class TotalTimeUpdate(
override val conversationId: ConversationId,
override val messageId: String,
val totalTimeInMs: Int
) : AudioMediaPlayerStateUpdate(messageId)
) : AudioMediaPlayerStateUpdate(conversationId, messageId)

data class WaveMaskUpdate(
override val conversationId: ConversationId,
override val messageId: String,
val waveMask: List<Int>
) : AudioMediaPlayerStateUpdate(messageId)
) : AudioMediaPlayerStateUpdate(conversationId, messageId)
}

sealed class RecordAudioMediaPlayerStateUpdate {
Expand Down
Loading
Loading