-
Notifications
You must be signed in to change notification settings - Fork 382
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
[sdcard] Improve SD-Card support, home on sd looping #603
Comments
Yes help is helpful for sure. Inside markor's More section there is a button for supporting the project, using my android contribution guide. It will give you the correct commands to run to get log of markor |
OK, it tryed to open that page and in fact (after many minutes searching around) that other Well, it took some time because I wasn't allow to install something at work (no computer at home where I use my Android device only) and had to wait to found someone to ask to. In fact, Android Platform Tool has no system dependency (and thus may be run from an USB stick), but one need to install drivers also (what xda knows but didn't point out in it's guide) Plus my device manufacturer's one. Why on earth things are so difficult in Microsoft ecosystm? Here are the output for the following actions: lauch the app, create a new file named test.md, notice that it doesn't show up but some new directory appeared (a copy of existing tree)
I don't know how to read that logs, but the default location configured is: I've delete the extra tree, in order to reproduce the same/exact behaviour and capture it with MatLog Libre but I can nolonger create file (the "plus" button doesn't respond) but the tree looping is still there. Those logs are attached there: |
I am observing this same problem with Markor v2.2.5 (107) on LineageOS 16 (Android 9) (lineage_a5y17lte). Using
|
This behaviour persists even after numerous updates since this bug was reported. How can I help resolve this? What code do I need to look at? |
@pajot I cannot reproduce it on any device hence cannot exactly fix it :D. The most relevant file & function is: |
@gsantner I wonder how it is that users keep reporting this bug, yet you are unable to reproduce it on any device. Which devices have you tested? How can I configure logging such that we can trace the behaviour to its cause on my device? I would like to use Markor but this bug is also a "deal-breaker" for me. I'm prepared to offer a bounty for resolution. |
I said it already at others:
Hence be civil guys and take a look yourself if you really want it fixed. Thats at least how open source community should work. |
@gsantner The erroneous extra directories are being created in this section of code, specifically in line 1101: markor/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java Lines 1092 to 1107 in dcbf2a1
In order to fix this properly I need to understand what this code was originally intended to do. Isn't it enough to just return the original DocumentFile object as returned in 1092? Why do we need to walk through the path elements with a for loop? |
Saving modified documents on the SD card does not work either. You get
None of the modifications are saved. Ouch. Worse, every time you reopen the file, it creates a new copy in a nested subdirectory, probably because Markor attempts to save on pause, every time, and since saving doesn't work properly... Let's walk through the offending code: markor/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java Lines 1092 to 1109 in dcbf2a1
Say you had a file saved under the following path: The base folder (the SD card, essentially) is /storage/3537-3433/. Now, try to use Markor's picker to go into docs and access 20200727_test.txt. The function getDocumentFile is supposed to return a DocumentFile object. We split the relative path obtained earlier into parts using a string method and get an array with path elements "docs" and "20200727_text.txt". parts[0] is "docs" The treeUri is "content://com.android.externalstorage.documents/tree/3537-3433%3Adocs/document/3537-3433%3Adocs". But now we're using the loop index to check an element of 'parts' against the existing TreeDocumentFile 'dof'. So dof.findFile(parts[0]), which is "docs", necessarily returns null (there is no "docs" in the directory defined by treeUri, remember, that's the tree) and puts the execution into this try catch expression markor/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java Lines 1099 to 1105 in dcbf2a1
Bingo, it's now written a new "docs" directory in the parent. Then it overwrites the existing dof with the new TreeDocumentFile object based on the newly created directory. Before: content://com.android.externalstorage.documents/tree/3537-3433%3Adocs/document/3537-3433%3Adocs The next time around the loop (i = 1), the string to be matched is "20200727_test.txt". This might have worked, except that now we are in the newly created subdirectory, so again the match fails, dof.findFile() returns null and we are in the try catch expression yet again. The directory test condition fails so dof.createFile() gets executed. Now we not only have a new subdirectory, but we have a new file with the same filename in our new subdirectory. I tried correcting this with the much simpler array reference
which returns the TreeDocumentFile object we were aiming for and doesn't require a for loop. While this takes care of the erroneous subdirectory creation, it does not resolve the issue of file changes not being saved. The cause of that must be elsewhere. With all due respect, I do not know how this ever could have worked on anybody's device. There must not be many Markor users who are routinely saving to an SD card. |
thanks! As said, this should be fixed by somebody who can reproduce it, and has abilities to fix it. I also verified today on a fresh Markor installation on a Poco F1, Android 9. All cases work and worked same like always have been here. See yourself in video.:
I'm happy to see pull request, review and merge it in case:
Well it does, but seemingly not for everybody. As you see or will learn, the DocumentFile stuff is pretty crap compared to standard File access that just works. And just works everywhere the same. Thats why I pressure normal file access with Markor as long as possible. Just to make clear: I don't want to waste my own time with trying and trying and trying to fix it, when I'm not able to reproduce it and can verify afterwards it is fixed. So thats why somebody of the the community has to step up. After all, this is a open source community project (and no propritary & private company project), so don't make assumptions that I do everything everybody wants. Community should take care of things as well and especially if theres demand on something. |
Your test example is striking. Markor is behaving totally differently on your device. (I thought the whole point of abstractions like DocumentFile was to make the device irrelevant! By the way, how can I make a screenshot gif like yours?) For me:
So much is broken, I can't even properly save and access files (this was true even before my minor change, I have the same problems with an unaltered current version of Markor). I tried following the create, write and read process in the Android Studio debugger but it is very difficult to follow what is happening. The document handling through DocumentFile is clearly a mess. But what are the alternatives to DocumentFile? In the DocumentFile documentation it says:
Oh lord. Switching to DocumentsContract methods would imply rewriting all the Storage Access Framework code in Markor. How would I even start fixing this? Just to avoid any misunderstanding: Of course, I am not expecting you to do everything. But you did start this project and I assume you know more about how it is built than anybody. I have never done any Java programming period, let alone Java on Android. Without at least some guidance from someone experienced like you, I am not going to get very far. |
Well thats how it worked for all devices like that, which I had in my hands. So might be 50 / 50, might be 25% / 75% where happens..you don't know, just that it's happening for you.
Well it's for making source irrelevant. Device irrelevant = Standard java methods, and thats what markor is on.
Normal video recodring, share file to desktop, ffmpeg convert to gif.
Ah you see, and now think I randomly try to fix it for somebody and just do one small thing bad. Then I potentially make the 50%/25% whatever to 0% working :D. Thats why I've said it's hard for me to work on it.
None that has wanted featureset, that is the problem. And for what Markor wants. Like file info, file size, modtime, creating/edit/delete/update/folder view inside markor. Things like that.
Rewriting everything is out of scope. The goal is just to get it fixed on SD Card so it works for you (and for my at verification), nothing else. Android brings every year a new "preffered file access" option, and I'm sick of it. Next up is the scoped access, limiting & locking down everything more again. Markor lives from open access to files and I want to keep it that way. Probably next year comes another thing that deprecates everything once more. But the "Android gets locked down" is not something Markor has influence on.
I'm happy to help. To my understanding above you already setup Android Studio and installed Markor on your phone, AND tweaked some code and installed that. So thats already the biggest part you need to do. Everything required to change is inside the ShareUtils file you already seen. See video below how to set debug points, see values at this state, and how to get to next step/points/states. |
Anyway, with Android 11, Google breaks pretty much every kinds of shared-file-access. Like no normal traditional file access shared between apps. Including but not limited to internal storage and SD Cards. What a joke, haha. https://developer.android.com/preview/privacy/storage#other-app-specific-dirs BTW, yes ACTION_OPEN_DOCUMENT_TREE is what is used at Markor as that is the only way to get write access to SDCard as a whole. Say goodbye to many functionalities on Android>=11 🤣 |
Hello everybody, @gilcot @pajot @BStai @stevenleeS0ht @riveravaldez @orez-ero @GregoryTrzonkowski @BOND12 @ AtlcatlQ today I'm asking you to give a test version of Markor a try, which has many experimental new features for file handling from other/external apps. Besides, architectural upgrade to AndroidX & latest Android SDK33 and improved SD-Card support (Android>=30). To help testing, please download & install the APK from here and start it. Yes, the test app is called Mordor and can be installed beside Markor. After your first start(s) please try some file manager and sync apps you have and try to open a file with Mordor (not Markor). And give me feedback. For example I could get it to work that selected files from Dropbox and NextCloud respective android app can be opened, can be be edited/viewed/saved and is later synced up to the server by the Dropbox/NextCloud app. |
I have this issue as well with Markor, tested out Mordor and the issue does not seem to be present there! Also, since you requested to check that as well, trying to open with Mordor from a file manager works for me though I noticed an issue, when I do that, it opens the file in edit mode even though "Prefer View" is set to true. Ah, then that (opening a file with Mordor from the sd card using the file manager, editing and saving) works for me. Of course, I backed-up (from Markor) and restored (into Mordor) the settings and also double-checked that it's set to true. |
Yes please help with testing with opening from other apps, and testing
from various filepaths especially from SD-Card.
Getting the file content, editing & saving back is the main focus, i.e.
"rendered View Mode" isn't related to the filesystem changes :-).
Good to get some first feedback, happy about more!
also note that Mordor and Markor have separate settings, like different
apps. So if you have "Prefer view" in Markor, it won't be there in
Mordor...Just like when you would install Firefox Beta vs Firefox itself.
|
The opening of Markdown files from other applications and from different storage locations was tested. POCO X3 NFC Open with File Manager and File Manager+:
|
Looks like it works with MiXplorer and the stock File Manager on Android 11, Moto G Stylus 2020. Great work! |
Mordor is just the name of the development version, so not only users but also we developers can have both installed - stable/release Markor (like you get it) and something developers can freely work on while not messing up important files, trying different settings etc. |
Using Markor 1.8.3 on Android 5.0.2
In settings, I move my default folder to SD card. Then notice the app is behaving strangly: When I try to create a new file there, it's put in a different location (which is the selected one but nested...) and content is not saved.
How can I help you to trace/debug that? May I generate some logs to attach here?
Thanks.
The text was updated successfully, but these errors were encountered: