Skip to content

Commit

Permalink
Structured content beta
Browse files Browse the repository at this point in the history
  • Loading branch information
arianneorpilla committed Sep 30, 2023
1 parent 6d9d9f3 commit 66668e7
Show file tree
Hide file tree
Showing 26 changed files with 3,124 additions and 885 deletions.
1 change: 1 addition & 0 deletions yuuna/android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -118,4 +118,5 @@ flutter {
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
implementation 'com.github.ankidroid:Anki-Android:api-v1.1.0'
implementation 'com.github.umair13adil:RxLogs:v1.0.18'
}
2 changes: 1 addition & 1 deletion yuuna/android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
android:icon="@mipmap/launcher_icon"
android:usesCleartextTraffic="true"
android:requestLegacyExternalStorage="true"
android:enableOnBackInvokedCallback="true"
android:enableOnBackInvokedCallback="false"
xmlns:tools="http://schemas.android.com/tools"
tools:replace="android:label">
<activity
Expand Down
1 change: 1 addition & 0 deletions yuuna/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ buildscript {
repositories {
google()
mavenCentral()
maven { url "https://jitpack.io" }
}

dependencies {
Expand Down
1 change: 1 addition & 0 deletions yuuna/lib/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export 'src/dictionary/dictionary_heading.dart';
export 'src/dictionary/dictionary_tag.dart';
export 'src/dictionary/dictionary_format.dart';
export 'src/dictionary/dictionary_operations_params.dart';
export 'src/dictionary/structured_content.dart';

export 'src/dictionary/formats/yomichan_dictionary_format.dart';
export 'src/dictionary/formats/abbyy_lingvo_format.dart';
Expand Down
8 changes: 6 additions & 2 deletions yuuna/lib/i18n/strings.g.dart
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
/// Generated file. Do not edit.
///
/// Locales: 1
/// Strings: 395
/// Strings: 397
///
/// Built on 2023-07-02 at 01:09 UTC
/// Built on 2023-09-30 at 09:59 UTC
// coverage:ignore-file
// ignore_for_file: type=lint
Expand Down Expand Up @@ -233,6 +233,7 @@ class _StringsEn implements BaseTranslations<AppLocale, _StringsEn> {
String get import_in_progress => 'Import in progress';
String get import_start => 'Preparing for import...';
String get import_clean => 'Cleaning working space...';
String import_extract_count({required Object n}) => 'Extracted ${n} files...';
String get import_extract => 'Extracting files...';
String import_name({required Object name}) => 'Importing 『${name}』...';
String get import_entries => 'Processing entries...';
Expand Down Expand Up @@ -407,6 +408,7 @@ class _StringsEn implements BaseTranslations<AppLocale, _StringsEn> {
String get stream_url => 'Stream URL';
String get default_option => 'Default';
String get paste => 'Paste';
String get select_all => 'Select all';
String get lyrics_title => 'Title';
String get lyrics_artist => 'Artist';
String get set_media => 'Set Media';
Expand Down Expand Up @@ -660,6 +662,7 @@ extension on _StringsEn {
case 'import_in_progress': return 'Import in progress';
case 'import_start': return 'Preparing for import...';
case 'import_clean': return 'Cleaning working space...';
case 'import_extract_count': return ({required Object n}) => 'Extracted ${n} files...';
case 'import_extract': return 'Extracting files...';
case 'import_name': return ({required Object name}) => 'Importing 『${name}』...';
case 'import_entries': return 'Processing entries...';
Expand Down Expand Up @@ -834,6 +837,7 @@ extension on _StringsEn {
case 'stream_url': return 'Stream URL';
case 'default_option': return 'Default';
case 'paste': return 'Paste';
case 'select_all': return 'Select all';
case 'lyrics_title': return 'Title';
case 'lyrics_artist': return 'Artist';
case 'set_media': return 'Set Media';
Expand Down
2 changes: 2 additions & 0 deletions yuuna/lib/i18n/strings.i18n.json
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@
"import_in_progress": "Import in progress",
"import_start": "Preparing for import...",
"import_clean": "Cleaning working space...",
"import_extract_count": "Extracted $n files...",
"import_extract": "Extracting files...",
"import_name": "Importing 『$name』...",
"import_entries": "Processing entries...",
Expand Down Expand Up @@ -279,6 +280,7 @@
"stream_url": "Stream URL",
"default_option": "Default",
"paste": "Paste",
"select_all": "Select all",
"lyrics_title": "Title",
"lyrics_artist": "Artist",
"set_media": "Set Media",
Expand Down
15 changes: 15 additions & 0 deletions yuuna/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import 'package:flutter_logs/flutter_logs.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:network_to_file_image/network_to_file_image.dart';
import 'package:receive_intent/receive_intent.dart' as intents;
import 'package:stack_trace/stack_trace.dart';
import 'package:spaces/spaces.dart';
import 'package:uri_to_file/uri_to_file.dart';
import 'package:wakelock/wakelock.dart';
Expand Down Expand Up @@ -67,6 +68,20 @@ void main() {
final appModel = container.read(appProvider);
await appModel.initialise();

/// Some packages propagate their [StackTrace] in an unusual format as
/// opposed to the format generated by Dart. This function allows the
/// Flutter framework to handle such formats so they can be displayed
/// appropriately.
FlutterError.demangleStackTrace = (stack) {
if (stack is Trace) {
return stack.vmTrace;
}
if (stack is Chain) {
return stack.toTrace().vmTrace;
}
return stack;
};

/// Start the application, specifying the [ProviderContainer] with the
/// already initialised [AppModel].
runApp(
Expand Down
12 changes: 1 addition & 11 deletions yuuna/lib/src/creator/fields/meaning_field.dart
Original file line number Diff line number Diff line change
Expand Up @@ -74,17 +74,7 @@ class MeaningField extends Field {
meaning = dictionaryFormat.getCustomDefinitionText(meaning);
}
meaning = meaning.trim();
if (meaningsCount == 1) {
meaningBuffer.write('$meaning\n');
} else {
if (index == 0) {
meaningBuffer.write('• ');
}
meaningBuffer.write(meaning);
if (index != entry.definitions.length - 1) {
meaningBuffer.write('; ');
}
}
meaningBuffer.write('$meaning\n');
});
}

Expand Down
8 changes: 2 additions & 6 deletions yuuna/lib/src/dictionary/dictionary.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,16 @@ part 'dictionary.g.dart';
class Dictionary {
/// Initialise a dictionary with details determined from import.
Dictionary({
required this.id,
required this.name,
required this.formatKey,
required this.order,
this.hiddenLanguages = const [],
this.collapsedLanguages = const [],
});

/// Function to generate a lookup ID for heading by its unique string key.
static int hash({required String name}) {
return fastHash(name);
}

/// Identifier for database purposes.
Id get id => hash(name: name);
final Id id;

/// The name of the dictionary. For example, this could be 'Merriam-Webster
/// Dictionary' or '大辞林' or 'JMdict'.
Expand Down
1 change: 1 addition & 0 deletions yuuna/lib/src/dictionary/dictionary.g.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

31 changes: 20 additions & 11 deletions yuuna/lib/src/dictionary/dictionary_format.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import 'dart:io';

import 'package:file_picker/file_picker.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:isar/isar.dart';
import 'package:yuuna/dictionary.dart';
import 'package:flutter/widgets.dart';

Expand Down Expand Up @@ -86,26 +87,34 @@ abstract class DictionaryFormat {
/// Prepares a list of tags that will be added to the database.
/// See [PrepareDictionaryParams] for how to work with the individual input
/// parameters.
Future<List<DictionaryTag>> Function(PrepareDictionaryParams params)
prepareTags;
void Function({
required PrepareDictionaryParams params,
required Isar isar,
}) prepareTags;

/// Prepares a map with entries that will be added to the database.
/// Prepares entries that will be added to the database.
/// See [PrepareDictionaryParams] for how to work with the individual input
/// parameters.
Future<Map<DictionaryHeading, List<DictionaryEntry>>> Function(
PrepareDictionaryParams params) prepareEntries;
void Function({
required PrepareDictionaryParams params,
required Isar isar,
}) prepareEntries;

/// Prepares a map with pitch entries that will be added to the database.
/// Prepares pitch entries that will be added to the database.
/// See [PrepareDictionaryParams] for how to work with the individual input
/// parameters.
Future<Map<DictionaryHeading, List<DictionaryPitch>>> Function(
PrepareDictionaryParams params) preparePitches;
void Function({
required PrepareDictionaryParams params,
required Isar isar,
}) preparePitches;

/// Prepares a map with frequency entries that will be added to the database.
/// Prepares frequency entries that will be added to the database.
/// See [PrepareDictionaryParams] for how to work with the individual input
/// parameters.
Future<Map<DictionaryHeading, List<DictionaryFrequency>>> Function(
PrepareDictionaryParams params) prepareFrequencies;
void Function({
required PrepareDictionaryParams params,
required Isar isar,
}) prepareFrequencies;

/// Used to allow a format to render its dictionary entries with a custom
/// widget.
Expand Down
14 changes: 5 additions & 9 deletions yuuna/lib/src/dictionary/dictionary_operations_params.dart
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class PrepareDirectoryParams extends IsolateParams {
PrepareDirectoryParams({
required this.file,
required this.charset,
required this.workingDirectory,
required this.resourceDirectory,
required this.dictionaryFormat,
required super.sendPort,
required super.directoryPath,
Expand All @@ -47,7 +47,7 @@ class PrepareDirectoryParams extends IsolateParams {

/// A working directory to be used in isolation and where data is to be
/// handled in later steps.
final Directory workingDirectory;
final Directory resourceDirectory;

/// The dictionary format to be used for entry processing.
final DictionaryFormat dictionaryFormat;
Expand All @@ -62,8 +62,7 @@ class PrepareDictionaryParams extends IsolateParams {
PrepareDictionaryParams({
required this.dictionary,
required this.dictionaryFormat,
required this.workingDirectory,
required this.useSlowImport,
required this.resourceDirectory,
required this.alertSendPort,
required super.sendPort,
required super.directoryPath,
Expand All @@ -75,11 +74,8 @@ class PrepareDictionaryParams extends IsolateParams {
/// The dictionary format to be used for entry processing.
final DictionaryFormat dictionaryFormat;

/// A working directory from which to extract dictionary data from.
final Directory workingDirectory;

/// Whether or not to use ACID-compliant importing.
final bool useSlowImport;
/// A working directory to extract dictionary data to.
final Directory resourceDirectory;

/// For communication with a [ReceivePort] to show a dialog message to notify
/// the user of critical information relating to import.
Expand Down
Loading

0 comments on commit 66668e7

Please sign in to comment.