Skip to content
Open
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 @@ -132,6 +132,39 @@ class FileListAdapter(
listener.selectFiles(files, true)
}

fun rangeSelectFiles() {
var firstSelectItem = -1
var lastSelectItem = -1
for (index in 0..<itemCount) {
val file = getItem(index)
if (file in selectedFiles) {
firstSelectItem = index
break
}
}
for (index in itemCount - 1 downTo firstSelectItem) {
val file = getItem(index)
if (file in selectedFiles) {
lastSelectItem = index
break
}
}
val files = fileItemSetOf()
if (firstSelectItem >= 0
&& lastSelectItem >= 0
&& lastSelectItem < itemCount
&& firstSelectItem < lastSelectItem
) {
for (index in firstSelectItem..lastSelectItem) {
val file = getItem(index)
if (isFileSelectable(file)) {
files.add(file)
}
}
}
listener.selectFiles(files, true)
}

private fun isFileSelectable(file: FileItem): Boolean {
val pickOptions = pickOptions ?: return true
return when (pickOptions.mode) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -950,6 +950,10 @@ class FileListFragment : Fragment(), BreadcrumbLayout.Listener, FileListAdapter.
selectAllFiles()
true
}
R.id.action_select_range -> {
rangeSelectFiles()
true
}
else -> false
}

Expand Down Expand Up @@ -1023,6 +1027,10 @@ class FileListFragment : Fragment(), BreadcrumbLayout.Listener, FileListAdapter.
adapter.selectAllFiles()
}

private fun rangeSelectFiles() {
adapter.rangeSelectFiles()
}

private fun onPasteStateChanged(pasteState: PasteState) {
updateBottomToolbar()
}
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/menu/file_list_select.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@
android:orderInCategory="100"
android:title="@string/select_all"
app:showAsAction="never" />
<item
android:id="@+id/action_select_range"
android:orderInCategory="100"
android:title="@string/select_range"
app:showAsAction="never" />
</menu>
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -642,4 +642,5 @@
<string name="about_author_name_title">张海</string>
<string name="about_author_github_title">在 GitHub 上关注</string>
<string name="about_author_twitter_title">在 Twitter 上关注</string>
<string name="select_range">区间选择</string>
</resources>
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -799,4 +799,5 @@

<string name="shortcut_downloads_title" translatable="false">@string/navigation_standard_directory_downloads</string>
<string name="shortcut_ftp_server_title" translatable="false">@string/ftp_server_title</string>
<string name="select_range">Select range</string>
</resources>