From 30e4f0452ee663357013c9eeaa692ed5cf21da4b Mon Sep 17 00:00:00 2001 From: KevinBoulongne Date: Mon, 28 Mar 2022 11:22:20 +0200 Subject: [PATCH 1/2] Fix MultiSelect download outside of default FileList --- .../drive/ui/fileList/FavoritesFragment.kt | 3 +- .../drive/ui/fileList/FileListFragment.kt | 3 +- .../MultiSelectActionsBottomSheetDialog.kt | 32 +++++++++++++------ ...rashMultiSelectActionsBottomSheetDialog.kt | 2 +- .../drive/ui/menu/MySharesFragment.kt | 3 +- .../drive/ui/menu/OfflineFileFragment.kt | 3 +- .../drive/ui/menu/PicturesFragment.kt | 4 ++- .../drive/ui/menu/RecentChangesFragment.kt | 3 +- .../drive/ui/menu/SharedWithMeFragment.kt | 3 +- .../infomaniak/drive/ui/menu/TrashFragment.kt | 3 +- .../main/res/navigation/main_navigation.xml | 4 +++ 11 files changed, 44 insertions(+), 19 deletions(-) diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt index d868a5f2fb..0c03f46077 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt @@ -84,7 +84,8 @@ class FavoritesFragment : FileListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionFavoritesMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt index 0341fe046c..e0148b44c8 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt @@ -670,7 +670,8 @@ open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefresh onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = true, ).toBundle() }.show(childFragmentManager, "ActionFileListMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt index a5538432d0..72b12a284d 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectActionsBottomSheetDialog.kt @@ -59,7 +59,7 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S configureColoredFolder(areIndividualActionsVisible) configureAddFavorites(areIndividualActionsVisible) configureAvailableOffline() - configureDownloadFile() + configureDownload() configureDuplicateFile() configureRestoreFileIn() configureRestoreFileToOriginalPlace() @@ -122,10 +122,10 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S onActionSelected(action) } - protected open fun configureDownloadFile() { + protected open fun configureDownload() { val drivePermissions = DrivePermissions().apply { registerPermissions(this@MultiSelectActionsBottomSheetDialog) { authorized -> - if (authorized) downloadFileArchive() + if (authorized) download() } } @@ -133,7 +133,7 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S setOnClickListener { if (drivePermissions.checkWriteStoragePermission()) { context?.applicationContext?.trackEvent(matomoCategory, TrackerAction.CLICK, "bulkDownload") - downloadFileArchive() + download() } } @@ -157,13 +157,14 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S deletePermanently.isGone = true } - private fun downloadFileArchive() { - - fun downloadArchive(fileIds: IntArray) = liveData(Dispatchers.IO) { - emit(ApiRepository.getUUIDArchiveFiles(AccountUtils.currentDriveId, fileIds)) - } + private fun download() { + if (navigationArgs.areAllFromTheSameFolder) downloadArchive() else downloadFiles() + } - downloadArchive(navigationArgs.fileIds).observe(viewLifecycleOwner) { apiResponse -> + private fun downloadArchive() { + liveData(Dispatchers.IO) { + emit(ApiRepository.getUUIDArchiveFiles(AccountUtils.currentDriveId, navigationArgs.fileIds)) + }.observe(viewLifecycleOwner) { apiResponse -> if (apiResponse.isSuccess()) { apiResponse.data?.let { val downloadURL = Uri.parse(ApiRoutes.downloadArchiveFiles(AccountUtils.currentDriveId, it.uuid)) @@ -176,6 +177,17 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S } } + private fun downloadFiles() { + navigationArgs.fileIds.forEach { fileId -> + FileController.getFileProxyById(fileId = fileId, customRealm = mainViewModel.realm)?.let { file -> + val downloadUrl = Uri.parse(ApiRoutes.downloadFile(file)) + val fileName = if (file.isFolder()) "${file.name}.zip" else file.name + requireContext().startDownloadFile(downloadUrl, fileName) + } + } + onActionSelected() + } + fun onActionSelected(type: SelectDialogAction? = null) { val finalType = when (type) { SelectDialogAction.COLOR_FOLDER -> BulkOperationType.COLOR_FOLDER diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/TrashMultiSelectActionsBottomSheetDialog.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/TrashMultiSelectActionsBottomSheetDialog.kt index 89dcac2244..ff09060592 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/TrashMultiSelectActionsBottomSheetDialog.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/TrashMultiSelectActionsBottomSheetDialog.kt @@ -36,7 +36,7 @@ class TrashMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDi availableOffline.isGone = true } - override fun configureDownloadFile() { + override fun configureDownload() { downloadFile.isGone = true } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt index e84c119a9c..49e9bd332d 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt @@ -77,7 +77,8 @@ class MySharesFragment : FileSubTypeListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionMySharesMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt index 6630ca99cb..6e6b89fc2a 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt @@ -52,7 +52,8 @@ open class OfflineFileFragment : FileSubTypeListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionOfflineMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt index c8e47f3254..c87b04462c 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt @@ -239,13 +239,15 @@ class PicturesFragment : MultiSelectFragment(MATOMO_CATEGORY) { } fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline) = multiSelectManager.getMenuNavArgs() + val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() PicturesMultiSelectActionsBottomSheetDialog().apply { arguments = MultiSelectActionsBottomSheetDialogArgs( fileIds = fileIds, onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionPicturesMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt index 71b063a810..d597a63785 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt @@ -71,7 +71,8 @@ class RecentChangesFragment : FileSubTypeListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionRecentChangesMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt index e56ff4c80e..61a6849de2 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt @@ -133,7 +133,8 @@ class SharedWithMeFragment : FileSubTypeListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionSharedWithMeMultiSelectBottomSheetDialog") } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt index 3cb0eb828b..c229e00f9c 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt @@ -131,7 +131,8 @@ class TrashFragment : FileSubTypeListFragment() { onlyFolders = onlyFolders, onlyFavorite = onlyFavorite, onlyOffline = onlyOffline, - isAllSelected = isAllSelected + isAllSelected = isAllSelected, + areAllFromTheSameFolder = false, ).toBundle() }.show(childFragmentManager, "ActionTrashMultiSelectBottomSheetDialog") } diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index 3e07991a82..5a99f8df9e 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -205,6 +205,10 @@ android:name="isAllSelected" android:defaultValue="false" app:argType="boolean" /> + Date: Thu, 31 Mar 2022 17:04:26 +0200 Subject: [PATCH 2/2] Remove duplication for `onMenuButtonClicked` --- .../drive/ui/fileList/FavoritesFragment.kt | 22 ++++++++----------- .../drive/ui/fileList/FileListFragment.kt | 22 +++++-------------- .../multiSelect/MultiSelectFragment.kt | 21 ++++++++++++++++++ .../drive/ui/menu/MenuPicturesFragment.kt | 8 ++++++- .../drive/ui/menu/MySharesFragment.kt | 22 ++++++++----------- .../drive/ui/menu/OfflineFileFragment.kt | 22 ++++++++----------- .../drive/ui/menu/PicturesFragment.kt | 16 -------------- .../drive/ui/menu/RecentChangesFragment.kt | 22 ++++++++----------- .../drive/ui/menu/SharedWithMeFragment.kt | 22 ++++++++----------- .../infomaniak/drive/ui/menu/TrashFragment.kt | 22 ++++++++----------- .../main/res/navigation/main_navigation.xml | 1 - 11 files changed, 88 insertions(+), 112 deletions(-) diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt index 0c03f46077..37779ce068 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/FavoritesFragment.kt @@ -27,7 +27,7 @@ import com.infomaniak.drive.data.cache.FileController import com.infomaniak.drive.data.models.BulkOperationType import com.infomaniak.drive.data.models.File import com.infomaniak.drive.ui.fileList.multiSelect.FavoritesMultiSelectActionsBottomSheetDialog -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.Utils import com.infomaniak.drive.utils.Utils.OTHER_ROOT_ID import com.infomaniak.drive.utils.Utils.ROOT_ID @@ -76,18 +76,14 @@ class FavoritesFragment : FileListFragment() { multiSelectLayout?.selectAllButton?.isGone = true } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - FavoritesMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionFavoritesMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = FavoritesMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } override fun performBulkOperation( diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt index e0148b44c8..169f098aef 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/FileListFragment.kt @@ -55,7 +55,6 @@ import com.infomaniak.drive.databinding.MultiSelectLayoutBinding import com.infomaniak.drive.ui.bottomSheetDialogs.ColorFolderBottomSheetDialog import com.infomaniak.drive.ui.bottomSheetDialogs.FileInfoActionsBottomSheetDialogArgs import com.infomaniak.drive.ui.fileList.multiSelect.FileListMultiSelectActionsBottomSheetDialog -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectFragment import com.infomaniak.drive.utils.* import com.infomaniak.drive.utils.FilePresenter.openBookmark @@ -343,7 +342,12 @@ open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefresh toolbarMultiSelect.setNavigationOnClickListener { closeMultiSelect() } moveButtonMultiSelect.setOnClickListener { moveFiles(folderId) } deleteButtonMultiSelect.setOnClickListener { deleteFiles(getAllSelectedFilesCount()) } - menuButtonMultiSelect.setOnClickListener { onMenuButtonClicked() } + menuButtonMultiSelect.setOnClickListener { + onMenuButtonClicked( + multiSelectBottomSheet = FileListMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = true, + ) + } selectAllButton.apply { initProgress(viewLifecycleOwner) @@ -662,20 +666,6 @@ open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefresh } } - protected open fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - FileListMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = true, - ).toBundle() - }.show(childFragmentManager, "ActionFileListMultiSelectBottomSheetDialog") - } - override fun performBulkOperation( type: BulkOperationType, areAllFromTheSameFolder: Boolean, diff --git a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt index 4760f5e072..cbdd1ebc76 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/fileList/multiSelect/MultiSelectFragment.kt @@ -160,6 +160,27 @@ abstract class MultiSelectFragment(private val matomoCategory: String) : Fragmen multiSelectLayout?.root?.isGone = true } + open fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + multiSelectBottomSheet.apply { + arguments = getMultiSelectBottomSheetArguments(areAllFromTheSameFolder) + }.show(childFragmentManager, "MultiSelectActionsBottomSheetDialog") + } + + private fun getMultiSelectBottomSheetArguments(areAllFromTheSameFolder: Boolean): Bundle { + val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() + return MultiSelectActionsBottomSheetDialogArgs( + fileIds = fileIds, + onlyFolders = onlyFolders, + onlyFavorite = onlyFavorite, + onlyOffline = onlyOffline, + isAllSelected = isAllSelected, + areAllFromTheSameFolder = areAllFromTheSameFolder, + ).toBundle() + } + fun moveFiles(folderId: Int?) { requireContext().moveFileClicked(folderId, selectFolderResultLauncher) } diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/MenuPicturesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/MenuPicturesFragment.kt index cbae234c70..2218017aa0 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/MenuPicturesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/MenuPicturesFragment.kt @@ -28,6 +28,7 @@ import androidx.navigation.fragment.findNavController import com.infomaniak.drive.R import com.infomaniak.drive.databinding.FragmentMenuPicturesBinding import com.infomaniak.drive.databinding.MultiSelectLayoutBinding +import com.infomaniak.drive.ui.fileList.multiSelect.PicturesMultiSelectActionsBottomSheetDialog class MenuPicturesFragment : Fragment() { @@ -53,7 +54,12 @@ class MenuPicturesFragment : Fragment() { toolbarMultiSelect.setNavigationOnClickListener { closeMultiSelect() } moveButtonMultiSelect.setOnClickListener { onMoveButtonClicked() } deleteButtonMultiSelect.setOnClickListener { deleteFiles() } - menuButtonMultiSelect.setOnClickListener { onMenuButtonClicked() } + menuButtonMultiSelect.setOnClickListener { + onMenuButtonClicked( + multiSelectBottomSheet = PicturesMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) + } } override fun onViewCreated(view: View, savedInstanceState: Bundle?) { diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt index 49e9bd332d..b933bdda24 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/MySharesFragment.kt @@ -23,7 +23,7 @@ import androidx.navigation.fragment.findNavController import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.infomaniak.drive.R import com.infomaniak.drive.data.cache.FileController -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.ui.fileList.multiSelect.MySharesMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.Utils import com.infomaniak.drive.utils.Utils.OTHER_ROOT_ID @@ -69,18 +69,14 @@ class MySharesFragment : FileSubTypeListFragment() { } } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - MySharesMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionMySharesMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = MySharesMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } companion object { diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt index 6e6b89fc2a..cb73d0595c 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/OfflineFileFragment.kt @@ -21,7 +21,7 @@ import android.os.Bundle import android.view.View import com.infomaniak.drive.R import com.infomaniak.drive.data.cache.FileController -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.ui.fileList.multiSelect.OfflineMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.Utils import kotlinx.android.synthetic.main.fragment_file_list.* @@ -44,18 +44,14 @@ open class OfflineFileFragment : FileSubTypeListFragment() { folderId = Utils.OTHER_ROOT_ID } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - OfflineMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionOfflineMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = OfflineMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } companion object { diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt index c87b04462c..6953824561 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/PicturesFragment.kt @@ -38,9 +38,7 @@ import com.infomaniak.drive.data.models.* import com.infomaniak.drive.data.services.DownloadWorker import com.infomaniak.drive.databinding.FragmentMenuPicturesBinding import com.infomaniak.drive.databinding.MultiSelectLayoutBinding -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectFragment -import com.infomaniak.drive.ui.fileList.multiSelect.PicturesMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.* import com.infomaniak.lib.core.utils.Utils.createRefreshTimer import com.infomaniak.lib.core.utils.setPagination @@ -238,20 +236,6 @@ class PicturesFragment : MultiSelectFragment(MATOMO_CATEGORY) { moveFiles(folderId) } - fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - PicturesMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionPicturesMultiSelectBottomSheetDialog") - } - override fun performBulkOperation( type: BulkOperationType, areAllFromTheSameFolder: Boolean, diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt index d597a63785..d1624f12a6 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/RecentChangesFragment.kt @@ -24,7 +24,7 @@ import androidx.fragment.app.viewModels import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import com.infomaniak.drive.R import com.infomaniak.drive.data.cache.FileController -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.ui.fileList.multiSelect.RecentChangesMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.AccountUtils import com.infomaniak.drive.utils.Utils @@ -63,18 +63,14 @@ class RecentChangesFragment : FileSubTypeListFragment() { folderId = Utils.OTHER_ROOT_ID } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - RecentChangesMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionRecentChangesMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = RecentChangesMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } companion object { diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt index 61a6849de2..16df9b455e 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/SharedWithMeFragment.kt @@ -31,7 +31,7 @@ import com.infomaniak.drive.data.cache.FileController import com.infomaniak.drive.data.models.File import com.infomaniak.drive.data.models.UserDrive import com.infomaniak.drive.ui.bottomSheetDialogs.DriveMaintenanceBottomSheetDialog -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.ui.fileList.multiSelect.SharedWithMeMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.AccountUtils import com.infomaniak.drive.utils.Utils @@ -125,18 +125,14 @@ class SharedWithMeFragment : FileSubTypeListFragment() { } } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - SharedWithMeMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionSharedWithMeMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = SharedWithMeMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } companion object { diff --git a/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt b/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt index c229e00f9c..5681df0bbb 100644 --- a/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt +++ b/app/src/main/java/com/infomaniak/drive/ui/menu/TrashFragment.kt @@ -29,7 +29,7 @@ import com.infomaniak.drive.data.api.ErrorCode.Companion.translateError import com.infomaniak.drive.data.models.File import com.infomaniak.drive.data.models.File.SortType import com.infomaniak.drive.data.models.File.SortTypeUsage -import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialogArgs +import com.infomaniak.drive.ui.fileList.multiSelect.MultiSelectActionsBottomSheetDialog import com.infomaniak.drive.ui.fileList.multiSelect.TrashMultiSelectActionsBottomSheetDialog import com.infomaniak.drive.utils.* import com.infomaniak.drive.utils.MatomoUtils.trackTrashEvent @@ -123,18 +123,14 @@ class TrashFragment : FileSubTypeListFragment() { } } - override fun onMenuButtonClicked() { - val (fileIds, onlyFolders, onlyFavorite, onlyOffline, isAllSelected) = multiSelectManager.getMenuNavArgs() - TrashMultiSelectActionsBottomSheetDialog().apply { - arguments = MultiSelectActionsBottomSheetDialogArgs( - fileIds = fileIds, - onlyFolders = onlyFolders, - onlyFavorite = onlyFavorite, - onlyOffline = onlyOffline, - isAllSelected = isAllSelected, - areAllFromTheSameFolder = false, - ).toBundle() - }.show(childFragmentManager, "ActionTrashMultiSelectBottomSheetDialog") + override fun onMenuButtonClicked( + multiSelectBottomSheet: MultiSelectActionsBottomSheetDialog, + areAllFromTheSameFolder: Boolean, + ) { + super.onMenuButtonClicked( + multiSelectBottomSheet = TrashMultiSelectActionsBottomSheetDialog(), + areAllFromTheSameFolder = false, + ) } override fun closeMultiSelect() { diff --git a/app/src/main/res/navigation/main_navigation.xml b/app/src/main/res/navigation/main_navigation.xml index 5a99f8df9e..4a9ece6d65 100644 --- a/app/src/main/res/navigation/main_navigation.xml +++ b/app/src/main/res/navigation/main_navigation.xml @@ -207,7 +207,6 @@ app:argType="boolean" />