diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml
index a8c9e0b..ee55fc8 100644
--- a/android/app/src/main/AndroidManifest.xml
+++ b/android/app/src/main/AndroidManifest.xml
@@ -3,8 +3,7 @@
package="com.example.queuing_system">
-
-
+
diff --git a/lib/home/home_screen.dart b/lib/home/home_screen.dart
index e548b45..c875c94 100644
--- a/lib/home/home_screen.dart
+++ b/lib/home/home_screen.dart
@@ -51,13 +51,21 @@ class _MyHomePageState extends State {
}
Future getCurrentIP() async {
- for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) {
- log("interfaces: ${interface.name}");
+ final ips = await NetworkInterface.list(type: InternetAddressType.IPv4);
+ for (var interface in ips) {
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
// if (interface.name == "wlan0") {
if (interface.name == "eth0") {
for (var address in interface.addresses) {
deviceIPGlobal = address.address;
+ print("IP with eth0: ${address.address}");
+ return deviceIPGlobal;
+ }
+ }
+ if (interface.name == "wlan0") {
+ for (var address in interface.addresses) {
+ deviceIPGlobal = address.address;
+ print("IP with wlan0: ${address.address}");
return deviceIPGlobal;
}
}
@@ -76,7 +84,12 @@ class _MyHomePageState extends State {
signalRHelper.startSignalRConnection(await getCurrentIP(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect);
}
});
-
+ audioPlayer.playerStateStream.listen((playerState) {
+ if (playerState.processingState == ProcessingState.completed) {
+ isCallingInProgress = false;
+ print("isCallingInProgress in Stream: $isCallingInProgress");
+ }
+ });
super.initState();
}
@@ -84,11 +97,6 @@ class _MyHomePageState extends State {
@override
Widget build(BuildContext context) {
- audioPlayer.playerStateStream.listen((playerState) {
- if (playerState.processingState == ProcessingState.completed) {
- isCallingInProgress = false;
- }
- });
return AppScaffold(
appBar: AppHeader(),
body: dataContent(audioPlayer),
@@ -152,6 +160,11 @@ class _MyHomePageState extends State {
Widget dataContent(AudioPlayer audioPlayer) {
voiceCall(audioPlayer);
+ // print("wlength: ${waitings.length}");
+ // if (waitings.length > callConfigsGlobal.screenMaxDisplayPatients) {
+ // final newList = waitings.sublist(0, callConfigsGlobal.screenMaxDisplayPatients );
+ // print("wlength: ${newList.length}");
+ // }
if (waitings.isEmpty) {
// No Patient in Queue
@@ -209,12 +222,14 @@ class _MyHomePageState extends State {
audioPlayer.setAsset("assets/tones/call_tone.mp3");
await audioPlayer.play();
await Future.delayed(const Duration(seconds: 2));
+ isCallingInProgress = false;
}
if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) {
final postVoice = getCallTypeText(waitings.first, callConfigsGlobal);
- voiceCaller = CallByVoice(waitings.first.queueNo.trim().toString(), preVoice: "Ticket Number", postVoice: postVoice, lang: 'en');
+ voiceCaller = CallByVoice(preVoice: "Ticket Number", ticketNo: waitings.first.queueNo.trim().toString(), postVoice: postVoice, lang: 'en');
await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
voiceCaller = null;
+ isCallingInProgress = false;
}
}
if (isQueuePatients.isNotEmpty) {
@@ -259,7 +274,11 @@ class _MyHomePageState extends State {
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) {
setState(() {
callConfigsGlobal = callConfigs;
- waitings = waitingCalls;
+ if (waitingCalls.length > callConfigsGlobal.screenMaxDisplayPatients) {
+ waitings = waitingCalls.sublist(0, callConfigsGlobal.screenMaxDisplayPatients);
+ } else {
+ waitings = waitingCalls;
+ }
isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic;
});
@@ -279,8 +298,11 @@ class _MyHomePageState extends State {
// return;
// }
if (waitings.isNotEmpty) {
+ print("isCallingInProgress: ${isCallingInProgress}");
+ print("voiceCaller: ${voiceCaller == null}");
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
// if (true) {
+ print("I will wait now for ${callConfigsGlobal.concurrentCallDelaySec} seconds");
Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async {
await callPatientsAPI();
});
@@ -317,9 +339,10 @@ class _MyHomePageState extends State {
}
listenNetworkConnectivity() async {
- Connectivity().onConnectivityChanged.listen((event) {
+ Connectivity().onConnectivityChanged.listen((event) async {
switch (event) {
case ConnectivityResult.wifi:
+ await getCurrentIP();
signalRHelper.connection.start();
break;
case ConnectivityResult.none:
diff --git a/lib/utils/call_by_voice.dart b/lib/utils/call_by_voice.dart
index 739544b..0c5720d 100644
--- a/lib/utils/call_by_voice.dart
+++ b/lib/utils/call_by_voice.dart
@@ -7,17 +7,20 @@ class CallByVoice {
final String ticketNo;
final String postVoice;
- CallByVoice(this.ticketNo, {this.lang = 'en', @required this.preVoice, @required this.postVoice});
+ CallByVoice({this.lang = 'en', @required this.ticketNo, @required this.preVoice, @required this.postVoice});
final FlutterTts textToSpeech = FlutterTts();
double volume = 1.0;
- double pitch = 0.9;
- double rate = 0.5;
-
- Future _getLanguages() async => await textToSpeech.getLanguages;
+ double pitch = 0.6;
+ double rate = 0.2;
startCalling(bool isClinicNameAdded) async {
+ // print("langs: ${(await textToSpeech.setEngine("com.google.android.tts"))}");
+ print("langs: ${(await textToSpeech.getVoices).toString()}");
+ print("langs: ${(await textToSpeech.getLanguages).toString()}");
+ print("langs: ${(await textToSpeech.getEngines).toString()}");
+
String clinicName = "";
String patientAlpha = "";
String patientNumeric = "";
@@ -31,12 +34,12 @@ class CallByVoice {
patientAlpha = ticketNo.split("-")[0];
patientNumeric = ticketNo.split("-")[1];
}
- textToSpeech.setLanguage("en-US");
+ await textToSpeech.setLanguage("en-US");
// Create Pre Voice Players
if (preVoice != null && preVoice.isNotEmpty) {
- textToSpeech.setSpeechRate(rate);
- textToSpeech.setPitch(pitch);
- textToSpeech.setVolume(volume);
+ textToSpeech.setSpeechRate(0.4);
+ textToSpeech.setPitch(0.9);
+ textToSpeech.setVolume(1.0);
await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
}