Mobile app (Android):
- Sign-in to any server, with authenticator codes. The server address and
token are kept in secure storage; a dropped connection never signs out.
- Workspaces, recent pages, spaces and a foldable page tree; search; the
inbox with mark-read.
- Pages open read-only in the shared editor from their saved content and
join the live document to edit (with the native toolbar). Page links in
the text open in the app (new "navigate" bridge message).
- Comments: threads, replies, resolve.
- "Save to Docwell" in the Android share sheet makes a page from shared
text, with web addresses as links.
- Offline reading: every answer the app reads is kept on the phone, and
used when the server can't be reached.
- Push through UnifiedPush (ntfy, NextPush, ...). The app uses the Android
connector directly; the umbrella package pulls in a native crypto build
for Linux that breaks `dart run` and tests.
Server:
- /me/devices registers a phone's UnifiedPush endpoint and Web Push keys
(new push_devices collection). Each notification is also pushed,
encrypted with RFC 8291 aes128gcm so the distributor can't read it; the
app drops messages that don't decrypt. Endpoints answering 404/410 are
forgotten. Endpoints follow the webhook address rules.
- /collab accepts the apps' own origins ("null" for the mobile editor page,
wails:// for the desktop app). Sign-in is a token in the first message,
not a cookie, so this opens no cross-site hijacking.
Tried on an Android 15 emulator: sign-in, browsing, reading, live editing,
sharing and offline reading. Not covered: push end to end (no distributor
on the emulator), iOS, and YouTube embeds, which refuse to play from the
app's local editor page (error 153).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
40 lines
1.1 KiB
Dart
40 lines
1.1 KiB
Dart
// SPDX-License-Identifier: AGPL-3.0-or-later
|
|
|
|
import 'package:flutter/services.dart';
|
|
|
|
/// Text or a link shared to the app from another app.
|
|
class SharedText {
|
|
const SharedText(this.text, [this.subject = '']);
|
|
|
|
final String text;
|
|
|
|
/// The sender's title for it, e.g. a web page's title; often empty.
|
|
final String subject;
|
|
}
|
|
|
|
/// "Save to Docwell" from the Android share sheet (see MainActivity.kt).
|
|
class ShareReceiver {
|
|
static const _channel = MethodChannel('docwell/share');
|
|
|
|
/// Calls [onShare] for the share that started the app and every later one.
|
|
Future<void> listen(void Function(SharedText) onShare) async {
|
|
_channel.setMethodCallHandler((call) async {
|
|
if (call.method == 'shared') onShare(_read(call.arguments));
|
|
});
|
|
try {
|
|
final first = await _channel.invokeMethod<Object?>('takeShared');
|
|
if (first != null) onShare(_read(first));
|
|
} on MissingPluginException {
|
|
// Not on Android.
|
|
}
|
|
}
|
|
|
|
static SharedText _read(Object? raw) {
|
|
final m = (raw as Map).cast<String, Object?>();
|
|
return SharedText(
|
|
m['text'] as String? ?? '',
|
|
m['subject'] as String? ?? '',
|
|
);
|
|
}
|
|
}
|