Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .fvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"flutter": "beta"
}
2 changes: 1 addition & 1 deletion .run/Generate localizations.run.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<component name="ProjectRunConfigurationManager">
<configuration name="Generate localizations" default="false" type="ShConfigurationType">
<option name="SCRIPT_TEXT" value="flutter gen-l10" />
<option name="SCRIPT_TEXT" value="flutter gen-l10n" />
<option name="INDEPENDENT_SCRIPT_PATH" value="true" />
<option name="SCRIPT_PATH" value="" />
<option name="SCRIPT_OPTIONS" value="" />
Expand Down
2 changes: 1 addition & 1 deletion lib/common/system_utils.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ import 'package:device_info_plus/device_info_plus.dart';
import 'package:flag_secure/flag_secure.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:listen_sharing_intent/listen_sharing_intent.dart';
import 'package:local_auth/local_auth.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:quick_actions/quick_actions.dart';
import 'package:receive_sharing_intent/receive_sharing_intent.dart';

import '../l10n/app_localizations/app_localizations.g.dart';
import '../models/note/types/note_type.dart';
Expand Down
1 change: 1 addition & 0 deletions lib/models/note/note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import '../../../common/constants/constants.dart';
import '../../common/files/encryption_utils.dart';
import '../../common/preferences/enums/sort_method.dart';
import '../../common/preferences/preference_key.dart';
import '../../services/notes/notes_service.dart';
import '../label/label.dart';
import 'note_status.dart';
import 'types/note_type.dart';
Expand Down
14 changes: 12 additions & 2 deletions lib/models/note/types/rich_text_note.dart
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ class RichTextNote extends Note {
encryptionPassword != null ? EncryptionUtils().decrypt(encryptionPassword, contentAsJson) : contentAsJson,
);
ParchmentDocument.fromJson(content);
} on Exception {
} catch (_) {
return false;
}

Expand All @@ -81,7 +81,17 @@ class RichTextNote extends Note {

/// Document containing the fleather content representation.
@ignore
ParchmentDocument get document => ParchmentDocument.fromJson(jsonDecode(content) as List);
ParchmentDocument get document {
try {
return ParchmentDocument.fromJson(jsonDecode(content) as List);
} catch (exception, stackTrace) {
logger.e('Failed to decode the content of a rich text note, deleting it.', exception, stackTrace);

NotesService().delete(this);

return ParchmentDocument();
}
}

@ignore
@override
Expand Down
27 changes: 20 additions & 7 deletions lib/services/backup/backup_service.dart
Original file line number Diff line number Diff line change
Expand Up @@ -157,20 +157,23 @@ class ManualBackupService {

// If the note type is null, it's an export from before v2.0.0 when only rich text notes were available
if (noteType == null) {
if (RichTextNote.isFleatherData(noteAsJson['content'] as String)) {
notes.add(RichTextNote.fromJson(noteAsJson));
} else {
logger.w('Imported a note without a type as a plain text note because its content is not fleather data');
notes.add(PlainTextNote.fromJson(noteAsJson));
}
_addRichTextNote(
noteAsJson,
notes,
'Imported a note without a type as a plain text note because its content is not fleather data',
);
} else {
switch (noteType) {
case NoteType.plainText:
notes.add(PlainTextNote.fromJson(noteAsJson));
case NoteType.markdown:
notes.add(MarkdownNote.fromJson(noteAsJson));
case NoteType.richText:
notes.add(RichTextNote.fromJson(noteAsJson));
_addRichTextNote(
noteAsJson,
notes,
'Imported a rich text note as a plain text note because its content is not fleather data',
);
case NoteType.checklist:
notes.add(ChecklistNote.fromJson(noteAsJson));
}
Expand Down Expand Up @@ -199,6 +202,16 @@ class ManualBackupService {
return true;
}

void _addRichTextNote(dynamic noteAsJson, List<Note> notes, String warningMessage) {
if (RichTextNote.isFleatherData(noteAsJson['content'] as String)) {
notes.add(RichTextNote.fromJson(noteAsJson));
} else {
logger.w(warningMessage);

notes.add(PlainTextNote.fromJson(noteAsJson));
}
}

Future<bool> _importPreferences(dynamic importedJson) async {
final preferencesAndValues = importedJson['preferences'] as Map<String, dynamic>;

Expand Down
17 changes: 8 additions & 9 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -821,6 +821,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "6.0.0"
listen_sharing_intent:
dependency: "direct main"
description:
name: listen_sharing_intent
sha256: df12e6c78666018985c39df494fc12412ece6510c38c79fe1230f2abef0965fa
url: "https://pub.dev"
source: hosted
version: "1.9.2"
local_auth:
dependency: "direct main"
description:
Expand Down Expand Up @@ -1173,15 +1181,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "3.2.2"
receive_sharing_intent:
dependency: "direct main"
description:
path: "."
ref: "2cea396843cd3ab1b5ec4334be4233864637874e"
resolved-ref: "2cea396843cd3ab1b5ec4334be4233864637874e"
url: "https://github.com/KasemJaffer/receive_sharing_intent"
source: git
version: "1.8.1"
remove_markdown:
dependency: "direct main"
description:
Expand Down
7 changes: 2 additions & 5 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: localmaterialnotes
description: Simple, local, material design notes
repository: https://github.com/maelchiotti/LocalMaterialNotes

version: 2.1.1+30
version: 2.1.1+31
publish_to: none

# TODO(maelchiotti): move back to the stable branch when native assets are released
Expand Down Expand Up @@ -45,6 +45,7 @@ dependencies:
isar_community: ^3.3.0-dev.3
isar_community_flutter_libs: ^3.3.0-dev.3
json_annotation: ^4.9.0
listen_sharing_intent: ^1.9.2
local_auth: ^3.0.0
locale_names: ^1.1.1
logger: ^2.6.2
Expand All @@ -57,10 +58,6 @@ dependencies:
path: ^1.9.1
path_provider: ^2.1.5
quick_actions: ^1.1.0
receive_sharing_intent: # TODO: change when the fix is released
git:
url: https://github.com/KasemJaffer/receive_sharing_intent
ref: 2cea396843cd3ab1b5ec4334be4233864637874e
remove_markdown: ^0.0.2
restart_app: ^1.3.2
riverpod_annotation: ^3.0.3
Expand Down
Loading