Before changing into provider!

faiz_dev_new
FaizHashmiCS22 2 years ago
parent 0ac7d68a65
commit 1a3ed42951

@ -3,8 +3,7 @@
package="com.example.queuing_system"> package="com.example.queuing_system">
<uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" /> <uses-permission android:name="android.permission.RECEIVE_BOOT_COMPLETED" />
<uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
<queries> <queries>
<intent> <intent>

@ -51,13 +51,21 @@ class _MyHomePageState extends State<MyHomePage> {
} }
Future<String> getCurrentIP() async { Future<String> getCurrentIP() async {
for (var interface in await NetworkInterface.list(type: InternetAddressType.IPv4)) { final ips = await NetworkInterface.list(type: InternetAddressType.IPv4);
log("interfaces: ${interface.name}"); for (var interface in ips) {
//TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN //TODO: WE WILL UPDATE THIS WHEN TESTING ON SCREEN
// if (interface.name == "wlan0") { // if (interface.name == "wlan0") {
if (interface.name == "eth0") { if (interface.name == "eth0") {
for (var address in interface.addresses) { for (var address in interface.addresses) {
deviceIPGlobal = address.address; 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; return deviceIPGlobal;
} }
} }
@ -76,7 +84,12 @@ class _MyHomePageState extends State<MyHomePage> {
signalRHelper.startSignalRConnection(await getCurrentIP(), onUpdateAvailable: onUpdateAvailable, onConnect: onConnect, onConnecting: onConnecting, onDisconnect: onDisconnect); 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(); super.initState();
} }
@ -84,11 +97,6 @@ class _MyHomePageState extends State<MyHomePage> {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
audioPlayer.playerStateStream.listen((playerState) {
if (playerState.processingState == ProcessingState.completed) {
isCallingInProgress = false;
}
});
return AppScaffold( return AppScaffold(
appBar: AppHeader(), appBar: AppHeader(),
body: dataContent(audioPlayer), body: dataContent(audioPlayer),
@ -152,6 +160,11 @@ class _MyHomePageState extends State<MyHomePage> {
Widget dataContent(AudioPlayer audioPlayer) { Widget dataContent(AudioPlayer audioPlayer) {
voiceCall(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) { if (waitings.isEmpty) {
// No Patient in Queue // No Patient in Queue
@ -209,12 +222,14 @@ class _MyHomePageState extends State<MyHomePage> {
audioPlayer.setAsset("assets/tones/call_tone.mp3"); audioPlayer.setAsset("assets/tones/call_tone.mp3");
await audioPlayer.play(); await audioPlayer.play();
await Future.delayed(const Duration(seconds: 2)); await Future.delayed(const Duration(seconds: 2));
isCallingInProgress = false;
} }
if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) { if (waitings.first.isVoiceReq && voiceCaller == null && !waitings.first.isQueue) {
final postVoice = getCallTypeText(waitings.first, callConfigsGlobal); 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()); await voiceCaller.startCalling(waitings.first.queueNo.trim().toString() != waitings.first.callNoStr.trim().toString());
voiceCaller = null; voiceCaller = null;
isCallingInProgress = false;
} }
} }
if (isQueuePatients.isNotEmpty) { if (isQueuePatients.isNotEmpty) {
@ -259,7 +274,11 @@ class _MyHomePageState extends State<MyHomePage> {
API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) { API.getCallRequestInfoByClinicInfo(deviceIPGlobal, onSuccess: (waitingCalls, isQueuePatientsCalls, callConfigs) {
setState(() { setState(() {
callConfigsGlobal = callConfigs; callConfigsGlobal = callConfigs;
waitings = waitingCalls; if (waitingCalls.length > callConfigsGlobal.screenMaxDisplayPatients) {
waitings = waitingCalls.sublist(0, callConfigsGlobal.screenMaxDisplayPatients);
} else {
waitings = waitingCalls;
}
isQueuePatients = isQueuePatientsCalls; isQueuePatients = isQueuePatientsCalls;
// currents = currentInClinic; // currents = currentInClinic;
}); });
@ -279,8 +298,11 @@ class _MyHomePageState extends State<MyHomePage> {
// return; // return;
// } // }
if (waitings.isNotEmpty) { if (waitings.isNotEmpty) {
print("isCallingInProgress: ${isCallingInProgress}");
print("voiceCaller: ${voiceCaller == null}");
if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) { if ((waitings.first.isToneReq && isCallingInProgress) || (waitings.first.isVoiceReq && voiceCaller != null)) {
// if (true) { // if (true) {
print("I will wait now for ${callConfigsGlobal.concurrentCallDelaySec} seconds");
Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async { Timer(Duration(seconds: callConfigsGlobal.concurrentCallDelaySec), () async {
await callPatientsAPI(); await callPatientsAPI();
}); });
@ -317,9 +339,10 @@ class _MyHomePageState extends State<MyHomePage> {
} }
listenNetworkConnectivity() async { listenNetworkConnectivity() async {
Connectivity().onConnectivityChanged.listen((event) { Connectivity().onConnectivityChanged.listen((event) async {
switch (event) { switch (event) {
case ConnectivityResult.wifi: case ConnectivityResult.wifi:
await getCurrentIP();
signalRHelper.connection.start(); signalRHelper.connection.start();
break; break;
case ConnectivityResult.none: case ConnectivityResult.none:

@ -7,17 +7,20 @@ class CallByVoice {
final String ticketNo; final String ticketNo;
final String postVoice; 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(); final FlutterTts textToSpeech = FlutterTts();
double volume = 1.0; double volume = 1.0;
double pitch = 0.9; double pitch = 0.6;
double rate = 0.5; double rate = 0.2;
Future<dynamic> _getLanguages() async => await textToSpeech.getLanguages;
startCalling(bool isClinicNameAdded) async { 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 clinicName = "";
String patientAlpha = ""; String patientAlpha = "";
String patientNumeric = ""; String patientNumeric = "";
@ -31,12 +34,12 @@ class CallByVoice {
patientAlpha = ticketNo.split("-")[0]; patientAlpha = ticketNo.split("-")[0];
patientNumeric = ticketNo.split("-")[1]; patientNumeric = ticketNo.split("-")[1];
} }
textToSpeech.setLanguage("en-US"); await textToSpeech.setLanguage("en-US");
// Create Pre Voice Players // Create Pre Voice Players
if (preVoice != null && preVoice.isNotEmpty) { if (preVoice != null && preVoice.isNotEmpty) {
textToSpeech.setSpeechRate(rate); textToSpeech.setSpeechRate(0.4);
textToSpeech.setPitch(pitch); textToSpeech.setPitch(0.9);
textToSpeech.setVolume(volume); textToSpeech.setVolume(1.0);
await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice); await textToSpeech.speak(preVoice + " .. " + clinicName + " .. " + patientAlpha + " .. " + patientNumeric + " .. " + postVoice);
} }

Loading…
Cancel
Save