Skip to content
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

Most File Managers don't support Open Folder Intent #838

Open
Nutomic opened this issue Jan 25, 2017 · 33 comments
Open

Most File Managers don't support Open Folder Intent #838

Nutomic opened this issue Jan 25, 2017 · 33 comments
Labels

Comments

@Nutomic
Copy link
Contributor

Nutomic commented Jan 25, 2017

#831 (comment)

https://forum.syncthing.net/t/poll-open-folder-button-and-file-managers/9067

@Nutomic Nutomic added the bug label Jan 25, 2017
@Nutomic
Copy link
Contributor Author

Nutomic commented Jan 26, 2017

This Stackoverflow thread has some more options, like different mime types. Might be worth a try

ping @PaulAnnekov

@PaulAnnekov
Copy link
Contributor

I googled all the web and checked many SO questions. Immediately remove answers with /ACTION_GET_CONTENT/, because it's wrong action. Of course it can show you the contents, but when you will click on any file - activity will close and return you a link to selected file, because that's the purpose of ACTION_GET_CONTENT.

And ACTION_VIEW is not supported by most of the file managers + it's crashing. So I still think we should better integrate own file manager, because Android will tighten the screws more and more. Most sync software (Google Drive/Dropbox) have their own files view, so it won't damage UX.

@Nutomic
Copy link
Contributor Author

Nutomic commented Jan 26, 2017

Did you try the mime type */* or text/csv with ACTION_VIEW already? Integrated file manager would be okay if its not too much effort, but it would be much better if we could also support the user's chosen file manager.

@PaulAnnekov
Copy link
Contributor

I tried */* and text/csv with ACTION_VIEW.

*/* + ACTION_VIEW means - "show me intents that can view at least one mime type", so you get EVERYTHING (Contact viewers, Google Play Store, Music players, file explorers, emails apps...).

text/csv + ACTION_VIEW means "show me intents that can view files with csv mime type", so you get listed all text editors (ES Note Editor, FE Text Editor, FX Text Viewer, Totalcmd-Editor...).

@pchampin
Copy link

This is a hard choice here:

  • either guarantee a smoother user experience with a built-in file manager, but locking at the same time the users in that view,
  • or leave the user free to use their own file manager, but with a rougher interface...
    There's no surprise that Google or Dropbox would chose the first option; locking the user in is part of their business model. But for an open-source project, it is trickier.

Wouldn't it be possible to use */* + ACTION_VIEW the first time, and then remember the choice of the user in order to not bother them anymore with this long list of options??

@PaulAnnekov
Copy link
Contributor

@pchampin no, 1st option is "use embedded file manager", 2nd is "use intent that is supported by 1-2 file managers among dozens in the market + add ugly hack for Android 7".

Wouldn't it be possible to use / + ACTION_VIEW the first time, and then remember the choice of the user in order to not bother them anymore with this long list of options??

I don't know if you have an access to "use as default app..." checkbox in intents chooser, but I think - no.

@k3b
Copy link

k3b commented Oct 7, 2017

goal:

  • Intent to open filemanager and view content of a specified directory in the filemanager.
  • This feature should not be a picker

since it seems there is no standard for this so whe should define the standard and ask the other file manager developers to implement this specific intent we define here.

my proposal: use this: https://stackoverflow.com/questions/17165972/android-how-to-open-a-specific-folder-via-intent-and-show-its-content-in-a-file
it already works with "EF File Explorer".

  • action=android.intent.action.VIEW
  • data=file:///path/to/directory/
  • mime=resource/folder

@contrapunctus-1 already made an attempt to ask file manager developers but without specifying how the intent should exactly look like.

note: total commander supports action=android.intent.action.VIEW with mime= * / * . i donot know if there is a more specific mime for total commander specific mime for this. There is also the proposal to use mime=resource/folder ( https://www.ghisler.ch/board/viewtopic.php?p=323853 )

@PaulAnnekov
Copy link
Contributor

@k3b yes, we can ask file manager devs to implement one of the API's, it requires a minimum of effort (but don't rely on them). Who will do this?

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 8, 2017

