Skip to content

Commit

Permalink
Remove duplication for open ColorFolderBottomSheetDialog
Browse files Browse the repository at this point in the history
  • Loading branch information
JorisBodin authored and KevinBoulongne committed Mar 31, 2022
1 parent e1cab8c commit 30470e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import android.view.View
import android.view.ViewGroup
import androidx.activity.result.contract.ActivityResultContracts.StartActivityForResult
import androidx.core.os.bundleOf
import androidx.fragment.app.Fragment
import androidx.fragment.app.activityViewModels
import androidx.lifecycle.Observer
import androidx.lifecycle.lifecycleScope
Expand Down Expand Up @@ -213,11 +214,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc

override fun colorFolderClicked(color: String) {
super.colorFolderClicked(color)
if (AccountUtils.getCurrentDrive()?.pack == Drive.DrivePack.FREE.value) {
safeNavigate(R.id.colorFolderUpgradeBottomSheetDialog)
} else {
safeNavigate(FileInfoActionsBottomSheetDialogDirections.actionFileInfoActionsToColorFolder(color))
}
openColorFolderBottomSheetDialog(color)
}

override fun addFavoritesClicked() {
Expand Down Expand Up @@ -387,4 +384,18 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
val bundle = bundleOf(CANCELLABLE_TITLE_KEY to message, CANCELLABLE_ACTION_KEY to action)
setBackNavigationResult(CANCELLABLE_MAIN_KEY, bundle)
}

companion object {

fun Fragment.openColorFolderBottomSheetDialog(color: String?) {
if (AccountUtils.getCurrentDrive()?.pack == Drive.DrivePack.FREE.value) {
safeNavigate(R.id.colorFolderUpgradeBottomSheetDialog)
} else {
safeNavigate(
R.id.colorFolderBottomSheetDialog,
ColorFolderBottomSheetDialogArgs(color = color).toBundle()
)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.infomaniak.drive.data.api.ApiRoutes
import com.infomaniak.drive.data.cache.FileController
import com.infomaniak.drive.data.models.BulkOperationType
import com.infomaniak.drive.ui.MainViewModel
import com.infomaniak.drive.ui.bottomSheetDialogs.FileInfoActionsBottomSheetDialog.Companion.openColorFolderBottomSheetDialog
import com.infomaniak.drive.utils.*
import com.infomaniak.drive.utils.MatomoUtils.trackEvent
import kotlinx.android.synthetic.main.fragment_bottom_sheet_multi_select_actions.*
Expand Down Expand Up @@ -194,7 +195,7 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S
closeMultiSelect()
} else {
when (finalType) {
BulkOperationType.COLOR_FOLDER -> colorFolders()
BulkOperationType.COLOR_FOLDER -> openColorFolderBottomSheetDialog(null)
BulkOperationType.COPY -> duplicateFiles()
BulkOperationType.RESTORE_IN -> restoreIn()
BulkOperationType.RESTORE_TO_ORIGIN, BulkOperationType.DELETE_PERMANENTLY -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,11 +40,9 @@ import com.infomaniak.drive.data.cache.FileController
import com.infomaniak.drive.data.models.BulkOperation
import com.infomaniak.drive.data.models.BulkOperationType
import com.infomaniak.drive.data.models.File
import com.infomaniak.drive.data.models.drive.Drive
import com.infomaniak.drive.data.services.MqttClientWrapper
import com.infomaniak.drive.databinding.MultiSelectLayoutBinding
import com.infomaniak.drive.ui.MainViewModel
import com.infomaniak.drive.ui.fileList.FileListFragmentDirections
import com.infomaniak.drive.ui.fileList.SelectFolderActivity
import com.infomaniak.drive.ui.fileList.SelectFolderActivity.Companion.ARE_ALL_FROM_THE_SAME_FOLDER_CUSTOM_TAG
import com.infomaniak.drive.ui.fileList.SelectFolderActivity.Companion.BULK_OPERATION_CUSTOM_TAG
Expand Down Expand Up @@ -170,14 +168,6 @@ abstract class MultiSelectFragment(private val matomoCategory: String) : Fragmen
performBulkOperation(type = BulkOperationType.TRASH, allSelectedFilesCount = allSelectedFilesCount)
}

fun colorFolders() {
if (AccountUtils.getCurrentDrive()?.pack == Drive.DrivePack.FREE.value) {
safeNavigate(R.id.colorFolderUpgradeBottomSheetDialog)
} else {
safeNavigate(FileListFragmentDirections.actionFileListToColorFolder(null))
}
}

fun duplicateFiles() {
val intent = Intent(requireContext(), SelectFolderActivity::class.java).apply {
putExtra(USER_ID_TAG, AccountUtils.currentUserId)
Expand Down
9 changes: 0 additions & 9 deletions app/src/main/res/navigation/main_navigation.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,6 @@
<action
android:id="@+id/action_fileListFragment_to_downloadProgressDialog"
app:destination="@id/downloadProgressDialog" />
<action
android:id="@+id/action_fileList_to_colorFolder"
app:destination="@id/colorFolderBottomSheetDialog" />
</fragment>

<fragment
Expand Down Expand Up @@ -182,9 +179,6 @@
<action
android:id="@+id/action_fileInfoActionsBottomSheetDialog_to_selectCategoriesFragment"
app:destination="@id/selectCategoriesFragment" />
<action
android:id="@+id/action_fileInfoActions_to_colorFolder"
app:destination="@id/colorFolderBottomSheetDialog" />
</dialog>

<dialog
Expand Down Expand Up @@ -260,9 +254,6 @@
<action
android:id="@+id/action_favoritesFragment_self"
app:destination="@id/favoritesFragment" />
<action
android:id="@+id/action_fileList_to_colorFolder"
app:destination="@id/colorFolderBottomSheetDialog" />
</fragment>

<fragment
Expand Down

0 comments on commit 30470e5

Please sign in to comment.