Skip to content

Commit d840753

Browse files
committed
update notes import and export file type to jsonl
Changes the file type of notes exports to .jsonl (JSON Lines), which is a more common format used by compatible wallets as specified in BIP-329. For example, exporting labels with Sparrow Wallet creates a .jsonl, which would previously have to be renamed manually in order to allow importing it in the BitBoxApp. The supported import file types are updated accordingly, still allowing .txt imports for exports created prior to this change.
1 parent 1e5ec74 commit d840753

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
- Fix a bug that would prevent the app to perform firmware upgrade when offline.
77
- Replace sidebar with bottom navigation bar for mobile devices
88
- Introduce full screen selector for mobile in place of dropdown
9+
- Change notes export file type to JSON Lines
910

1011
# v4.47.2
1112
- Linux: fix compatiblity with some versions of Mesa that are incompatible with the bundled wayland libraries

backend/notes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ func (backend *Backend) ExportNotes() error {
158158
if err != nil {
159159
return err
160160
}
161-
name := fmt.Sprintf("%s-notes.txt", time.Now().Format("2006-01-02-at-15-04-05"))
161+
name := fmt.Sprintf("%s-notes.jsonl", time.Now().Format("2006-01-02-at-15-04-05"))
162162
suggestedPath := filepath.Join(exportsDir, name)
163163
path := backend.Environment().GetSaveFilename(suggestedPath)
164164
if path == "" {

frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import java.io.IOException;
5252
import java.io.InputStream;
5353
import java.io.InputStreamReader;
54+
import java.util.Arrays;
5455
import java.util.ArrayList;
5556
import java.util.HashMap;
5657
import java.util.Iterator;
@@ -350,15 +351,14 @@ public void onActivityResult(Uri uri) {
350351
@Override
351352
public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) {
352353
MainActivity.this.filePathCallback = filePathCallback;
353-
String[] mimeTypes = fileChooserParams.getAcceptTypes();
354+
List<String> mimeTypes = Arrays.asList(fileChooserParams.getAcceptTypes());
354355
String fileType = "*/*";
355-
if (mimeTypes.length == 1) {
356-
// import notes form uses .txt file type, but is not supported here.
357-
if (".txt".equals(mimeTypes[0])) {
358-
fileType = "text/plain";
359-
} else if (MimeTypeMap.getSingleton().hasMimeType(mimeTypes[0])) {
360-
fileType = mimeTypes[0];
361-
}
356+
if (mimeTypes.contains(".jsonl") && mimeTypes.contains(".txt")) {
357+
// Import notes form uses .jsonl and .text file types, but they are not supported here.
358+
// Fallback to any texty file instead.
359+
fileType = "text/*";
360+
} else if (mimeTypes.size() == 1 && MimeTypeMap.getSingleton().hasMimeType(mimeTypes.get(0))) {
361+
fileType = mimeTypes.get(0);
362362
}
363363
mGetContent.launch(fileType);
364364
return true;

frontends/web/src/routes/settings/components/appearance/notesImport.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ export const NotesImport = () => {
3232
type="file"
3333
className={style.fileInput}
3434
ref={fileInputRef}
35-
accept=".txt"
35+
accept=".jsonl,.txt"
3636
onChange={async (e: React.ChangeEvent<HTMLInputElement>) => {
3737
setImportDisabled(e.target.files === null || e.target.files.length === 0);
3838
if (fileInputRef.current === null) {

0 commit comments

Comments
 (0)