diff --git a/assets/sounds/aaa.mp3 b/assets/sounds/aaa.mp3 new file mode 100644 index 0000000..01fb86d Binary files /dev/null and b/assets/sounds/aaa.mp3 differ diff --git a/assets/sounds/asbeep.mp3 b/assets/sounds/asbeep.mp3 new file mode 100644 index 0000000..7bead27 Binary files /dev/null and b/assets/sounds/asbeep.mp3 differ diff --git a/assets/sounds/job_received.mp3 b/assets/sounds/job_received.mp3 new file mode 100644 index 0000000..a020280 Binary files /dev/null and b/assets/sounds/job_received.mp3 differ diff --git a/lib/content_views/accepted_jobs_page.dart b/lib/content_views/accepted_jobs_page.dart index fbc1cdc..6e5a434 100644 --- a/lib/content_views/accepted_jobs_page.dart +++ b/lib/content_views/accepted_jobs_page.dart @@ -24,7 +24,7 @@ class AcceptedJobsPage extends ContentViewWidget { 'Angenommene Aufträge', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: false, diff --git a/lib/content_views/approach_area_page.dart b/lib/content_views/approach_area_page.dart index 16d55f1..984064d 100644 --- a/lib/content_views/approach_area_page.dart +++ b/lib/content_views/approach_area_page.dart @@ -3,7 +3,6 @@ import 'package:isar/isar.dart'; import 'package:stadtbote/content_views/tour_list_page.dart'; import 'package:stadtbote/content_views/utils/content_view_widget.dart'; import 'package:stadtbote/content_views/utils/header_info.dart'; -import 'package:intl/intl.dart'; import 'package:stadtbote/tools/message_service.dart'; import '../main.dart'; @@ -24,12 +23,12 @@ class ApproachAreaPage extends ContentViewWidget { 'Angenommene Aufträge', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: true, rightButtonVisible: true, - rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)), + rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.help_outline, size: 20.0, color: Colors.white)), rightButtonOnPressed: () async { await Util.startBrowser('https://app.assecutor.de/help/sb/app/context/001/index.html'); }); diff --git a/lib/content_views/assigned_jobs_page.dart b/lib/content_views/assigned_jobs_page.dart index f054d4f..33180db 100644 --- a/lib/content_views/assigned_jobs_page.dart +++ b/lib/content_views/assigned_jobs_page.dart @@ -27,7 +27,7 @@ class AssignedJobsPage extends ContentViewWidget { 'Zugewiesene Aufträge', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: false, diff --git a/lib/content_views/finished_jobs_page.dart b/lib/content_views/finished_jobs_page.dart index cd538c6..2bd651d 100644 --- a/lib/content_views/finished_jobs_page.dart +++ b/lib/content_views/finished_jobs_page.dart @@ -24,7 +24,7 @@ class FinishedJobsPage extends ContentViewWidget { 'Erledigte Aufträge', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: false, diff --git a/lib/content_views/main_page.dart b/lib/content_views/main_page.dart index fe37387..cb108c6 100644 --- a/lib/content_views/main_page.dart +++ b/lib/content_views/main_page.dart @@ -235,22 +235,6 @@ class _MainPageState extends State { ); } - /*_test() async { - var json = await rootBundle.loadString('assets/job.json'); - var jsonMap = jsonDecode(json); - var payload = jsonMap["payload"]; - - var jobsPayload = JobsPayload.fromJson(payload); - - if (jobsPayload.jobs != null) { - MyApp.isarInstance.writeTxnSync(() { - for (var job in jobsPayload.jobs as List) { - MyApp.isarInstance.jobs.putSync(job); - } - }); - } - }*/ - _initMessages() { MessageService().subscribe(Constants.messageTopicStatusInfoUpdate, this, (statusInfoUpdateMessage) { widget.sidValueNotifier.value = statusInfoUpdateMessage.status.sid; diff --git a/lib/content_views/messages_page.dart b/lib/content_views/messages_page.dart index b8a46bc..4ad4d5a 100644 --- a/lib/content_views/messages_page.dart +++ b/lib/content_views/messages_page.dart @@ -26,12 +26,12 @@ class MessagesPage extends ContentViewWidget { 'Nachrichten', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: true, rightButtonVisible: true, - rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)), + rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.help_outline, size: 20.0, color: Colors.white)), rightButtonOnPressed: () async { await Util.startBrowser('https://app.assecutor.de/help/sb/app/context/003/index.html'); }); diff --git a/lib/content_views/task_list_page.dart b/lib/content_views/task_list_page.dart index de3974d..5ac8187 100644 --- a/lib/content_views/task_list_page.dart +++ b/lib/content_views/task_list_page.dart @@ -43,12 +43,12 @@ class TaskListPage extends ContentViewWidget { 'Liste der Aufgaben', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: true, rightButtonVisible: true, - rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)), + rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.help_outline, size: 20.0, color: Colors.white)), rightButtonOnPressed: () async { await Util.startBrowser('https://app.assecutor.de/help/sb/app/context/002/index.html'); }); diff --git a/lib/content_views/tour_details_page.dart b/lib/content_views/tour_details_page.dart index 90ad3c2..6d98442 100644 --- a/lib/content_views/tour_details_page.dart +++ b/lib/content_views/tour_details_page.dart @@ -29,7 +29,7 @@ class TourDetailsPage extends ContentViewWidget { 'Details der Station', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: false, diff --git a/lib/content_views/tour_list_page.dart b/lib/content_views/tour_list_page.dart index b67a55f..7381899 100644 --- a/lib/content_views/tour_list_page.dart +++ b/lib/content_views/tour_list_page.dart @@ -27,12 +27,12 @@ class TourListPage extends ContentViewWidget { 'Liste der Stationen', style: TextStyle( color: Colors.white, - fontSize: 24.0, + fontSize: 20.0, ), ), rightButtonEnabled: true, rightButtonVisible: true, - rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.info_outline, size: 20.0, color: Colors.white)), + rightButtonImage: Util.fetchFutureIcon(const Icon(Icons.help_outline, size: 20.0, color: Colors.white)), rightButtonOnPressed: () async { await Util.startBrowser('https://app.assecutor.de/help/sb/app/context/004/index.html'); }); diff --git a/lib/tools/mqtt_core.dart b/lib/tools/mqtt_core.dart index d52138a..10f8ef5 100644 --- a/lib/tools/mqtt_core.dart +++ b/lib/tools/mqtt_core.dart @@ -144,7 +144,7 @@ class MqttCore { _mqttClient.updates?.listen((List> c) { try { final MqttPublishMessage message = c[0].payload as MqttPublishMessage; - final payload = MqttPublishPayload.bytesToStringAsString(message.payload.message); + String payload = utf8.decode(MqttPublishPayload.bytesToStringAsString(message.payload.message).codeUnits); var topic = message.variableHeader?.topicName; Util.logInfo('message received'); @@ -238,6 +238,14 @@ class MqttCore { MyApp.isarInstance.jobs.putSync(newJob); }); + if (newJob.state == 0) { + if (newJob.global) { + await Util.playMp3('aaa.mp3'); + } else { + await Util.playMp3('job_received.mp3'); + } + } + MessageService().publish(Constants.messageTopicJobReceived, arguments: JobReceivedMessage(job: newJob)); } } @@ -259,15 +267,7 @@ class MqttCore { void _syncRequestReceived(payloadData) async { Util.logInfo('_syncRequestReceived'); - /*for (var foundJobData in payloadData) { - Job newJob = Job.fromJson(foundJobData); - - await MyApp.isarInstance.writeTxn(() async { - await MyApp.isarInstance.jobs.put(newJob); - }); - - BroadcastReceiver().publish(Constants.messageTopicJobReceived, arguments: JobReceivedMessage(job: newJob)); - }*/ + _sendSyncMessage(); } void _messageMessageReceived(Map payloadData) async { @@ -277,6 +277,8 @@ class MqttCore { await MyApp.isarInstance.messages.put(newMessage); }); + await Util.playMp3('asbeep.mp3'); + MessageService().publish(Constants.messageTopicMessageReceived, arguments: MessageReceivedMessage(message: newMessage)); } @@ -400,7 +402,7 @@ class MqttCore { } void _cancelTrackTimer() { - if (_trackTimer != null) { + if (_trackTimer != null && _trackTimer!.isActive) { _trackTimer!.cancel(); } } diff --git a/lib/tools/util.dart b/lib/tools/util.dart index 9853855..b842685 100644 --- a/lib/tools/util.dart +++ b/lib/tools/util.dart @@ -1,5 +1,6 @@ import 'dart:io'; +import 'package:audioplayers/audioplayers.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; @@ -181,45 +182,14 @@ class Util { throw Exception('Could not launch $websiteUrl'); } } + + static Future playMp3(String name) async { + final player = AudioPlayer(); + await player.play(AssetSource('sounds/$name'), volume: 1); + } } Widget getDefaultButton(String text, Function() onPressed, {Image? image, double? buttonHeight}) { - /*return SizedBox( - height: buttonHeight ?? 60, - child: Stack( - fit: StackFit.expand, - children: [ - Row( - children: [ - Padding( - padding: const EdgeInsets.all(0), - child: Expanded( - child: SizedBox( - height: 60, - child: ElevatedButton( - style: ButtonStyle( - shape: MaterialStateProperty.all( - RoundedRectangleBorder( - borderRadius: BorderRadius.circular(8.0), - side: const BorderSide(color: Colors.grey), - ), - ), - backgroundColor: MaterialStateProperty.all(const Color.fromARGB(255, 220, 220, 220)), - foregroundColor: MaterialStateProperty.all(Colors.black), - ), - onPressed: () { - onPressed(); - }, - child: Text(text)), - ), - ), - ), - ], - ), - Positioned(left: 20, top: 15, child: Center(child: image)) - ], - ), - );*/ return SizedBox( height: buttonHeight ?? 50, child: MaterialButton( @@ -244,7 +214,7 @@ Widget getDefaultButton(String text, Function() onPressed, {Image? image, double Expanded( child: Text( text, - style: const TextStyle(color: Colors.black, fontSize: 18.0), + style: const TextStyle(color: Colors.black, fontSize: 14.0), textAlign: TextAlign.center, ), ), diff --git a/pubspec.lock b/pubspec.lock index 0a3e057..28203b5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -57,6 +57,62 @@ packages: url: "https://pub.dev" source: hosted version: "2.11.0" + audioplayers: + dependency: "direct main" + description: + name: audioplayers + sha256: c05c6147124cd63e725e861335a8b4d57300b80e6e92cea7c145c739223bbaef + url: "https://pub.dev" + source: hosted + version: "5.2.1" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + sha256: b00e1a0e11365d88576320ec2d8c192bc21f1afb6c0e5995d1c57ae63156acb5 + url: "https://pub.dev" + source: hosted + version: "4.0.3" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + sha256: "3034e99a6df8d101da0f5082dcca0a2a99db62ab1d4ddb3277bed3f6f81afe08" + url: "https://pub.dev" + source: hosted + version: "5.0.2" + audioplayers_linux: + dependency: transitive + description: + name: audioplayers_linux + sha256: "60787e73fefc4d2e0b9c02c69885402177e818e4e27ef087074cf27c02246c9e" + url: "https://pub.dev" + source: hosted + version: "3.1.0" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + sha256: "365c547f1bb9e77d94dd1687903a668d8f7ac3409e48e6e6a3668a1ac2982adb" + url: "https://pub.dev" + source: hosted + version: "6.1.0" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + sha256: "22cd0173e54d92bd9b2c80b1204eb1eb159ece87475ab58c9788a70ec43c2a62" + url: "https://pub.dev" + source: hosted + version: "4.1.0" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + sha256: "9536812c9103563644ada2ef45ae523806b0745f7a78e89d1b5fb1951de90e1a" + url: "https://pub.dev" + source: hosted + version: "3.1.0" badges: dependency: "direct main" description: @@ -1197,6 +1253,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + synchronized: + dependency: transitive + description: + name: synchronized + sha256: "539ef412b170d65ecdafd780f924e5be3f60032a1128df156adad6c5b373d558" + url: "https://pub.dev" + source: hosted + version: "3.1.0+1" term_glyph: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 8921e09..b076b45 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -67,6 +67,7 @@ dependencies: geolocator: ^10.1.0 expandable: ^5.0.1 url_launcher: ^6.2.4 + audioplayers: ^5.2.1 dev_dependencies: flutter_test: @@ -96,6 +97,7 @@ flutter: assets: - assets/ + - assets/sounds/ # To add assets to your application, add an assets section, like this: # assets: