Skip to content

Commit

Permalink
Feat: Add extract menu item for selection overlay
Browse files Browse the repository at this point in the history
Fixes: #769
  • Loading branch information
zhanghai committed Apr 16, 2024
1 parent d03d233 commit 2852651
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -889,9 +889,15 @@ class FileListFragment : Fragment(), BreadcrumbLayout.Listener, FileListAdapter.
}
)
.setTitle(
if (areAllFilesArchivePaths) R.string.file_list_select_action_extract else R.string.copy
if (areAllFilesArchivePaths) {
R.string.file_list_select_action_extract
} else {
R.string.copy
}
)
menu.findItem(R.id.action_delete).isVisible = !isAnyFileReadOnly
val areAllFilesArchiveFiles = files.all { it.isArchiveFile }
menu.findItem(R.id.action_extract).isVisible = areAllFilesArchiveFiles
val isCurrentPathReadOnly = viewModel.currentPath.fileSystem.isReadOnly
menu.findItem(R.id.action_archive).isVisible = !isCurrentPathReadOnly
}
Expand Down Expand Up @@ -935,6 +941,10 @@ class FileListFragment : Fragment(), BreadcrumbLayout.Listener, FileListAdapter.
confirmDeleteFiles(viewModel.selectedFiles)
true
}
R.id.action_extract -> {
extractFiles(viewModel.selectedFiles)
true
}
R.id.action_archive -> {
showCreateArchiveDialog(viewModel.selectedFiles)
true
Expand Down Expand Up @@ -988,6 +998,11 @@ class FileListFragment : Fragment(), BreadcrumbLayout.Listener, FileListAdapter.
viewModel.selectFiles(files, false)
}

private fun extractFiles(files: FileItemSet) {
copyFiles(files.mapTo(fileItemSetOf()) { it.createDummyArchiveRoot() })
viewModel.selectFiles(files, false)
}

private fun showCreateArchiveDialog(files: FileItemSet) {
CreateArchiveDialogFragment.show(files, this)
}
Expand Down
6 changes: 6 additions & 0 deletions app/src/main/res/menu/file_list_select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@
android:title="@string/delete"
app:showAsAction="always" />

<item
android:id="@+id/action_extract"
android:orderInCategory="100"
android:title="@string/file_list_select_action_extract"
app:showAsAction="never" />

<item
android:id="@+id/action_archive"
android:orderInCategory="100"
Expand Down

0 comments on commit 2852651

Please sign in to comment.