diff --git a/example/lib/main.dart b/example/lib/main.dart index ff07511..20dc0b2 100644 --- a/example/lib/main.dart +++ b/example/lib/main.dart @@ -1,11 +1,9 @@ import 'dart:io'; -import 'dart:math'; import 'dart:typed_data'; import 'package:flutter/material.dart'; import 'package:file_picker/file_picker.dart'; import 'package:moxplatform/moxplatform.dart'; import 'package:path/path.dart'; -import 'package:permission_handler/permission_handler.dart'; /// The id of the notification channel. const channelId = "me.polynom.moxplatform.testing3"; @@ -31,54 +29,6 @@ class MyApp extends StatefulWidget { } class MyAppState extends State { - @override - void initState() { - super.initState(); - - initStateAsync(); - } - - Future initStateAsync() async { - await Permission.notification.request(); - - await MoxplatformPlugin.notifications.createNotificationChannels( - [ - NotificationChannel( - id: channelId, - title: "Test1", - description: "Test notification channel", - importance: NotificationChannelImportance.MIN, - showBadge: true, - vibration: false, - enableLights: false, - ), - NotificationChannel( - id: otherChannelId, - title: "Test2", - description: "Test notification channel for warnings", - importance: NotificationChannelImportance.MIN, - showBadge: true, - vibration: false, - enableLights: false, - ), - ], - ); - await MoxplatformPlugin.notifications.setI18n( - NotificationI18nData( - reply: "答える", - markAsRead: "読みた", - you: "あなた", - ), - ); - - MoxplatformPlugin.notifications.getEventStream().listen((event) { - // ignore: avoid_print - print( - 'NotificationEvent(type: ${event.type}, jid: ${event.jid}, payload: ${event.payload}, extras: ${event.extra})', - ); - }); - } - @override Widget build(BuildContext context) { return MaterialApp( @@ -106,10 +56,6 @@ class MyHomePageState extends State { Sender('Raiden Shogun', 'raiden@tevhat'), ]; - /// List of sent messages. - List messages = - List.empty(growable: true); - Future _cryptoTest() async { final result = await FilePicker.platform.pickFiles(); if (result == null) { @@ -187,87 +133,6 @@ class MyHomePageState extends State { }, child: const Text('Test recordSentMessage (notes fallback)'), ), - ElevatedButton( - onPressed: () async { - final result = await FilePicker.platform.pickFiles( - type: FileType.image, - ); - // ignore: avoid_print - print('Picked file: ${result?.files.single.path}'); - - // Create a new message. - final senderIndex = Random().nextInt(senders.length); - final time = DateTime.now().millisecondsSinceEpoch; - messages.add(NotificationMessage( - jid: senders[senderIndex].jid, - sender: senders[senderIndex].name, - content: NotificationMessageContent( - body: result != null ? null : 'Message #${messages.length}', - mime: 'image/jpeg', - path: result?.files.single.path, - ), - timestamp: time, - )); - - await Future.delayed(const Duration(seconds: 4)); - await MoxplatformPlugin.notifications.showMessagingNotification( - MessagingNotification( - id: 2343, - title: 'Test conversation', - messages: messages, - channelId: channelId, - jid: 'testjid', - isGroupchat: true, - extra: { - 'jid': 'testjid', - 'avatarPath': 'lol', - 'rio': 'cute', - }, - ), - ); - }, - child: const Text('Show messaging notification'), - ), - ElevatedButton( - onPressed: () { - MoxplatformPlugin.notifications.showNotification( - RegularNotification( - id: 4384, - title: 'Warning', - body: 'Something brokey', - channelId: otherChannelId, - icon: NotificationIcon.warning, - ), - ); - }, - child: const Text('Show warning notification'), - ), - ElevatedButton( - onPressed: () { - MoxplatformPlugin.notifications.showNotification( - RegularNotification( - id: 4384, - title: 'Error', - body: "Lol, you're on your own", - channelId: otherChannelId, - icon: NotificationIcon.error, - ), - ); - }, - child: const Text('Show error notification'), - ), - ElevatedButton( - onPressed: () async { - final result = await FilePicker.platform.pickFiles( - type: FileType.image, - ); - if (result == null) return; - - MoxplatformPlugin.notifications - .setNotificationSelfAvatar(result.files.single.path!); - }, - child: const Text('Set notification self-avatar'), - ), ElevatedButton( onPressed: () async { // ignore: avoid_print diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 77cae0c..658bd97 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -40,8 +40,6 @@ dependencies: file_picker: 5.2.0+1 path: 1.8.3 - - permission_handler: 10.4.3 # The following adds the Cupertino Icons font to your application. # Use with the CupertinoIcons class for iOS style icons. diff --git a/packages/moxplatform_platform_interface/lib/src/api.g.dart b/packages/moxplatform_platform_interface/lib/src/api.g.dart index f7dfd5c..64c8dd7 100644 --- a/packages/moxplatform_platform_interface/lib/src/api.g.dart +++ b/packages/moxplatform_platform_interface/lib/src/api.g.dart @@ -61,7 +61,7 @@ class _MoxplatformApiCodec extends StandardMessageCodec { @override Object? readValueOfType(int type, ReadBuffer buffer) { switch (type) { - case 128: + case 128: return CryptographyResult.decode(readValue(buffer)!); default: return super.readValueOfType(type, buffer); @@ -82,10 +82,10 @@ class MoxplatformApi { /// Platform APIs Future getPersistentDataPath() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getPersistentDataPath', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getPersistentDataPath', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -109,10 +109,10 @@ class MoxplatformApi { Future getCacheDataPath() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getCacheDataPath', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.getCacheDataPath', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -136,10 +136,10 @@ class MoxplatformApi { Future openBatteryOptimisationSettings() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.openBatteryOptimisationSettings', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.openBatteryOptimisationSettings', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -158,10 +158,10 @@ class MoxplatformApi { Future isIgnoringBatteryOptimizations() async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.isIgnoringBatteryOptimizations', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.isIgnoringBatteryOptimizations', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send(null) as List?; + final List? replyList = await channel.send(null) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -184,12 +184,18 @@ class MoxplatformApi { } /// Contacts APIs - Future recordSentMessage(String arg_name, String arg_jid, String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async { + Future recordSentMessage(String arg_name, String arg_jid, + String? arg_avatarPath, FallbackIconType arg_fallbackIcon) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.recordSentMessage', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.recordSentMessage', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_name, arg_jid, arg_avatarPath, arg_fallbackIcon.index]) as List?; + final List? replyList = await channel.send([ + arg_name, + arg_jid, + arg_avatarPath, + arg_fallbackIcon.index + ]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -207,12 +213,25 @@ class MoxplatformApi { } /// Cryptography APIs - Future encryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async { + Future encryptFile( + String arg_sourcePath, + String arg_destPath, + Uint8List arg_key, + Uint8List arg_iv, + CipherAlgorithm arg_algorithm, + String arg_hashSpec) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.encryptFile', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.encryptFile', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List?; + final List? replyList = await channel.send([ + arg_sourcePath, + arg_destPath, + arg_key, + arg_iv, + arg_algorithm.index, + arg_hashSpec + ]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -229,12 +248,25 @@ class MoxplatformApi { } } - Future decryptFile(String arg_sourcePath, String arg_destPath, Uint8List arg_key, Uint8List arg_iv, CipherAlgorithm arg_algorithm, String arg_hashSpec) async { + Future decryptFile( + String arg_sourcePath, + String arg_destPath, + Uint8List arg_key, + Uint8List arg_iv, + CipherAlgorithm arg_algorithm, + String arg_hashSpec) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.decryptFile', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.decryptFile', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_sourcePath, arg_destPath, arg_key, arg_iv, arg_algorithm.index, arg_hashSpec]) as List?; + final List? replyList = await channel.send([ + arg_sourcePath, + arg_destPath, + arg_key, + arg_iv, + arg_algorithm.index, + arg_hashSpec + ]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -251,12 +283,14 @@ class MoxplatformApi { } } - Future hashFile(String arg_sourcePath, String arg_hashSpec) async { + Future hashFile( + String arg_sourcePath, String arg_hashSpec) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.hashFile', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.hashFile', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_sourcePath, arg_hashSpec]) as List?; + final List? replyList = await channel + .send([arg_sourcePath, arg_hashSpec]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error', @@ -274,12 +308,14 @@ class MoxplatformApi { } /// Media APIs - Future generateVideoThumbnail(String arg_src, String arg_dest, int arg_maxWidth) async { + Future generateVideoThumbnail( + String arg_src, String arg_dest, int arg_maxWidth) async { final BasicMessageChannel channel = BasicMessageChannel( - 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.generateVideoThumbnail', codec, + 'dev.flutter.pigeon.moxplatform_platform_interface.MoxplatformApi.generateVideoThumbnail', + codec, binaryMessenger: _binaryMessenger); - final List? replyList = - await channel.send([arg_src, arg_dest, arg_maxWidth]) as List?; + final List? replyList = await channel + .send([arg_src, arg_dest, arg_maxWidth]) as List?; if (replyList == null) { throw PlatformException( code: 'channel-error',