Closed Bug 677001 Opened 13 years ago Closed 3 years ago

Choosing a different download folder

Categories

(Firefox for Android Graveyard :: General, enhancement)

ARM
Android
enhancement
Not set
normal

Tracking

(firefox59 affected, firefox60 affected, firefox61 affected)

RESOLVED INCOMPLETE
Tracking Status
firefox59 --- affected
firefox60 --- affected
firefox61 --- affected

People

(Reporter: dumitru, Unassigned)

References

Details

Right now, when downloading a file in Fennec, it is automatically saved in /sdcard/Download.
I think it would be good to have an "advanced" setting similar to the one existing in the desktop version of Firefox, where you can choose either a different location for all the downloads or have Fennec always ask you where to save those files.
Severity: minor → enhancement
Hardware: x86_64 → ARM
Version: Firefox 6 → Trunk
Sounds like extension material to me. You can set this using the browser.download.dir pref in about:config. https://developer.mozilla.org/en/Download_Manager_preferences
Product: Fennec Graveyard → Firefox for Android
So should I go ahead and fix it?
To fix this I think we'd have to write some sort of Dir-chooser since there isn't one built into Android and there's not even a standard intent to launch one if the user did have one installed. Our nsIFilePicker implementation just ignores modeGetFolder right now:

http://mxr.mozilla.org/mozilla-central/source/widget/nsIFilePicker.idl#32

so technically fixing this would also be fixing that (and that might get better traction than writing one just for this one bug).

We might be able to write a dir picker in JS using prompt.jsm. I'm not exactly sure how we'd handle selecting a dir vs opening a dir to select a subfolder inside in the dialog though.
Hi Wesley. I am new to Firefox, would I be able to take this on? Which bug are you referring to (ie which ignores modeGetFolder)? 
After our chat I am looking at how to start using prompt.jsm.
Sure. This won't be an easy first bug though. You'll be fixing our implementation of the nsIFilePicker component to support picking a dir. i.e. this init method of the File Picker:

https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Reference/Interface/nsIFilePicker#init%28%29

can take a modeGetFolder argument:
http://mxr.mozilla.org/mozilla-central/source/widget/nsIFilePicker.idl#32

Fennec's implementation of this is here:
http://mxr.mozilla.org/mozilla-central/source/mobile/android/components/FilePicker.js#29

Note, we throw in there if you specify modeGetFolder right now, so you'll have to undo that. We don't do anything with it until you call show():

http://mxr.mozilla.org/mozilla-central/source/mobile/android/components/FilePicker.js#167

right now that sends a message to Java, which is picked up and handled by FilePicker.java and FilePickerResultHandler.java:

http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/FilePicker.java#72
http://mxr.mozilla.org/mozilla-central/source/mobile/android/base/FilePickerResultHandler.java#72

If you wanted to use Prompt.jsm, you should probably just jump out of show() into a separate (new) _showDirPicker() function in FilePicker.jsm.

Prompts can show lists using setSingleChoiceItems. You might use that to show a list of folders (and maybe a "Go up one folder" row to go up a row? In order to support "Opening" vs "Selecting", we could try multiple buttons? That doesn't feel like great UX to me but it might be a good start here for a seldom used feature. i.e. We can make it better from there.

For instance, this dir picker: http://bgreco.net/directorypicker/ just has one "Pick this dir" button. Tapping the rows opens subfolders. We could try something like that, but right now JS doesn't know when you tap a row, so we'd have to improve Prompt.jsm to send that callback. That's complex enough, it should be a separate bug.
I think it might be better to implement an activity to handle the ACTION_GET_CONTENT intent in Fennec with some sort of mime-type for folders. Then the existing ACTION_GET_CONTENT code could be re-used. The activity we write could also be exposed to other apps and/or the mime type for folders could be standardized leading to more unification down the line.
Note also bug 846931 seems to be picking up steam, so we might want to get ahead of the curve and implement that too as part of this.
True. Just worried that's a rabbit hole (for instance, on KitKat we'd eventually want to try and support the new Documents stuff if we can...). But we could write something really simple that just launched a transparent activity and did what I mentioned above (i.e. show an AlertDialog in NativeJava code). Do you know/want to write some Android code here? The nice thing is, there isn't any hurry :)

Alternatively, we could try to find some third party code to ship. There are lots of dir picker widgets that show up in a search, but they all look kinda awful to me.
check this file org.mozilla.gecko.DownloadsIntegration#getTemporaryDownloadDirectory
and see related Javascript
I don't believe we need to have a dirpicker for this.

Other browsers simply have a preference in settings as to where the download goes by default, and you can change that.

See:

https://bug1342728.bmoattachments.org/attachment.cgi?id=8841398


Trying to build a file picker is definitely a rabbit hole.

Incidentally, this has moved up in priority from our partners because it's needed if you are to become the system browser.

I suggest we focus on providing a simple preference especially given that dirpickers are being worked on in bug 1188880
Firefox for Android supports setting a custom folder via about:config set browser.download.folderList to 2 and browser.download.dir to a valid linux path example /storage/emulated/0/test

It would take someone to build a UI for this and plumb the parts into the config settings. Some consideration should be given to sanitizing the user input. If the user gets a text input then they may enter a path that Firefox does not have access to write to such as /data/data or input some difficult to deal with strings such as non printing characters or emoji.
¡Hola!

Ended up here via https://support.mozilla.org/questions/1210255

Setting flags accordingly FWIW.

¡Gracias!
Alex
We have completed our launch of our new Firefox on Android. The development of the new versions use GitHub for issue tracking. If the bug report still reproduces in a current version of [Firefox on Android nightly](https://play.google.com/store/apps/details?id=org.mozilla.fenix) an issue can be reported at the [Fenix GitHub project](https://github.com/mozilla-mobile/fenix/). If you want to discuss your report please use [Mozilla's chat](https://wiki.mozilla.org/Matrix#Connect_to_Matrix) server https://chat.mozilla.org and join the [#fenix](https://chat.mozilla.org/#/room/#fenix:mozilla.org) channel.
Status: NEW → RESOLVED
Closed: 3 years ago
Resolution: --- → INCOMPLETE
Product: Firefox for Android → Firefox for Android Graveyard
You need to log in before you can comment on or make changes to this bug.