@k3b That's exactly the intent we're using, and it works with "ES File Explorer" (I assume you meant that).

Please go ahead and contact any developers of file managers. Here is the exact code we're using.

@pchampin
Copy link

pchampin commented Oct 8, 2017

FTR, there is already an issue about that for the open-source Amaze file manager:
TeamAmaze/AmazeFileManager#419

@VishalNehra
Copy link

Hello everyone, I'm new to synthing.
I'm one of the developer of Amaze File Manager. We do support Intent.ACTION_VIEW but only for limited number of files (zip, rar, text/, xml/json/js, db/). As these are the extensions Amaze supports for viewing files. As for returning files, we support Intent.ACTION_GET_CONTENT for both files and folders.
Like I said, I'm new to synthing, I tried the app but couldn't find the option to opening a folder. One I did find was to browse for folder from 'Create folder' screen when I pressed on + icon at top right which popped up the inbuilt directory selection screen. Like I said, we support returning files/folders, hence this operation is already supported by Amaze.
So I'm not able to really understand the use case for this operation, please help me understand.

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 9, 2017

@vishal0071 This button will launch an intent to open the folder path in an external file manager:

screenshot_20171009-124808

@VishalNehra
Copy link

@Nutomic so what is the option supposed to do? Simply open the file manager from that specific path?

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 9, 2017

Yes exactly

@VishalNehra
Copy link

Very well. I've added support in Amaze for this form of intent.

@VishalNehra
Copy link

I was made aware that there exists API to denote a directory mime type. Please check it here and make syncthing compatible to this so that I can also reflect to these changes.

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 9, 2017

