-
-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Choose alternative download location in settings (external SD) #117
Comments
There is currently no way to change the download location. I tried to avoid implementing a file chooser. However, your use case does look like a common one. So I will leave this issue open as enhancement. |
Instead of a file chooser, you could just offer two had-coded paths. One points to internal memory, the other to a fixed path (e.g. |
This would be a great addition. I also have little internal memory and a big 32 GB sd card. I also agree with the proposal from the comment before. |
File handling on Android is insane: I found Context.getExternalMediaDirs() to enumerate all valid media download locations (including sd cards and other removable storage) but encountered an issue with the download manager on my phone. For future reference:
I'll retry in a month or so. |
Android 9 on the Pocophone has a similar issue. DownloadManager is not able to access the external SD despite read and write permissions correctly set. I have no idea what is wrong with this SD card thingy. Shouldn't it be possible to transfer Zapp as an app to an external SD card? Does this solve the problem? |
There are two problems with this
So did you check for the And if I read this properly it should be possible to use the integrated system dialogue from Android (since Android 5.0) with Otherwise there are some libraries:
PS: I'm not an Android developer so I have no idea whether anything I wrote actually makes sense. |
ACTION_OPEN_DOCUMENT_TREE might actually work, because it does return a content uri instad of an absolute path. |
Installation on external storage has to be enabled inside the manifest: https://developer.android.com/guide/topics/data/install-location.html |
Android Q has restricted file handling even further. Additionally DownloadManager is not able to download to any I am thinking about using ExoPlayer for downloading content. This would play back downloaded media from disk automatically. But downloaded shows will not be saved as files and not readable by any other application (which is quire a big limitation...). |
Is this not solving the problem? |
I tried similar code snippets without success. Finding up to date answers is Quote difficult. |
And would it be possible just to use a fixed path, like suggested by @rugk earlier? Something like File sdCard = Environment.getExternalStorageDirectory();
File dir = new File (sdCard.getAbsolutePath() + "/zapp_downloads");
dir.mkdirs();
File file = new File(dir, "video.mp4");
Uri uri = Uri.fromFile(file);
DownloadManager.Request request = new DownloadManager.Request(Uri.parse(downloadURL));
request.setTitle("video");
request.setDescription("video");
request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED);
request.setDestinationUri(uri);
request.allowScanningByMediaScanner();
downloadID = downloadManager.enqueue(request);
downloadProgressView.show(downloadID, new DownloadProgressView.DownloadStatusListener() {
@Override
public void downloadFailed(int reason) {
Log.d(TAG, "downloadFailed" + reason);
}
@Override
public void downloadSuccessful() {
Log.d(TAG, "downloadSuccessful");
}
@Override
public void downloadCancelled() {
Log.d(TAG, "downloadCancelled");
}
});
downloadButton.setVisibility(View.GONE); PS: I took this from stackoverflow. 😉 |
Is there anything I could help here, except from doing some Java? 🤔
|
getExternalStorageDirectory() is deprecated and did never work for all device models. At the moment I see no solution to this (seemingly simple and common) problem, that is not:
What might work: Downloading the files in some sort of cache/temp directory and copying it over once the download is complete. This however is a UX nightmare and a lot of work to implement. The download manager will notify the user with a wrong (temp) path and zapp has to listen to finished downloads. As it stands now I will not implement this feature to avoid hacks, compatibility issues, UX fails and a LOT of work for a small feature. If you know another application that handles this issue gracefully on all Android versions I may be able to look into it. |
@cemrich I just created a StackOverflow question for it. Maybe someone comes up with an good idea. Someone suggested:
And
Furthermore the application RCX seems also support SD cards when using SAF according to the docs. Does this help? |
@alexanderadam ACTION_CREATE_DOCUMENT does return a content:// uri (as does ACTION_OPEN_DOCUMENT_TREE ) which is not compatible with the download manager. NewPipe does support SD cards (with SAF enabled, which might break some devices?) but implements its own download manager. You StackOverflow question does not mention Download manager which is the main limiting factor here, because it does require (old style) file:// urls. |
I see, I wasn't able to understand the issue here. To be honest: I'm still not understanding. So to clarify this: you need a certain representation of the download path for the download manager? How is it called? Does Or setting a destination URI on the Download Manager via Or maybe Or does this StackOverflow thread help? |
I've seen other apps that open the Android file picker, ask the user to select the sdcard there and press okay, and then they have access to it. Don't ask me which API level that is though. |
But did they use the default Download Manager, too? Because from what I understand so far, other download manager libraries (i.e. Fetch, novoda's download manager, okdownload or PRDownloader) don't have this problem anyway (apart from having additional features like support for long running downloads, checksum validation, resuming, etc.).
EDIT 2: I transferred the money on another way as discussed via email. For others: Do not use BountySource! Use any other of the mentioned possibilities. |
I guess no, at least they were not intended for downloading things, maybe just saving files AFAIK. But TBH I don't know… 🤷 |
@alexanderadam Most apps seem to use download manager libraries. I am hesitant to use these because these libraries tend to be deprecated/unmaintained pretty quickly. However, fetch seems to be actively maintained for a long period now, so I'll consider using it. The problem lies within how Android handles its file system. Newer Android versions try to abstract away the file system to restrict and decouple apps and increase security. As a result apps don't work with old school file paths any more (like file:///sdcard/Movies/Zapp/download.mp4), but with abstracted content uris (like content://media/external/audio/media/710). These can't be converted in any meaningful, non-hacky way. Most Android apis can work with the newer content urls (which are the right way to go). But DownloadManager seems to require the old school file paths. |
This would probably fix other issues, too.
So I hope this makes it understandable how painful it is to use Zapp on a device that is low on internal storage. 😉 I guess that a proper download library would not only just fix the external space issue but might also give possibilities for error handling (i.e. low on space) and add checksum checks/resuming. |
A quick update: I am still working on it, but due to this crazy pandemic-childcare-situation progress is rather slow. Fetch is usable. I need to fix some quirks regarding notifications but otherwise it integrates nicely. Also I think I found a solution to switch between primary storage and sdcard on all supported Android versions (which is insane, given these APIs are all over the place and changing constantly). Both storage locations will be fixed to the apps own external (media) directory for ease of use and to avoid configuration clutter. Bonus points: Zapp does not require its storage permission any more. I simplified the ui and need to re-add some features like quality selection. It will take a while, but an in-app download progress indicator is worth the wait :) |
Oh wow, this sounds wonderful! Thank you so much for working on this! |
I just released a beta version to test this feature on a wide variety of devices. To install it, you have to uninstall any Zapp version from F-Droid first. Please let me know if you experience any issues! |
Wow, the download progress bar looks very nice! ❤️ Just two things: I had issues downloading some videos and had to hit
It was not very clear where I could find the video (I found it on the SD card in the Movies directory). Maybe it would be nice to have it mentioned somewhere (in case I didn't miss this information). Or even better a It's just a small detail, however. 😉 |
@alex1702 I added the raw error codes as shown in #197. I use the default Fetch timeouts which should be fine for most use cases and are certainly way better than my guesses. Pause / Resume is supported (small action buttons inside the download notification) but I think Fetch cleans up any file parts after an error event. There is no fool proof way of opening up a directory in Android. Do you think it is too hard to find? I tried to add it to every media collection I could find :) |
Nice! Is there a APK that has the error codes patch integrated? You didn't had to push the Retry button in your tests?
It's no big issue in any case. Would it be easier to write the path (i.e. a small text below that says |
Not yet. I'll release another beta before releasing.
Not even once. But I've very stable wifi here. I'll test again with an emulator.
There is no path that has any meaning to the user. It will look something like |
@alexanderadam Sorry, I forgot to mention the new Release. Version 2.5.0 is available on Github and F-Droid. I did not find a clean way to open the download directory, so I'll skip this feature. However, another user reported sporadic errors during download with a lot of retries. I opened #204 to continue investigating. Could you please test if you are also experiencing an "Unknown io error"? Also, which version of Android are you using? I'll close this issue. Feel free to open new ones for more detailed error reports. |
Hi,
and thanks for the great app!!!
Is there a way to change the download folder/location? My internal memory is very limited, so I'd like to download TV shows to a folder an the external SD card.
Thanks again!
The text was updated successfully, but these errors were encountered: