Signed-off-by: tobiasKaminsky <tobias@kaminsky.me>
This commit is contained in:
tobiasKaminsky 2024-12-13 09:06:39 +01:00
parent f5b5f8fab6
commit 175a2421dd
No known key found for this signature in database
GPG key ID: 0E00D4D47D0C5AF7
4 changed files with 12 additions and 18 deletions

View file

@ -26,7 +26,7 @@ enum class TrashbinFileAction(@IdRes val id: Int, @StringRes val title: Int, @Dr
DELETE_PERMANENTLY,
RESTORE,
SELECT_ALL,
SELECT_NONE,
SELECT_NONE
)
}
}

View file

@ -220,14 +220,11 @@ class TrashbinFileActionsBottomSheet : BottomSheetDialogFragment(), Injectable {
private const val RESULT_KEY_ACTION_ID = "RESULT_KEY_ACTION_ID"
@JvmStatic
fun newInstance(
numberOfAllFiles: Int,
files: Collection<TrashbinFile>,
): TrashbinFileActionsBottomSheet {
fun newInstance(numberOfAllFiles: Int, files: Collection<TrashbinFile>): TrashbinFileActionsBottomSheet {
return TrashbinFileActionsBottomSheet().apply {
val argsBundle = bundleOf(
TrashbinFileActionsViewModel.ARG_ALL_FILES_COUNT to numberOfAllFiles,
TrashbinFileActionsViewModel.ARG_FILES to ArrayList<TrashbinFile>(files),
TrashbinFileActionsViewModel.ARG_FILES to ArrayList<TrashbinFile>(files)
)
arguments = argsBundle
}

View file

@ -29,7 +29,7 @@ class TrashbinFileActionsViewModel @Inject constructor(
data object Error : UiState
data class LoadedForSingleFile(
val actions: List<TrashbinFileAction>,
val titleFile: TrashbinFile?,
val titleFile: TrashbinFile?
) : UiState
data class LoadedForMultipleFiles(val actions: List<TrashbinFileAction>, val fileCount: Int) : UiState
@ -56,10 +56,7 @@ class TrashbinFileActionsViewModel @Inject constructor(
}
}
private fun load(
files: Collection<TrashbinFile>,
numberOfAllFiles: Int?,
) {
private fun load(files: Collection<TrashbinFile>, numberOfAllFiles: Int?) {
viewModelScope.launch(Dispatchers.IO) {
val toHide = getHiddenActions(numberOfAllFiles, files)
val availableActions = getActionsToShow(toHide)
@ -67,10 +64,7 @@ class TrashbinFileActionsViewModel @Inject constructor(
}
}
private fun getHiddenActions(
numberOfAllFiles: Int?,
files: Collection<TrashbinFile>,
): List<Int> {
private fun getHiddenActions(numberOfAllFiles: Int?, files: Collection<TrashbinFile>): List<Int> {
numberOfAllFiles?.let {
if (files.size >= it) {
return listOf(R.id.action_select_all_action_menu)

View file

@ -178,7 +178,9 @@ class TrashbinActivity :
handleOnBackPressed()
mMultiChoiceModeListener = MultiChoiceModeListener(
this, trashbinListAdapter, viewThemeUtils,
this,
trashbinListAdapter,
viewThemeUtils
) { filesCount, checkedFiles -> openActionsMenu(filesCount, checkedFiles) }
addDrawerListener(mMultiChoiceModeListener)
}
@ -373,7 +375,8 @@ class TrashbinActivity :
TrashbinFileActionsBottomSheet.newInstance(filesCount, checkedFiles)
.setResultListener(
supportFragmentManager, this
supportFragmentManager,
this
) { id: Int ->
onFileActionChosen(
id,
@ -533,7 +536,7 @@ class TrashbinActivity :
val inflater: MenuInflater = activity.menuInflater
inflater.inflate(R.menu.custom_menu_placeholder, menu)
val item = menu.findItem(R.id.custom_menu_placeholder_item)
item.icon?.let{
item.icon?.let {
item.setIcon(
viewThemeUtils.platform.colorDrawable(
it,