Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -215,11 +215,6 @@
android:taskAffinity=".call"
android:theme="@style/AppTheme.CallLauncher" />

<activity
android:name=".fullscreenfile.FullScreenMediaActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
android:theme="@style/FullScreenMediaTheme" />

<activity
android:name=".fullscreenfile.FullScreenTextViewerActivity"
android:configChanges="orientation|keyboardHidden|screenSize"
Expand Down
26 changes: 20 additions & 6 deletions app/src/main/java/com/nextcloud/talk/chat/ChatActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1126,9 +1126,14 @@ class ChatActivity :
fun setupAndPlay(controller: MediaController, message: ChatMessage, file: String) {
val avatarUrl = chatViewModel.getAvatarUrl(message)

val artist = if (message.isVoiceMessage) {
"Voice Message"
} else {
message.fileParameters.name
}
val metadata = MediaMetadata.Builder()
.setTitle(message.actorDisplayName)
.setArtist("Voice Message")
.setArtist(artist)
.setArtworkUri(avatarUrl.toUri())
.build()

Expand Down Expand Up @@ -1181,20 +1186,29 @@ class ChatActivity :
}
)

if (controller.currentMediaItem?.mediaId != currentMessageId) {
fun finishPreparing() {
setupAndPlay(controller, message, filePath)
if (message.isVoiceMessage) {
setUpWaveform(message, file)
} else {
message.isDownloadingVoiceMessage = false
chatViewModel.syncVoiceMessageUiState(message)
}
}

val alreadyLoaded = controller.currentMediaItem?.mediaId == currentMessageId
if (!alreadyLoaded || !file.exists()) {
if (!file.exists()) {
downloadFileToCache(message, true) {
chatViewModel.syncVoiceMessageUiState(
message.apply {
voiceMessageDuration = getAudioDuration(file.absolutePath).toInt()
}
)
setupAndPlay(controller, message, filePath)
setUpWaveform(message, file)
finishPreparing()
}
} else {
setupAndPlay(controller, message, filePath)
setUpWaveform(message, file)
finishPreparing()
}

return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.nextcloud.talk.ui.PlaybackSpeed
import com.nextcloud.talk.utils.ApiUtils
import com.nextcloud.talk.utils.CapabilitiesUtil
import com.nextcloud.talk.utils.DrawableUtils
import com.nextcloud.talk.utils.Mimetype
import com.nextcloud.talk.utils.MimetypeUtils
import java.time.Instant
import java.time.LocalDate
Expand Down Expand Up @@ -107,6 +108,15 @@ sealed interface MessageTypeContent {
val waveform: List<Float>,
val playbackSpeed: PlaybackSpeed = PlaybackSpeed.NORMAL
) : MessageTypeContent

data class AudioFile(
val fileName: String,
val isPlaying: Boolean,
val isDownloading: Boolean,
val durationSeconds: Int,
val playedSeconds: Int,
val seekbarProgress: Int
) : MessageTypeContent
}

enum class MessageStatusIcon {
Expand Down Expand Up @@ -269,6 +279,8 @@ fun getMessageTypeContent(user: User, message: ChatMessage, isClassified: Boolea
getVoiceContent(message)
} else if (message.hasFileAttachment && message.isTemporary) {
getUploadingMediaContent(message)
} else if (message.hasFileAttachment && message.fileParameters.mimetype.startsWith(Mimetype.AUDIO_PREFIX)) {
getAudioFileContent(message)
} else if (message.hasFileAttachment) {
getMediaContent(user, message, isClassified)
} else if (message.hasGeoLocation) {
Expand Down Expand Up @@ -392,3 +404,13 @@ fun getVoiceContent(message: ChatMessage): MessageTypeContent.Voice =
seekbarProgress = message.voiceMessageSeekbarProgress,
waveform = message.voiceMessageFloatArray?.toList().orEmpty()
)

fun getAudioFileContent(message: ChatMessage): MessageTypeContent.AudioFile =
MessageTypeContent.AudioFile(
fileName = message.fileParameters.name,
isPlaying = message.isPlayingVoiceMessage,
isDownloading = message.isDownloadingVoiceMessage,
durationSeconds = message.voiceMessageDuration,
playedSeconds = message.voiceMessagePlayedSeconds,
seekbarProgress = message.voiceMessageSeekbarProgress
)
Original file line number Diff line number Diff line change
Expand Up @@ -1095,22 +1095,34 @@ class ChatViewModel @AssistedInject constructor(
_uiState.update { current ->
val updatedItems = current.items.map { item ->
if (item is ChatItem.MessageItem && item.uiMessage.id == message.jsonMessageId) {
val voiceContent = item.uiMessage.content as? MessageTypeContent.Voice
if (voiceContent != null) {
val updatedVoiceContent = voiceContent.copy(
actorId = message.actorId,
isPlaying = message.isPlayingVoiceMessage,
wasPlayed = message.wasPlayedVoiceMessage,
isDownloading = message.isDownloadingVoiceMessage,
durationSeconds = message.voiceMessageDuration,
playedSeconds = message.voiceMessagePlayedSeconds,
seekbarProgress = message.voiceMessageSeekbarProgress,
waveform = message.voiceMessageFloatArray?.toList() ?: voiceContent.waveform
// playbackSpeed is preserved from existing voiceContent
)
item.copy(uiMessage = item.uiMessage.copy(content = updatedVoiceContent))
} else {
item
when (val content = item.uiMessage.content) {
is MessageTypeContent.Voice -> {
val updatedVoiceContent = content.copy(
actorId = message.actorId,
isPlaying = message.isPlayingVoiceMessage,
wasPlayed = message.wasPlayedVoiceMessage,
isDownloading = message.isDownloadingVoiceMessage,
durationSeconds = message.voiceMessageDuration,
playedSeconds = message.voiceMessagePlayedSeconds,
seekbarProgress = message.voiceMessageSeekbarProgress,
waveform = message.voiceMessageFloatArray?.toList() ?: content.waveform
// playbackSpeed is preserved from existing content
)
item.copy(uiMessage = item.uiMessage.copy(content = updatedVoiceContent))
}

is MessageTypeContent.AudioFile -> {
val updatedAudioFileContent = content.copy(
isPlaying = message.isPlayingVoiceMessage,
isDownloading = message.isDownloadingVoiceMessage,
durationSeconds = message.voiceMessageDuration,
playedSeconds = message.voiceMessagePlayedSeconds,
seekbarProgress = message.voiceMessageSeekbarProgress
)
item.copy(uiMessage = item.uiMessage.copy(content = updatedAudioFileContent))
}

else -> item
}
} else {
item
Expand Down

This file was deleted.

Loading
Loading