That intent seems pretty bad. With intent.setData("file:/...) it doesn't bring up any app, not even ES Explorer which supports the resource/folder mime. Without that and only org.openintents.extra.ABSOLUTE_PATH, it shows every single app that can handle Intent.ACTION_VIEW. So using the mime type seems like the better option.

@k3b
Copy link

k3b commented Oct 9, 2017

@Nutomic sorry my fault: only version with file:///path.... works. the version with file:/path.... does not.

I just checked it with the new IntentIntercept https://gitlab.com/fdroid/fdroiddata/merge_requests/2553 and ES Explorer.

I have just fixed my proposal in all threads where i added the proposal text.

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 10, 2017

This is the code I'm using, so Uri is something like file:///storage/emulated/0/DCIM:

Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setData(Uri.fromFile(new File(folder.path)));
intent.putExtra("org.openintents.extra.ABSOLUTE_PATH", folder.path);
if (intent.resolveActivity(getContext().getPackageManager()) != null) {
    getContext().startActivity(intent);

And its not working with ES Explorer (not sure which other apps I should test. Like I said, the resource/folder mime type at least works with ES Explorer.

@VishalNehra
Copy link

@Nutomic Please use FileProvider for normal filesystem or DocumentProvider in case of SD Card/OTG to send data instead of using Uri#fromFile
I'll give you a modified apk of Amaze which shall work with this version. Meanwhile please provide me your build apk after making these changes so that I can also test on my end.

@Nutomic
Copy link
Contributor Author

Nutomic commented Oct 11, 2017

@vishal0071 Good point about FileProvider, I wasn't aware of that API. I still had to declare resource/folder mime type explicitly, otherwise ES Explorer wouldn't be shown in the intent chooser.

debug build download

Edit: actually it doesn't work with ES Explorer. Either it doesn't show any folder contents, or it's loading forever.

@tibbi
Copy link

tibbi commented Oct 23, 2017

Added support for opening resource/folder to Simple File Manager, for now only for "file://" uris. I will check the rest later.

@Catfriend1
Copy link
Contributor

Catfriend1 commented Apr 27, 2018

@VishalNehra @k3b @pchampin @PaulAnnekov Hi together. I implemented a fallback mechanism in a debug build if resource/folder approach did not work to open the folder. Can you please check if it helps in cases a specific file explorer app was previously not supported? Link: https://build.syncthing.net/repository/download/SyncthingAndroid_Build/19963:id/debug/app-debug.apk

@PaulAnnekov
Copy link
Contributor

@Catfriend1 that's what I get. I have Xiaomi device with native File Explorer app.

photo_2018-05-19_13-50-27

I don't know why this issue was closed. I think the only way to close it is to use embedded file manager, because we won't ever support all variety of file managers, as there is no standard way to achieve what we want.

@Catfriend1
Copy link
Contributor

@PaulAnnekov Sorry, this seems to be hard way to find a compromise for all software out there. Let's sum up what we got now. If you click the open folder button, this will happen:

  1. Check if the "resource/folder" URI type is implemented by some app and open this (or let the user choose if more are present). I read something about this data type isn't official and that's the reason why not every file manager app has it implemented this way.
  2. If the first attempt retrieving an URI compatible app by asking the android package manager failed, a second attempt is made asking for all apps that can handle file types. For me, it's getting more popular apps from GPlay like Root Explorer, ES Explorer, ... to work.

This is also the reason why all apps are shown to you on the screenshot. Looking with the "all" file type results in all apps being shown. I'd have liked to, but android won't let me filter out any app from there.

Built-In file managers afaik also don't have a common UI resource type they register. Some have, some won't. I'm pretty sorry it seems I only can help you if you figure out the URI type your built-in file manager listens to and put it maybe in between the checks of step 1) and 2) making sure the fallback is done correctly for the majority of users.

@PaulAnnekov
Copy link
Contributor

My point is that this issue should not be closed, because it's not resolved. And the only way to resolve it is to create embedded file manager.

@Nutomic
Copy link
Contributor Author

Nutomic commented May 29, 2018

Agreed. @Catfriend1 please don't close issues if people still have the problem.

@Nutomic Nutomic reopened this May 29, 2018
@Catfriend1
Copy link
Contributor

Here is a good SO showing alternatives and on which devices they are expected to work: https://stackoverflow.com/questions/50072638/fileuriexposedexception-in-android/50102119#50102119
Sorry about the close, happened during the merge process.

@Catfriend1
Copy link
Contributor

@PaulAnnekov Would you mind helping me out by figuring out and posting your builtin file managers android package name here? Its sth like com.romname.filemanager.

@PaulAnnekov
Copy link
Contributor

@Catfriend1 com.mi.android.globalFileexplorer.
We already have some file managing activity, it's FolderPickerActivity (https://github.com/syncthing/syncthing-android/blob/master/app/src/main/java/com/nutomic/syncthingandroid/activities/FolderPickerActivity.java). We can adjust it to support open/cut/paste/remove/share file actions. That should be enough.

@Catfriend1
Copy link
Contributor

@PaulAnnekov
I did some google research on com.mi.android.globalFileExplorer . Until now, I couldn't find any documented way to launch this file explorer app with a folder given it should initially open.
Only reference I found was here: https://github.com/gsantner/memetastic/blob/master/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java (line 454 // Mi File Explorer)
The Xiaomi app only seems to provide a folder chooser returning an URI with an absolute path which is not what what we need in this case.
I guess you're out of luck getting this fixed as I'm not happy to take time to reinvent the wheel and put a complete file manager code into syncthing-android which we have to maintain in the future. If someone else likes to do this, I would leave the decision if the code gets in or not to our maintainer.
I would have helped you if I could with a small adjustment as there are many file manager out in the wild. Is it really unacceptable for you to install another third party app that is supported by syncthing-android like ES File Explorer, OpenIntents File Explorer, Root Explorer ...?

@PaulAnnekov
Copy link
Contributor

@Catfriend1 I want every user to be able to browse synced folder from Syncthing. And I think the best way to do this is to implement it like other file clouds do - manage files directly in the app (Dropbox, Google Drive, ownCloud...). I don't force you to implement it or to support all external file managers.
We can treat this task as "Add support for all external file managers we can" and close it, if it's done. Then when somebody will be ready to do google drive-like file manager, he will open a new issue to discuss.

@Catfriend1
Copy link
Contributor

SideNote - I tried to implement opening syncthing folder using Samsung myFiles but it doesn't work. In case anyone reading this later has an idea, please give me a hint. Link to the branch code: master...Catfriend1:supportSamsungFileManager

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants