Add download filter, close #1

This commit is contained in:
NekoInverter committed 2020-03-25 22:40:21 +08:00
1 parent 10a64ee26e
commit 8e0cba644a
7 files changed
+59 -8

No files matched your search

+2 -2
View File
@@ -35,8 +35,8 @@ jobs:
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
with:
tag_name: SNAPSHOT-${{ github.sha }}
release_name: SNAPSHOT-${{ github.sha }}
tag_name: 1.7.4_${{ github.run_id }}
release_name: 1.7.4_${{ github.run_id }}
body: ""
draft: false
prerelease: true
@@ -147,6 +147,8 @@ public class DownloadsScene extends ToolbarScene
private List<String> mLabels;
private int mType = -1;
private static void deleteFileAsync(UniFile... files) {
new AsyncTask<UniFile, Void, Void>() {
@Override
@@ -259,17 +261,28 @@ public class DownloadsScene extends ToolbarScene
if (null == mDownloadManager) {
return;
}
List<DownloadInfo> list;
if (mLabel == null) {
mList = mDownloadManager.getDefaultDownloadInfoList();
list = mDownloadManager.getDefaultDownloadInfoList();
} else {
mList = mDownloadManager.getLabelDownloadInfoList(mLabel);
if (mList == null) {
list = mDownloadManager.getLabelDownloadInfoList(mLabel);
if (list == null) {
mLabel = null;
mList = mDownloadManager.getDefaultDownloadInfoList();
list = mDownloadManager.getDefaultDownloadInfoList();
}
}
if (mType != -1) {
mList = new ArrayList<>();
for (DownloadInfo info : list) {
if (info.state == mType) {
mList.add(info);
}
}
} else {
mList = list;
}
if (mAdapter != null) {
mAdapter.notifyDataSetChanged();
}
@@ -505,6 +518,16 @@ public class DownloadsScene extends ToolbarScene
int id = item.getItemId();
switch (id) {
case R.id.action_filter: {
new MaterialAlertDialogBuilder(requireActivity())
.setSingleChoiceItems(R.array.download_state, mType + 1, (dialog, which) -> {
mType = which - 1;
updateForLabel();
dialog.dismiss();
})
.show();
return true;
}
case R.id.action_start_all: {
Intent intent = new Intent(activity, DownloadService.class);
intent.setAction(DownloadService.ACTION_START_ALL);
@@ -0,0 +1,9 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@color/primary_drawable_dark"
android:pathData="M10,18h4v-2h-4v2zM3,6v2h18L21,6L3,6zM6,13h12v-2L6,11v2z" />
</vector>
+7 -1
View File
@@ -17,11 +17,17 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<item
android:id="@+id/action_filter"
android:icon="@drawable/v_filter_dark_x24"
android:title="@string/download_filter"
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_start_all"
android:icon="@drawable/v_play_dark_x24"
android:title="@string/download_start_all"
app:showAsAction="always" />
app:showAsAction="ifRoom" />
<item
android:id="@+id/action_stop_all"
@@ -713,4 +713,6 @@
<string name="follow_system">跟随系统</string>
<string name="black_dark_theme">纯黑深色主题</string>
<string name="download_filter">过滤</string>
<string name="download_all">全部</string>
</resources>
+9
View File
@@ -292,4 +292,13 @@
<item>1</item>
<item>2</item>
</string-array>
<string-array name="download_state">
<item>@string/download_all</item>
<item>@string/download_state_none</item>
<item>@string/download_state_wait</item>
<item>@string/download_state_downloading</item>
<item>@string/download_state_finish</item>
<item>@string/download_state_failed</item>
</string-array>
</resources>
+2
View File
@@ -777,4 +777,6 @@
<string name="follow_system">Follow system</string>
<string name="black_dark_theme">Black dark theme</string>
<string name="download_filter">Filter</string>
<string name="download_all">All</string>
</resources>