Skip to content
Draft
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
1 change: 1 addition & 0 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -213,6 +213,7 @@ dependencies {
implementationWithCoverage(projects.core.di)
implementationWithCoverage(projects.core.media)
implementationWithCoverage(projects.core.mediaPlayer)
implementationWithCoverage(projects.core.pdfViewer)
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 @@ -21,6 +21,7 @@ import com.wire.android.di.CurrentAccount
import com.wire.android.di.KaliumCoreLogic
import com.wire.android.feature.cells.util.FileNameResolver
import com.wire.android.ui.home.conversations.model.messagetypes.multipart.CellAssetRefreshHelper
import com.wire.android.pdfviewer.PdfRemoteLoader
import com.wire.kalium.cells.CellsScope
import com.wire.kalium.cells.domain.CellUploadManager
import com.wire.kalium.cells.domain.usecase.AddAttachmentDraftUseCase
Expand Down Expand Up @@ -72,11 +73,14 @@ import com.wire.kalium.cells.domain.usecase.versioning.GetNodeVersionsUseCase
import com.wire.kalium.cells.domain.usecase.versioning.RestoreNodeVersionUseCase
import com.wire.kalium.cells.paginatedConversationsFlowUseCase
import com.wire.kalium.cells.paginatedFilesFlowUseCase
import com.wire.kalium.common.functional.fold
import com.wire.kalium.logic.CoreLogic
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.featureFlags.KaliumConfigs
import dev.zacsweers.metro.BindingContainer
import dev.zacsweers.metro.Provides
import java.io.IOException
import okio.Path.Companion.toOkioPath

@Suppress("TooManyFunctions")
@BindingContainer
Expand Down Expand Up @@ -253,4 +257,20 @@ class CellsModule {

@Provides
fun provideGetUserNamesUseCase(cellsScope: CellsScope): GetUserNameUseCase = cellsScope.getUserName

@Provides
fun providePdfRemoteLoader(download: DownloadCellFileUseCase): PdfRemoteLoader =
PdfRemoteLoader { assetId, remotePath, conversationId, assetSize, outFile ->
download(
assetId = assetId,
conversationId = conversationId,
outFilePath = outFile.toPath().toOkioPath(),
assetSize = assetSize,
remoteFilePath = remotePath,
onProgressUpdate = {},
).fold(
{ failure -> Result.failure(IOException("PDF download failed: $failure")) },
{ Result.success(Unit) },
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ import com.wire.android.feature.meetings.ui.MeetingsManualViewModelFactoryMetroB
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.pdfviewer.PdfViewerManualViewModelFactoryMetroBindings
import com.wire.android.search.SearchManualViewModelFactoryMetroBindings
import com.wire.android.ui.authentication.AuthenticationViewModelGraph
import com.wire.android.ui.calling.CallingMetroViewModelBindings
Expand Down Expand Up @@ -111,6 +112,7 @@ annotation class MetroSessionScope
CoreUICommonManualViewModelFactoryMetroBindings::class,
SearchManualViewModelFactoryMetroBindings::class,
MediaPlayerManualViewModelFactoryMetroBindings::class,
PdfViewerManualViewModelFactoryMetroBindings::class,
ImageLoadingModule::class,
]
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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.pdfviewer.PdfViewer
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 Expand Up @@ -122,6 +123,17 @@ internal fun mediaNavigation3Entries(
onNavigateBack = runtime.navigator::goBack,
)
}
wireEntry<PdfViewerRoute>(presentation = WireEntryPresentation.PopUp) { route ->
PdfViewer(
localPath = route.localPath,
assetId = route.assetId,
remotePath = route.remotePath,
conversationId = route.conversationId,
assetSize = route.assetSize,
fileName = route.fileName,
onNavigateBack = runtime.navigator::goBack,
)
}
wireEntry<MessageDetailsRoute>(presentation = WireEntryPresentation.PopUp) { route ->
MessageDetailsRouteScreen(messageDetailsViewModel(route.toViewModelArgs()), runtime.navigator::goBack)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,21 @@ data class VideoPlayerRoute(
companion object { const val ROUTE_ID = "app/video_player_screen" }
}

@Serializable
data class PdfViewerRoute(
override val sessionId: WireSessionId,
val localPath: String? = null,
val assetId: String? = null,
val remotePath: String? = null,
val conversationId: String? = null,
val assetSize: Long = 0L,
val fileName: String? = null,
override val entryId: WireNavEntryId = WireNavEntryId.random(),
) : SessionRoute {
override val routeId = ROUTE_ID
companion object { const val ROUTE_ID = "app/pdf_viewer_screen" }
}

@Serializable
data class MessageDetailsRoute(
override val sessionId: WireSessionId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ internal data class WireNavigation3ContributionCatalog(
* app-lock overlays finish the registry. An entry type must be owned by exactly one contribution.
*/
internal object WireNavigation3Contributions {
const val EXPECTED_ROUTE_REGISTRATION_COUNT: Int = 107
const val EXPECTED_ROUTE_REGISTRATION_COUNT: Int = 109
const val EXPECTED_INSTALLER_COUNT: Int = 19

fun create(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.wire.android.feature.cells.navigation.CellImageViewerRoute
import com.wire.android.feature.cells.navigation.CellsFilesArguments
import com.wire.android.feature.cells.navigation.CellsSearchType
import com.wire.android.feature.cells.navigation.ConversationFilesRoute
import com.wire.android.feature.cells.navigation.PdfViewerRoute
import com.wire.android.feature.cells.navigation.PublicLinkRoute
import com.wire.android.feature.cells.navigation.SearchRoute
import com.wire.android.feature.cells.navigation.VideoPlayerRoute
Expand Down Expand Up @@ -196,6 +197,19 @@ internal class WireNavigation3ProductionActions(
)
)
},
showPdfViewer = {
navigate(
PdfViewerRoute(
sessionId = requireSession(),
localPath = it.localPath,
assetId = it.uuid,
remotePath = it.remotePath,
conversationId = it.conversationId,
assetSize = it.size ?: 0L,
fileName = it.name,
)
)
},
)
override val conversationList: ConversationListNavigationActions = ConversationListNavigationActions(
openConversation = { openConversation(it.toProfileId()) },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ data class MultipartAttachmentUi(
val contentUrl: String? = null,
val contentUrlExpiresAt: Long? = null,
val previewUrl: String? = null,
val remotePath: String? = null,
val mimeType: String,
val assetType: AttachmentFileType,
val assetSize: Long?,
Expand Down Expand Up @@ -60,6 +61,7 @@ fun CellAssetContent.toUiModel(progress: Float?, isAvailableOffline: Boolean = f
contentUrl = this.contentUrl,
contentUrlExpiresAt = this.contentUrlExpiresAt,
previewUrl = this.previewUrl,
remotePath = this.assetPath,
mimeType = this.mimeType,
assetType = AttachmentFileType.fromMimeType(mimeType),
assetSize = this.assetSize,
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,
onPdfClick: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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,
onPdfClicked = onPdfClick,
onLinkClicked = onLinkClick,
onReplyClicked = onNavigateToReplyOriginalMessage,
onResetSessionClicked = onResetSessionClicked,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import com.wire.android.navigation.routes.media.MediaGalleryNavigation3ResultTyp
import com.wire.android.navigation.routes.media.MediaGalleryResult
import com.wire.android.navigation.routes.media.MediaGalleryResultAction
import com.wire.android.navigation.routes.media.MediaGalleryRoute
import com.wire.android.navigation.routes.media.PdfViewerRoute
import com.wire.android.navigation.routes.media.VideoPlayerRoute
import com.wire.android.navigation.routes.media.MessageDetailsRoute
import com.wire.android.navigation.routes.media.toLegacy
Expand Down Expand Up @@ -251,6 +252,21 @@ private fun ConversationNavigation3Entry(
)
}

override fun openPdfViewer(localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, fileName: String?) {
runtime.navigator.navigate(
WireNavigationCommand(
PdfViewerRoute(
sessionId = route.sessionId,
localPath = localPath,
assetId = assetId,
remotePath = remotePath,
assetSize = assetSize,
fileName = 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 @@ -52,6 +52,8 @@ internal interface ConversationRouteScreenNavigation {

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

fun openPdfViewer(localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, fileName: String?)

fun openDrawingCanvas(
conversationName: String,
tempWritableUri: Uri?,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ internal fun ConversationScreenRouteContent(
}
},
onVideoClick = navigation::openVideoPlayer,
onPdfClick = navigation::openPdfViewer,
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,
onPdfClick: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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,
onPdfClick = onPdfClick,
onReactionClicked = onReactionClick,
onResetSessionClicked = onResetSessionClick,
onOpenProfile = onOpenProfile,
Expand Down Expand Up @@ -896,6 +899,7 @@ fun PreviewConversationScreen() = WireTheme {
onAssetItemClicked = { },
onImageFullScreenMode = { _, _, _ -> },
onVideoClick = { _, _, _ -> },
onPdfClick = { _, _, _, _, _ -> },
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 onPdfClicked: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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 onPdfClicked: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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,
onPdfClicked: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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,
onMultipartPdfClick = onPdfClicked,
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,
onMultipartPdfClick: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, 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,
onPdfAttachmentClick = onMultipartPdfClick,
)
}

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,
onPdfClicked = clickActions.onPdfClicked,
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,
onPdfAttachmentClick: (localPath: String?, assetId: String?, remotePath: String?, assetSize: Long, fileName: String?) -> Unit,
modifier: Modifier = Modifier,
viewModel: MultipartAttachmentsViewModel = when {
LocalInspectionMode.current -> MultipartAttachmentsViewModelPreview
Expand All @@ -68,6 +69,15 @@ fun MultipartAttachmentsView(
// Collect to trigger recomposition when offline availability changes.
val offlineAttachmentIds by viewModel.offlineAttachmentIds.collectAsStateWithLifecycle()

val handleClick: (MultipartAttachmentUi) -> Unit = { clicked ->
viewModel.onClick(
attachment = clicked,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att -> onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName) },
openInPdfViewer = { att -> onPdfAttachmentClick(att.localPath, att.uuid, att.remotePath, att.assetSize ?: 0L, att.fileName) },
)
}

// TODO I found out that empty attachments list is not handled here and it shows empty message with no information
if (attachments.size == 1) {
val attachment = attachments.first()
Expand All @@ -86,15 +96,7 @@ fun MultipartAttachmentsView(
},
item = it,
messageStyle = messageStyle,
onClick = {
viewModel.onClick(
attachment = it,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
},
)
},
onClick = { handleClick(it) },
)
}
} else {
Expand All @@ -119,30 +121,14 @@ fun MultipartAttachmentsView(
AttachmentsGrid(
attachments = group.attachments,
messageStyle = messageStyle,
onClick = {
viewModel.onClick(
attachment = it,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
},
)
},
onClick = handleClick,
)

is MultipartAttachmentsViewModel.MultipartAttachmentGroup.Files ->
AttachmentsList(
attachments = group.attachments,
messageStyle = messageStyle,
onClick = {
viewModel.onClick(
attachment = it,
openInImageViewer = onImageAttachmentClick,
openInVideoPlayer = { att ->
onVideoAttachmentClick(att.localPath, att.contentUrl, att.fileName)
},
)
},
onClick = handleClick,
)
}
}
Expand Down
Loading
Loading