Skip to content

Commit

Permalink
Merge branch 'refs/heads/main' into fix/53/resolve-OutOfMemoryError-i…
Browse files Browse the repository at this point in the history
…ssue
  • Loading branch information
BBarisKilic committed Jul 22, 2024
2 parents a62d626 + 57e90d5 commit 016b1df
Show file tree
Hide file tree
Showing 32 changed files with 632 additions and 99 deletions.
26 changes: 23 additions & 3 deletions lib/bootstrap.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_native_splash/flutter_native_splash.dart';
import 'package:get_it/get_it.dart';
import 'package:launch_review_service/launch_review_service.dart';
import 'package:in_app_review_service/in_app_review_service.dart';
import 'package:package_info_plus/package_info_plus.dart';
import 'package:path/path.dart';
import 'package:path_provider/path_provider.dart';
Expand Down Expand Up @@ -132,11 +132,31 @@ Future<void> setup() async {
repository: getIt<MergeSettingsRepository>(),
),
)
..registerLazySingleton<LocalMergeStatisticsService>(
() => ObjectBoxMergeStatisticsService(
service: getIt<ObjectBoxService>(),
),
)
..registerLazySingleton<MergeStatisticsRepository>(
() => MergeStatisticsRepositoryImpl(
localService: getIt<LocalMergeStatisticsService>(),
),
)
..registerLazySingleton<GetMergeStatisticsUseCase>(
() => GetMergeStatisticsUseCase(
repository: getIt<MergeStatisticsRepository>(),
),
)
..registerLazySingleton<SaveMergeStatisticsUseCase>(
() => SaveMergeStatisticsUseCase(
repository: getIt<MergeStatisticsRepository>(),
),
)
..registerLazySingleton<PackageInfo>(
() => packageInfo,
)
..registerLazySingleton<LaunchReviewService>(
() => LaunchReviewService(androidAppId: getIt<PackageInfo>().packageName),
..registerLazySingleton<InAppReviewService>(
InAppReviewService.new,
)
..registerLazySingleton<UrlLauncherService>(
() => const UrlLauncherService(),
Expand Down
31 changes: 29 additions & 2 deletions lib/src/core/gen/objectbox-model.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,17 +60,44 @@
}
],
"relations": []
},
{
"id": "3:6752277543447190155",
"lastPropertyId": "5:7060629709470016846",
"name": "LocalMergeStatistics",
"properties": [
{
"id": "1:5740094858668497488",
"name": "id",
"type": 6,
"flags": 1
},
{
"id": "4:7986270554451540890",
"name": "successMergeCount",
"type": 6
},
{
"id": "5:7060629709470016846",
"name": "failedMergeCount",
"type": 6
}
],
"relations": []
}
],
"lastEntityId": "2:4520518054235479906",
"lastEntityId": "3:6752277543447190155",
"lastIndexId": "0:0",
"lastRelationId": "0:0",
"lastSequenceId": "0:0",
"modelVersion": 5,
"modelVersionParserMinimum": 5,
"retiredEntityUids": [],
"retiredIndexUids": [],
"retiredPropertyUids": [],
"retiredPropertyUids": [
3379488580577270059,
4991885907385683044
],
"retiredRelationUids": [],
"version": 1
}
75 changes: 73 additions & 2 deletions lib/src/core/gen/objectbox.g.dart

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

12 changes: 6 additions & 6 deletions lib/src/core/l10n/app_localizations.dart
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,12 @@ abstract class AppLocalizations {
/// **'Could not open privacy policy! Please check your internet connection and try again.'**
String get couldNotOpenPrivacyPolicyMessage;

/// No description provided for @couldNotOpenStoreListingMessage.
///
/// In en, this message translates to:
/// **'Could not open store listing! Please check your internet connection and try again.'**
String get couldNotOpenStoreListingMessage;

/// No description provided for @couldNotOpenTermsAndConditionsMessage.
///
/// In en, this message translates to:
Expand All @@ -236,12 +242,6 @@ abstract class AppLocalizations {
/// **'Could not launch email service! Please check your internet connection and try again.'**
String get couldNotLaunchEmailServiceMessage;

/// No description provided for @couldNotLaunchReviewServiceMessage.
///
/// In en, this message translates to:
/// **'Could not launch review service! Please check your internet connection and try again.'**
String get couldNotLaunchReviewServiceMessage;

/// No description provided for @couldNotSeekVideoPositionMessage.
///
/// In en, this message translates to:
Expand Down
8 changes: 4 additions & 4 deletions lib/src/core/l10n/app_localizations_en.dart
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,10 @@ class AppLocalizationsEn extends AppLocalizations {
String get couldNotOpenPrivacyPolicyMessage =>
'Could not open privacy policy! Please check your internet connection and try again.';

@override
String get couldNotOpenStoreListingMessage =>
'Could not open store listing! Please check your internet connection and try again.';

@override
String get couldNotOpenTermsAndConditionsMessage =>
'Could not open terms and conditions! Please check your internet connection and try again.';
Expand All @@ -87,10 +91,6 @@ class AppLocalizationsEn extends AppLocalizations {
String get couldNotLaunchEmailServiceMessage =>
'Could not launch email service! Please check your internet connection and try again.';

@override
String get couldNotLaunchReviewServiceMessage =>
'Could not launch review service! Please check your internet connection and try again.';

@override
String get couldNotSeekVideoPositionMessage =>
'Could not seek video position! Please try again later.';
Expand Down
2 changes: 1 addition & 1 deletion lib/src/core/l10n/arb/app_en.arb
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@
"couldNotLoadVideosMessage": "Could not load videos! Please confirm that video files are valid.",
"couldNotOpenAssetPickerMessage": "Could not open the asset picker! Please grant the necessary permissions.",
"couldNotOpenPrivacyPolicyMessage": "Could not open privacy policy! Please check your internet connection and try again.",
"couldNotOpenStoreListingMessage": "Could not open store listing! Please check your internet connection and try again.",
"couldNotOpenTermsAndConditionsMessage": "Could not open terms and conditions! Please check your internet connection and try again.",
"couldNotPauseVideoMessage": "Could not pause video! Please try again later.",
"couldNotPlayVideoMessage": "Could not play video! Please confirm that video files are valid.",
"couldNotLaunchEmailServiceMessage": "Could not launch email service! Please check your internet connection and try again.",
"couldNotLaunchReviewServiceMessage": "Could not launch review service! Please check your internet connection and try again.",
"couldNotSeekVideoPositionMessage": "Could not seek video position! Please try again later.",
"couldNotSetVideoSpeedMessage": "Could not set video playback speed! Please try again later.",
"cyan": "Cyan",
Expand Down
1 change: 1 addition & 0 deletions lib/src/features/merge/data/data_sources/data_sources.dart
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,4 @@
// in the LICENSE file.

export 'merge_settings_service/merge_settings_service.dart';
export 'merge_statistics_service/merge_statistics_service.dart';
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import 'package:vmerge/src/features/merge/merge.dart';
/// An interface that inherits from [MergeSettingsService] and defines the
/// requirements for implementations that use a local service.
///
/// The [LocalMergeSettings] type is the model
/// type.
/// The [LocalMergeSettings] type is the model type.
/// {@endtemplate}
abstract interface class LocalMergeSettingsService
implements MergeSettingsService<LocalMergeSettings> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ final class ObjectBoxMergeSettingsService implements LocalMergeSettingsService {
final box = _service.store.box<LocalMergeSettings>();
final query = box.query().build();
final entities = query.find();

if (entities.isEmpty) {
query.close();
return saveMergeSettings(LocalMergeSettings());
}

final settings = entities.first;
query.close();

Expand All @@ -30,7 +36,9 @@ final class ObjectBoxMergeSettingsService implements LocalMergeSettingsService {

/// Saves the [LocalMergeSettings].
@override
Future<void> saveMergeSettings(LocalMergeSettings settings) async {
Future<LocalMergeSettings> saveMergeSettings(
LocalMergeSettings settings,
) async {
final box = _service.store.box<LocalMergeSettings>();
final query = box.query().build();
final entities = query.find();
Expand All @@ -39,6 +47,6 @@ final class ObjectBoxMergeSettingsService implements LocalMergeSettingsService {

if (oldSettings != null) settings.id = oldSettings.id;

box.put(settings);
return box.putAndGetAsync(settings);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright 2024 BBK Development. All rights reserved.
// Use of this source code is governed by a GPL-style license that can be found
// in the LICENSE file.

import 'package:vmerge/src/features/merge/merge.dart';

/// {@template local_merge_statistics_service}
/// An interface that inherits from [MergeStatisticsService] and defines the
/// requirements for implementations that use a local service.
///
/// The [LocalMergeStatistics] type is the model type.
/// {@endtemplate}
abstract interface class LocalMergeStatisticsService
implements MergeStatisticsService<LocalMergeStatistics> {
/// {@macro local_merge_statistics_service}
const LocalMergeStatisticsService();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2024 BBK Development. All rights reserved.
// Use of this source code is governed by a GPL-style license that can be found
// in the LICENSE file.

export 'local_merge_statistics_service.dart';
export 'object_box_merge_statistics_service.dart';

/// {@template merge_statistics_service}
/// An interface that defines the requirements for implementations that provide
/// merge statistics.
///
/// The [M] type is the model type.
/// {@endtemplate}
abstract interface class MergeStatisticsService<M> {
/// {@macro merge_statistics_service}
const MergeStatisticsService();

Future<M> getMergeStatistics();

Future<void> saveMergeStatistics(M statistics);
}
Loading

0 comments on commit 016b1df

Please sign in to comment.