From 60c875a604ba096bb580452cb3ef6a52867e0076 Mon Sep 17 00:00:00 2001 From: Christian Pauly Date: Thu, 14 Apr 2022 19:26:20 +0200 Subject: [PATCH] chore: Follow up push --- .../settings_notifications.dart | 16 ---------------- .../settings_notifications_view.dart | 14 -------------- lib/utils/push_helper.dart | 17 ++++++++++------- macos/Flutter/GeneratedPluginRegistrant.swift | 2 ++ pubspec.lock | 18 +++++++++--------- pubspec.yaml | 3 +-- 6 files changed, 22 insertions(+), 48 deletions(-) diff --git a/lib/pages/settings_notifications/settings_notifications.dart b/lib/pages/settings_notifications/settings_notifications.dart index 1e677edc..828152a3 100644 --- a/lib/pages/settings_notifications/settings_notifications.dart +++ b/lib/pages/settings_notifications/settings_notifications.dart @@ -2,12 +2,9 @@ import 'package:flutter/material.dart'; import 'package:collection/collection.dart' show IterableExtension; import 'package:flutter_gen/gen_l10n/l10n.dart'; -import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:future_loading_dialog/future_loading_dialog.dart'; import 'package:matrix/matrix.dart'; -import 'package:open_noti_settings/open_noti_settings.dart'; -import 'package:fluffychat/config/app_config.dart'; import '../../widgets/matrix.dart'; import 'settings_notifications_view.dart'; @@ -59,19 +56,6 @@ class SettingsNotifications extends StatefulWidget { } class SettingsNotificationsController extends State { - void openAndroidNotificationSettingsAction() async { - await NotificationSetting.configureChannel( - const NotificationDetails( - android: AndroidNotificationDetails( - AppConfig.pushNotificationsChannelId, - AppConfig.pushNotificationsChannelName, - AppConfig.pushNotificationsChannelDescription, - ), - ), - ); - return NotificationSetting.open(); - } - bool? getNotificationSetting(NotificationSettingsItem item) { final pushRules = Matrix.of(context).client.globalPushRules; switch (item.type) { diff --git a/lib/pages/settings_notifications/settings_notifications_view.dart b/lib/pages/settings_notifications/settings_notifications_view.dart index d80b0ecf..c01d8220 100644 --- a/lib/pages/settings_notifications/settings_notifications_view.dart +++ b/lib/pages/settings_notifications/settings_notifications_view.dart @@ -1,6 +1,3 @@ -import 'dart:io'; - -import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; @@ -51,17 +48,6 @@ class SettingsNotificationsView extends StatelessWidget { ), ), if (!Matrix.of(context).client.allPushNotificationsMuted) ...{ - if (!kIsWeb && Platform.isAndroid) - ListTile( - title: Text(L10n.of(context)!.soundVibrationLedColor), - trailing: CircleAvatar( - backgroundColor: - Theme.of(context).scaffoldBackgroundColor, - foregroundColor: Colors.grey, - child: const Icon(Icons.edit_outlined), - ), - onTap: controller.openAndroidNotificationSettingsAction, - ), const Divider(thickness: 1), ListTile( title: Text( diff --git a/lib/utils/push_helper.dart b/lib/utils/push_helper.dart index 919ffe6d..00771f36 100644 --- a/lib/utils/push_helper.dart +++ b/lib/utils/push_helper.dart @@ -3,6 +3,7 @@ import 'dart:ui'; import 'package:flutter/material.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_gen/gen_l10n/l10n.dart'; import 'package:flutter_local_notifications/flutter_local_notifications.dart'; import 'package:matrix/matrix.dart'; @@ -37,11 +38,9 @@ Future pushHelper( // Initialise the plugin. app_icon needs to be a added as a drawable resource to the Android head project final _flutterLocalNotificationsPlugin = FlutterLocalNotificationsPlugin(); await _flutterLocalNotificationsPlugin.initialize( - InitializationSettings( - android: const AndroidInitializationSettings('notifications_icon'), - iOS: IOSInitializationSettings( - onDidReceiveLocalNotification: (i, a, b, c) async => null, - ), + const InitializationSettings( + android: AndroidInitializationSettings('notifications_icon'), + iOS: IOSInitializationSettings(), ), onSelectNotification: onSelectNotification, ); @@ -79,16 +78,20 @@ Future pushHelper( // The person object for the android message style notification if (isBackgroundMessage) WidgetsFlutterBinding.ensureInitialized(); final avatar = event.room.avatar?.toString(); + final avatarFile = + avatar == null ? null : await DefaultCacheManager().getSingleFile(avatar); + final person = Person( name: event.room.getLocalizedDisplayname(matrixLocals), - icon: avatar == null ? null : ContentUriAndroidIcon(avatar), + icon: + avatarFile == null ? null : BitmapFilePathAndroidIcon(avatarFile.path), ); // Show notification final androidPlatformChannelSpecifics = AndroidNotificationDetails( AppConfig.pushNotificationsChannelId, AppConfig.pushNotificationsChannelName, - AppConfig.pushNotificationsChannelDescription, + channelDescription: AppConfig.pushNotificationsChannelDescription, styleInformation: MessagingStyleInformation( person, conversationTitle: title, diff --git a/macos/Flutter/GeneratedPluginRegistrant.swift b/macos/Flutter/GeneratedPluginRegistrant.swift index 62cfaffc..0e69f284 100644 --- a/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/macos/Flutter/GeneratedPluginRegistrant.swift @@ -12,6 +12,7 @@ import desktop_lifecycle import device_info_plus_macos import emoji_picker_flutter import file_selector_macos +import flutter_app_badger import flutter_local_notifications import flutter_secure_storage_macos import flutter_web_auth @@ -35,6 +36,7 @@ func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) { DeviceInfoPlusMacosPlugin.register(with: registry.registrar(forPlugin: "DeviceInfoPlusMacosPlugin")) EmojiPickerFlutterPlugin.register(with: registry.registrar(forPlugin: "EmojiPickerFlutterPlugin")) FileSelectorPlugin.register(with: registry.registrar(forPlugin: "FileSelectorPlugin")) + FlutterAppBadgerPlugin.register(with: registry.registrar(forPlugin: "FlutterAppBadgerPlugin")) FlutterLocalNotificationsPlugin.register(with: registry.registrar(forPlugin: "FlutterLocalNotificationsPlugin")) FlutterSecureStorageMacosPlugin.register(with: registry.registrar(forPlugin: "FlutterSecureStorageMacosPlugin")) FlutterWebAuthPlugin.register(with: registry.registrar(forPlugin: "FlutterWebAuthPlugin")) diff --git a/pubspec.lock b/pubspec.lock index 29db9d19..ba2cf5ed 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -546,14 +546,21 @@ packages: name: flutter_local_notifications url: "https://pub.dartlang.org" source: hosted - version: "8.2.0" + version: "9.4.0" + flutter_local_notifications_linux: + dependency: transitive + description: + name: flutter_local_notifications_linux + url: "https://pub.dartlang.org" + source: hosted + version: "0.4.2" flutter_local_notifications_platform_interface: dependency: transitive description: name: flutter_local_notifications_platform_interface url: "https://pub.dartlang.org" source: hosted - version: "4.0.1" + version: "5.0.0" flutter_localizations: dependency: "direct main" description: flutter @@ -1091,13 +1098,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.0" - open_noti_settings: - dependency: "direct main" - description: - name: open_noti_settings - url: "https://pub.dartlang.org" - source: hosted - version: "0.4.0" package_config: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 282d7832..6b32b5dd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -32,7 +32,7 @@ dependencies: flutter_app_lock: ^2.0.0 flutter_blurhash: ^0.6.4 flutter_cache_manager: ^3.3.0 - flutter_local_notifications: ^8.2.0 + flutter_local_notifications: ^9.4.0 flutter_localizations: sdk: flutter flutter_map: ^0.14.0 @@ -61,7 +61,6 @@ dependencies: matrix_link_text: ^1.0.2 native_imaging: git: https://gitlab.com/famedly/company/frontend/libraries/native_imaging.git - open_noti_settings: ^0.4.0 package_info_plus: ^1.3.0 path_provider: ^2.0.9 permission_handler: ^9.2.0