Android app

Mobile text editor with version control

An Android text editor for code and notes that keeps every version of a file without saving the file again: each version after the first is stored as a small patch.

Versions without copies

The first snapshot of a file stores its full text. Every later snapshot stores only a unified-diff patch against the one before, made with java-diff-utils. To rebuild version K the app takes the first text and applies the patches of versions 2 to K in order.

Room keeps the snapshots in two tables. A unique index on the file and version number, with each snapshot written in a transaction, stops two quick taps from creating the same version twice and breaking the chain. A diff view shows any version against the one before, line by line, and Restore puts an old version back without losing the history.

Never losing work

Every 10 seconds, and whenever the app is paused, the editor's text is copied to a backup file. The backup is cleared each time the file is really saved. If the app crashes or is killed with unsaved text, the next launch offers to restore it.

The editor

Files live in a folder the user picks, so they stay visible outside the app, and Save As offers UTF-8, UTF-16 or ISO-8859-1, remembered per file. There is search, find and replace (a replace-all is undone in one step), word wrap, undo and redo, a read-only lock, a Markdown preview and a simple brace-based re-indent for Kotlin.

Highlighting colours the text with spans, 250 ms after the last keystroke. Kotlin keywords come from a word list, and strings and comments are matched by one combined pattern, so a // inside a URL in a string is not coloured as a comment.

More projects