Skip to content

Commit

Permalink
Add showAboveFab parameter name
Browse files Browse the repository at this point in the history
  • Loading branch information
KevinBoulongne committed Feb 23, 2024
1 parent 94974d1 commit 59327f3
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,10 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {
mainViewModel.createOffice(currentFolderFile.driveId, currentFolderFile.id, createFile)
.observe(viewLifecycleOwner) { apiResponse ->
if (apiResponse.isSuccess()) {
showSnackbar(getString(R.string.modalCreateFileSucces, createFile.name), true)
showSnackbar(getString(R.string.modalCreateFileSucces, createFile.name), showAboveFab = true)
apiResponse.data?.let { file -> requireContext().openOnlyOfficeActivity(file) }
} else {
showSnackbar(R.string.errorFileCreate, true)
showSnackbar(R.string.errorFileCreate, showAboveFab = true)
}
mainViewModel.refreshActivities.value = true
dialog.dismiss()
Expand Down Expand Up @@ -234,7 +234,7 @@ class AddFileBottomSheetDialog : BottomSheetDialogFragment() {
}
} catch (exception: Exception) {
exception.printStackTrace()
showSnackbar(R.string.errorDeviceStorage, true)
showSnackbar(R.string.errorDeviceStorage, showAboveFab = true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ class ImportFilesDialog : DialogFragment() {

if (errorCount > 0) {
val errorMessage = resources.getQuantityString(R.plurals.snackBarUploadError, errorCount, errorCount)
showSnackbar(errorMessage, true)
showSnackbar(errorMessage, showAboveFab = true)
}

if (successCount > 0) mainViewModel.refreshActivities.value = true
Expand All @@ -104,7 +104,10 @@ class ImportFilesDialog : DialogFragment() {

if (errorCount > 0) {
withContext(Dispatchers.Main) {
showSnackbar(resources.getQuantityString(R.plurals.snackBarUploadError, errorCount, errorCount), true)
showSnackbar(
title = resources.getQuantityString(R.plurals.snackBarUploadError, errorCount, errorCount),
showAboveFab = true,
)
}
}
lifecycleScope.launch { lifecycle.withResumed { findNavController().popBackStack() } }
Expand All @@ -118,7 +121,7 @@ class ImportFilesDialog : DialogFragment() {

when {
isLowMemory() -> withContext(Dispatchers.Main) {
showSnackbar(R.string.uploadOutOfMemoryError, true)
showSnackbar(R.string.uploadOutOfMemoryError, showAboveFab = true)
}
else -> {
val outputFile = getOutputFile(uri, fileModifiedAt)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
} else {
getString(apiResponse.translatedError)
}
showSnackbar(text, true)
showSnackbar(text, showAboveFab = true)
}
}
}
Expand Down Expand Up @@ -198,7 +198,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
onActionFinished()
},
onError = { translatedError ->
showSnackbar(translatedError, true)
showSnackbar(translatedError, showAboveFab = true)
onActionFinished()
},
)
Expand Down Expand Up @@ -229,7 +229,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
showFavoritesResultSnackbar()
setBackNavigationResult(REFRESH_FAVORITE_FILE, currentFile.id)
} else {
showSnackbar(R.string.errorAddFavorite, true)
showSnackbar(R.string.errorAddFavorite, showAboveFab = true)
findNavController().popBackStack()
}
}
Expand Down Expand Up @@ -319,7 +319,7 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
override fun openWithClicked() {
super.openWithClicked()
if (requireContext().openWithIntent(currentFile).resolveActivity(requireContext().packageManager) == null) {
showSnackbar(R.string.errorNoSupportingAppFound, true)
showSnackbar(R.string.errorNoSupportingAppFound, showAboveFab = true)
findNavController().popBackStack()
} else {
safeNavigate(
Expand Down Expand Up @@ -367,13 +367,18 @@ class FileInfoActionsBottomSheetDialog : BottomSheetDialogFragment(), FileInfoAc
super.cancelExternalImportClicked()

mainViewModel.cancelExternalImport(currentFile.externalImport!!.id).observe(viewLifecycleOwner) { apiResponse ->
if (!apiResponse.isSuccess()) showSnackbar(requireContext().getString(apiResponse.translatedError), true)
if (!apiResponse.isSuccess()) {
showSnackbar(requireContext().getString(apiResponse.translatedError), showAboveFab = true)
}
findNavController().popBackStack()
}
}

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

private fun transmitActionAndPopBack(message: String, action: CancellableAction? = null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -289,8 +289,8 @@ open class FileListFragment : MultiSelectFragment(MATOMO_CATEGORY), SwipeRefresh
}
}) else null

showSnackbar(title, true, onActionClicked = onCancelActionClicked)
} ?: run { showSnackbar(title, true) }
showSnackbar(title, showAboveFab = true, onActionClicked = onCancelActionClicked)
} ?: run { showSnackbar(title, showAboveFab = true) }
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,7 @@ abstract class MultiSelectFragment(private val matomoCategory: String) : Fragmen
} else {
resources.getQuantityString(type.successMessage, success, success, destinationFolder?.name + "/")
}
showSnackbar(title, true)
showSnackbar(title, showAboveFab = true)
closeMultiSelect()

onAllIndividualActionsFinished(type)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class FileInfoActionsView @JvmOverloads constructor(
val fileName = currentFile.name
showSnackbar(
getString(R.string.snackBarInvalidFileNameError, Utils.getInvalidFileNameCharacter(fileName), fileName),
isBottomSheetFragmentView
showAboveFab = isBottomSheetFragmentView,
)
}
if (isBottomSheetFragmentView) {
Expand Down

0 comments on commit 59327f3

Please sign in to comment.