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

Opening txt files from "Recent changes" view does not work #816

Closed
Self-Perfection opened this issue Jun 3, 2021 · 15 comments · Fixed by #819
Closed

Opening txt files from "Recent changes" view does not work #816

Self-Perfection opened this issue Jun 3, 2021 · 15 comments · Fixed by #819
Assignees
Labels
Milestone

Comments

@Self-Perfection
Copy link

Description of the issue

Tapping on an item from "Recent changes" view is expected to open corresponding file in relevant app. But this almost does not work for txt files. Most of the apps can not recognize sent intent. For instance https://github.com/gsantner/markor can not open files from such intents.

I've tried to compare intents that sends Syncthing-Fork with intents of file managers that properly opens text files in all available text editors. https://github.com/MuntashirAkon/AppManager

Synthing-Fork:

Data: /storage/emulated/0/Notes/todo.txt#Intent;type=text/plain;launchFlags=0x3000001;component=io.github.muntashirakon.AppManager/.intercept.ActivityInterceptor;end
URI: /storage/emulated/0/Notes/todo.txt#Intent;type=text/plain;launchFlags=0x3000001;component=io.github.muntashirakon.AppManager/.intercept.ActivityInterceptor;end

Another app:

Data: content://com.simplemobiletools.filemanager.pro.provider/external_files/storage/emulated/0/Notes/todo.txt
URI: intent://com.simplemobiletools.filemanager.pro.provider/external_files/storage/emulated/0/Notes/todo.txt#Intent;scheme=content;type=text/plain;launchFlags=0x3000001;S.real_file_path_2=%2Fstorage%2Femulated%2F0%2FNotes%2Ftodo.txt;end

There is conspicuous difference. I am not familiar with Android ways but it seems to me that Data and URI most likely should not be identical.

Reproduction Steps

See above.

Version Information

  • App Version: 1.16.0.6
  • Syncthing Version: v1.16.0
  • Android Version: Android x.y
  • Device manufacturer: Xiaomi
  • Device model: Mi A1

Device platform info

Not collected, I believe irrelevant

Android Log

Not collected, I believe irrelevant

@Catfriend1
Copy link
Owner

Hi, the problem seems to be the URIs Android expects and prefers since SAF introduction. Syncthing does not access files by URIs (nor FileProvider, nor MediaStore) which causes limits to be effective either from Android side or from the security other app developers believe in (according to google developer docs rooted paths should not be used in intents).

@Self-Perfection
Copy link
Author

Your answer is cryptic for me unfortunately. (What is SAF? What is FileProvider? What is MediaStore? ... Too many unknowns)

Yet I figured out that I can edit intercepted intent in AppManager in such a way that it becomes reasonable for Markor.

Data: /storage/emulated/0/Notes/todo.txt#Intent;type=text/plain;launchFlags=0x3000001;component=io.github.muntashirakon.AppManager/.intercept.ActivityInterceptor;end

Data: content:///storage/emulated/0/Notes/todo.txt

and also set MIME type to text/plain.

And voilá! Edited intent opens file in Markor. And this seems to me more in line with the way file managers send intents to open text files.

Does it seem reasonable to send content:// intents from Syncthing-Fork?

@Catfriend1
Copy link
Owner

@Self-Perfection we could at least try to add the content:// prefix "in text form" and hope it gets a little better than now. It depends on Android (version, implementation, restrictions) if that will work, but let's try.

@Catfriend1
Copy link
Owner

It's also on F-Droid: https://f-droid.org/en/packages/net.gsantner.markor/

@Catfriend1
Copy link
Owner

Testing on v1.17.0.0 (preview) here:

image

@Catfriend1
Copy link
Owner

Hmm okay... clicking "Markor" opens a blank screen.

image

@Catfriend1
Copy link
Owner

Ok, now getting a little bit more ...
image

@Catfriend1
Copy link
Owner

image

@Catfriend1
Copy link
Owner

MaterialFiles' text editor now also works:

image

@Catfriend1
Copy link
Owner

@Self-Perfection Please report back if https://github.com/Catfriend1/syncthing-android/releases/tag/v1.17.0.0 solves your problem. Thank you :-).

@Self-Perfection
Copy link
Author

I'd like to test this fix, but somehow v 1.17.0 has not yet arrived in F-Droid. ☹️

@Catfriend1
Copy link
Owner

You could use https://github.com/Catfriend1/syncthing-android/releases/download/v1.17.0.0/com.github.catfriend1.syncthingandroid_github_v1.17.0.0_4e4bce31.apk , for the moment. If the change works, I'll do the F-Droid release when I have some spare time again :).

@Self-Perfection
Copy link
Author

I've tested F-Droid build v 1.18.0 and txt files opens as expected.

Thank you!

@Catfriend1
Copy link
Owner

Cool, thanks for the follow up :)

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.

2 participants