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
3 changes: 2 additions & 1 deletion app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ dependencies {
implementationWithCoverage(projects.core.datastore)
implementationWithCoverage(projects.core.di)
implementationWithCoverage(projects.core.media)
implementationWithCoverage(projects.core.mediaPlayer)
implementationWithCoverage(projects.core.videoPlayer)
implementationWithCoverage(projects.core.audioPlayer)
implementationWithCoverage(projects.core.notification)
implementationWithCoverage(projects.core.navigation)
implementationWithCoverage(projects.core.search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
*/
package com.wire.android.di.metro

import com.wire.android.audioplayer.AudioPlayerManualViewModelFactoryMetroBindings
import com.wire.android.di.CurrentAccount
import com.wire.android.di.ImageLoadingModule
import com.wire.android.di.SessionModule
Expand All @@ -40,25 +41,25 @@ import com.wire.android.feature.cells.ui.CellsMetroViewModelBindings
import com.wire.android.feature.meetings.ui.MeetingsManualViewModelFactoryMetroBindings
import com.wire.android.feature.meetings.ui.MeetingsMetroViewModelBindings
import com.wire.android.feature.sketch.SketchMetroViewModelBindings
import com.wire.android.mediaplayer.MediaPlayerManualViewModelFactoryMetroBindings
import com.wire.android.search.SearchManualViewModelFactoryMetroBindings
import com.wire.android.ui.authentication.AuthenticationViewModelGraph
import com.wire.android.ui.calling.CallingMetroViewModelBindings
import com.wire.android.ui.calling.CallingManualViewModelFactoryMetroBindings
import com.wire.android.ui.common.CommonMetroViewModelBindings
import com.wire.android.ui.calling.CallingMetroViewModelBindings
import com.wire.android.ui.common.CommonManualViewModelFactoryMetroBindings
import com.wire.android.ui.common.CommonMetroViewModelBindings
import com.wire.android.ui.common.CoreUICommonManualViewModelFactoryMetroBindings
import com.wire.android.ui.debug.DebugMetroViewModelBindings
import com.wire.android.ui.debug.DebugInfoManualViewModelFactoryMetroBindings
import com.wire.android.ui.debug.DebugInfoViewModelGraph
import com.wire.android.ui.debug.DebugMetroViewModelBindings
import com.wire.android.ui.home.HomeMetroViewModelBindings
import com.wire.android.ui.home.HomeViewModelGraph
import com.wire.android.ui.home.conversations.ConversationSearchFolderMetroViewModelBindings
import com.wire.android.ui.home.conversations.ConversationCoreManualViewModelFactoryMetroBindings
import com.wire.android.ui.home.conversations.ConversationDetailsManualViewModelFactoryMetroBindings
import com.wire.android.ui.home.conversations.ConversationSearchFolderManualViewModelFactoryMetroBindings
import com.wire.android.ui.home.conversations.ConversationSearchFolderMetroViewModelBindings
import com.wire.android.ui.home.settings.SettingsManualViewModelFactoryMetroBindings
import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.android.videoplayer.VideoPlayerManualViewModelFactoryMetroBindings
import com.wire.kalium.logic.data.user.UserId
import dev.zacsweers.metro.AppScope
import dev.zacsweers.metro.ContributesTo
Expand Down Expand Up @@ -110,7 +111,8 @@ annotation class MetroSessionScope
SketchMetroViewModelBindings::class,
CoreUICommonManualViewModelFactoryMetroBindings::class,
SearchManualViewModelFactoryMetroBindings::class,
MediaPlayerManualViewModelFactoryMetroBindings::class,
VideoPlayerManualViewModelFactoryMetroBindings::class,
AudioPlayerManualViewModelFactoryMetroBindings::class,
ImageLoadingModule::class,
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import com.wire.android.navigation.navigation3.WireEntryProviderInstaller
import com.wire.android.navigation.navigation3.WireNavigation3ResultType
import com.wire.android.navigation.navigation3.WireNavigation3Runtime
import com.wire.android.navigation.navigation3.wireEntry
import com.wire.android.mediaplayer.VideoPlayer
import com.wire.android.videoplayer.VideoPlayer
import com.wire.android.ui.home.FeatureFlagState
import com.wire.android.ui.home.conversations.ConversationNavArgs
import com.wire.android.ui.home.conversations.checkAssetRestrictionsViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ internal fun ConversationMessageComposer(
onAssetItemClicked: (String) -> Unit,
onImageFullScreenMode: (UIMessage.Regular, Boolean, String?) -> Unit,
onVideoClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onAudioClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onReactionClicked: (String, String) -> Unit,
onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit,
onOpenProfile: (senderId: MessageSenderId) -> Unit,
Expand Down Expand Up @@ -115,6 +116,7 @@ internal fun ConversationMessageComposer(
onAssetClicked = onAssetItemClicked,
onImageClicked = onImageFullScreenMode,
onVideoClicked = onVideoClick,
onAudioClicked = onAudioClick,
onLinkClicked = onLinkClick,
onReplyClicked = onNavigateToReplyOriginalMessage,
onResetSessionClicked = onResetSessionClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.saveable.rememberSaveable
import androidx.compose.runtime.setValue
import com.wire.android.feature.cells.navigation.AudioPlayerRoute
import com.wire.android.feature.sketch.navigation.DrawingCanvasNavigation3ResultType
import com.wire.android.feature.sketch.navigation.DrawingCanvasRoute
import com.wire.android.navigation.navigation3.WireEntryPresentation
Expand Down Expand Up @@ -251,6 +252,14 @@ private fun ConversationNavigation3Entry(
)
}

override fun openAudioPlayer(localPath: String?, contentUrl: String?, fileName: String?) {
runtime.navigator.navigate(
WireNavigationCommand(
AudioPlayerRoute(route.sessionId, localPath, contentUrl, fileName)
)
)
}

override fun openDrawingCanvas(conversationName: String, tempWritableUri: Uri?) {
drawingRequestId = runtime.navigateForResult(
DrawingCanvasRoute(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ internal interface ConversationRouteScreenNavigation {
)

fun openVideoPlayer(localPath: String?, contentUrl: String?, fileName: String?)
fun openAudioPlayer(localPath: String?, contentUrl: String?, fileName: String?)

fun openDrawingCanvas(
conversationName: String,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ internal fun ConversationScreenRouteContent(
}
},
onVideoClick = navigation::openVideoPlayer,
onAudioClick = navigation::openAudioPlayer,
onStartCall = {
conversationCallViewModel.startCallIfPossible(conversationInfoViewModel.conversationInfoViewState.conversationType)
},
Expand Down Expand Up @@ -642,6 +643,7 @@ private fun ConversationScreenContent(
onAssetItemClicked: (String) -> Unit,
onImageFullScreenMode: (UIMessage.Regular, Boolean, String?) -> Unit,
onVideoClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onAudioClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onStartCall: () -> Unit,
onJoinCall: () -> Unit,
onReactionClick: (messageId: String, reactionEmoji: String) -> Unit,
Expand Down Expand Up @@ -754,6 +756,7 @@ private fun ConversationScreenContent(
onAssetItemClicked = onAssetItemClicked,
onImageFullScreenMode = onImageFullScreenMode,
onVideoClick = onVideoClick,
onAudioClick = onAudioClick,
onReactionClicked = onReactionClick,
onResetSessionClicked = onResetSessionClick,
onOpenProfile = onOpenProfile,
Expand Down Expand Up @@ -896,6 +899,7 @@ fun PreviewConversationScreen() = WireTheme {
onAssetItemClicked = { },
onImageFullScreenMode = { _, _, _ -> },
onVideoClick = { _, _, _ -> },
onAudioClick = { _, _, _ -> },
onStartCall = { },
onJoinCall = { },
onReactionClick = { _, _ -> },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ sealed class MessageClickActions {
open val onAssetClicked: (String) -> Unit = {}
open val onImageClicked: (UIMessage.Regular, Boolean, String?) -> Unit = { _, _, _ -> }
open val onVideoClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit = { _, _, _ -> }
open val onAudioClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit = { _, _, _ -> }
open val onLinkClicked: (String) -> Unit = {}
open val onReplyClicked: (UIMessage.Regular) -> Unit = {}
open val onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit = { _, _ -> }
Expand All @@ -48,6 +49,7 @@ sealed class MessageClickActions {
override val onAssetClicked: (String) -> Unit = {},
override val onImageClicked: (UIMessage.Regular, Boolean, String?) -> Unit = { _, _, _ -> },
override val onVideoClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit = { _, _, _ -> },
override val onAudioClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit = { _, _, _ -> },
override val onLinkClicked: (String) -> Unit = {},
override val onReplyClicked: (UIMessage.Regular) -> Unit = {},
override val onResetSessionClicked: (senderUserId: UserId, clientId: String?) -> Unit = { _, _ -> },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ internal fun UIMessage.Regular.MessageContentAndStatus(
onAssetClicked: (String) -> Unit,
onImageClicked: (UIMessage.Regular, Boolean, String?) -> Unit,
onVideoClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onAudioClicked: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onProfileClicked: (senderId: MessageSenderId) -> Unit,
onLinkClicked: (String) -> Unit,
onReplyClicked: (UIMessage.Regular) -> Unit,
Expand Down Expand Up @@ -121,6 +122,7 @@ internal fun UIMessage.Regular.MessageContentAndStatus(
onImageClick = onImageClickable,
onMultipartImageClick = onMultipartImageClickable,
onMultipartVideoClick = onVideoClicked,
onMultipartAudioClick = onAudioClicked,
onOpenProfile = onProfileClicked,
onLinkClick = onLinkClicked,
onReplyClick = onReplyClickable,
Expand Down Expand Up @@ -170,6 +172,7 @@ private fun MessageContent(
onImageClick: Clickable,
onMultipartImageClick: (String) -> Unit,
onMultipartVideoClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onMultipartAudioClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onOpenProfile: (senderId: MessageSenderId) -> Unit,
onLinkClick: (String) -> Unit,
onReplyClick: Clickable,
Expand Down Expand Up @@ -464,6 +467,7 @@ private fun MessageContent(
messageStyle = messageStyle,
onImageAttachmentClick = onMultipartImageClick,
onVideoAttachmentClick = onMultipartVideoClick,
onAudioAttachmentClick = onMultipartAudioClick,
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@ fun MessageContentItem(
onAssetClicked = clickActions.onAssetClicked,
onImageClicked = clickActions.onImageClicked,
onVideoClicked = clickActions.onVideoClicked,
onAudioClicked = clickActions.onAudioClicked,
searchQuery = searchQuery,
accent = accent,
onProfileClicked = clickActions.onProfileClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ fun MultipartAttachmentsView(
messageStyle: MessageStyle,
onImageAttachmentClick: (String) -> Unit,
onVideoAttachmentClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
onAudioAttachmentClick: (localPath: String?, contentUrl: String?, fileName: String?) -> Unit,
modifier: Modifier = Modifier,
viewModel: MultipartAttachmentsViewModel = when {
LocalInspectionMode.current -> MultipartAttachmentsViewModelPreview
Expand Down Expand Up @@ -93,6 +94,9 @@ fun MultipartAttachmentsView(
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
},
openInAudioPlayer = { att ->
onAudioAttachmentClick(att.localPath, att.contentUrl, att.fileName)
},
)
},
)
Expand Down Expand Up @@ -123,8 +127,11 @@ fun MultipartAttachmentsView(
viewModel.onClick(
attachment = it,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
openInVideoPlayer = { attachment ->
onVideoAttachmentClick(attachment.localPath, attachment.contentUrl, attachment.fileName)
},
openInAudioPlayer = { attachment ->
onAudioAttachmentClick(attachment.localPath, attachment.contentUrl, attachment.fileName)
},
)
},
Expand All @@ -138,8 +145,11 @@ fun MultipartAttachmentsView(
viewModel.onClick(
attachment = it,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
openInVideoPlayer = { attachment ->
onVideoAttachmentClick(attachment.localPath, attachment.contentUrl, attachment.fileName)
},
openInAudioPlayer = { attachment ->
onAudioAttachmentClick(attachment.localPath, attachment.contentUrl, attachment.fileName)
},
)
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.wire.android.appLogger
import com.wire.android.feature.cells.domain.model.AttachmentFileType
import com.wire.android.feature.cells.domain.model.AttachmentFileType.AUDIO
import com.wire.android.feature.cells.domain.model.AttachmentFileType.IMAGE
import com.wire.android.feature.cells.domain.model.AttachmentFileType.PDF
import com.wire.android.feature.cells.domain.model.AttachmentFileType.VIDEO
Expand Down Expand Up @@ -62,6 +63,7 @@ interface MultipartAttachmentsViewModel {
attachment: MultipartAttachmentUi,
openInImageViewer: (String) -> Unit,
openInVideoPlayer: (MultipartAttachmentUi) -> Unit,
openInAudioPlayer: (MultipartAttachmentUi) -> Unit,
)
fun mapAttachment(attachment: MessageAttachment): MultipartAttachmentUi {
val isAvailableOffline = attachment.assetId() in offlineAttachmentIds.value
Expand Down Expand Up @@ -128,6 +130,7 @@ object MultipartAttachmentsViewModelPreview : MultipartAttachmentsViewModel {
attachment: MultipartAttachmentUi,
openInImageViewer: (String) -> Unit,
openInVideoPlayer: (MultipartAttachmentUi) -> Unit,
openInAudioPlayer: (MultipartAttachmentUi) -> Unit,
) {}
override fun onAttachmentsVisible(attachments: List<MessageAttachment>) {}
override fun onAttachmentsHidden(attachments: List<MessageAttachment>) {}
Expand Down Expand Up @@ -164,10 +167,12 @@ class MultipartAttachmentsViewModelImpl @AssistedInject constructor(
loadWireCellConfig()
}

@Suppress("CyclomaticComplexMethod")
override fun onClick(
attachment: MultipartAttachmentUi,
openInImageViewer: (String) -> Unit,
openInVideoPlayer: (MultipartAttachmentUi) -> Unit,
openInAudioPlayer: (MultipartAttachmentUi) -> Unit,
) {
when {
attachment.isImage() && !attachment.fileNotFound() -> openInImageViewer(attachment.uuid)
Expand All @@ -181,6 +186,9 @@ class MultipartAttachmentsViewModelImpl @AssistedInject constructor(
attachment.isVideo() && (attachment.localFileAvailable() || attachment.canOpenWithUrl()) ->
openInVideoPlayer(attachment)

attachment.isAudio() && (attachment.localFileAvailable() || attachment.canOpenWithUrl()) ->
openInAudioPlayer(attachment)

attachment.localFileAvailable() -> openLocalFile(attachment)
attachment.canOpenWithUrl() -> openUrl(attachment)
else -> downloadAsset(attachment)
Expand Down Expand Up @@ -275,6 +283,8 @@ private fun MultipartAttachmentUi.isImage() = AttachmentFileType.fromMimeType(mi

private fun MultipartAttachmentUi.isVideo() = assetType == VIDEO

private fun MultipartAttachmentUi.isAudio() = assetType == AUDIO

private fun MessageAttachment.isMediaAttachment() =
when (AttachmentFileType.fromMimeType(mimeType())) {
IMAGE, VIDEO -> true
Expand All @@ -283,4 +293,4 @@ private fun MessageAttachment.isMediaAttachment() =

private fun MultipartAttachmentUi.fileNotFound() = transferStatus == AssetTransferStatus.NOT_FOUND
private fun MultipartAttachmentUi.localFileAvailable() = localPath != null
private fun MultipartAttachmentUi.canOpenWithUrl() = contentUrl != null && assetType in listOf(IMAGE, VIDEO, PDF)
private fun MultipartAttachmentUi.canOpenWithUrl() = contentUrl != null && assetType in listOf(IMAGE, VIDEO, AUDIO, PDF)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
* You should have received a copy of the GNU General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*/

package com.wire.android.ui.sharing

import android.net.Uri
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ class MultipartAttachmentsViewModelTest {

val callback = mockk<OpenImageCallback>(relaxed = true)

viewModel.onClick(testAttachmentUi, callback, {})
viewModel.onClick(testAttachmentUi, callback, {}, {})

coVerify(exactly = 1) { callback.invoke(testAttachmentUi.uuid) }
}
Expand All @@ -203,7 +203,8 @@ class MultipartAttachmentsViewModelTest {
transferStatus = AssetTransferStatus.NOT_FOUND,
),
openInImageViewer = callback,
openInVideoPlayer = { }
openInVideoPlayer = { },
openInAudioPlayer = { },
)

coVerify(exactly = 0) { callback.invoke(testAttachmentUi.uuid) }
Expand All @@ -223,7 +224,8 @@ class MultipartAttachmentsViewModelTest {
transferStatus = AssetTransferStatus.NOT_FOUND,
),
openInImageViewer = callback,
openInVideoPlayer = { }
openInVideoPlayer = { },
openInAudioPlayer = { },
)

coVerify(exactly = 0) { callback.invoke(testAttachmentUi.uuid) }
Expand All @@ -243,7 +245,8 @@ class MultipartAttachmentsViewModelTest {
localPath = "local/path",
),
openInImageViewer = callback,
openInVideoPlayer = { }
openInVideoPlayer = { },
openInAudioPlayer = { },
)

coVerify(exactly = 1) { arrangement.fileManager.openWithExternalApp(any(), any(), any(), any()) }
Expand All @@ -262,7 +265,8 @@ class MultipartAttachmentsViewModelTest {
contentUrl = "content/url",
),
openInImageViewer = callback,
openInVideoPlayer = { }
openInVideoPlayer = { },
openInAudioPlayer = { },
)

coVerify(exactly = 1) { arrangement.fileManager.openUrlWithExternalApp(any(), any(), any()) }
Expand Down
Loading