Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mobile: Support importing from JEX files #10269

Merged

Conversation

personalizedrefrigerator
Copy link
Collaborator

Summary

Related forum post: https://discourse.joplinapp.org/t/import-jex-file-on-android/31126/8

This pull request adds support for importing from .JEX files on mobile.

Notes

This pull request is mostly UI changes (InteropService.instance().import already works for .jex files on mobile). Specifically, it:

  1. Renames the "Export" section in settings to "Import and Export"
  2. Creates a new TaskButton.tsx file that handles displaying progress and warnings for both export and import tasks.
  3. Adds a new import button that uses TaskButton.

Note that it now also possible to do multiple exports without closing and re-opening the export settings tab.

Currently, imported notebooks are added to the top level (not added within a notebook). It may make sense to change this, for example, by creating a new notebook for each import.

Screenshots

Note: The foo warning was added as a demonstration of the warning UI:
Screenshot: Import complete, shows one warning directly below the "Import" button, "Completed with warnings: \ foo" screenshot: Import and export screen: Import running, shows progress bar, button labeled "Importing"
screenshot: Main settings screen in dark mode, the renamed "Import and Export" tab is highlighted.

Testing

  1. Ensure that at least one image and emoji or other non-ASCII character is present in a note.
  2. Export all notes as JEX from the "Import and Export" settings screen.
  3. Import from the just-exported JEX file.
  4. Verify that notebooks and notes have been duplicated.
  5. Verify that the image and emoji from step 1 are present in the duplicated (imported) note.

This has been tested successfully on an Android 12 emulator.

Comment on lines +50 to +53
const sourceFilePath = Platform.select({
android: sourceFileUri,
ios: decodeURI(sourceFileUri),
});
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently, we have a similar Platform.select in most places we use pickDocument. It may make sense to move this into the implementation of pickDocument.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good idea, would you mind doing this refactoring? Maybe with some wrapper over pickDocument

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note.tsx currently relies on pickDocument producing the same output as the image picker library:

const localFilePath = Platform.select({

Doing this refactor would likely cause this assumption to break. Refactoring pickDocument should be done while also refactoring Note.tsx.

@laurent22 laurent22 merged commit 2ae08ff into laurent22:dev Apr 8, 2024
10 checks passed
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.

None yet

2 participants