gsantner / markor

Text editor - Notes & ToDo (for Android) - Markdown, todo.txt, plaintext, math, ..
https://github.com/gsantner/markor/discussions/2269
Other
3.83k stars 367 forks source link

Problems receiving file intents (several apps) #439

Closed troyengel closed 5 years ago

troyengel commented 5 years ago

General information

Description

I'm having problems with consistent and reliable file sending into Markor, I've tried to reproduce this in several ways with different sending apps. In general, it feels like Markor has trouble receiving file intents sometimes, while other editors can receive them fine. I'm not sure where the bugs lie, I realize that they may be with the other apps so just trying to gather information.

I first added Editor, a very basic open source editor which seems to receive the file intents from all the below OK (except LabCoat) as an A / B test against Markor at the same time.

The only counter-example of "seems to work right" is when using FX File Explorer, however this app uses a different method than most others (you have to choose "Open as..." then select a MIME type text/plain, then choose the app to receive - both Markor and Editor receive the file intent fine this way). This app is not open source and has different behaviour traits - interesting, but maybe not useful for this debugging.

Perhaps if nothing else, figuring out why another open source editor (Editor) receives the file intents OK from "GMail" and "Files" stock Android/Google apps would be a clue as to what's going on with Markor's basic file-opening issues. Green Git Client doesn't seem to have source to look at yet (it's alpha), but is an interesting "why doesn't this work either with Markor?". LabCoat's source seems like they copied it from another project so it's an outlier here. Thanks for listening!

troyengel commented 5 years ago

(trying to help do some legwork) - it appears that modern Android now uses the mime type from RFC 7763 text/markdown, which I am not seeing in the Markor AndroidManifest.xml. The Android mappings being used are located here now:

These are pulled in from the MimeTypeMap and parsed, so if we add that it should help. The Editor project is accepting text/* which makes sense why it works -- the Android subsystem is not sending the file as type text/plain but as text/markdown, so Markor doesn't get triggered as it's not built to accept that mime type (that I can tell, not an android coder :) ).

I also managed to find another link that shows using a +extension method to a mime type is pretty common (?), he shows his solution to read XML files was <data android:mimeType="application/xhtml+xml" /> (adding the +xml after the type) which may or may not help here, possibly adding the text/plain+md mapping would be enough. I think that would at least allow the default Google apps to show Markor as an intent receiver to get started... hope this helps!

troyengel commented 5 years ago

I found another open source editor Simple Markdown and was able to test, it works correctly and receives the file intents from the GMail and Files apps, GGC and LabCoat as well. Once I installed it, I was then able to choose which editor to launch from LabCoat again so can now confirm Editor works fine there.

gsantner commented 5 years ago

@troyengel Thanks for report and doing research & testing! The reason is that (as you probably noticed already) Markor is only registered with text mimetypes. If other apps not set that (they should do that in case of a textfile) Android won't list Markor.

gsantner commented 5 years ago

@troyengel Have added some mimetypes, checkout next update release if it works better for you ;)

troyengel commented 5 years ago

Looking good for step 1 - using the two test cases above with the stock phone apps: can I open from the GMail app, and can I open using the Files app from /sdcard/Downloads/. Both now show Markor as a possibility for test.md as expected, the new mimetypes work.

Alas, both still launch Markor and I get the error message posted in the first comment, for some reason Markor does not like the way the GMail and Files apps pass the file handle over to Markor via the intent. If you simply file-attach a test.md and email it to yourself, do you see the same results? (wondering if this is an Android 9 specific problem?)

contrapunctus-1 commented 5 years ago

Possibly the same issue when sending a Markdown file using Conversations and trying to open it with Markor. Markor opens the sent file on the sender's Conversations (Nokia 6.1) just fine, but on the receiver's Conversations (Samsung J7 Prime) it says that it can only open local files. The Conversations lead developer said that this was a Markor issue.

gsantner commented 5 years ago

Can you please send me such a file to xmpp:gsantner@trashserver.net . If possible please also link the conversations issue no.

EDIT: Had a chat with contra, could not resolve the issue so far. Seems to be a device specific issue I can't reproduce.

gsantner commented 5 years ago

Closing in favor of #197 . Please comment there if required. Conversations: Cannot reproduce the issue as said, so expect this a device specific issue.