From 4d35efb6d57167dc49f0e33117d845077ffcfa6b Mon Sep 17 00:00:00 2001 From: parneet-guraya Date: Mon, 22 Jan 2024 03:54:03 +0530 Subject: [PATCH] WIP Signed-off-by: parneet-guraya --- .../dependecyinjection/UseCaseModule.kt | 2 + .../files/details/FileDetailsFragment.kt | 10 +++-- .../files/filelist/MainFileListFragment.kt | 20 +++++++--- .../removefile/RemoveFilesDialogFragment.kt | 13 +++---- .../android/ui/activity/DrawerActivity.kt | 38 +++++++++++++++++++ .../ui/preview/PreviewAudioFragment.kt | 15 +++++++- .../ui/preview/PreviewImageFragment.kt | 15 +++++++- .../ui/preview/PreviewTextFragment.java | 18 ++++++--- .../ui/preview/PreviewVideoActivity.kt | 6 ++- .../files/GetIfFileFolderLocalUseCase.kt | 24 ++++++++++++ 10 files changed, 132 insertions(+), 29 deletions(-) create mode 100644 owncloudApp/src/main/java/com/owncloud/android/usecases/files/GetIfFileFolderLocalUseCase.kt diff --git a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/UseCaseModule.kt b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/UseCaseModule.kt index 395f9d37ad1..4b7253852de 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/UseCaseModule.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/dependecyinjection/UseCaseModule.kt @@ -59,6 +59,7 @@ import com.owncloud.android.domain.files.usecases.GetFileByRemotePathUseCase import com.owncloud.android.domain.files.usecases.GetFileWithSyncInfoByIdUseCase import com.owncloud.android.domain.files.usecases.GetFolderContentAsStreamUseCase import com.owncloud.android.domain.files.usecases.GetFolderContentUseCase +import com.owncloud.android.usecases.files.GetIfFileFolderLocalUseCase import com.owncloud.android.domain.files.usecases.GetFolderImagesUseCase import com.owncloud.android.domain.files.usecases.GetPersonalRootFolderForAccountUseCase import com.owncloud.android.domain.files.usecases.GetSearchFolderContentUseCase @@ -164,6 +165,7 @@ val useCaseModule = module { factoryOf(::GetFolderContentAsStreamUseCase) factoryOf(::GetFolderContentUseCase) factoryOf(::GetFolderImagesUseCase) + factoryOf(::GetIfFileFolderLocalUseCase) factoryOf(::GetPersonalRootFolderForAccountUseCase) factoryOf(::GetSearchFolderContentUseCase) factoryOf(::GetSharedByLinkForAccountAsStreamUseCase) diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt index c32ec1d407e..99883871be2 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/details/FileDetailsFragment.kt @@ -69,6 +69,7 @@ import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragm import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragment.Companion.FRAGMENT_TAG_CONFIRMATION import com.owncloud.android.presentation.files.renamefile.RenameFileDialogFragment import com.owncloud.android.presentation.files.renamefile.RenameFileDialogFragment.Companion.FRAGMENT_TAG_RENAME_FILE +import com.owncloud.android.ui.activity.FileActivity import com.owncloud.android.ui.activity.FileDisplayActivity import com.owncloud.android.ui.fragment.FileFragment import com.owncloud.android.ui.preview.PreviewAudioFragment @@ -251,8 +252,11 @@ class FileDetailsFragment : FileFragment() { } R.id.action_remove_file -> { - val dialog = RemoveFilesDialogFragment.newInstance(safeFile.file) - dialog.show(parentFragmentManager, FRAGMENT_TAG_CONFIRMATION) + val fileActivity = requireActivity() as FileActivity + fileActivity.showRemoveDialog(safeFile.file) { isLocallyAvailable -> + val dialog = RemoveFilesDialogFragment.newInstance(safeFile.file, isLocallyAvailable) + dialog.show(parentFragmentManager, FRAGMENT_TAG_CONFIRMATION) + } true } @@ -353,7 +357,7 @@ class FileDetailsFragment : FileFragment() { thumbnailImageView.bringToFront() thumbnailImageView.isVisible = false - val file = ocFileWithSyncInfo.file + val file = ocFileWithSyncInfo.file if (ocFileWithSyncInfo.isSynchronizing) { thumbnailImageView.setImageResource(R.drawable.sync_pin) thumbnailImageView.visibility = View.VISIBLE diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt index a935c83d0e2..1a0cf4dbb40 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/filelist/MainFileListFragment.kt @@ -68,6 +68,7 @@ import com.owncloud.android.domain.files.model.OCFile import com.owncloud.android.domain.files.model.OCFile.Companion.ROOT_PATH import com.owncloud.android.domain.files.model.OCFileSyncInfo import com.owncloud.android.domain.files.model.OCFileWithSyncInfo +import com.owncloud.android.usecases.files.GetIfFileFolderLocalUseCase import com.owncloud.android.domain.spaces.model.OCSpace import com.owncloud.android.domain.transfers.model.OCTransfer import com.owncloud.android.domain.transfers.model.TransferStatus @@ -111,6 +112,7 @@ import com.owncloud.android.utils.DisplayUtils import com.owncloud.android.utils.MimetypeIconUtil import com.owncloud.android.utils.PreferenceUtils import okio.Path.Companion.toPath +import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.sharedViewModel import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf @@ -473,8 +475,10 @@ class MainFileListFragment : Fragment(), } FileMenuOption.REMOVE -> { - val dialogRemove = RemoveFilesDialogFragment.newInstance(file) - dialogRemove.show(requireActivity().supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + (requireActivity() as FileActivity).showRemoveDialog(file) { isLocallyAvailable -> + val dialogRemove = RemoveFilesDialogFragment.newInstance(file, isLocallyAvailable) + dialogRemove.show(requireActivity().supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + } } FileMenuOption.OPEN_WITH -> { @@ -1095,10 +1099,14 @@ class MainFileListFragment : Fragment(), } R.id.action_remove_file -> { - val dialog = RemoveFilesDialogFragment.newInstance(checkedFiles) - dialog.show(requireActivity().supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) - fileListAdapter.clearSelection() - updateActionModeAfterTogglingSelected() + val parentActivity = requireActivity() as FileActivity + + parentActivity.showRemoveDialog(checkedFiles) { isLocallyAvailable -> + val dialog = RemoveFilesDialogFragment.newInstance(checkedFiles, isLocallyAvailable) + dialog.show(requireActivity().supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + fileListAdapter.clearSelection() + updateActionModeAfterTogglingSelected() + } return true } diff --git a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/removefile/RemoveFilesDialogFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/removefile/RemoveFilesDialogFragment.kt index dc197ec8cce..8619950b7c6 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/presentation/files/removefile/RemoveFilesDialogFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/presentation/files/removefile/RemoveFilesDialogFragment.kt @@ -77,22 +77,19 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial * @return Dialog ready to show. */ @JvmStatic - fun newInstance(files: ArrayList): RemoveFilesDialogFragment { + fun newInstance(files: ArrayList, isLocal: Boolean): RemoveFilesDialogFragment { val messageStringId: Int var containsFolder = false - var containsDown = false var containsAvailableOffline = false for (file in files) { if (file.isFolder) { containsFolder = true } - if (file.isAvailableLocally) { - containsDown = true - } if (file.isAvailableOffline) { containsAvailableOffline = true } } + messageStringId = if (files.size == 1) { // choose message for a single file val file = files.first() @@ -109,7 +106,7 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial R.string.confirmation_remove_files_alert } } - val localRemoveButton = if (!containsAvailableOffline && (containsFolder || containsDown)) { + val localRemoveButton = if (!containsAvailableOffline && isLocal) { R.string.confirmation_remove_local } else { -1 @@ -139,8 +136,8 @@ class RemoveFilesDialogFragment : ConfirmationDialogFragment(), ConfirmationDial */ @JvmStatic @JvmName("newInstanceForSingleFile") - fun newInstance(file: OCFile): RemoveFilesDialogFragment { - return newInstance(arrayListOf(file)) + fun newInstance(file: OCFile, isLocal: Boolean): RemoveFilesDialogFragment { + return newInstance(arrayListOf(file), isLocal) } } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt index a1d84593a40..bee301acd70 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/activity/DrawerActivity.kt @@ -48,12 +48,16 @@ import androidx.core.view.get import androidx.core.view.isVisible import androidx.drawerlayout.widget.DrawerLayout import androidx.drawerlayout.widget.DrawerLayout.DrawerListener +import androidx.lifecycle.lifecycleScope import com.google.android.material.bottomnavigation.BottomNavigationView import com.google.android.material.navigation.NavigationView import com.owncloud.android.BuildConfig import com.owncloud.android.R +import com.owncloud.android.domain.UseCaseResult import com.owncloud.android.domain.capabilities.model.OCCapability import com.owncloud.android.domain.files.model.FileListOption +import com.owncloud.android.domain.files.model.OCFile +import com.owncloud.android.usecases.files.GetIfFileFolderLocalUseCase import com.owncloud.android.domain.utils.Event import com.owncloud.android.extensions.goToUrl import com.owncloud.android.extensions.openPrivacyPolicy @@ -70,6 +74,10 @@ import com.owncloud.android.presentation.common.UIResult import com.owncloud.android.presentation.settings.SettingsActivity import com.owncloud.android.utils.DisplayUtils import com.owncloud.android.utils.PreferenceUtils +import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.launch +import kotlinx.coroutines.withContext +import org.koin.android.ext.android.inject import org.koin.androidx.viewmodel.ext.android.viewModel import org.koin.core.parameter.parametersOf import timber.log.Timber @@ -87,6 +95,7 @@ abstract class DrawerActivity : ToolbarActivity() { account?.name ) } + private val getIfFileFolderLocalUseCase: GetIfFileFolderLocalUseCase by inject() private var menuAccountAvatarRadiusDimension = 0f private var currentAccountAvatarRadiusDimension = 0f @@ -205,17 +214,20 @@ abstract class DrawerActivity : ToolbarActivity() { val settingsIntent = Intent(applicationContext, SettingsActivity::class.java) startActivity(settingsIntent) } + R.id.drawer_menu_account_add -> createAccount(false) R.id.drawer_menu_account_manage -> { val manageAccountsIntent = Intent(applicationContext, AccountsManagementActivity::class.java) startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS) } + R.id.drawer_menu_feedback -> openFeedback() R.id.drawer_menu_help -> openHelp() R.id.drawer_menu_privacy_policy -> openPrivacyPolicy() Menu.NONE -> { accountClicked(menuItem.title.toString()) } + else -> Timber.i("Unknown drawer menu item clicked: %s", menuItem.title) } true @@ -274,6 +286,7 @@ abstract class DrawerActivity : ToolbarActivity() { uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP) startActivity(uploadListIntent) } + R.id.nav_available_offline_files -> navigateToOption(FileListOption.AV_OFFLINE) R.id.nav_shared_by_link_files -> navigateToOption(FileListOption.SHARED_BY_LINK) } @@ -462,10 +475,12 @@ abstract class DrawerActivity : ToolbarActivity() { ) } + userQuota.available == 0L -> { // Quota 0, guest users getAccountQuotaBar()?.isVisible = false getAccountQuotaText()?.text = getString(R.string.drawer_unavailable_used_storage) } + else -> { // Limited quota // Update progress bar rounding up to next int. Example: quota is 0.54 => 1 getAccountQuotaBar()?.run { @@ -482,6 +497,7 @@ abstract class DrawerActivity : ToolbarActivity() { } } } + is UIResult.Loading -> getAccountQuotaText()?.text = getString(R.string.drawer_loading_quota) is UIResult.Error -> getAccountQuotaText()?.text = getString(R.string.drawer_unavailable_used_storage) } @@ -672,6 +688,28 @@ abstract class DrawerActivity : ToolbarActivity() { restart() } + // TODO: only for temp basis, should be in FileActivity (not possible currently because it is in java) + + fun showRemoveDialog( + fileToRemove: OCFile, + showDialog: (isLocallyAvailable: Boolean) -> Unit + ) = showRemoveDialog(listOf(fileToRemove), showDialog) + + fun showRemoveDialog( + filesToRemove: List, + showDialog: (isLocallyAvailable: Boolean) -> Unit + ) { + lifecycleScope.launch { + val useCaseResult = withContext(Dispatchers.IO) { + getIfFileFolderLocalUseCase(GetIfFileFolderLocalUseCase.Params(filesToRemove)) + } + when (useCaseResult) { + is UseCaseResult.Error -> {} + is UseCaseResult.Success -> showDialog(useCaseResult.data) + } + } + } + /** * populates the avatar drawer array with the first three ownCloud [Account]s while the first element is * always the current account. diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.kt index 403d5b13d8f..efda34970ae 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewAudioFragment.kt @@ -44,6 +44,7 @@ import android.widget.ImageView import android.widget.ProgressBar import com.owncloud.android.R import com.owncloud.android.domain.files.model.OCFile +import com.owncloud.android.usecases.files.GetIfFileFolderLocalUseCase import com.owncloud.android.extensions.collectLatestLifecycleFlow import com.owncloud.android.extensions.filterMenuOptions import com.owncloud.android.extensions.sendDownloadedFilesByShareSheet @@ -54,6 +55,7 @@ import com.owncloud.android.presentation.files.operations.FileOperation import com.owncloud.android.presentation.files.operations.FileOperationsViewModel import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragment import com.owncloud.android.presentation.previews.PreviewAudioViewModel +import com.owncloud.android.ui.activity.FileActivity import com.owncloud.android.ui.controller.TransferProgressController import com.owncloud.android.ui.dialog.ConfirmationDialogFragment import com.owncloud.android.ui.fragment.FileFragment @@ -260,35 +262,44 @@ class PreviewAudioFragment : FileFragment() { mContainerActivity.fileOperationsHelper.showShareFile(file) true } + R.id.action_open_file_with -> { openFile() true } + R.id.action_remove_file -> { - val dialog = RemoveFilesDialogFragment.newInstance(file) - dialog.show(parentFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + (requireActivity() as FileActivity).showRemoveDialog(file) { isLocallyAvailable -> + val dialog = RemoveFilesDialogFragment.newInstance(file, isLocallyAvailable) + dialog.show(parentFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + } true } R.id.action_see_details -> { seeDetails() true } + R.id.action_send_file -> { requireActivity().sendDownloadedFilesByShareSheet(listOf(file)) true } + R.id.action_sync_file -> { mContainerActivity.fileOperationsHelper.syncFile(file) true } + R.id.action_set_available_offline -> { fileOperationsViewModel.performOperation(FileOperation.SetFilesAsAvailableOffline(listOf(file))) true } + R.id.action_unset_available_offline -> { fileOperationsViewModel.performOperation(FileOperation.UnsetFilesAsAvailableOffline(listOf(file))) true } + else -> super.onOptionsItemSelected(item) } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt index 5e6b3a7a262..d6b05eabee6 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt @@ -56,6 +56,7 @@ import com.owncloud.android.extensions.sendDownloadedFilesByShareSheet import com.owncloud.android.presentation.files.operations.FileOperation import com.owncloud.android.presentation.files.operations.FileOperationsViewModel import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragment +import com.owncloud.android.ui.activity.FileActivity import com.owncloud.android.ui.controller.TransferProgressController import com.owncloud.android.ui.dialog.ConfirmationDialogFragment import com.owncloud.android.ui.fragment.FileFragment @@ -213,35 +214,45 @@ class PreviewImageFragment : FileFragment() { mContainerActivity.fileOperationsHelper.showShareFile(file) true } + R.id.action_open_file_with -> { openFile() true } + R.id.action_remove_file -> { - val dialog = RemoveFilesDialogFragment.newInstance(file) - dialog.show(requireFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION) + (requireActivity() as FileActivity).showRemoveDialog(file) { isLocallyAvailable -> + val dialog = RemoveFilesDialogFragment.newInstance(file, isLocallyAvailable) + dialog.show(requireFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION) + } true } + R.id.action_see_details -> { seeDetails() true } + R.id.action_send_file -> { requireActivity().sendDownloadedFilesByShareSheet(listOf(file)) true } + R.id.action_sync_file -> { mContainerActivity.fileOperationsHelper.syncFile(file) true } + R.id.action_set_available_offline -> { fileOperationsViewModel.performOperation(FileOperation.SetFilesAsAvailableOffline(listOf(file))) true } + R.id.action_unset_available_offline -> { fileOperationsViewModel.performOperation(FileOperation.UnsetFilesAsAvailableOffline(listOf(file))) true } + else -> super.onOptionsItemSelected(item) } } diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java index 7da619736d6..224a6c400f4 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewTextFragment.java @@ -5,18 +5,18 @@ * @author Shashvat Kedia * @author Juan Carlos Garrote Gascón * @author Parneet Singh - * + *

* Copyright (C) 2023 ownCloud GmbH. - * + *

* This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2, * as published by the Free Software Foundation. - * + *

* This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + *

* You should have received a copy of the GNU General Public License * along with this program. If not, see . */ @@ -55,11 +55,13 @@ import com.owncloud.android.presentation.files.operations.FileOperationsViewModel; import com.owncloud.android.presentation.files.removefile.RemoveFilesDialogFragment; import com.owncloud.android.presentation.previews.PreviewTextViewModel; +import com.owncloud.android.ui.activity.FileActivity; import com.owncloud.android.ui.controller.TransferProgressController; import com.owncloud.android.ui.dialog.ConfirmationDialogFragment; import com.owncloud.android.ui.dialog.LoadingDialog; import com.owncloud.android.ui.fragment.FileFragment; import com.owncloud.android.utils.PreferenceUtils; +import kotlin.Unit; import timber.log.Timber; import java.io.BufferedWriter; @@ -412,8 +414,12 @@ public boolean onOptionsItemSelected(MenuItem item) { return true; } case R.id.action_remove_file: { - RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstanceForSingleFile(getFile()); - dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION); + FileActivity fileActivity = (FileActivity) requireActivity(); + fileActivity.showRemoveDialog(getFile(), isLocallyAvailable -> { + RemoveFilesDialogFragment dialog = RemoveFilesDialogFragment.newInstanceForSingleFile(getFile(), isLocallyAvailable); + dialog.show(getFragmentManager(), ConfirmationDialogFragment.FTAG_CONFIRMATION); + return Unit.INSTANCE; + }); return true; } case R.id.action_see_details: { diff --git a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.kt b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.kt index eaded97df88..0f0c577d364 100644 --- a/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.kt +++ b/owncloudApp/src/main/java/com/owncloud/android/ui/preview/PreviewVideoActivity.kt @@ -364,8 +364,10 @@ class PreviewVideoActivity : FileActivity(), Player.Listener, OnPrepareVideoPlay R.id.action_remove_file -> { player?.pause() - val dialog = newInstance(file) - dialog.show(supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + showRemoveDialog(file) { isLocallyAvailable -> + val dialog = newInstance(file, isLocallyAvailable) + dialog.show(supportFragmentManager, ConfirmationDialogFragment.FTAG_CONFIRMATION) + } true } diff --git a/owncloudApp/src/main/java/com/owncloud/android/usecases/files/GetIfFileFolderLocalUseCase.kt b/owncloudApp/src/main/java/com/owncloud/android/usecases/files/GetIfFileFolderLocalUseCase.kt new file mode 100644 index 00000000000..223cb4e42d5 --- /dev/null +++ b/owncloudApp/src/main/java/com/owncloud/android/usecases/files/GetIfFileFolderLocalUseCase.kt @@ -0,0 +1,24 @@ +package com.owncloud.android.usecases.files + +import com.owncloud.android.domain.BaseUseCaseWithResult +import com.owncloud.android.domain.files.FileRepository +import com.owncloud.android.domain.files.model.OCFile + +class GetIfFileFolderLocalUseCase(private val fileRepository: FileRepository) : BaseUseCaseWithResult() { + + override fun run(params: Params): Boolean = getIfFileFolderLocal(params.listOfFiles) + + private fun getIfFileFolderLocal(listOfFiles: List): Boolean { + listOfFiles.forEach { file -> + if (file.isFolder) { + if (getIfFileFolderLocal(fileRepository.getFolderContent(file.id!!))) return true + } else { + if (file.isAvailableLocally) return true + } + } + return false + } + + data class Params(val listOfFiles: List) + +}