Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix pop stack in preview #725

Merged
merged 7 commits into from
Apr 5, 2022
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 @@ -186,10 +186,10 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {
mainViewModel.createOffice(currentFolderFile.driveId, currentFolderFile.id, createFile)
.observe(viewLifecycleOwner) { apiResponse ->
if (apiResponse.isSuccess()) {
requireActivity().showSnackbar(getString(R.string.modalCreateFileSucces, createFile.name))
showSnackbar(getString(R.string.modalCreateFileSucces, createFile.name), true)
apiResponse.data?.let { file -> requireContext().openOnlyOfficeActivity(file) }
} else {
requireActivity().showSnackbar(R.string.errorFileCreate)
showSnackbar(R.string.errorFileCreate, true)
}
mainViewModel.refreshActivities.value = true
dialog.dismiss()
Expand All @@ -215,7 +215,7 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {
launchSync = true
}
} catch (exception: Exception) {
requireActivity().showSnackbar(R.string.errorDeviceStorage)
showSnackbar(R.string.errorDeviceStorage, true)
} finally {
if (launchSync) requireContext().syncImmediately()
}
Expand Down Expand Up @@ -244,7 +244,7 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {
}
} catch (exception: Exception) {
exception.printStackTrace()
requireActivity().showSnackbar(R.string.errorDeviceStorage)
showSnackbar(R.string.errorDeviceStorage, true)
}
}

