Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ import com.wire.kalium.cells.domain.usecase.publiclink.SetPublicLinkExpirationUs
import com.wire.kalium.cells.domain.usecase.publiclink.UpdatePublicLinkPasswordUseCase
import com.wire.kalium.cells.domain.usecase.versioning.GetNodeVersionsUseCase
import com.wire.kalium.cells.domain.usecase.versioning.RestoreNodeVersionUseCase
import com.wire.kalium.cells.domain.usecase.GetConversationNameUseCase
import com.wire.kalium.cells.domain.usecase.GetUserNameUseCase
import com.wire.kalium.cells.domain.usecase.offline.DeleteOfflineFileUseCase
import com.wire.kalium.cells.domain.usecase.offline.GetOfflineFileUseCase
import com.wire.kalium.cells.domain.usecase.offline.ObserveOfflineFilesUseCase
Expand Down Expand Up @@ -279,4 +281,12 @@ class CellsModule {
@ViewModelScoped
@Provides
fun provideGetOfflineFileUseCase(cellsScope: CellsScope): GetOfflineFileUseCase = cellsScope.getOfflineFile

@ViewModelScoped
@Provides
fun provideGetConversationNamesUseCase(cellsScope: CellsScope): GetConversationNameUseCase = cellsScope.getConversationName

@ViewModelScoped
@Provides
fun provideGetUserNamesUseCase(cellsScope: CellsScope): GetUserNameUseCase = cellsScope.getUserName
}
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,9 @@

