-
Notifications
You must be signed in to change notification settings - Fork 304
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
Support org attachments #795
base: master
Are you sure you want to change the base?
Conversation
Great work! Let me share some thoughts on it:
|
Thanks for your testing and feedback!
This is now fixed, by allowing any kind of file type for the link method. It will try to find the file path for the note content, and file name for the note title. But from my testing, real file path almost always could not be found. Instead "content:" path are found, so I think this method is a lot less useful.
This is also fixed. For the second option, "file:" link prefix should have been used instead of "attachment:" link prefix. Also added the surrounding brackets which fixed for spaces in filenames.
This path translation is actually expected of the org-attach behavior, see |
I've tested again this new version and all work fine. Regarding the second option, I think it can be interesting to also add the attach path before the filename. In that way, I can open the file I just attached by clicking on it on Android (as opposed by generating a link that only can be followed on desktop by emacs). I don't know a lot of Java/Android but the patch would be something like: diff --git a/app/src/main/java/com/orgzly/android/ui/share/ShareActivity.java b/app/src/main/java/com/orgzly/android/ui/share/ShareActivity.java
index 7b225ae3..cbdd673a 100644
--- a/app/src/main/java/com/orgzly/android/ui/share/ShareActivity.java
+++ b/app/src/main/java/com/orgzly/android/ui/share/ShareActivity.java
@@ -36,6 +36,7 @@ import com.orgzly.android.usecase.UseCaseResult;
import com.orgzly.android.util.LogUtils;
import com.orgzly.android.util.MiscUtils;
import com.orgzly.org.OrgStringUtils;
+import com.orgzly.android.prefs.AppPreferences;
import java.io.File;
import java.io.IOException;
@@ -168,7 +169,8 @@ public class ShareActivity extends CommonActivity
}
} else if (ATTACH_METHOD_COPY_DIR.equals(AppPreferences.attachMethod(this))) {
- handleCopyFile(intent, data, "file:");
+ String attachDirPath = AppPreferences.attachDirDefaultPath(this);
+ handleCopyFile(intent, data, "file:"+attachDirPath+"/");
} else if (ATTACH_METHOD_COPY_ID.equals(AppPreferences.attachMethod(this))) {
handleCopyFile(intent, data, "attachment:");
} else { E.g. I can open a pdf file using a pdf reader, a voice note using a music app, etc |
Maybe it should work too with a DIR property based directory
https://orgmode.org/manual/Attachment-options.html#Attachment-options |
For copy method, pass the content Uri to NoteFragment to be saved. For the link method, keep old behavior.
…ID based directory.
This is to support storing a file into a directory path in the repo. Only implemented for ContentRepo and DirectoryRepo for now.
Tested with a webdav server to confirm that attachment and its parent directories can be created. Caveat: - The attachment: link cannot be resolved. Because this link currently only resolves to local files, it cannot deal with remote files (like webdav). To handle remote files, need additional changes to download and cache the remote files.
@lytex Currently |
Tested with Dropbox to confirm that attachment and its parent directories can be created.
@nevenz I'd like some feedback on how best to proceed here. This PR adds the functionality for Orgzly to act as a file share target, so that users can save attachments into Orgzly, but only access them through the links within the content. The options for saving attachment are opinionated. I have another WIP PR that depends on this PR, but further enables Orgzly to manage files within a note, by adding/deleting/listing multiple files within a note. People may have different taste for the UI. I haven't received feedback on this PR yet from you, but I need to keep up with the merge conflicts as the main branch develops. Maybe I can submit both PR to prove the prototype concept, and you can modify as you see fit as that seems to be the most efficient way? |
Resolves #1
attachment:
linkFeedback on UX or code are welcome :)
There is something left that should be addressed
storeFile
is not implemented for otherRepo
yet. Would others who are more familiar with those implement them?Other nice to have improvements, but should be future work