publicvoit/AndroidOrgdownCapture
Watch
0
0
Fork
You've already forked AndroidOrgdownCapture
0
A very simple Android app that captures information from various apps or as manual entries from its user. Each capture is a text file in Orgdown (the syntax of Emacs Org-mode) in a user-chosen directory.
  • Kotlin 94.3%
  • Shell 5.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Karl Voit ae5157b980 Use raw URL as heading when shared URL has no description
Bare-URL shares without a subject (or with the URL as subject) no
longer produce a redundant [[URL][URL]] link; the heading is the
plain URL instead. Bump to 1.1.2.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-03 14:57:17 +01:00
app Use raw URL as heading when shared URL has no description 2026-11-03 14:57:17 +01:00
gradle/wrapper initial commit 2026-05-25 11:32:14 +02:00
.gitignore initial commit 2026-05-25 11:32:14 +02:00
AGENTS.md Use raw URL as heading when shared URL has no description 2026-11-03 14:57:17 +01:00
build-apk.sh initial commit 2026-05-25 11:32:14 +02:00
build.gradle.kts initial commit 2026-05-25 11:32:14 +02:00
gradle.properties initial commit 2026-05-25 11:32:14 +02:00
gradlew initial commit 2026-05-25 11:32:14 +02:00
gradlew.bat initial commit 2026-05-25 11:32:14 +02:00
LICENSE initial commit 2026-05-25 11:32:14 +02:00
README.org initial commit 2026-05-25 11:32:14 +02:00
settings.gradle.kts initial commit 2026-05-25 11:32:14 +02:00

Android Orgdown Capture (AOC)

Copyright © 2026 Karl Voit. Licensed under the GNU General Public License, version 3 or any later version. See the LICENSE file for the full text, or https://www.gnu.org/licenses/gpl-3.0.html.

CAUTION: As I don't have any knowledge on Android app development, this app was purely vibe-coded with Claude Code starting with Opus 4.7 in 2026-05.

What it does

Android Orgdown Capture is a small Android app that turns text snippets into Emacs Org-mode headings. Each captured snippet is written as its own .org file in a folder that you point Syncthing at, so your desktop Emacs sees new captures within seconds.

Capture sources supported:

  • Share-sheet from any app (with friendly :SOURCE: recognition for Pachli (Mastodon), Vanadium Browser, and NewsBlur).
  • The + floating action button inside the app, for free-form thoughts.
  • A home-screen AOC+ widget that jumps straight into the capture dialog.

The capture dialog has a "Add clipboard as quote" button so you can pre-copy interesting bits of an article into a single #+BEGIN_QUOTE block on the captured heading.

Capture file format

Each capture is a self-contained .org file holding exactly one heading. Filenames are timestamped + a 3-character random nonce so two devices never collide:

20260524-105530-x7q.org

Content:

* to read: Title goes here
:PROPERTIES:
:CREATED:  [2026-05-25 Mon 10:55]
:SOURCE:   NewsBlur
:END:

Body text goes here.

#+BEGIN_QUOTE
First clipboard entry.

-----

Second clipboard entry.
#+END_QUOTE

The :SOURCE: line is only emitted when the calling app is recognised. The #+BEGIN_QUOTE block is only emitted when at least one clipboard entry was added. The heading prefix (to read: above) is the one you picked from the dropdown in the capture dialog — see Heading prefixes below. When no prefix is selected, the heading is just * Title goes here with no leading word.

Why one file per capture, not one big file?

Syncthing is two-way and can mutate files at any time. A single shared captures.org would suffer write-during-sync corruption and frequent *.sync-conflict-* files. With one file per capture:

  • New captures only ever create new files (unique names) — no collision is possible.
  • Existing captures are written atomically (write tmp; rename) and only when the user explicitly edits one.
  • Deletion on one device is just a missing file on the other — the app shows the new state on next refresh, no duplicates.

Permissions and GrapheneOS Storage Scopes

The app declares exactly one permission: android.permission.MANAGE_EXTERNAL_STORAGE. No network, no clipboard permission, no foreground service, nothing else.

On GrapheneOS, when you grant this permission, the OS intercepts it and presents Storage Scopes instead. You pin the app to only the captures folder, and the app sees nothing else. This is the recommended configuration.

On stock Android the same permission grants the broader "All files access". If you don't want that, GrapheneOS is the way to go.

Building the APK on a fresh Debian 13 (Trixie) system

Goal: end up with a signed APK at app/build/outputs/apk/release/AOC v<version> release.apk using only the command line. The filename is generated from versionName in app/build.gradle.kts, so a v1.1.1 build is called AOC v1.1.1 release.apk. Older builds in the same folder keep their names — no silent overwrites.

TL;DR for re-builds

Once you've done the one-time setup below (JDK 17, Android SDK, licenses), every subsequent build is a single command:

