# Android (Capacitor / Tauri) — handoff

## Summary

Paarrot ships an Android build via Capacitor and/or Tauri (`src-tauri/`, `cinny/capacitor.config.json`). Mobile-specific code handles native notifications, UnifiedPush background sync, share intents, and platform detection branching away from Electron APIs.

## User-facing behavior

- Native Android app with Paarrot UI (WebView)
- Share into Paarrot from other apps (images/files → room upload draft)
- Background notifications via UnifiedPush (not FCM-only)
- No local HTTP API on mobile (Electron-only)

## Architecture

```
Capacitor/Tauri shell
  → WebView loads cinny bundle
ClientNonUIFeatures.tsx
  → isCapacitorNative / isTauri branches
backgroundSync.ts → UnifiedPush + Matrix pusher
androidShare.ts → share intent → room draft
tauri.ts → native notification APIs
```

## Key files

| Path | Role |
|------|------|
| `cinny/capacitor.config.json` | Capacitor app id, web dir |
| `src-tauri/src/main.rs` | Tauri Android entry |
| `cinny/src/app/utils/tauri.ts` | Platform detection, notifications |
| `cinny/src/app/utils/backgroundSync.ts` | UnifiedPush registration |
| `cinny/src/app/utils/androidShare.ts` | Share target handling |
| `cinny/src/app/pages/client/ClientNonUIFeatures.tsx` | Share listener wiring |

## Data model

Same as background notifications (`paarrot.unifiedpush.*` localStorage).

Share payloads: ephemeral in-memory until user picks room.

## Dependencies

- Capacitor plugins / Tauri mobile toolchain
- UnifiedPush distributor (ntfy, etc.)
- Android notification icon resources

## Integration points

- **background-notifications**: primary overlap
- **Room input drafts**: `roomIdToUploadItemsAtomFamily` for shared files
- **NOT Electron**: `initPaarrotAPI` skips on mobile webview

## Testing

### Manual

1. Build Android APK/AAB per project scripts.
2. Share image from Gallery → Paarrot → pick room → verify upload draft.
3. Background app; trigger mention; verify UP notification.
4. Tap notification → opens correct room.

### Automated

- None on device CI in repo (check Gitea workflow)

## Known issues & gotchas

- `ANDROID_NOTIFICATION_SMALL_ICON = 'ic_stat_paarrot'` must exist in Android res
- UnifiedPush without distributor shows user-facing error string
- Feature parity gap vs desktop (plugins, Stream Deck, local API)
- Test `isTauri` vs `isCapacitorNative` — both may be true in some builds

## Future work

- iOS Capacitor target
- Play Store release pipeline docs
- Mobile plugin sandbox policy

## Related docs

- [background-notifications HANDOFF](../background-notifications/HANDOFF.md)

## Add your extra things here

- `listenForAndroidShares`, `getPendingAndroidShare`, `materializeSharedFile` in `androidShare.ts`
- Capacitor app name in `capacitor.config.json` — verify `appId` matches push config
