From 707e4f7167b537804b6abf9ae11dbe5a128b3bb9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Szcz=C4=99k?= Date: Fri, 11 Oct 2019 15:07:51 +0200 Subject: [PATCH] Add option to remove downloaded files when clearing finished downloads --- .../shandian/giga/ui/adapter/MissionAdapter.java | 12 +++++++++++- .../giga/ui/fragment/MissionsFragment.java | 8 +++++++- app/src/main/res/layout/delete_files_checkbox.xml | 14 ++++++++++++++ app/src/main/res/values/strings.xml | 2 +- 4 files changed, 33 insertions(+), 3 deletions(-) create mode 100644 app/src/main/res/layout/delete_files_checkbox.xml diff --git a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java index 8420e343b..e20417aa9 100644 --- a/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java +++ b/app/src/main/java/us/shandian/giga/ui/adapter/MissionAdapter.java @@ -19,6 +19,7 @@ import android.view.MenuItem; import android.view.View; import android.view.ViewGroup; import android.webkit.MimeTypeMap; +import android.widget.CheckBox; import android.widget.ImageView; import android.widget.PopupMenu; import android.widget.TextView; @@ -557,7 +558,16 @@ public class MissionAdapter extends Adapter implements Handler.Callb ); } - public void clearFinishedDownloads() { + public void clearFinishedDownloads(boolean delete) { + if (delete && mIterator.hasFinishedMissions()) { + for(int i=0; i mAdapter.clearFinishedDownloads()); + prompt.setView(checkBoxView); + prompt.setPositiveButton(android.R.string.ok, (dialog, which) -> { + CheckBox checkBox = checkBoxView.findViewById(R.id.delete_files_checkbox); + mAdapter.clearFinishedDownloads(checkBox.isChecked()); + }); prompt.setNegativeButton(R.string.cancel, null); prompt.create().show(); return true; diff --git a/app/src/main/res/layout/delete_files_checkbox.xml b/app/src/main/res/layout/delete_files_checkbox.xml new file mode 100644 index 000000000..cbc6ecd10 --- /dev/null +++ b/app/src/main/res/layout/delete_files_checkbox.xml @@ -0,0 +1,14 @@ + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 54ae40d1d..d3899583b 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -587,5 +587,5 @@ Use SAF The Storage Access Framework allows downloads to an external SD card.\nNote: some devices are not compatible Choose an instance - + Delete downloaded files