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 @@ -35,6 +35,7 @@ import com.owncloud.android.presentation.common.DrawerViewModel
import com.owncloud.android.presentation.conflicts.ConflictsResolveViewModel
import com.owncloud.android.presentation.files.details.FileDetailsViewModel
import com.owncloud.android.presentation.files.filelist.MainFileListViewModel
import com.owncloud.android.presentation.files.globalsearch.GlobalSearchViewModel
import com.owncloud.android.presentation.files.operations.FileOperationsViewModel
import com.owncloud.android.presentation.logging.LogListViewModel
import com.owncloud.android.presentation.migration.MigrationViewModel
Expand Down Expand Up @@ -85,6 +86,7 @@ val viewModelModule = module {
viewModelOf(::SettingsVideoUploadsViewModel)
viewModelOf(::SettingsViewModel)
viewModelOf(::FileOperationsViewModel)
viewModelOf(::GlobalSearchViewModel)

viewModel { (accountName: String) -> CapabilityViewModel(accountName, get(), get(), get(), get()) }
viewModel { (action: PasscodeAction) -> PassCodeViewModel(get(), get(), action) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ fun FileListOption.toTitleStringRes(): Int = when (this) {
FileListOption.SHARED_BY_LINK -> R.string.file_list_empty_title_shared_by_links
FileListOption.AV_OFFLINE -> R.string.file_list_empty_title_available_offline
FileListOption.UPLOADS_LIST -> R.string.upload_list_empty
FileListOption.GLOBAL_SEARCH -> R.string.homecloud_global_search_empty_title
}

@StringRes
Expand All @@ -39,6 +40,7 @@ fun FileListOption.toSubtitleStringRes(): Int = when (this) {
FileListOption.SHARED_BY_LINK -> R.string.file_list_empty_subtitle_shared_by_links
FileListOption.AV_OFFLINE -> R.string.file_list_empty_subtitle_available_offline
FileListOption.UPLOADS_LIST -> R.string.upload_list_empty_subtitle
FileListOption.GLOBAL_SEARCH -> R.string.homecloud_global_search_empty_subtitle
}

@DrawableRes
Expand All @@ -48,4 +50,5 @@ fun FileListOption.toDrawableRes(): Int = when (this) {
FileListOption.SHARED_BY_LINK -> R.drawable.ic_shared_by_link
FileListOption.AV_OFFLINE -> R.drawable.ic_available_offline
FileListOption.UPLOADS_LIST -> R.drawable.ic_uploads
FileListOption.GLOBAL_SEARCH -> R.drawable.ic_search
}
Original file line number Diff line number Diff line change
Expand Up @@ -1651,7 +1651,7 @@ class MainFileListFragment : Fragment(),
fun syncFile(file: OCFile)
fun openFile(file: OCFile)
fun sendDownloadedFile(file: OCFile)
fun cancelFileTransference(files: ArrayList<OCFile>)
fun cancelFileTransference(files: List<OCFile>)
fun setBottomBarVisibility(isVisible: Boolean)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import com.owncloud.android.domain.files.model.OCFileSyncInfo
import com.owncloud.android.domain.files.model.OCFileWithSyncInfo
import com.owncloud.android.domain.files.usecases.GetFileByIdUseCase
import com.owncloud.android.domain.files.usecases.GetFileByRemotePathUseCase
import com.owncloud.android.domain.files.usecases.GetFileByRemotePathUseCase.*
import com.owncloud.android.domain.files.usecases.GetFolderContentAsStreamUseCase
import com.owncloud.android.domain.files.usecases.GetSharedByLinkForAccountAsStreamUseCase
import com.owncloud.android.domain.files.usecases.SortFilesWithSyncInfoUseCase
Expand Down Expand Up @@ -73,6 +74,7 @@ import kotlinx.coroutines.flow.flowOf
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.flow.update
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import kotlin.time.Duration.Companion.minutes
import kotlin.time.Duration.Companion.seconds
Expand Down Expand Up @@ -172,10 +174,7 @@ class MainFileListViewModel(
)
)
}
/*
TODO: Investigate why folders are duplicated in the list.
*/
// startPeriodicalFoldersUpdate(accountName = initialFolderToDisplay.owner)
startPeriodicalFoldersUpdate(accountName = initialFolderToDisplay.owner)
}

fun navigateToFolderId(folderId: Long) {
Expand Down Expand Up @@ -235,7 +234,7 @@ class MainFileListViewModel(
val fileById = fileByIdResult.getDataOrNull()
parentDir =
if (fileById != null && (!fileById.sharedByLink || fileById.sharedWithSharee != true) && fileById.spaceId == null) {
getFileByRemotePathUseCase(GetFileByRemotePathUseCase.Params(fileById.owner, ROOT_PATH)).getDataOrNull()
getFileByRemotePathUseCase(Params(fileById.owner, ROOT_PATH)).getDataOrNull()
} else {
fileById
}
Expand All @@ -244,7 +243,7 @@ class MainFileListViewModel(
FileListOption.AV_OFFLINE -> {
val fileById = fileByIdResult.getDataOrNull()
parentDir = if (fileById != null && (!fileById.isAvailableOffline)) {
getFileByRemotePathUseCase(GetFileByRemotePathUseCase.Params(fileById.owner, ROOT_PATH)).getDataOrNull()
getFileByRemotePathUseCase(Params(fileById.owner, ROOT_PATH)).getDataOrNull()
} else {
fileById
}
Expand All @@ -258,6 +257,10 @@ class MainFileListViewModel(
parentDir = null
// do nothing
}

FileListOption.GLOBAL_SEARCH -> {
parentDir = null
}
}
} else if (parentId == ROOT_PARENT_ID) {
// Browsing to parent folder. Root
Expand Down Expand Up @@ -377,9 +380,10 @@ class MainFileListViewModel(
}

private fun startPeriodicalFoldersUpdate(accountName: String) {
// TODO: move to background job worker
viewModelScope.launch(coroutinesDispatcherProvider.io) {
delay(10.seconds) // initial delay to not interfere with the current folder refresh
while (true) {
while (isActive) {
updateFoldersRecursivelyUseCase(params = UpdateFoldersRecursivelyUseCase.Params(accountName = accountName))
delay(5.minutes) // delay between updates
}
Expand All @@ -399,6 +403,7 @@ class MainFileListViewModel(
FileListOption.AV_OFFLINE -> retrieveFlowForAvailableOffline(currentFolderDisplayed, currentFolderDisplayed.owner)
FileListOption.SPACES_LIST -> flowOf()
FileListOption.UPLOADS_LIST -> flowOf()
FileListOption.GLOBAL_SEARCH -> flowOf()
}.toFileListUiState(
currentFolderDisplayed,
fileListOption,
Expand Down Expand Up @@ -479,7 +484,7 @@ class MainFileListViewModel(
}

companion object {
private const val RECYCLER_VIEW_PREFERRED = "RECYCLER_VIEW_PREFERRED"
internal const val RECYCLER_VIEW_PREFERRED = "RECYCLER_VIEW_PREFERRED"
}
}

Loading