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

Can't edit text files with external app #2952

Closed
erikw opened this issue Sep 2, 2018 · 21 comments
Closed

Can't edit text files with external app #2952

erikw opened this issue Sep 2, 2018 · 21 comments
Labels
bug needs info Waiting for info from user(s). Issues with this label will auto-stale.

Comments

@erikw
Copy link

erikw commented Sep 2, 2018

Since Dropbox is effectively shutting down Linux support, I'm now one of the Dropbox2Nextcloud migrating users.

My main use case with Dropbox has been for years and years to view and edit .txt files on shared between my laptop and my mobile phone. Unfortunately this use case it not working for me with Nextcloud Android.

Actual behavior

External text editors can't open or save a .txt file from Nextcloud. I've tried these following text editor which all works fine with editing text files from Dropbox with. See attached Screenshots at the end of this issue.

  • Quoda
    • Shows a blank file.
  • TED
    • Shows error message
  • SE Text Editor (Solid Explorer)
    • The file contents is actually loaded, but saving changes gives errors.

Expected behavior

Opening .txt files with external text editor apps should work. It should be possible to open them for reading and editing. When saving from external app, Nextcloud should upload the changes (Like Dropbox works)

Steps to reproduce

  1. Pick a .txt in Nextcloud android app which has content inside.
  2. Select "Open With"
  3. Select a text editor
  4. Error opening & saving file from external app.

Environment data

Android version: 6.0.1

Device model: Oneplus 2

Stock or customized system: Stock

Nextcloud app version: 3.2.3

Nextcloud server version: 13.0.5

Screenshots

quoda

ted

se_editor

@nextcloud-android-bot
Copy link
Collaborator

GitMate.io thinks possibly related issues are #2758 (Can't upload files for android app), #2336 (Can't view External Storage in APP), #126 (In-App Text Editor), #31 (Removing file crashes app.), and #877 (Create new text file from within NC).

@erikw
Copy link
Author

erikw commented Sep 5, 2018

I verified that the same problem is also present in version 3.3.0 RC1 of the app.

@tobiasKaminsky
Copy link
Member

tobiasKaminsky commented Sep 7, 2018

I tested it with 3.3.0 RC1 and amaze text editor:

  • download txt file
  • open with amaze text editor
  • changed text
  • press save
  • go back to return to NC files app
  • click on overflow menu of file and "sync"

This is done on a 8.x device with only internal storage

@tobiasKaminsky tobiasKaminsky added bug needs info Waiting for info from user(s). Issues with this label will auto-stale. labels Sep 7, 2018
@erikw
Copy link
Author

erikw commented Sep 7, 2018

@tobiasKaminsky Indeed it works with the Amaze text editor for some reason. I wonder how it's different from all other text editors I've tried (that works with Dropbox)

I think this is still a problem, it should be agnostic to which text editor you are using. How many people will happen to have one of the magic text editors that works with Nextcloud?

I would consider Quoda to be one of the most important popular free Android text editors, and nextcloud Android should behave properly so it can edit text files from NC.

Could you try one of the text editors I linked to, to confirm other NC doesn't play well with them?

@sehucke
Copy link

sehucke commented Sep 7, 2018

I just tried Quoda on a BQ Aquarius X Pro with Android 8.1. Indeed, you cannot open text files with Quoda from within the NC app. But you can open the files stored under Android/media/com.nextcloud.client/... with Quoda's "open" dialog. Then you can edit and save them. Afterwards, you can use the "Sync" feature of NC client to upload the changes.

Just a workaround, though.

To add an editor to the list of working apps:
Markor works fine with opening markdown files from within NC client.

@erikw
Copy link
Author

erikw commented Sep 7, 2018

@sehucke Thank you for confirming.

I do not find my downloaded (available offline, is this what you mean with "downloaded"?) textfile in Android/media/com.nextcloud.client/ or the subdirectories cache and files there. In the NC app under Settings, it's configured to use this path for storage.

@sehucke
Copy link

sehucke commented Sep 7, 2018

Imho, the wording of those features is a bit misleading. I remember there was a discussion about it between some Nextcloud devs some time ago.
AFAIK, "Download" (or "Herunterladen") downloads the file to your NC data folder (i.e. Android/media/com.nextcloud.client/...). It does not keep the file up to date in any direction - it just makes it available offline. ;-p If you change it (remote or locally) you have to hit the "Sync" button for that file or for the parent folder.

And then there is the "mark as available offline" ("Als Offline verfügbar markieren") feature. It automatically syncs remote and local changes to the file with your NC server.

Imho the second feature should be renamed to "Keep in sync" or "Auto-sync with server".

Now back to your permission problem:
Have you stored your NC data on the internal storage or on an external storage (i.e. a MicroSD card). I once had similar problems on a MotoG 4G with Android 6.x. I think someone worked on that topic. But I am not quiet sure... I switched back to internal storage some time ago since my current phone got much of it. :-)

@erikw
Copy link
Author

erikw commented Sep 7, 2018

@sehucke NC is set to internal storage (there is not external on Oneplus 2). See NC settings:

screenshot_20180908-003200

@sehucke
Copy link

sehucke commented Sep 8, 2018

Hmm... Have you checked app permissions?

I had #1285 in mind but it should be fixed since 3.0.0.

@erikw
Copy link
Author

erikw commented Sep 8, 2018

@sehucke NC has storage permission.

It does not look like the same issue as #1285, because

  • Opening .txt works with some external apps, but not all,and that ticket says

I'm unable to open files at all

  • Opening PDF files for viewing workes with all external PDF viewer apps on my phone.

screenshot_20180908-094530

