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

[sdcard] Improve SD-Card support, home on sd looping #603

Closed
gilcot opened this issue Jul 3, 2019 · 19 comments
Closed

[sdcard] Improve SD-Card support, home on sd looping #603

gilcot opened this issue Jul 3, 2019 · 19 comments

Comments

@gilcot
Copy link

gilcot commented Jul 3, 2019

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.

@gsantner
Copy link
Owner

gsantner commented Jul 4, 2019

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

@gilcot
Copy link
Author

gilcot commented Aug 29, 2019

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/Timeline( 3593): Timeline: Activity_launch_request id:net.gsantner.markor time:336982712
I/ActivityManager(  938): START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.gsantner.markor/.activity.MainActivity} from uid 10024 on display 0
D/ContextHelper(  938): convertTheme. context->name=net.gsantner.markor themeResourceId=2131886094
D/SplitWindow(  938): check instance of lgWin Window{13905f12 u0 Starting net.gsantner.markor}
I/ActivityManager(  938): Start proc net.gsantner.markor for activity net.gsantner.markor/.activity.MainActivity: pid=9626 uid=10788 gids={50788, 9997, 1028, 1015, 3003} abi=armeabi-v7a
I/SystemUI[Framework](  938): PhoneWindowManager.updateSystemUiVisibilityLw() :visibility=0x8600, pkg=net.gsantner.markor
D/ContextHelper( 9626): convertTheme. context->name=net.gsantner.markor themeResourceId=2131886094
D/ContextHelper( 9626): convertTheme. context->name=net.gsantner.markor themeResourceId=2131886094
D/SplitWindow(  938): check instance of lgWin Window{2352b30c u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
I/CliptrayUtils( 9626): CliptrayUtils created!! mTextView = net.gsantner.markor.ui.hleditor.HighlightingEditor{127ee7a8 VFED.VC. ......ID 0,0-0,0 #7f090084 app:id/document__fragment__edit__highlighting_editor}
I/CliptrayUtils( 9626): CliptrayUtils created!! mTextView = net.gsantner.markor.ui.hleditor.HighlightingEditor{221b8a00 VFED.VC. ......ID 0,0-0,0 #7f090084 app:id/document__fragment__edit__highlighting_editor}
I/SystemUI[Framework](  938): PhoneWindowManager.updateSystemUiVisibilityLw() :visibility=0x8700, pkg=net.gsantner.markor
D/InputDispatcher(  938): Focus entered window: Window{2352b30c u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
I/ActivityManager(  938): Displayed net.gsantner.markor/.activity.MainActivity: +2s845ms
I/Timeline(  938): Timeline: Activity_windows_visible id: ActivityRecord{c88756b u0 net.gsantner.markor/.activity.MainActivity t30125} time:336985584
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=336990678633000, eventTime=336990678633000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=336990678633000, eventTime=336990769501000, pointerCount=1
D/SplitWindow(  938): check instance of lgWin Window{38a2f9e6 u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
D/InputDispatcher(  938): Focus left window: Window{2352b30c u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
D/InputDispatcher(  938): Focus entered window: Window{38a2f9e6 u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
I/SystemUI[Framework](  938): PhoneWindowManager.updateSystemUiVisibilityLw() :visibility=0x8000, pkg=net.gsantner.markor
D/Cliptray Service( 1763): ignore packageName : net.gsantner.markor
D/InputTransport(  938): channel '38a2f9e6 net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=337003267604000, eventTime=337003267604000, pointerCount=1
D/InputTransport(  938): channel '38a2f9e6 net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=337003267604000, eventTime=337003338600000, pointerCount=1
I/SystemUI[Framework](  938): PhoneWindowManager.updateSystemUiVisibilityLw() :visibility=0x8700, pkg=net.gsantner.markor
D/InputDispatcher(  938): Focus left window: Window{38a2f9e6 u0 net.gsantner.markor}
D/InputDispatcher(  938): Focus entered window: Window{2352b30c u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}
D/InputDispatcher(  938): Window went away: Window{38a2f9e6 u0 net.gsantner.markor}
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=337020839526000, eventTime=337020839526000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=337020839526000, eventTime=337020940590000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=337026706712000, eventTime=337026706712000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=337026706712000, eventTime=337027055274000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=337027838962000, eventTime=337027838962000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=337027838962000, eventTime=337028032488000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_DOWN, downTime=337028878642000, eventTime=337028878642000, pointerCount=1
D/InputTransport(  938): channel '2352b30c net.gsantner.markor/net.gsantner.markor.activity.MainActivity (server)' : action=ACTION_UP, downTime=337028878642000, eventTime=337028981222000, pointerCount=1
D/InputDispatcher(  938): Focus left window: Window{2352b30c u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity}

I don't know how to read that logs, but the default location configured is: /storage/external_SD/LGBackup/sdcard/writeily/ Last time I tryed, the app created another directory where it put the file: /storage/external_SD/LGBackup/sdacard/writeily/LGBackup/sdcard/writeily/ It didn't open the file for edition and this wasn't shown in current directory either (what made me think first the operation failed till I noticed the strange directory) When I went to that location I could see my file, and try to create another file to be sure, then check with the file manager: it then created /storage/external_SD/LGBackup/sdcard/writeily/LGBackup/sdcard/writeily/LGBackup/sdcard/writeily/

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:
2019-08-29-markor.txt

@pajot
Copy link

pajot commented Jan 18, 2020

I am observing this same problem with Markor v2.2.5 (107) on LineageOS 16 (Android 9) (lineage_a5y17lte).

Using adb logcat | grep net.gsantner.markor, I get the following log output when trying to open and write to a file on the SD card:

01-18 16:40:28.569 2660 2672 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=net.gsantner.markor/.activity.MainActivity bnds=[540,703][792,999]} from uid 10022 01-18 16:40:28.637 2660 2677 I ActivityManager: Start proc 26144:net.gsantner.markor/u0a121 for activity net.gsantner.markor/.activity.MainActivity 01-18 16:40:28.996 2660 2677 I ActivityManager: Start proc 26177:com.android.webview:sandboxed_process0/u0i7 for webview_service net.gsantner.markor/org.chromium.content.app.SandboxedProcessService0 01-18 16:40:29.121 26144 26144 I chatty : uid=10121(net.gsantner.markor) identical 12 lines 01-18 16:40:29.455 2660 2674 I ActivityManager: Displayed net.gsantner.markor/.activity.MainActivity: +874ms 01-18 16:40:31.517 26144 26144 I chatty : uid=10121(net.gsantner.markor) identical 12 lines 01-18 16:40:50.580 2660 4318 I ActivityManager: START u0 {flg=0x8080000 cmp=net.gsantner.markor/.activity.DocumentActivity (has extras)} from uid 10121 01-18 16:40:51.655 2480 2581 E BufferQueueProducer: [net.gsantner.markor/net.gsantner.markor.activity.MainActivity#0] disconnect: not connected (req=1) 01-18 16:41:07.339 2480 2581 D SurfaceFlinger: duplicate layer name: changing net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity to net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#1 01-18 16:41:09.604 2480 2688 E BufferQueueProducer: [net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#1] disconnect: not connected (req=1) 01-18 16:41:09.773 2480 2581 W SurfaceFlinger: Attempting to set client state on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#1 01-18 16:41:09.773 2480 2581 W SurfaceFlinger: Attempting to destroy on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#1 01-18 16:41:26.795 2660 13640 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x1000c000 cmp=net.gsantner.markor/.activity.MainActivity} from uid 10121 01-18 16:41:27.197 26144 26144 I chatty : uid=10121(net.gsantner.markor) identical 12 lines 01-18 16:41:28.117 2480 4416 E BufferQueueProducer: [net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0] disconnect: not connected (req=1) 01-18 16:41:28.176 2480 4416 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{1c95f13 token=Token{9eb9a02 ActivityRecord{43d3f4d u0 net.gsantner.markor/.activity.DocumentActivity t767}}}#0 01-18 16:41:44.800 2660 13640 I ActivityManager: START u0 {flg=0x8080000 cmp=net.gsantner.markor/.activity.DocumentActivity (has extras)} from uid 10121 01-18 16:41:29.609 26144 26144 I chatty : uid=10121(net.gsantner.markor) identical 12 lines 01-18 16:41:45.838 2480 2581 E BufferQueueProducer: [net.gsantner.markor/net.gsantner.markor.activity.MainActivity#0] disconnect: not connected (req=1) 01-18 16:42:11.386 2480 4416 E BufferQueueProducer: [net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0] disconnect: not connected (req=1) 01-18 16:42:11.717 2480 4416 W SurfaceFlinger: Attempting to set client state on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0 01-18 16:42:11.717 2480 4416 W SurfaceFlinger: Attempting to destroy on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0 01-18 16:42:11.724 2480 4416 W SurfaceFlinger: Attempting to set client state on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0 01-18 16:42:11.724 2480 4416 W SurfaceFlinger: Attempting to destroy on removed layer: net.gsantner.markor/net.gsantner.markor.activity.DocumentActivity#0 01-18 16:42:12.650 2480 2688 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{71f7845 token=Token{f2670bc ActivityRecord{ffab4af u0 net.gsantner.markor/.activity.DocumentActivity t768}}}#0 01-18 16:42:18.835 2660 4321 I ActivityManager: Killing 26144:net.gsantner.markor/u0a121 (adj 900): remove task 01-18 16:42:18.886 2660 3441 W ActivityManager: Scheduling restart of crashed service net.gsantner.markor/org.chromium.content.app.SandboxedProcessService0 in 1000ms 01-18 16:42:18.969 2660 13640 I WindowManager: WIN DEATH: Window{9eda88a u0 net.gsantner.markor/net.gsantner.markor.activity.MainActivity} 01-18 16:42:18.978 2480 2579 W SurfaceFlinger: Attempting to destroy on removed layer: AppWindowToken{b9dec00 token=Token{569c283 ActivityRecord{f6aa532 u0 net.gsantner.markor/.activity.MainActivity t766}}}#0

@pajot
Copy link

pajot commented Apr 5, 2020

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?

@gsantner
Copy link
Owner

gsantner commented Apr 5, 2020

@pajot I cannot reproduce it on any device hence cannot exactly fix it :D.

The most relevant file & function is: app/src/main/java/net/gsantner/opoc/util/ShareUtils.java :: getDocumentFile().
Also theres a number of other *StorageAccess* methods in the same file that are used in getDocumentFile.

@pajot
Copy link

pajot commented Jul 24, 2020

@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.

@gsantner
Copy link
Owner

gsantner commented Jul 24, 2020

I said it already at others:

  1. Doesn't happen on my device
  2. I tried on phone of friend, Moto G2 doesnt happen there either.

-> Community takes a look or this wont be fixed. And especially, this should be done by somebody this happens for. I have never had a occurence of this bug.

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 gsantner added this to the Community Contribution milestone Jul 24, 2020
@gsantner gsantner changed the title home on sd looping Improve SD-Card support, home on sd looping Jul 24, 2020
@pajot
Copy link

pajot commented Jul 25, 2020

@gsantner The erroneous extra directories are being created in this section of code, specifically in line 1101:

DocumentFile dof = DocumentFile.fromTreeUri(_context, treeUri);
if (originalDirectory) {
return dof;
}
String[] parts = relPath.split("\\/");
for (int i = 0; i < parts.length; i++) {
DocumentFile nextDof = dof.findFile(parts[i]);
if (nextDof == null) {
try {
nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]);
} catch (Exception ignored) {
nextDof = null;
}
}
dof = nextDof;
}

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?

@pajot
Copy link

pajot commented Jul 27, 2020

Saving modified documents on the SD card does not work either. You get

  • the original file that you opened, without the changes you made, and
  • a copy of the original file in the nested subdirectory.

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:

DocumentFile dof = DocumentFile.fromTreeUri(_context, treeUri);
if (originalDirectory) {
return dof;
}
String[] parts = relPath.split("\\/");
for (int i = 0; i < parts.length; i++) {
DocumentFile nextDof = dof.findFile(parts[i]);
if (nextDof == null) {
try {
nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]);
} catch (Exception ignored) {
nextDof = null;
}
}
dof = nextDof;
}
return dof;
}

Say you had a file saved under the following path:
/storage/3537-3433/docs/20200727_test.txt

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"
parts[1] is "20200727_test.txt"

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

if (nextDof == null) {
try {
nextDof = ((i < parts.length - 1) || isDir) ? dof.createDirectory(parts[i]) : dof.createFile("image", parts[i]);
} catch (Exception ignored) {
nextDof = null;
}
}

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
After: content://com.android.externalstorage.documents/tree/3537-3433%3Adocs/document/3537-3433%3Adocs%2Fdocs

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

DocumentFile nextDof = dof.findFile(parts[parts.length-1]);

https://github.com/pajot/markor/blob/689f0c5240830a059a13c83d795a9c5eaf0220e2/app/src/main/java/net/gsantner/opoc/util/ShareUtil.java#L1095

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.

@gsantner
Copy link
Owner

gsantner commented Jul 27, 2020

thanks! As said, this should be fixed by somebody who can reproduce it, and has abilities to fix it.
This seem to be the case both here in your case. So please go ahead and create a pull request, and fix this for you and everybody in the community wanting it. Your comment tell me you have the abilities, or at least want to take deeper look and handle this. Thanks.

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.:

  • Create folders
  • Create subfolders
  • no "nested subfolder hierachy" created
  • Create new files
  • Read files
  • Edit & Update/Write files

video_2020-07-27_19-45-18

I'm happy to see pull request, review and merge it in case:

  • Everything still works as above for my cases.
  • Works for your cases. (Which I cannot verify, but you can)

With all due respect, I do not know how this ever could have worked on anybody's device.

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.

@pajot
Copy link

pajot commented Jul 27, 2020

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:

  • Create folders - yes, in the base folder.
  • Create subfolders - no; the folder is created in the base folder(!)
  • no "nested subfolder hierachy" created - my change corrects this
  • Create new files - every new file is created in the base folder, no matter where I initiate this in the hierarchy
  • Read files - file reads fail without a warning or exception (the file appears empty). My changes are saved but are only visible when the file is viewed with another app (HTML viewer)
  • Edit & Update/Write files - initial writes seem to be "working", but are not very useful. I can only read the changes in another app.

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:

Representation of a document backed by either a DocumentsProvider or a raw file on disk. This is a utility class designed to emulate the traditional File interface. It offers a simplified view of a tree of documents, but it has substantial overhead. For optimal performance and a richer feature set, use the DocumentsContract methods and constants directly. (my emphasis)

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.

@gsantner
Copy link
Owner

Your test example is striking. Markor is behaving totally differently on your device.

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.

(I thought the whole point of abstractions like DocumentFile was to make the device irrelevant!

Well it's for making source irrelevant. Device irrelevant = Standard java methods, and thats what markor is on.

By the way, how can I make a screenshot gif like yours?

Normal video recodring, share file to desktop, ffmpeg convert to gif.

I tried following the create, write and read process in the Android Studio debugger but it is very difficult to follow what is happening.

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.

The document handling through DocumentFile is clearly a mess. But what are the alternatives to DocumentFile?

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.

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.

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 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.

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.

screenrecord

@gsantner
Copy link
Owner

gsantner commented Aug 6, 2020

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.

grafik

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 🤣

@gsantner
Copy link
Owner

gsantner commented Aug 14, 2022

Hello everybody, @gilcot @pajot @BStai @stevenleeS0ht @riveravaldez @orez-ero @GregoryTrzonkowski @BOND12 @ AtlcatlQ
@schnappgha @schnapphans @NomadicVoxel

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.
For NextCloud, here is some notes, as I also had to find it in their app how to open textfiles in external app...:
screenshot-2022-08-12__21-30-26

@gsantner gsantner changed the title Improve SD-Card support, home on sd looping [sdcard] Improve SD-Card support, home on sd looping Aug 14, 2022
@TheLittleYH
Copy link

TheLittleYH commented Aug 14, 2022

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.
About "Prefer View" I assumed the check for the setting wasn't happening when opening files from external apps (as opposed to when opening from inside Mordor), sorry if it's unrelated!


Of course, I backed-up (from Markor) and restored (into Mordor) the settings and also double-checked that it's set to true.

@gsantner
Copy link
Owner

gsantner commented Aug 14, 2022 via email

@schnapphans
Copy link

The opening of Markdown files from other applications and from different storage locations was tested.

POCO X3 NFC
Android 11

Open with File Manager and File Manager+:

  • SD card => works
  • Google Cloud => works
  • with Google Drive => works
  • open from app Obsidian => works

Repository owner deleted a comment from TheLittleYH Aug 14, 2022
Repository owner deleted a comment from TheLittleYH Aug 14, 2022
@BurntVoxel
Copy link

Looks like it works with MiXplorer and the stock File Manager on Android 11, Moto G Stylus 2020. Great work!
Question, why is it called Mordor, just specifically so you can have this experiment and the stable release at the same time?

@gsantner
Copy link
Owner

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.

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

No branches or pull requests

6 participants