Expand All @@ -260,10 +260,10 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {

when {
isLowMemory -> {
requireActivity().showSnackbar(R.string.uploadOutOfMemoryError)
showSnackbar(R.string.uploadOutOfMemoryError, true)
}
fileName == null -> {
requireActivity().showSnackbar(R.string.anErrorHasOccurred)
showSnackbar(R.string.anErrorHasOccurred, true)
}
else -> {
CoroutineScope(Dispatchers.IO).launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,15 +80,15 @@ class CreateCommonFolderFragment : CreateFolderFragment() {
if (apiResponse.error?.code == ErrorCode.DESTINATION_ALREADY_EXISTS.code) {
folderNameValueLayout.error = getString(apiResponse.translateError())
}
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}

createFolderButton.hideProgress(R.string.createFolderTitle)
}
}

private fun whenFolderCreated(file: File) {
requireActivity().showSnackbar(R.string.createCommonFolderSucces)
showSnackbar(R.string.createCommonFolderSucces)

if (newFolderViewModel.currentPermission == SPECIFIC_USERS) {
safeNavigate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class CreateDropBoxFolderFragment : CreateFolderFragment() {
navigateToFileShareDetails(file)
}
}, onError = { translatedError ->
requireActivity().showSnackbar(translatedError)
showSnackbar(translatedError)
findNavController().popBackStack(R.id.newFolderFragment, true)
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ open class CreateFolderFragment : Fragment() {
if (apiResponse.formatError() == ErrorCode.DESTINATION_ALREADY_EXISTS) {
folderNameValueLayout.error = getString(apiResponse.translateError())
}
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
createFolderButton.hideProgress(R.string.createFolderTitle)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import com.infomaniak.drive.data.models.Permission
import com.infomaniak.drive.utils.MatomoUtils.trackNewElementEvent
import com.infomaniak.drive.utils.safeNavigate
import com.infomaniak.drive.utils.showSnackbar
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_create_folder.*

class CreatePrivateFolderFragment : CreateFolderFragment() {
Expand Down Expand Up @@ -54,7 +53,7 @@ class CreatePrivateFolderFragment : CreateFolderFragment() {
createFolder(newFolderViewModel.currentPermission == ONLY_ME) { file, redirectToShareDetails ->
file?.let {
saveNewFolder(file)
requireActivity().showSnackbar(R.string.createPrivateFolderSucces, anchorView = requireActivity().mainFab)
showSnackbar(R.string.createPrivateFolderSucces, true)
if (redirectToShareDetails) {
safeNavigate(
CreatePrivateFolderFragmentDirections.actionCreatePrivateFolderFragmentToFileShareDetailsFragment(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ import com.infomaniak.drive.utils.Utils.openWith
import com.infomaniak.drive.utils.Utils.openWithIntent
import com.infomaniak.drive.views.FileInfoActionsView
import com.infomaniak.lib.core.models.ApiResponse
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_bottom_sheet_file_info_actions.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
Expand Down Expand Up @@ -120,7 +119,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
} else {
getString(apiResponse.translatedError)
}
requireActivity().showSnackbar(text, mainFab)
showSnackbar(text, true)
}
}
}
Expand Down Expand Up @@ -189,11 +188,9 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
override fun copyPublicLink() {
super.copyPublicLink()
fileInfoActionsView.createPublicCopyLink(onSuccess = {
requireActivity().showSnackbar(title = R.string.fileInfoLinkCopiedToClipboard, anchorView = requireActivity().mainFab)
showSnackbar(R.string.fileInfoLinkCopiedToClipboard, true)
findNavController().popBackStack()
}, onError = { translatedError ->
requireActivity().showSnackbar(translatedError, anchorView = requireActivity().mainFab)
})
}, onError = { translatedError -> showSnackbar(translatedError, true) })
}

override fun downloadFileClicked() {
Expand Down Expand Up @@ -226,7 +223,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
showFavoritesResultSnackbar()
setBackNavigationResult(REFRESH_FAVORITE_FILE, currentFile.id)
} else {
requireActivity().showSnackbar(R.string.errorAddFavorite, requireActivity().mainFab)
showSnackbar(R.string.errorAddFavorite, true)
findNavController().popBackStack()
}
}
Expand Down Expand Up @@ -321,7 +318,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
override fun openWithClicked() {
super.openWithClicked()
if (requireContext().openWithIntent(currentFile).resolveActivity(requireContext().packageManager) == null) {
requireActivity().showSnackbar(R.string.allActivityNotFoundError)
showSnackbar(R.string.allActivityNotFoundError, true)
findNavController().popBackStack()
} else {
safeNavigate(
Expand Down Expand Up @@ -367,17 +364,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
}

private fun File.showFavoritesResultSnackbar() {
if (isFavorite) {
requireActivity().showSnackbar(
getString(R.string.allFileAddFavoris, name),
anchorView = requireActivity().mainFab
)
} else {
requireActivity().showSnackbar(
getString(R.string.allFileDeleteFavoris, name),
anchorView = requireActivity().mainFab
)
}
showSnackbar(getString(if (isFavorite) R.string.allFileAddFavoris else R.string.allFileDeleteFavoris, name), true)
}

private fun transmitActionAndPopBack(message: String, action: CancellableAction? = null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class NotSupportedExtensionBottomSheetDialog : InformationBottomSheetDialog() {
ApiResponse.Status.SUCCESS -> apiResponse.data?.let { newFile ->
requireContext().openOnlyOfficeActivity(newFile)
}
else -> requireActivity().showSnackbar(apiResponse.translateError())
else -> showSnackbar(apiResponse.translateError())
}
dismiss()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@ class TrashedFileActionsBottomSheetDialog : BottomSheetDialogFragment() {
dialog.dismiss()
if (apiResponse.data == true) {
val title = resources.getQuantityString(R.plurals.snackbarDeleteConfirmation, 1, currentTrashedFile.name)
requireActivity().showSnackbar(title)
showSnackbar(title)
dismissAndRemoveFileFromList()
} else {
requireActivity().showSnackbar(R.string.errorDelete)
showSnackbar(R.string.errorDelete)
findNavController().popBackStack()
}
}
Expand All @@ -112,13 +112,13 @@ class TrashedFileActionsBottomSheetDialog : BottomSheetDialogFragment() {
if (!originalPlace && folderName != null) add(folderName)
}

requireActivity().showSnackbar(resources.getQuantityString(title, 1, *args.toTypedArray()))
showSnackbar(resources.getQuantityString(title, 1, *args.toTypedArray()))
dismissAndRemoveFileFromList()
} else {
val title = if (apiResponse.formatError() == ErrorCode.AN_ERROR_HAS_OCCURRED) R.string.errorRestore
else apiResponse.translateError()

requireActivity().showSnackbar(title)
showSnackbar(title)
findNavController().popBackStack()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ class ConvertToDropBoxFragment : ManageDropboxFragment() {
mainViewModel.createDropBoxSuccess.value = apiResponse.data
findNavController().popBackStack()
} else {
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
saveButton.hideProgress(R.string.buttonSave)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ class DownloadProgressDialog : DialogFragment() {
downloadProgress.progress = progress
}
} ?: run {
requireActivity().showSnackbar(R.string.anErrorHasOccurred)
showSnackbar(R.string.anErrorHasOccurred)
findNavController().popBackStack()
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ import com.infomaniak.lib.core.utils.hideProgress
import com.infomaniak.lib.core.utils.initProgress
import com.infomaniak.lib.core.utils.setPagination
import com.infomaniak.lib.core.utils.showProgress
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.fragment_file_list.*
import kotlinx.coroutines.*

Expand Down Expand Up @@ -279,12 +278,8 @@ open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefresh
}
}) else null

requireActivity().showSnackbar(
title,
anchorView = requireActivity().mainFab,
onActionClicked = onCancelActionClicked
)
} ?: run { requireActivity().showSnackbar(title, anchorView = requireActivity().mainFab) }
showSnackbar(title, true, onActionClicked = onCancelActionClicked)
} ?: run { showSnackbar(title, true) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ open class ManageDropboxFragment : Fragment() {
if (apiResponse?.isSuccess() == true) {
apiResponse.data?.let { updateUi(file, it) }
} else {
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
}
}
Expand Down Expand Up @@ -165,7 +165,7 @@ open class ManageDropboxFragment : Fragment() {
if (apiResponse.isSuccess()) {
findNavController().popBackStack()
} else {
requireActivity().showSnackbar(R.string.errorDelete)
showSnackbar(R.string.errorDelete)
}
hideProgress(R.string.buttonDisableDropBox)
}
Expand All @@ -190,7 +190,7 @@ open class ManageDropboxFragment : Fragment() {
if (apiResponse.isSuccess()) {
findNavController().popBackStack()
} else {
requireActivity().showSnackbar(R.string.errorModification)
showSnackbar(R.string.errorModification)
}
hideProgress(R.string.buttonSave)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ class SearchFragment : FileListFragment() {

fun handleApiCallFailure(apiResponse: ApiResponse<ArrayList<File>>) {
searchViewModel.visibilityMode.value = VisibilityMode.NO_RESULTS
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}

fun getSearchResults(data: ArrayList<File>?): ArrayList<File> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ class FileDetailsCommentsFragment : FileDetailsSubFragment() {
if (apiResponse.isSuccess()) {
apiResponse?.data?.let { comment ->
commentsAdapter.addComment(comment)
requireActivity().showSnackbar(R.string.fileDetailsCommentsConfirmationSnackbar)
showSnackbar(R.string.fileDetailsCommentsConfirmationSnackbar)
}
} else {
requireActivity().showSnackbar(R.string.errorAddComment)
showSnackbar(R.string.errorAddComment)
}
dialog.dismiss()
noCommentsLayout.toggleVisibility(commentsAdapter.itemCount == 0, showRefreshButton = false)
Expand Down Expand Up @@ -147,7 +147,7 @@ class FileDetailsCommentsFragment : FileDetailsSubFragment() {
commentsAdapter.deleteComment(comment)
noCommentsLayout.toggleVisibility(commentsAdapter.itemCount == 0, showRefreshButton = false)
} else {
requireActivity().showSnackbar(R.string.errorDelete)
showSnackbar(R.string.errorDelete)
}
}
}
Expand All @@ -165,7 +165,7 @@ class FileDetailsCommentsFragment : FileDetailsSubFragment() {
fileComment.likesCount = fileComment.likesCount - 1
commentsAdapter.updateComment(fileComment)
} else {
requireActivity().showSnackbar(apiResponse.translatedError)
showSnackbar(apiResponse.translatedError)
}
}
} else {
Expand All @@ -179,7 +179,7 @@ class FileDetailsCommentsFragment : FileDetailsSubFragment() {
fileComment.likesCount = fileComment.likesCount + 1
commentsAdapter.updateComment(fileComment)
} else {
requireActivity().showSnackbar(apiResponse.translatedError)
showSnackbar(apiResponse.translatedError)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@ class FileDetailsInfoFragment : FileDetailsSubFragment() {
if (apiResponse.isSuccess()) {
shareLinkContainer.update(apiResponse.data)
} else {
requireActivity().showSnackbar(getString(R.string.errorShareLink))
showSnackbar(R.string.errorShareLink)
}
}
}
Expand All @@ -306,7 +306,7 @@ class FileDetailsInfoFragment : FileDetailsSubFragment() {
if (success) {
shareLinkContainer.update(null)
} else {
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ class FileShareDetailsFragment : Fragment() {
if (apiResponse.isSuccess()) {
shareLinkContainer.update(apiResponse.data)
} else {
requireActivity().showSnackbar(getString(R.string.errorShareLink))
showSnackbar(R.string.errorShareLink)
}
}
}
Expand All @@ -260,7 +260,7 @@ class FileShareDetailsFragment : Fragment() {
if (success) {
shareLinkContainer.update(null)
} else {
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ class FileShareLinkSettingsFragment : Fragment() {
if (apiResponse.data == true) {
findNavController().popBackStack()
} else {
requireActivity().showSnackbar(R.string.errorModification)
showSnackbar(R.string.errorModification)
}
saveButton?.hideProgress(R.string.buttonSave)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ abstract class MultiSelectActionsBottomSheetDialog(private val matomoCategory: S
requireContext().startDownloadFile(downloadURL, ARCHIVE_FILE_NAME)
}
} else {
requireActivity().showSnackbar(apiResponse.translatedError)
showSnackbar(apiResponse.translatedError)
}
onActionSelected()
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ import com.infomaniak.drive.utils.BulkOperationsUtils.launchBulkOperationWorker
import com.infomaniak.drive.utils.MatomoUtils.trackEvent
import com.infomaniak.drive.utils.NotificationUtils.showGeneralNotification
import com.infomaniak.drive.utils.Utils.moveFileClicked
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
Expand Down Expand Up @@ -297,7 +296,7 @@ abstract class MultiSelectFragment(private val matomoCategory: String) : Fragmen
)
}
} else {
requireActivity().showSnackbar(apiResponse.translateError())
showSnackbar(apiResponse.translateError())
}
closeMultiSelect()
}
Expand Down Expand Up @@ -441,7 +440,7 @@ abstract class MultiSelectFragment(private val matomoCategory: String) : Fragmen
} else {
resources.getQuantityString(type.successMessage, success, success, destinationFolder?.name + "/")
}
requireActivity().showSnackbar(title, anchorView = requireActivity().mainFab)
showSnackbar(title, true)
closeMultiSelect()

onAllIndividualActionsFinished(type)
Expand Down
Loading