./build-apk.sh             # release build (default)
./build-apk.sh debug       # debug build

build-apk.sh is a thin wrapper around ./gradlew: it sets JAVA_HOME to JDK 17 (with the Debian default of JDK 25, Gradle 8.7 would otherwise refuse to start), points ANDROID_HOME at ~/Android/Sdk, sanity-checks both are present, runs the right assemble<Variant> task, and prints the path of the produced APK plus a ready-to-paste adb install command.

Override the defaults via env vars when needed — e.g. a different JDK location:

JAVA_HOME=/opt/jdk-17 ./build-apk.sh

The manual recipe below explains what build-apk.sh is doing under the hood and is what you should follow on a fresh machine that doesn't have JDK 17 / Android SDK installed yet.

1. Install JDK 17 and adb

The Android Gradle Plugin used here (8.5.2) needs the Gradle daemon to run on JDK 17. Debian 13's default-jdk is JDK 25, which Gradle 8.7 does not yet support, so install JDK 17 explicitly and point JAVA_HOME at it for the build.

sudo apt update
sudo apt install -y openjdk-17-jdk-headless adb

Verify and capture the install path (you'll need it in step 3):

/usr/lib/jvm/java-17-openjdk-amd64/bin/java -version    # should report 17
adb --version

2. Download the Android command-line SDK tools

The Android SDK is not in Debian. Download the official cmdline-tools zip from https://developer.android.com/studio#command-line-tools-only (the "Command line tools only" download for Linux). It is small (~150 MB).

Unpack it into ~/Android/Sdk/cmdline-tools/latest/. The latest/ subdirectory layout is mandatory — sdkmanager refuses to run unless its own bin/ is exactly one level below cmdline-tools/<version>/.

mkdir -p ~/Android/Sdk/cmdline-tools
cd ~/Android/Sdk/cmdline-tools
unzip ~/Downloads/commandlinetools-linux-*.zip
mv cmdline-tools latest

3. Set environment variables (zsh)

Append to ~/.zshrc:

export JAVA_HOME="/usr/lib/jvm/java-17-openjdk-amd64"
export ANDROID_HOME="$HOME/Android/Sdk"
export ANDROID_SDK_ROOT="$ANDROID_HOME"
export PATH="$JAVA_HOME/bin:$ANDROID_HOME/cmdline-tools/latest/bin:$ANDROID_HOME/platform-tools:$PATH"

The JAVA_HOME override is what makes ./gradlew use JDK 17 instead of the system default (JDK 25 on Debian 13, which Gradle 8.7 cannot run on). sdkmanager also picks JAVA_HOME up.

Reload:

source ~/.zshrc

4. Install platform 34, platform-tools, build-tools

Important: in zsh, the semicolon in package names like platforms;android-34 will be parsed as a command separator. Always quote those arguments.

sdkmanager --install "platform-tools" "build-tools;34.0.0" "platforms;android-34"

5. Accept the SDK licenses

yes | sdkmanager --licenses

6. Create a release signing keystore (one time)

The app's build.gradle.kts looks for keystore.properties at the repo root and signs the release build automatically when it's present. If it isn't, the release build falls back to the debug keystore — that also installs fine, you just won't have a stable signature across machines.

Generate the keystore:

keytool -genkeypair -v \
  -keystore aoc-release.keystore \
  -alias aoc \
  -keyalg RSA -keysize 2048 -validity 10000 \
  -storepass changeme -keypass changeme \
  -dname "CN=AOC, O=Personal"

Pick a real password for -storepass / -keypass. Then create keystore.properties in the repo root (already gitignored):

storeFile=aoc-release.keystore
storePassword=changeme
keyAlias=aoc
keyPassword=changeme

7. Build the APK

From the repo root:

./gradlew assembleRelease

On the first run this downloads Gradle 8.7 itself (about 130 MB) and all Android/Kotlin dependencies. Subsequent builds are fast.

The output is:

app/build/outputs/apk/release/AOC v<version> release.apk

For a quicker debug build (signed automatically with a generated debug keystore, no keystore.properties needed):

./gradlew assembleDebug
# -> app/build/outputs/apk/debug/AOC v<version> debug.apk

Filenames contain a space, so quote the path when you pass it to adb or other shell tools (see Installing on the phone).

Installing on the phone

Option A: adb over USB (recommended)

Enable Developer options and USB debugging on the phone, plug it in, accept the trust prompt, then:

adb install -r "app/build/outputs/apk/release/AOC v1.1.1 release.apk"

The quotes are mandatory — the filename contains spaces.

Option B: copy the APK and tap it

Copy the .apk to the phone (Syncthing, USB-MTP, etc.), open it in a file manager, allow "install from this source" once, install.

First-launch configuration

  1. Open Android Orgdown Capture from the launcher.
  2. Tap the overflow menu → Settings.
  3. Tap Grant storage access. On GrapheneOS choose Storage Scopes and pin the folder you want captures to live in. On stock Android, confirm the "All files access" prompt.
  4. Type the absolute path of your captures folder, e.g.: /storage/emulated/0/Documents/orgdown-captures/. Tap Save folder. The app will create the folder if it doesn't exist.
  5. (Optional) Edit the Heading prefixes list — one prefix per line, in the order you want them in the capture dropdown. The first line is the default selection. An empty first line means "no prefix by default" while still letting you pick a named prefix on the fly. Trailing whitespace is trimmed when you tap Save prefixes. The shipped defaults are:

    TODO
    to read:
    read comments:
    comment:
    refile:
    bookmark:
    
  6. (Optional) Toggle Write aoc-debug.log on every capture if you want to inspect raw share-intent data.
  7. Long-press your home screen → Widgets → AOC+ to add the one-tap quick-capture widget.

Heading prefixes

The capture dialog shows a Prefix dropdown above the title field, populated from the list you configured in Settings. Pick a prefix and it is placed between the leading * and your title, separated by a single space:

Selected prefix Resulting heading
(no prefix) * My note
TODO * TODO My note
to read: * to read: My note
bookmark: * bookmark: My note

Empty entries in the list are shown as (no prefix) in the dropdown. If your whole list is empty (or contains only blank lines) the dropdown is hidden entirely.

Try it

  • Share an article from the Vanadium browser → AOC dialog opens with the page title and URL pre-filled → tap Save. A new YYYYMMDD-HHMMSS-xxx.org file appears in your folder, with :SOURCE: Vanadium.
  • Share a Mastodon post from Pachli → same flow, :SOURCE: Pachli.
  • Share an article from NewsBlur → :SOURCE: NewsBlur.
  • Open AOC, tap +, type something, tap Save → manual capture (no :SOURCE:).
  • Tap the AOC+ widget on the home screen → quick capture.
  • Copy text in any app, return to AOC capture dialog, tap Add clipboard as quote → that text is queued. Repeat with different clipboard contents to stack multiple quotes into one #+BEGIN_QUOTE block.

Troubleshooting

./gradlew: "Unsupported class file major version 69" or similar

Gradle 8.7 is running on a too-new JDK. Make sure JAVA_HOME points at JDK 17 (see step 1 / step 3):

export JAVA_HOME=/usr/lib/jvm/java-17-openjdk-amd64

sdkmanager: "Failed to find package 'platforms'"

You forgot to quote the semicolon. zsh splits platforms;android-34 into two commands. Use:

sdkmanager --install "platforms;android-34"

./gradlew: "Permission denied"

chmod +x gradlew

First build hangs at "Downloading https://services.gradle.org/..."

Normal on first run. Gradle 8.7 is ~130 MB. Wait it out; it's cached forever after.

Capture dialog says "Set the captures folder first"

Open Settings, grant the storage permission and save a folder path. Both are required.

:SOURCE: line is missing when sharing from Pachli/Vanadium/NewsBlur

Enable the debug log in Settings, capture once, and inspect aoc-debug.log in the captures folder. The intent.referrer line shows the raw calling package; the recognised set is hard-coded in app/src/main/kotlin/at/karl_voit/aoc/SourceDetector.kt. Add new packages there and rebuild if you want more sources mapped.

Syncthing produces *.sync-conflict-*.org files

Means both your phone and another device edited the same capture file at the same time. The app never reaches into existing files except via the Edit screen, so this only happens after you explicitly edited. Resolve in Emacs and delete the conflict copy.

License

This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License, version 3 (or, at your option, any later version), as published by the Free Software Foundation. The full license text is in LICENSE in the repository root, and online at https://www.gnu.org/licenses/gpl-3.0.html.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Every Kotlin source file carries an SPDX identifier (SPDX-License-Identifier: GPL-3.0-or-later) for tooling.

Project layout

.
├── README.org                              this file
├── settings.gradle.kts
├── build.gradle.kts
├── gradle.properties
├── gradle/wrapper/
├── gradlew
└── app/
    ├── build.gradle.kts
    └── src/main/
        ├── AndroidManifest.xml
        ├── kotlin/at/karl_voit/aoc/
        │   ├── MainActivity.kt
        │   ├── CaptureActivity.kt
        │   ├── EditActivity.kt
        │   ├── SettingsActivity.kt
        │   ├── CaptureStore.kt
        │   ├── OrgFormatter.kt
        │   ├── SourceDetector.kt
        │   ├── ClipboardQuotes.kt
        │   ├── DebugLog.kt
        │   ├── Prefs.kt
        │   └── widget/AocPlusWidget.kt
        └── res/
            ├── layout/
            ├── values/
            ├── menu/
            ├── xml/
            ├── drawable/
            └── mipmap-anydpi-v26/