Skip to content

Commit

Permalink
Added MultiSelect in SharedWithMe fragment
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Mar 25, 2022
1 parent 97386cf commit 0f0379e
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 2 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/*
* Infomaniak kDrive - Android
* Copyright (C) 2022 Infomaniak Network SA
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* 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 <http://www.gnu.org/licenses/>.
*/
package com.infomaniak.drive.ui.fileList.multiSelect

import androidx.core.view.isGone
import com.infomaniak.drive.ui.menu.SharedWithMeFragment
import kotlinx.android.synthetic.main.fragment_bottom_sheet_multi_select_actions.*

class SharedWithMeMultiSelectActionsBottomSheetDialog : MultiSelectActionsBottomSheetDialog(
matomoCategory = SharedWithMeFragment.MATOMO_CATEGORY,
) {

override fun configureColoredFolder(areIndividualActionsVisible: Boolean) {
coloredFolder.isGone = true
}

override fun configureAddFavorites(areIndividualActionsVisible: Boolean) {
addFavorites.isGone = true
}

override fun configureAvailableOffline() {
availableOffline.isGone = true
}

override fun configureDuplicateFile() {
duplicateFile.isGone = true
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,18 @@ import android.os.Bundle
import android.view.View
import androidx.core.os.bundleOf
import androidx.core.view.isGone
import androidx.core.view.isInvisible
import androidx.navigation.fragment.findNavController
import androidx.navigation.fragment.navArgs
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.infomaniak.drive.R
import com.infomaniak.drive.data.cache.DriveInfosController
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.SharedWithMeMultiSelectActionsBottomSheetDialog
import com.infomaniak.drive.utils.AccountUtils
import com.infomaniak.drive.utils.Utils
import com.infomaniak.drive.utils.Utils.ROOT_ID
Expand All @@ -39,11 +43,14 @@ import kotlinx.android.synthetic.main.fragment_file_list.*

class SharedWithMeFragment : FileSubTypeListFragment() {

private lateinit var realm: Realm
private val navigationArgs: SharedWithMeFragmentArgs by navArgs()
private lateinit var realm: Realm

override var enabledMultiSelectMode: Boolean = true
override var hideBackButtonWhenRoot: Boolean = false

override fun initSwipeRefreshLayout(): SwipeRefreshLayout? = swipeRefreshLayout

override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
val inDriveList = folderId == ROOT_ID && !navigationArgs.driveId.isPositive()
val inDriveRoot = folderId == ROOT_ID && navigationArgs.driveId.isPositive()
Expand All @@ -52,7 +59,10 @@ class SharedWithMeFragment : FileSubTypeListFragment() {
realm = FileController.getRealmInstance(userDrive)
downloadFiles = DownloadFiles(
when {
inDriveList -> null
inDriveList -> {
enabledMultiSelectMode = false
null
}
inDriveRoot -> File(driveId = navigationArgs.driveId, type = File.Type.DRIVE.value)
else -> File(id = folderId, name = folderName, driveId = navigationArgs.driveId)
}
Expand Down Expand Up @@ -82,6 +92,8 @@ class SharedWithMeFragment : FileSubTypeListFragment() {
}
}
}

setupMultiSelectLayout()
}

override fun onDestroy() {
Expand All @@ -106,6 +118,30 @@ class SharedWithMeFragment : FileSubTypeListFragment() {
)
}

private fun setupMultiSelectLayout() {
multiSelectLayout?.apply {
moveButtonMultiSelect.isInvisible = true
deleteButtonMultiSelect.isInvisible = true
}
}

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
).toBundle()
}.show(childFragmentManager, "ActionSharedWithMeMultiSelectBottomSheetDialog")
}

companion object {
const val MATOMO_CATEGORY = "sharedWithMeFileAction"
}

private inner class SetNoFilesLayout : () -> Unit {
override fun invoke() {
noFilesLayout.setup(
Expand Down

0 comments on commit 0f0379e

Please sign in to comment.