Merge branch 'krille/followup-push' into 'main'

chore: Follow up push

See merge request famedly/fluffychat!825
This commit is contained in:
Krille Fear 2022-04-14 17:48:14 +00:00
commit c1d978cb45
6 changed files with 22 additions and 48 deletions

View File

@ -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<SettingsNotifications> {
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) {

View File

@ -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(

View File

@ -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<void> 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<void> 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,

View File

@ -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"))

View File

@ -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:

View File

@ -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