@sehucke
Copy link

sehucke commented Sep 8, 2018

Please check the permissions of the apps used to open files out of NC as well.

Or it maybe a general problem with those specific apps when opening files stored within another app's media folder in Android 6. Have you tried this with Quoda and some other (sync) app?

@erikw
Copy link
Author

erikw commented Sep 8, 2018

Yes e.g. Quoda has storage permissions

Hmm there is obviously some difference between the combination NC + Quoda vs Dropbox + Quoda, as the latter works fine. Since the component Quoda is the common denominator, it must be that there is a difference between NC and Dropbox.

From the Screenshot in my first post here, we see that when files from NC are opened, they are in the path external_files/emulated/0/Android/media/com.nextcloud.client/nextcloud/user@domain/file.txt.

However when I open a text file from Dropbox, the path is storage/emulated/0/Android/data/com.dropbox.android/files/uid/scratch/file.txt.

Assuming that the prefix storage/ and external_files/ refer to the same thing, it seems better to put files in Android/data than Android/media.

screenshot_20180908-141123

screenshot_20180908-135728

Edit.

I went in to NC settings and tried out the 2 other storage paths available, but I get the same error as before (here trying the SE Editor)

screenshot_20180908-141745

45254128-2a793e80-b373-11e8-8da3-bb6d28de1f85

45254130-32d17980-b373-11e8-97d7-ef55c654d326

@sehucke
Copy link

sehucke commented Sep 10, 2018

Hmm... AFAIK, the first path option should be the place where you have the least problems to access files. It is the app's media folder that is also made available through the MediaStore. Every app with storage access can read and write those files. The third one is the app's private file storage. Thus, you should have to serve files explicitly to external apps. I am not quiet sure what the second path is - I suppose it has to do with Android's multi-user functionality?!

BTW: Which app did you use to explore the folder structure? Have you tried Total Commander?

I think this topic needs some third-level support. Maybe @mario or @tobiasKaminsky can help you further... I am not a Android/Java developer so all I can do is speculate... :-|

@tobiasKaminsky
Copy link
Member

There are different ways to open a file from one app to another (e.g. open with app XY from within NC files app):

XY can try to open the file directly, like you would do on a computer. This can fail depending on where the file is stored (in apps internal storage it is not readable; but on sdcard it is)

XY can use a file:// uri.
XY can use a content:// uri to request the file from the app.

We are using the latter one as this is the most recent one.
However it can happen that an app does not understand this.

To test this, can please someone point me to an open source app where it does not work, so I can debug it?

@erikw
Copy link
Author

erikw commented Sep 11, 2018

@sehucke I use Solid Explorer as my file manager, as it has integration with Dropbox, Samba, FTP etc. But this is unrelated to the issues reported if I'm not mistaken? :)

@tobiasKaminsky Thank you for digging in!
The Ted app I reported in the bug report above is open source. Code can be found at https://github.com/xgouchet/Ted

@tobiasKaminsky
Copy link
Member

Ted seems to be very old and I cannot get it to run :-/

@erikw
Copy link
Author

erikw commented Sep 12, 2018

@tobiasKaminsky

  • Jota
    • Play Store, Source code
    • Opening a .txt file from within Drobpox with Jota does work. Also saving the changes uploads them to Dropbox.
    • Opening a .txt file from within Nextcloud gives a useful error message: "Opened via Content Provider. So you can't overwrite this file."

In your previous post you said that Nextcloud uses "content:// uri", so I assume that this is the same as "Content Provider" mentioned in the error message.

Which ever other way Dropbox uses seems to be a better way, as it works with many more apps than the "content://" URI. Could we switch so that NC-android uses the better way? =)

screenshot_20180912-164300

@sehucke
Copy link

sehucke commented Sep 14, 2018

@sehucke I use Solid Explorer as my file manager, as it has integration with Dropbox, Samba, FTP etc. But this is unrelated to the issues reported if I'm not mistaken? :)

@erikw I was just wondering why you were not able to browse the downloaded Nextcloud files in the media folder. Thought of some issue special to your device that prohibits access to the files. But in the meantime the analysis points into a different direction.

Which ever other way Dropbox uses seems to be a better way, as it works with many more apps than the "content://" URI. Could we switch so that NC-android uses the better way? =)

I think this is not about "better" or "worse" (at least not only... :-) ). It is about the intended functionality. E.g. if one wants to explicitly permit a third party app to read/write files - or if you don't care and grant everyone access through choosing a publicly accessible storage space.

Please correct me if I got this wrong @tobiasKaminsky (since I am not an Android expert for now): If you choose to store the files inside Nextcloud's internal storage the mechanism to open the files with write access could be different compared to storage paths like a world-writable media folder? (See https://stackoverflow.com/questions/30286920/android-external-app-cant-access-apps-files )

@tobiasKaminsky
Copy link
Member

With upcoming version (and current dev version) this should be fixed/included, please test it and if there is something not working as expected, please re-open.

@AndyScherzinger
Copy link
Member

@ all beware that this means the app you are using to edit a file (no matter what format) needs to support the document provider (like the Android files app where you need to choose your Nextcloud account), if you open the file straight from the file system thatn this won't work since you are actually bypassing the Nextcloud files app itself. One example for a text editor that does support this would be: https://play.google.com/store/apps/details?id=com.byteexperts.texteditor

@erikw
Copy link
Author

erikw commented Jan 21, 2019

Great!! Thanks for for the work.

I'll try this out when I upgrade

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug needs info Waiting for info from user(s). Issues with this label will auto-stale.
Projects
None yet
Development

No branches or pull requests

5 participants