download(
assetId = attachment.uuid,
conversationId = null, // TODO to replace with real conversation id in next PR

Check warning on line 177 in app/src/main/kotlin/com/wire/android/ui/home/conversations/model/messagetypes/multipart/MultipartAttachmentsViewModel.kt

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Complete the task associated to this TODO comment.

See more on https://sonarcloud.io/project/issues?id=wireapp_wire-android&issues=AZ4hAoiSwJ1e4rinldwZ&open=AZ4hAoiSwJ1e4rinldwZ&pullRequest=4822
outFilePath = path,
assetSize = attachment.assetSize ?: 0,
conversationId = null, // TODO to replace with real conversation id in next PR
) { progress ->
attachment.assetSize?.let {
val value = progress.toFloat() / it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,13 @@
*/
package com.wire.android.feature.cells.ui

import androidx.compose.animation.AnimatedContent
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.input.rememberTextFieldState
import androidx.compose.runtime.Composable
import androidx.compose.runtime.collectAsState
import androidx.compose.runtime.getValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.res.stringResource
import androidx.hilt.navigation.compose.hiltViewModel
Expand All @@ -30,6 +32,7 @@ import com.ramcosta.composedestinations.generated.cells.destinations.AddRemoveTa
import com.ramcosta.composedestinations.generated.cells.destinations.PublicLinkScreenDestination
import com.ramcosta.composedestinations.generated.cells.destinations.SearchScreenDestination
import com.wire.android.feature.cells.R
import com.wire.android.feature.cells.ui.common.OfflineBanner
import com.wire.android.feature.cells.ui.search.DriveSearchScreenType
import com.wire.android.navigation.NavigationCommand
import com.wire.android.navigation.WireNavigator
Expand All @@ -48,26 +51,33 @@ fun AllFilesScreen(
) {

val pagingListItems = viewModel.nodesFlow.collectAsLazyPagingItems()
val isOnline by viewModel.isOnline.collectAsState()

WireScaffold(
modifier = modifier,
topBar = {
Column {
SearchTopBar(
modifier = Modifier,
isSearchActive = false,
searchBarHint = stringResource(R.string.search_label),
searchQueryTextState = rememberTextFieldState(),
onTap = {
navigator.navigate(
NavigationCommand(
SearchScreenDestination(
screenType = DriveSearchScreenType.DRIVE,
AnimatedContent(isOnline) {
if (it) {
SearchTopBar(
modifier = Modifier,
isSearchActive = false,
searchBarHint = stringResource(R.string.search_label),
searchQueryTextState = rememberTextFieldState(),
onTap = {
navigator.navigate(
NavigationCommand(
SearchScreenDestination(
screenType = DriveSearchScreenType.DRIVE,
)
)
)
)
},
)
},
)
} else {
OfflineBanner()
}
}
}
},
) { innerPadding ->
Expand All @@ -79,6 +89,7 @@ fun AllFilesScreen(
openFolder = { _, _, _ -> },
menuState = viewModel.menu,
isAllFiles = true,
isOffline = !isOnline,
isRestoreInProgress = viewModel.isRestoreInProgress.collectAsState().value,
isDeleteInProgress = viewModel.isDeleteInProgress.collectAsState().value,
isRecycleBin = viewModel.isRecycleBin(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ class CellFileActionsMenu @Inject constructor(
isAllFiles: Boolean,
isSearching: Boolean,
isCollaboraEnabled: Boolean,
isOnline: Boolean = true,
): List<NodeBottomSheetAction> {
if (!isOnline) {
return buildList {
val canOpenOffline = cellNode is CellNodeUi.Folder ||
(cellNode is CellNodeUi.File && cellNode.localFileAvailable())
if (canOpenOffline) {
add(NodeBottomSheetAction.OPEN)
}
if (cellNode is CellNodeUi.File && cellNode.isAvailableOffline) {
add(NodeBottomSheetAction.REMOVE_OFFLINE_ACCESS)
}
}
}
return when {
isRecycleBin -> recycleBinActions()

Expand Down Expand Up @@ -84,12 +97,13 @@ class CellFileActionsMenu @Inject constructor(
}

else -> {

add(NodeBottomSheetAction.OPEN)

if (cellNode.localFileAvailable()) {
add(NodeBottomSheetAction.SHARE)
}

add(NodeBottomSheetAction.PUBLIC_LINK)

add(
if (cellNode.isAvailableOffline) {
NodeBottomSheetAction.REMOVE_OFFLINE_ACCESS
Expand All @@ -100,7 +114,7 @@ class CellFileActionsMenu @Inject constructor(
}
}
} else {
add(NodeBottomSheetAction.PUBLIC_LINK)
add(NodeBottomSheetAction.OPEN)
}
}

Expand Down Expand Up @@ -129,6 +143,7 @@ class CellFileActionsMenu @Inject constructor(
addAll(
listOf(
NodeBottomSheetAction.ADD_REMOVE_TAGS,
NodeBottomSheetAction.PUBLIC_LINK,
NodeBottomSheetAction.MOVE,
NodeBottomSheetAction.RENAME,
NodeBottomSheetAction.DELETE,
Expand All @@ -138,6 +153,7 @@ class CellFileActionsMenu @Inject constructor(

internal sealed interface MenuActionResult
internal data class Action(val action: CellViewAction) : MenuActionResult
internal data class Open(val node: CellNodeUi) : MenuActionResult
internal data class Share(val node: CellNodeUi.File) : MenuActionResult
internal data class Edit(val node: CellNodeUi) : MenuActionResult
internal data class CancelLoading(val node: CellNodeUi) : MenuActionResult
Expand All @@ -153,6 +169,7 @@ class CellFileActionsMenu @Inject constructor(
onResult: (MenuActionResult) -> Unit,
) {
val result = when (action) {
NodeBottomSheetAction.OPEN -> Open(node)
NodeBottomSheetAction.SHARE -> {
if (node is CellNodeUi.File) {
Share(node)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ internal fun CellFilesScreen(
modifier: Modifier = Modifier,
isPullToRefreshEnabled: Boolean = true,
lazyListState: LazyListState = rememberLazyListState(),
showConversationName: Boolean = true,
onItemMenuClick: (CellNodeUi) -> Unit
) {
if (isPullToRefreshEnabled) {
Expand All @@ -79,6 +80,7 @@ internal fun CellFilesScreen(
lazyListState = lazyListState,
onItemClick = onItemClick,
onItemMenuClick = onItemMenuClick,
showConversationName = showConversationName,
)
}
} else {
Expand All @@ -88,6 +90,7 @@ internal fun CellFilesScreen(
lazyListState = lazyListState,
onItemClick = onItemClick,
onItemMenuClick = onItemMenuClick,
showConversationName = showConversationName,
)
}
}
Expand All @@ -99,6 +102,7 @@ private fun ContentList(
onItemClick: (CellNodeUi) -> Unit,
onItemMenuClick: (CellNodeUi) -> Unit,
modifier: Modifier = Modifier,
showConversationName: Boolean = true,
) {
LazyColumn(
modifier = modifier.fillMaxWidth(),
Expand All @@ -118,6 +122,7 @@ private fun ContentList(
.background(color = colorsScheme().surface)
.clickable { onItemClick(item) },
cell = item,
showConversationName = showConversationName,
onMenuClick = { onItemMenuClick(item) }
)
WireDivider(modifier = Modifier.fillMaxWidth())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ internal fun CellListItem(
cell: CellNodeUi,
onMenuClick: () -> Unit,
modifier: Modifier = Modifier,
showConversationName: Boolean = true,
) {
val interactionSource = remember { MutableInteractionSource() }
var showReadyState by remember { mutableStateOf(false) }
Expand Down Expand Up @@ -132,7 +133,7 @@ internal fun CellListItem(
)

Row(verticalAlignment = Alignment.CenterVertically) {
CellItemSubtitle(cell = cell, showReadyState = showReadyState)
CellItemSubtitle(cell = cell, showReadyState = showReadyState, showConversationName = showConversationName)
}
}

Expand Down Expand Up @@ -184,7 +185,7 @@ private fun CellItemIcon(cell: CellNodeUi, showReadyState: Boolean) {
}

@Composable
private fun CellItemSubtitle(cell: CellNodeUi, showReadyState: Boolean) {
private fun CellItemSubtitle(cell: CellNodeUi, showReadyState: Boolean, showConversationName: Boolean) {
when {
cell.openLoadState is OpenLoadState.Loading -> Text(
text = stringResource(R.string.tap_to_cancel_loading),
Expand Down Expand Up @@ -241,7 +242,7 @@ private fun CellItemSubtitle(cell: CellNodeUi, showReadyState: Boolean) {
modifier = Modifier.padding(end = dimensions().spacing4x)
)
}
cell.subtitle()?.let {
cell.subtitle(showConversationName)?.let {
Text(
text = it,
textAlign = TextAlign.Left,
Expand Down Expand Up @@ -446,19 +447,19 @@ private fun PublicLinkIcon(
}

@Composable
private fun CellNodeUi.subtitle(): String? {
private fun CellNodeUi.subtitle(showConversationName: Boolean): String? {
val formattedTime = modifiedTime?.let {
remember(it) { Instant.fromEpochMilliseconds(it).cellFileDateTime() }
}
return when {
userName != null && conversationName != null ->
showConversationName && userName != null && conversationName != null ->
stringResource(R.string.file_subtitle, userName!!, conversationName!!)

userName != null && formattedTime != null ->
stringResource(R.string.file_subtitle_modified, formattedTime, userName!!)

userName != null -> userName
conversationName != null -> conversationName
showConversationName && conversationName != null -> conversationName
formattedTime != null -> formattedTime
else -> null
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ internal fun CellScreenContent(
isRecycleBin: Boolean = false,
isAllFiles: Boolean = false,
isSearchResult: Boolean = false,
isOffline: Boolean = false,
isPullToRefreshEnabled: Boolean = true,
lazyListState: LazyListState = rememberLazyListState(),
retryEditNodeError: (String) -> Unit = {},
Expand Down Expand Up @@ -142,6 +143,7 @@ internal fun CellScreenContent(
onItemMenuClick = { sendIntent(CellViewIntent.OnItemMenuClick(it)) },
isRefreshing = isRefreshing,
onRefresh = onRefresh,
showConversationName = !isOffline || isAllFiles || isRecycleBin,
)
}

Expand Down Expand Up @@ -246,7 +248,7 @@ internal fun CellScreenContent(
is ShowFileDeletedMessage -> showDeleteConfirmation(context, action.isFile, action.permanently)
is OpenFolder -> openFolder(action.path, action.title, action.parentFolderUuid)
is ShowEditErrorDialog -> editNodeError = action.nodeUuid
is ShowOfflineFileSaved -> {
is ShowOfflineFileSaved -> {
Toast.makeText(
context,
offlineFileSavedToastDescription,
Expand Down
Loading
Loading