summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorByteHamster <ByteHamster@users.noreply.github.com>2024-09-14 11:44:59 +0200
committerGitHub <noreply@github.com>2024-09-14 11:44:59 +0200
commit2a1b537d13f018d4a08e14076700ff297c946bff (patch)
tree9f815d27bc0304c9f1882a550a75d38ebe156c53
parentf35e92c112b058c534a134b2314f6bc162d5a142 (diff)
downloadAntennaPod-2a1b537d13f018d4a08e14076700ff297c946bff.zip
Allow selecting external media dirs as data directory (#7400)
In addition to /sdcard/Android/data/de.danoeh.antennapod, this now enables /sdcard/Android/media/de.danoeh.antennapod. The folder is readable by other applications that have the "read storage" permission. At the same time, AntennaPod does not need the permission to write the folder.
-rw-r--r--ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/downloads/DataFolderAdapter.java19
1 files changed, 8 insertions, 11 deletions
diff --git a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/downloads/DataFolderAdapter.java b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/downloads/DataFolderAdapter.java
index 99f63156c..ba63d1107 100644
--- a/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/downloads/DataFolderAdapter.java
+++ b/ui/preferences/src/main/java/de/danoeh/antennapod/ui/preferences/screen/downloads/DataFolderAdapter.java
@@ -47,14 +47,14 @@ public class DataFolderAdapter extends RecyclerView.Adapter<DataFolderAdapter.Vi
String freeSpace = Formatter.formatShortFileSize(context, storagePath.getAvailableSpace());
String totalSpace = Formatter.formatShortFileSize(context, storagePath.getTotalSpace());
- holder.path.setText(storagePath.getShortPath());
+ holder.path.setText(storagePath.getPath());
holder.size.setText(String.format(freeSpaceString, freeSpace, totalSpace));
holder.progressBar.setProgress(storagePath.getUsagePercentage());
- View.OnClickListener selectListener = v -> selectionHandler.accept(storagePath.getFullPath());
+ View.OnClickListener selectListener = v -> selectionHandler.accept(storagePath.getPath());
holder.root.setOnClickListener(selectListener);
holder.radioButton.setOnClickListener(selectListener);
- if (storagePath.getFullPath().equals(currentPath)) {
+ if (storagePath.getPath().equals(currentPath)) {
holder.radioButton.toggle();
}
}
@@ -73,8 +73,10 @@ public class DataFolderAdapter extends RecyclerView.Adapter<DataFolderAdapter.Vi
}
private List<StoragePath> getStorageEntries(Context context) {
- File[] mediaDirs = context.getExternalFilesDirs(null);
- final List<StoragePath> entries = new ArrayList<>(mediaDirs.length);
+ final List<File> mediaDirs = new ArrayList<>();
+ mediaDirs.addAll(List.of(context.getExternalFilesDirs(null)));
+ mediaDirs.addAll(List.of(context.getExternalMediaDirs()));
+ final List<StoragePath> entries = new ArrayList<>(mediaDirs.size());
for (File dir : mediaDirs) {
if (!isWritable(dir)) {
continue;
@@ -115,12 +117,7 @@ public class DataFolderAdapter extends RecyclerView.Adapter<DataFolderAdapter.Vi
this.path = path;
}
- String getShortPath() {
- int prefixIndex = path.indexOf("Android");
- return (prefixIndex > 0) ? path.substring(0, prefixIndex) : path;
- }
-
- String getFullPath() {
+ String getPath() {
return this.path;
}