Skip to content

K2GO-427 feat(contentexchange): import content from a connected drive - #684

Merged
luisguzman-adfa merged 2 commits into
mainfrom
feat/K2GO-427-content-import
Oct 23, 2026
Merged

luisguzman-adfa merged 2 commits into
mainfrom
feat/K2GO-427-content-import

Conversation

@luisguzman-adfa

Copy link
Copy Markdown
Collaborator

The Import action of the content manager (slice 3): read a bundle from a user-picked
connected drive, validate it against this box, and import the selected items. The receiver
half of the disk round-trip (the K2GO-427 user deliverable).

  • SAF: an ACTION_OPEN_DOCUMENT_TREE picker; DocumentsContract directly (no new permission,
    no new dependency, mirrors SafExportCarrier). The persisted tree grant is released at the
    run's terminal points.
  • Flow: Manager -> "Import from drive" -> picker -> read manifest.json (a missing or oversized
    manifest is tolerated: the drive is scanned instead) -> POST /v1/import/validate -> a review
    list marking each item importable / already-have (same) / newer / older / no-app (the core's
    dedup; a Calibre soft verdict is advisory).
  • The user picks (partial first-class). A PHONE-DISK preflight (StorageProbe) shows
    "selected / free on device" and blocks a pick that will not fit: a small phone takes a
    subset of a big drive.
  • Import per item: SAF-read -> write to the box import-staging path (host rootfs <-> box
    /library/.cx-staging, the filename sanitized) -> POST /v1/import/item -> the core ingests
    (delegating to the app's own import) -> the staging copy is removed. The item is the unit of
    resume: retry a failed item; skip SAME_VERSION. A NEWER item over an OLDER one offers
    replace (optionally deleting the old).
  • A foreground service (the app's FGS pattern) owns the queue + progress; streaming copy
    (chunked), so a multi-GB item never buffers.
  • Layered: domain ports + value objects (ImportCarrier, ImportManifest, ImportVerdict,
    ImportScan, ImportPreflight) with JVM tests; data (SafImportCarrier, BoxImportStaging,
    CxCoreImportSource, ImportManifestReader); presentation (review + progress + service).

Verification: assembleStandardDebug builds; JVM unit tests. On-device import against a real
drive is a follow-up (needs a drive + a box running cx-core).

UI changes
New user-facing strings (parked in strings_untranslated.xml, l10n at the feature's closing
PR): the "import from drive" entry, the review screen (per-item status labels), the selection

  • preflight summary, the import progress screen, and the replace/skip prompts. Light/dark via
    Material 3 tokens; on-device render check pending.

Add the import action, the receiver half of the disk round-trip, mirroring
the merged export slice. The user picks a drive via SAF, the app reads the
bundle (manifest.json, tolerating a missing one by scanning for .zim), the
core validates per item (importable / already-have / newer / older / no-app),
the user selects with a phone-disk preflight, and a foreground service stages
each archive where the box (proot) can read it and calls the core to ingest it.

- domain: ImportEntry/Manifest/Verdict/Scan/Preflight + ImportCarrier/ImportSource
  ports; reuse the generic ExportJob for the transfer state.
- data: SafImportCarrier (DocumentsContract reader, no new permission/dependency),
  ImportManifestReader (parse + no-manifest scan), CxCoreImportSource (validate /
  import-item / delete), BoxImportStaging (box /library/.cx-staging <-> host path),
  CxCoreDataSource import/delete calls.
- presentation: ImportReviewFragment + ViewModel/Adapter (grouped states, preflight),
  ContentImportService (specialUse foreground, per-item retry, grant release),
  ImportProgressFragment; "Import from drive" entry on the manager.
- JVM tests for the scan, parse, verdict and preflight rules.

Replace-older imports the newer version; auto-deleting the old copy is deferred
(validate does not return the box's existing ref to delete, and it is per-app).
Strings parked in strings_untranslated.xml; l10n at the feature closing PR.
…race

Import picker takes READ only (it never writes the drive) and prunes stale
persisted grants, keeping each active run's tree so the two pickers do not
revoke each other. Cancel no longer clears the session while the worker drains:
the worker owns teardown, so the main thread only flags cancel and releases the
grant, clearing and stopping itself only when no run is active.
@luisguzman-adfa luisguzman-adfa added the ui change or edit to UI label Oct 23, 2026
@luisguzman-adfa
luisguzman-adfa merged commit c7aaa1f into main Oct 23, 2026
3 checks passed
@luisguzman-adfa
luisguzman-adfa deleted the feat/K2GO-427-content-import branch October 23, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ui change or edit to UI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant