mirror of
https://github.com/pbek/QOwnNotes.git
synced 2025-07-01 06:29:57 +00:00
Created Full feature integration with Android OS native apps (Linux edition) (markdown)
parent
3a094498ee
commit
fb872fb5c0
1 changed files with 167 additions and 0 deletions
|
@ -0,0 +1,167 @@
|
|||
# Full feature integration with Android OS native apps (Linux edition)
|
||||
|
||||
This article is about using Android OS native apps to view and edit QOwnNotes made notes with maximum comfort and features. Most of the workarounds described here are specific for Linux but some can be used with any other OS. This article was composed on Linux and Android using the apps and workaround described below.
|
||||
|
||||
|
||||
## Android apps
|
||||
|
||||
QOwnNotes uses plain text files with markdown syntax to store it's notes. We can use any plain text editor to view and edit this notes on Android but for getting most of markdown syntax we need a markdown editor.
|
||||
|
||||
After trying almost every markdown editor available in Play Store I found two which are light and most suited for viewing and editing folder structured notes:
|
||||
|
||||
**[MarkdownX](https://play.google.com/store/apps/details?id=com.ryeeeeee.markdownx&hl=en)**
|
||||
+ Great editor with easy formatting and image inserting;
|
||||
? File sorted by name;
|
||||
- Hardcoded "save directory" (/storage/emulated/0/Android/data/com.ryeeeeee.markdownx/files/notes/);
|
||||
- No syntax highlighting in editor;
|
||||
- Not customizable.
|
||||
|
||||
**[Writeily Pro](https://play.google.com/store/apps/details?id=me.writeily&hl=en)**
|
||||
+ Much more customizable: you can set "save directory", change fonts, lock the app with pin or password and so on;
|
||||
+ Editor has syntax highlighting;
|
||||
? Files sorted by modification time;
|
||||
- No buttons for easy inserting or formatting, you'll have to write all the markdown code yourself.
|
||||
|
||||
Personally I like MarkdownX more but Writeily Pro is strong contender and have some features you might find useful.
|
||||
|
||||
I have not found any Android markdown editor which could render relative links. The importance of this will be explained later.
|
||||
|
||||
|
||||
## Synchronisation
|
||||
|
||||
We need all notes available on the phone and synced two-way. QOwnNotes has built-in support for OwnCloud which has an Android client. Also note files can be synced using [BitTorrent Sync](https://getsync.com/) or [Syncthing](https://www.syncthing.net/).
|
||||
|
||||
As we use markdown editor QOwnNotes note file format should be ".md", not ".txt".
|
||||
|
||||
I run BitTorrent Sync on my Linux laptop, Android phone and Synology NAS which acts as an "always on" sync target. After proper setting I haven't yet encountered any issue with using this setup for two-way sync.
|
||||
|
||||
My QOwnNotes note folders on the laptop are all stored in one directory which is synced with the "save directory" of Android markdown editor.
|
||||
|
||||
**HELP WANTED: OwnCloud setup**
|
||||
|
||||
|
||||
## Features and integration
|
||||
|
||||
After initial sync we have all the notes in markdown editor which provides the basic features:
|
||||
1) View and edit notes;
|
||||
2) Render markdown;
|
||||
3) Same folder structure as in QOwnNotes;
|
||||
4) Notes and text search.
|
||||
|
||||
No tags, no inline images, no links to notes or stored files.
|
||||
|
||||
Lets try getting it all.
|
||||
|
||||
|
||||
### Tags
|
||||
|
||||
By default QOwnNotes doesn't store note tags in a portable form. Markdown editor have no tags support at all.
|
||||
|
||||
With plain text files there are only 3 easy ways to pass the data: file path, file name and file content. Markdown editor's file list shows path and name. Lets try using both for tags.
|
||||
|
||||
QOwnNotes sports a powerful in-app scripting support to implement any kind of odd behaviour. And that's just what we need.
|
||||
|
||||
Add this script in the scripting section of QOwnNotes options:
|
||||
```
|
||||
import QtQml 2.0
|
||||
import com.qownnotes.noteapi 1.0
|
||||
|
||||
/**
|
||||
* This script is an example how to add the tag names to the file names of notes
|
||||
* when a note file gets stored in QOwnNotes
|
||||
*/
|
||||
QtObject {
|
||||
/**
|
||||
* This function is called when a note gets stored to disk if
|
||||
* "Allow note file name to be different from headline" is enabled
|
||||
* in the settings
|
||||
*
|
||||
* It allows you to modify the name of the note file
|
||||
* Return an empty string if the file name of the note should
|
||||
* not be modified
|
||||
*
|
||||
* @param {NoteApi} note - the note object of the stored note
|
||||
* @return {string} the file name of the note
|
||||
*/
|
||||
function handleNoteTextFileNameHook(note) {
|
||||
// the current note name is the fallback
|
||||
var fileName = note.name;
|
||||
|
||||
// get a list of note text lines
|
||||
var noteLines = note.noteText.split("\n");
|
||||
|
||||
// set the first line of the note as base for the file name
|
||||
if (noteLines.length > 0) {
|
||||
// you maybe also want to exclude some disallowed characters here
|
||||
fileName = noteLines[0];
|
||||
}
|
||||
|
||||
// get a list of all assigned tag names
|
||||
var tagNameList = note.tagNames();
|
||||
|
||||
// add the tag names to the filename
|
||||
if (tagNameList.length > 0) {
|
||||
fileName += " [" + tagNameList.join("] [") + "]";
|
||||
}
|
||||
|
||||
script.log("note file name: " + fileName);
|
||||
return fileName;
|
||||
}
|
||||
}
|
||||
```
|
||||
Using this script we will get the note files names as "Note name [tag1] [tag2]" so file name search can now search for tags.
|
||||
|
||||
But search is not handy on the run. That's where the "path" shall be used. We'll make a second set of notes sorted into "tag" directories. Plain text files are quite small so it won't be a heavy burden.
|
||||
|
||||
**Dir script section**
|
||||
|
||||
**TODO: Dir script sections**
|
||||
|
||||
|
||||
### Render inline images
|
||||
|
||||
When we insert an image to QOwnNotes it copies it to media subdirectory and puts a relative link to the note text. While this is a perfectly portable solution none of Android markdown editors I've tried support such links. They want the absolute one. So lets give them what they they want in a way that will suit both desktop and phone.
|
||||
|
||||
For Linux the easiest way is having the notes stored on the desktop in the very exact path they are stored on the phone which is */storage/emulated/0/Android/data/com.ryeeeeee.markdownx/files/notes/* for MardownX and */storage/emulated/0/writeily* (or whatever you choose) for Writeily Pro.
|
||||
|
||||
While QOwnNotes insert only relative link there's a script that will change them to absolute right after insert.
|
||||
|
||||
[One of the example scripts](https://github.com/pbek/QOwnNotes/blob/develop/doc/scripting/absolute-media-links.qml) is just about that - putting absolute links instead of default relative ones. So load it in the scripting section in QOwnNotes options and give it a try.
|
||||
|
||||
**TODO: Make sure the script actually works**
|
||||
**MAYBE: Work out second way with having set of "export dirs" or having an external script that will put links to phone mode and back (maybe run on phone)**
|
||||
|
||||
To "convert" already written notes you can run the following bash script *from a directory where all notes directories (folders) stored*:
|
||||
```
|
||||
#!/bin/bash
|
||||
|
||||
IFS=$'\n'
|
||||
|
||||
for d in *
|
||||
do ( cd $d && sed -i -e "s|file://media|file://$PWD/media|g" *.md )
|
||||
done
|
||||
```
|
||||
As usual, while I used this script on my notes many times, any damage it can do is your responsibility. Make backup before using some internet guy's scripts on your files.
|
||||
|
||||
|
||||
### Links to other notes and files
|
||||
|
||||
Wanted to pull some smart workarounds from my sleeve but I don't have any. Markdown editor don't want to open such links no matter what syntax I use. Avoid depending on them for notes you want to use on phone.
|
||||
|
||||
|
||||
## Using todo.txt format todo lists
|
||||
|
||||
[Todo.txt format](http://todotxt.com/) is like markdown for todo lists. It's functional yet it's plain text. Simple and portable.
|
||||
|
||||
Best todo.txt app for Android I found is [Simpletask](https://play.google.com/store/apps/details?id=nl.mpcjanssen.simpletask&hl=en) - which provides the great UI for the todo.txt syntax files, even for those having .md extension. I use it's cloudless edition since the only cloud app support is Dropbox.
|
||||
|
||||
There are some apps for the desktop too, but I prefer plain text in QOwnNotes. To make it structured I put in section headlines followed by "h:1" in-text tag which tells Simpletask not to parse the line as task. Empty lines are also safe to use.
|
||||
|
||||
|
||||
## Fast inbox
|
||||
|
||||
Markdown editor provides additional features but it's too bloated when it comes to putting in notes on the run. We need something lightning fast. The fastest Andorid notepad I've found is [Fast Notepad](https://play.google.com/store/apps/details?id=com.taxaly.noteme.v2&hl=en). Change it's "save path" to the note directory you use for inbox and all new notes will appear in QOwnNotes.
|
||||
|
||||
For having even faster use I've put the shortcut for it's EditorActivity to the main screen. Such app activity shortcuts can be put by Sumsung TouchWiz, using [Tasker](https://play.google.com/store/apps/details?id=net.dinglisch.android.taskerm&hl=en) with [Secure Setting plug-in](https://play.google.com/store/apps/details?id=com.intangibleobject.securesettings.plugin&hl=en) or [many other apps](https://play.google.com/store/search?q=activity%20shortcut&c=apps&hl=en).
|
||||
|
||||
As such "fast notes" will have .txt extension they won't be shown in markdown editor, only in Fast Notepad. They will appear in QOwnNotes though where you can move their content to some other notes.
|
Loading…
Add table
Add a link
Reference in a new issue