Skip to content

feat(mobile): save images to the photo library - #2765

Merged
oneo-me merged 2 commits into
nsgo-dev:mainfrom
XiaoMengXinX:feat-mobile-save-photo
Nov 29, 2026
Merged

oneo-me merged 2 commits into
nsgo-dev:mainfrom
XiaoMengXinX:feat-mobile-save-photo

Conversation

@XiaoMengXinX

@XiaoMengXinX XiaoMengXinX commented Nov 29, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Add mobile.SavePhoto (mobile.PhotoSaveOptions) to save an encoded image directly to the system photo library on iOS and Android without routing through the system file-export document picker.

  • mobile / core
    • Export mobile.PhotoSaveOptions (Name, MIME, Path, Data) and mobile.SavePhoto(cx, o, done) backed by Scope.SavePhoto, gated under servicePicker.
    • Reject unsupported hosts (hostUntracked() other than iOS/Android, plus simulated web, watchOS, and tvOS), empty image inputs, and non-image media types before emitting a platform request; normalize MIME and sanitize Name.
  • iOS (internal/platform/ios/photos.go)
    • Request PhotoKit add-only authorization (PHAccessLevelAddOnly) and add the staged file via PHAssetCreationRequest + PHAssetResourceCreationOptions, preserving original format (including animated GIF) and filename.
    • Run staging and library writes off the UI thread, remove the staged temp directory on completion, and return the created asset's localIdentifier when available.
  • Android (internal/platform/android)
    • Route ItemSaveFile with Save.Photo through ItemSavePhoto on the pipe (reusing Go-side staging/unstaging).
    • Stream to MediaStore.Images (IS_PENDING on API 29+, public Pictures + WRITE_EXTERNAL_STORAGE runtime prompt on API 28), cleaning up incomplete entries on error and returning the content:// URI.
    • Java source changes only; classes.dex and classes.jar are left for the release/runtime rebuild.
  • nsgotest & Docs
    • Expose FileSave.Photo in nsgotest and allow returning a non-absolute library identifier/URI from App.SaveFile for photo saves.
    • Document mobile.SavePhoto in docs/architecture/services.md, docs/public/en/services.md, skills/nsgo/SKILL.md, docs/roadmap.md (HarmonyOS/TSX gap), and changelog.d/save-photo.md.

Targets

  • Shared code (core, base, ui, tsx, the nsgo tool)
  • macOS
  • iOS
  • tvOS
  • watchOS
  • Android
  • Windows
  • Linux
  • Web
  • Mini programs
  • Docs or website only

Screenshots

None

Verification

  • head: a78db33a13bb8549e544ddcf58889b2d5505ba79
  • base: 1d16f441d
  • commands:
    • go tool nsgo check -target ios,android_arm64,macos_arm64 -jobs 8 → 0
    • go tool nsgo test → 1
    • go tool nsgo test -run TestPublishedSiteLoadsFromACDNAndOpensRealLinks → 0
  • result: fail
  • not covered: iOS simulator and device, Android emulator, Windows, Linux and browser CI jobs; the full run's only failure, TestPublishedSiteLoadsFromACDNAndOpensRealLinks, timed out under load and passes alone

Checklist

  • The title is a Conventional Commit, such as fix(linux): keep the caret after a paste; a squash merge uses it as the commit subject.
  • Docs whose facts change are updated, and a capability users can see has a line in a changelog.d/ fragment, not in CHANGELOG.md.
  • New third-party code, assets and dependencies name their source and license.

@github-actions github-actions Bot added enhancement New feature or request size/M local-ci-pass The head commit declares that its local checks passed documentation Improvements or additions to documentation iOS Android core and removed local-ci-pass The head commit declares that its local checks passed labels Nov 29, 2026
@XiaoMengXinX
XiaoMengXinX force-pushed the feat-mobile-save-photo branch from 31674fa to b36b266 Compare November 29, 2026 13:26
@github-actions github-actions Bot added local-ci-skipped cli local-ci-pass The head commit declares that its local checks passed and removed local-ci-skipped labels Nov 29, 2026
@oneo-me
oneo-me force-pushed the feat-mobile-save-photo branch from b36b266 to a78db33 Compare November 29, 2026 14:44
@github-actions github-actions Bot added size/L local-ci-fail The head commit declares failing local checks, so a maintainer audits it and removed size/M local-ci-pass The head commit declares that its local checks passed labels Nov 29, 2026
@oneo-me
oneo-me enabled auto-merge (rebase) November 29, 2026 14:44
@github-actions

github-actions Bot commented Nov 29, 2026 •

Copy link
Copy Markdown

This pull request has no valid Local CI declaration for its head commit, so a maintainer audits it before merging:

  • head names a78db33a13bb8549e544ddcf58889b2d5505ba79, not the pushed head 315264786b7e6dd36a2b9e05e5bf550cb0b32129

Run the checks on the head commit, fill the block in the template, then push or edit the body: this label and comment update on their own.

@oneo-me
oneo-me force-pushed the feat-mobile-save-photo branch from a78db33 to 3152647 Compare November 29, 2026 15:59
@github-actions github-actions Bot added local-ci-skipped and removed local-ci-fail The head commit declares failing local checks, so a maintainer audits it labels Nov 29, 2026
@oneo-me
oneo-me merged commit 343c877 into nsgo-dev:main Nov 29, 2026
45 of 46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Android cli core documentation Improvements or additions to documentation enhancement New feature or request iOS local-ci-skipped size/L

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants