diff --git a/android/app/build.gradle b/android/app/build.gradle index 35d767782..a7bd673c7 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -35,6 +35,8 @@ android { compileSdkVersion localProperties.getProperty('flutter.compileSdkVersion').toInteger() compileOptions { + // Flag to enable support for the new language APIs + coreLibraryDesugaringEnabled true sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } @@ -55,6 +57,7 @@ android { defaultConfig { + multiDexEnabled true applicationId "com.miraisoft.shiori" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. @@ -107,4 +110,9 @@ dependencies { def appCenterSdkVersion = '4.4.5' implementation "com.microsoft.appcenter:appcenter-analytics:${appCenterSdkVersion}" implementation "com.microsoft.appcenter:appcenter-crashes:${appCenterSdkVersion}" + + // Required by the notifications plugin + coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' + implementation 'androidx.window:window:1.0.0' + implementation 'androidx.window:window-java:1.0.0' } diff --git a/android/app/proguard-rules.pro b/android/app/proguard-rules.pro index c89b0b332..c526cfa17 100644 --- a/android/app/proguard-rules.pro +++ b/android/app/proguard-rules.pro @@ -22,8 +22,6 @@ @com.google.gson.annotations.SerializedName ; } --keepattributes InnerClasses - # Retain generic signatures of TypeToken and its subclasses with R8 version 3.0 and higher. -keep,allowobfuscation,allowshrinking class com.google.gson.reflect.TypeToken -keep,allowobfuscation,allowshrinking class * extends com.google.gson.reflect.TypeToken diff --git a/lib/domain/services/notification_service.dart b/lib/domain/services/notification_service.dart index 24e97ed4a..490952b92 100644 --- a/lib/domain/services/notification_service.dart +++ b/lib/domain/services/notification_service.dart @@ -1,14 +1,9 @@ -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:shiori/domain/enums/enums.dart'; abstract class NotificationService { void init(); - //TODO: REMOVE THE PLUGIN DEPENDENCY FROM THIS LAYER - Future registerCallBacks({ - DidReceiveLocalNotificationCallback? onIosReceiveLocalNotification, - SelectNotificationCallback? onSelectNotification, - }); + Future registerCallBacks(); Future requestIOSPermissions(); diff --git a/lib/infrastructure/notification_service.dart b/lib/infrastructure/notification_service.dart index c8c05a9e3..24ca54c8c 100644 --- a/lib/infrastructure/notification_service.dart +++ b/lib/infrastructure/notification_service.dart @@ -50,19 +50,16 @@ class NotificationServiceImpl implements NotificationService { } @override - Future registerCallBacks({ - DidReceiveLocalNotificationCallback? onIosReceiveLocalNotification, - SelectNotificationCallback? onSelectNotification, - }) async { + Future registerCallBacks() async { try { if (!isPlatformSupported) { return Future.value(); } const android = AndroidInitializationSettings('ic_notification'); - final iOS = IOSInitializationSettings(onDidReceiveLocalNotification: onIosReceiveLocalNotification); - const macOS = MacOSInitializationSettings(); - final initializationSettings = InitializationSettings(android: android, iOS: iOS, macOS: macOS); - await _flutterLocalNotificationsPlugin.initialize(initializationSettings, onSelectNotification: onSelectNotification); + const iOS = DarwinInitializationSettings(); + const macOS = DarwinInitializationSettings(); + const initializationSettings = InitializationSettings(android: android, iOS: iOS, macOS: macOS); + await _flutterLocalNotificationsPlugin.initialize(initializationSettings); } catch (e, s) { _loggingService.error(runtimeType, 'registerCallBacks: Unknown error occurred', e, s); } @@ -128,7 +125,7 @@ class NotificationServiceImpl implements NotificationService { scheduledDate, specifics, uiLocalNotificationDateInterpretation: UILocalNotificationDateInterpretation.absoluteTime, - androidAllowWhileIdle: true, + androidScheduleMode: AndroidScheduleMode.exactAllowWhileIdle, payload: payload, ); } @@ -152,8 +149,8 @@ class NotificationServiceImpl implements NotificationService { largeIcon: const DrawableResourceAndroidBitmap(_largeIcon), tag: _getTagFromNotificationType(type), ); - const iOS = IOSNotificationDetails(presentAlert: true, presentBadge: true, presentSound: true, threadIdentifier: _channelId); - const macOS = MacOSNotificationDetails(presentAlert: true, presentBadge: true, presentSound: true, threadIdentifier: _channelId); + const iOS = DarwinNotificationDetails(presentAlert: true, presentBadge: true, presentSound: true, threadIdentifier: _channelId); + const macOS = DarwinNotificationDetails(presentAlert: true, presentBadge: true, presentSound: true, threadIdentifier: _channelId); return NotificationDetails(android: android, iOS: iOS, macOS: macOS); } diff --git a/lib/main.dart b/lib/main.dart index f5be0d096..7b768831a 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -28,10 +28,7 @@ Future main() async { setWindowMaxSize(Size.infinite); } final notificationService = getIt(); - final notifFuture = notificationService.registerCallBacks( - onSelectNotification: _onSelectNotification, - onIosReceiveLocalNotification: _onDidReceiveLocalNotification, - ); + final notifFuture = notificationService.registerCallBacks(); //TODO: CHECK THE NOTIFICATION LOGIC //TODO: WEBVIEW SUPPORT IN MACOS if (!Platform.isMacOS) { @@ -42,10 +39,6 @@ Future main() async { runApp(MyApp()); } -Future _onDidReceiveLocalNotification(int id, String? title, String? body, String? payload) async {} - -Future _onSelectNotification(String? json) async {} - class MyApp extends StatelessWidget { @override Widget build(BuildContext context) { diff --git a/pubspec.yaml b/pubspec.yaml index de9e008b1..331f1a150 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -34,7 +34,7 @@ dependencies: flutter_bloc: ^7.3.1 flutter_colorpicker: ^1.0.3 flutter_inappwebview: ^5.7.2+3 - flutter_local_notifications: ^9.5.3+1 + flutter_local_notifications: ^15.1.0+1 flutter_localizations: sdk: flutter flutter_markdown: ^0.6.17+1