feat(android): Phase 4 upload activity + manual photo picker upload #1127
Loading…
Reference in a new issue
No description provided.
Delete branch "ux-android-upload"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
What
Phase 4 upload work for the Android app (spec 049), in two parts:
A. Cross-device upload-activity surface — a new "Upload-Aktivität" card in the MEHR hub opens a screen that lists upload sessions across the family (any device), polling
GET /api/upload-activityevery 5s while visible. It shows active/interrupted work in plain German, per-session progress ("34 von 120 Fotos", current file name), state labels ("Wird geprüft…", "Wird verarbeitet…", "Fertig", "Fehler" with count), per-session cancel behind a confirmation dialog, an empty state ("Gerade läuft kein Upload."), pull-to-refresh, and a refresh on open.B. Manual photo upload from this device — a "Fotos hochladen" button on that same screen drives the system photo picker (
PickMultipleVisualMedia, ~20/invocation, "Mehr auswählen" repeats) and feeds the existingUploadSessionClientmachinery (create → files with fingerprint headers → commit withIdempotency-Key). Pickedcontent://URIs are read viaContentResolver. The manual session is a regular upload session, so it appears in surface A with live counts.Payload findings (important)
The activity feed does not carry
clientType. I verified this against the server source (UploadActivitySession,UploadActivityController) and the web client (uploadActivity.ts):clientType(browser/api/cli) is a session-creation field only and is never echoed back inGET /api/upload-activity.The wire shape is a bare JSON array of
UploadActivitySessionDto:Consequence: per-device labels ("Desktop" / "Browser" / "Telefon") are not possible from the feed. Rather than invent a label, the screen labels only sessions this device can prove it started — its own manual uploads plus the backup engine's open batch — as "Dieses Gerät", and leaves every other row unattributed. Tracked as [ISSUE-131].
POST /api/upload-activity/{sessionId}/cancel: any 2xx is success and the body is never parsed (the server may answer 200 with a fullUploadSessionor empty); 404 = not-found/foreign, 409 = already terminal.Design decisions
created,receiving,commit_requested,committing,processing,stale(interrupted = the prime cancel target per spec 049's unfinished-work focus),failed; showcompleted/completed_with_issuesonly within a ~15-min grace ofupdatedAt(mirrors the server's staleness window); hidecancelled/expired. Cancellable =created,receiving,commit_requested,committing,stale(the rest return 409).plannedCount ?: totalCount(the web client'splannedTotal); current file =receivingFileNames.firstOrNull().upload_activity_changedwith a 60s polling fallback. Android v1 polls every 5s while the screen is visible — simpler and just as resilient. SSE is out of scope here.plannedFileCountadded toCreateUploadSessionBody/createSession(additive, defaultnull) so manual sessions get a constant X/Y denominator.BackupEngineis unaffected.:coreasManualUploadCoordinator(pure JVM, MockWebServer-testable): hashes viaContentHasher, reusesUploadSessionClient, per-file 4xx → failed-and-continue (mirrorsBackupEngine), transport/auth errors propagate.clientFileKey = "picker:{uri}",sourceLabel= device label,clientTypeleft at the default"api"(honest).ViewerMessageKindprecedent). New DTOs live in a separatenet/UploadActivityDtos.ktto keep theMemoriesApi/HttpMemoriesApiconflict surface to one additive tail block.Scope / known limitations (v1)
stalesession, which is cancellable from this same screen.image/*+video/*).Testing
UploadActivityJsonTest— wire shapes (full row, older payload withoutplannedCount, unknown-field tolerance, empty feed).HttpUploadActivityApiTest— exact paths, bearer header, "any 2xx, body ignored" cancel rule, 404/409 surfacing.UploadActivityViewModelTest— visibility grace window, cancellability, planned/numerator mapping, local-vs-stranger labelling, 404/protocol degradation to empty, unauthorized logout, cancel confirm/fail/dismiss.ManualUploadCoordinatorTest(:core, MockWebServer) — one session with planned count, fingerprint headers (filename,client-file-key,client-content-hash,client-relative-path), single commitIdempotency-Key, per-file 4xx isolation, skipped counts, progress sequence, transport-failure abort.:app:testDebugUnitTest+:app:assembleDebug+:core:testpass;:app:lintDebugadds no new errors over the 18 pre-existing baseline.Refs: spec:049
Drive the pick -> upload -> commit pipeline against the existing UploadSessionClient machinery, without the backup engine's MediaStore scan or Room bookkeeping. - ManualUploadItem carries a re-openable stream factory (Android side hands ContentResolver.openInputStream) and a stable clientFileKey ("picker:{uri}") because a content:// uri has no MediaStore id. - Per-file 4xx rejections are isolated and counted, exactly like BackupEngine; transport/auth/session-gone errors abort the run. - Add an optional plannedFileCount to CreateUploadSessionBody/createSession so a manual session gets a constant X/Y denominator in the activity feed. BackupEngine is unaffected (defaults to null). Covers the pipeline with MockWebServer: fingerprint headers, commit Idempotency-Key, 4xx isolation, skipped counts, progress sequence.Expose GET /api/upload-activity and POST /api/upload-activity/{id}/cancel (spec 049). The endpoint is not in the OpenAPI contract yet, so the web client (uploadActivity.ts) is the source of truth for the shapes. - UploadActivitySessionDto is lenient (nullable/defaults) like the web client's normalizeSession, and lives in its own file so the MemoriesApi/HttpMemoriesApi conflict surface stays one additive tail block. Rows are a bare JSON array. - The feed carries NO clientType (it is a session-creation field only, never echoed back), so per-device labelling is impossible from the payload; documented on the DTO and guarded by a regression test. - Cancel treats any 2xx as success and never parses the body (the server may answer with a full session or empty); 404/409 surface as ApiHttpException. Covers DTO parsing and the exact paths/bearer header/cancel rule.Surface A: a screen (opened from a MEHR hub card) listing cross-device upload sessions, polling every 5s while visible. Shows unfinished work in plain German (active + interrupted always, finished within a ~15-min grace), per-session progress ("34 von 120 Fotos", current file), state labels, per-session cancel behind a confirmation dialog, an empty state, pull-to-refresh, and a refresh on open. Surface B: a "Fotos hochladen" button drives PickMultipleVisualMedia (~20/invocation, "Mehr auswählen" repeats) through the core ManualUploadCoordinator, so a picked batch is a regular upload session that appears in the same list with live counts. - VM keeps pure, testable policy (visibility grace, cancellability, planned/numerator mapping) and labels only sessions it can prove this device started (own manual uploads + the backup engine's open batch) as "Dieses Gerät"; the feed has no clientType, so strangers are left unattributed rather than guessed. - Status -> German mapping lives in the screen (VM stays resource-free, matching ViewerMessageKind). - AppViewModelFactory builds the VM with an UploadSessionClient for the current session and the device sourceLabel. - New plurals define both one and other in every locale, so no new MissingQuantity lint errors. Refs spec:049. SSE is out of scope for v1 (polling); manual upload is tied to the screen staying open.46b606a9ec9611bdd3879611bdd387d984e13b91