Skip to content

fix(android): import presets picked through the system file picker - #2217

Open
Floral-Overcast wants to merge 1 commit into
CyberTimon:mainfrom
Floral-Overcast:pr/android-preset-import
Open

Floral-Overcast wants to merge 1 commit into
CyberTimon:mainfrom
Floral-Overcast:pr/android-preset-import

Conversation

@Floral-Overcast

Copy link
Copy Markdown

Description

On Android, importing presets from the Presets panel does nothing (#1856). The system file picker returns content:// URIs. The import command read them with std::fs and took the file type from the URI string, so every file failed, and the failures were only written to the console.

This PR reads the picked files through the existing read_android_content_uri helper and takes the extension from resolve_android_content_uri_name, the same way LUT import already does.

Fixes #1856

Type of Change

  • Bug fix
  • New feature
  • Breaking change
  • Performance improvement
  • Code refactoring
  • Documentation update
  • UI/UX improvement
  • Build/CI or Dependency update

Changes Made

  • src-tauri/src/library/presets.rs
    • parse_preset_file reads content URIs through the ContentResolver on Android and decides between .rrpreset and legacy .xmp / .lrtemplate from the resolved display name. If a document provider reports a name without one of those extensions, it falls back to checking whether the content starts with {.
    • preset_file_display_name resolves content URIs, so failure messages show the real file name.
  • src/components/panel/right/PresetsPanel.tsx
    • No picker filters on Android, like the LUT and image pickers (Android filters by MIME type and the preset extensions have none registered).
    • Each file that fails to import now shows a toast. Before, the error only went to the console.
  • New string editor.presets.toasts.importFailed in all 17 locales. The non-English strings are machine translated.

Screenshots/Videos

Not included.

Testing

  • These changes were tested locally by a human and confirmed to work.
  • I haven't added any automated tests to the code because the codebase currently lacks a test suite.

What was tested:

  • On the phone below, preset files were imported with the import button in the Presets panel and appeared in the list with working previews. That build was v1.7.0 plus this change.
  • This branch (on current main): the Android release build (tauri android build --target aarch64) compiles with no new warnings; cargo fmt --check, cargo clippy --all-targets --all-features -- -D warnings and npm run typecheck pass; format:check, lint and i18n:check report the same results as main.

Not tested: legacy .xmp / .lrtemplate import on Android, and the desktop app was not run. On desktop parse_preset_file now reads the file once up front; the format decision is the same for the three extensions the desktop dialog allows.

Test Configuration:

  • OS: Android 17 (Samsung Galaxy S25 Ultra)
  • Hardware: Snapdragon 8 Elite, Adreno 830

Checklist

  • My code follows the project's code style
  • I haven't added unnecessary AI-generated code comments
  • My changes generate no new warnings or errors

Additional Notes

From reading the code, preset export on Android looks affected in the same way (handle_export_presets_to_file passes the save dialog's content URI to std::fs::write). A change for that exists but has not been run on a device yet, so it is not part of this PR.

AI Disclaimer:

Please state the involvement of AI in this PR:

  • This PR is created by an AI agent
  • This PR is mostly AI-generated but edited/merged together by a human
  • This PR was handwritten with AI assistance (spell check, logic suggestions, error resolving)
  • This PR contains only blood, sweat, and coffee (AI-free)

The code and this description were written by Claude (an AI agent) working for the account owner, who uses the patched build on the phone above and did the on-device import.

The Android file picker returns content:// URIs. Preset import read them
with std::fs and detected the format from the URI string, so every import
failed, and the failure was only logged to the console.

- read preset files through ContentResolver on Android and take the
  extension from the resolved display name (content sniff as fallback)
- pass no picker filters on Android, like the LUT and image pickers
- show a toast for each file that fails to import

Fixes CyberTimon#1856

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: Andriod presets importing

1 participant