diff --git a/lib/constants/app_constants.dart b/lib/constants/app_constants.dart index af2df4e..473bda8 100644 --- a/lib/constants/app_constants.dart +++ b/lib/constants/app_constants.dart @@ -167,7 +167,7 @@ class AppConstants { static String apiKey = 'EE17D21C7943485D9780223CCE55DCE5'; static String testIP = '12.4.5.1'; // projectID.QlineType.ScreenType.AnyNumber (1 to 10) static int thresholdForListUI = 5; - static double currentBuildVersion = 8.9; + static double currentBuildVersion = 9.1; static double clearLogsHoursThreshold = 48; } diff --git a/lib/main.dart b/lib/main.dart index d7c139d..e7ed40f 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,14 +13,12 @@ import 'package:wakelock_plus/wakelock_plus.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); - try { await AppDependencies.addDependencies(); await WakelockPlus.enable(); } catch (e) { log('Initialization error: $e'); } - runApp(const MyApp()); } diff --git a/lib/models/global_config_model.dart b/lib/models/global_config_model.dart index 6127b01..3a95e8d 100644 --- a/lib/models/global_config_model.dart +++ b/lib/models/global_config_model.dart @@ -203,9 +203,8 @@ class GlobalConfigurationsModel { screenLanguageText = json['screenLanguageText']; // textDirection = json['textDirection'] == 2 ? TextDirection.rtl : TextDirection.ltr; textDirection = TextDirection.rtl; - // screenMaxDisplayPatients = json['screenMaxDisplayPatients'] ?? 16; - // TODO: Uncomment this screenMaxDisplayPatients - screenMaxDisplayPatients = 15; + screenMaxDisplayPatients = json['screenMaxDisplayPatients'] ?? 16; + // screenMaxDisplayPatients = 15; voiceLanguageEnum = (json['voiceLanguage'] as int).toLanguageEnum(); voiceLanguageText = json['voiceLanguageText']; isNotiReq = json['isNotiReq']; diff --git a/lib/services/text_to_speech_service.dart b/lib/services/text_to_speech_service.dart index fb26420..868dafb 100644 --- a/lib/services/text_to_speech_service.dart +++ b/lib/services/text_to_speech_service.dart @@ -15,7 +15,7 @@ abstract class TextToSpeechService { bool isMute = false, }); - Future speechTextTest(TicketData ticket); + // Future speechTextTest(TicketData ticket); void listenToTextToSpeechEvents({required Function() onVoiceCompleted}); } @@ -31,119 +31,120 @@ class TextToSpeechServiceImp implements TextToSpeechService { Map arabicVoice = {"name": "ar-xa-x-ard-local", "locale": "ar"}; @override - Future speechTextTest(TicketData ticket) async { - const ttsGoogleEngine = 'com.google.android.tts'; - LanguageEnum langEnum = ticket.voiceLanguageEnum; - List engines = await textToSpeechInstance.getEngines; - if (engines.contains(ttsGoogleEngine)) { - await textToSpeechInstance.setEngine(ttsGoogleEngine); - } - textToSpeechInstance.setVolume(1.0); - - // final voices = await textToSpeechInstance.getVoices; - // log ("voices:: $voices"); - - await textToSpeechInstance.setVoice(arabicVoice); - - if (langEnum == LanguageEnum.arabic) { - try { - await textToSpeechInstance.setLanguage(LanguageEnum.arabic.enumToString()); - } catch (e) { - log("error setting language english: ${e.toString()}"); - } - } else if (langEnum == LanguageEnum.english) { - try { - await textToSpeechInstance.setLanguage(LanguageEnum.english.enumToString()); - } catch (e) { - log("error setting language english: ${e.toString()}"); - } - } - String preVoice = ticket.ticketNoText; - String postVoice = ticket.postVoiceText; - if (preVoice.isNotEmpty) { - preVoice = '$preVoice..'; - } - String ticketNo = ticket.queueNo!.trim().toString(); - - log("areLanguagesInstalled: ${await textToSpeechInstance.areLanguagesInstalled(["en", "ar"])}"); - - log("lang: $langEnum"); - log("preVoice: $preVoice"); - log("postVoice: $postVoice"); - log("ticketNo: $ticketNo"); - - String patientAlpha = ""; - String patientNumeric = ""; - String clinicName = ""; - - bool isClinicNameAdded = (ticket.queueNo != ticket.callNoStr); - - if (isClinicNameAdded) { - var queueNo = ""; - var clinic = ticketNo.split(" "); - if (clinic.length > 1) { - clinicName = clinic[0]; - queueNo = clinic[1]; - } else { - queueNo = ticketNo; - } - - var queueNoArray = queueNo.split("-"); - if (queueNoArray.length > 2) { - patientAlpha = "${queueNoArray[0]} .. ${queueNoArray[1]}"; - patientNumeric = queueNoArray[2]; - } else { - patientAlpha = queueNoArray[0]; - patientNumeric = queueNoArray[1]; - } - } else { - var queueNoArray = ticketNo.split("-"); - if (queueNoArray.length > 2) { - patientAlpha = "${queueNoArray[0]} .. ${queueNoArray[1]}"; - patientNumeric = queueNoArray[2]; - } else { - patientAlpha = queueNoArray[0]; - patientNumeric = queueNoArray[1]; - } - } - - patientAlpha = patientAlpha.split('').join(' .. '); - String roomNo = ""; - - log("I will now all this:{ $preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo } "); - - if (langEnum == LanguageEnum.english) { - await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo"); - return; - } - - if (isNeedToBreakVoiceForArabic) { - await textToSpeechInstance.awaitSpeakCompletion(true); - - isSpeechCompleted = false; - if (preVoice.isNotEmpty) { - await textToSpeechInstance.speak("$preVoice "); - } - try { - await textToSpeechInstance.setLanguage(LanguageEnum.english.enumToString()); - } catch (e) { - log("error setting language english: ${e.toString()}"); - } - await textToSpeechInstance.speak("$patientAlpha .. $patientNumeric"); - - try { - await textToSpeechInstance.setLanguage(langEnum.enumToString()); - } catch (e) { - log("error setting language langEnum: ${e.toString()}"); - } - - await textToSpeechInstance.speak("$postVoice $roomNo").whenComplete(() { - isSpeechCompleted = true; - }); - } else { - await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo"); - } - } + // Future speechTextTest(TicketData ticket) async { + // const ttsGoogleEngine = 'com.google.android.tts'; + // LanguageEnum langEnum = ticket.voiceLanguageEnum; + // List engines = await textToSpeechInstance.getEngines; + // if (engines.contains(ttsGoogleEngine)) { + // await textToSpeechInstance.setEngine(ttsGoogleEngine); + // } + // + // textToSpeechInstance.setVolume(1.0); + // + // // final voices = await textToSpeechInstance.getVoices; + // // log ("voices:: $voices"); + // + // await textToSpeechInstance.setVoice(arabicVoice); + // + // if (langEnum == LanguageEnum.arabic) { + // try { + // await textToSpeechInstance.setLanguage(LanguageEnum.arabic.enumToString()); + // } catch (e) { + // log("error setting language english: ${e.toString()}"); + // } + // } else if (langEnum == LanguageEnum.english) { + // try { + // await textToSpeechInstance.setLanguage(LanguageEnum.english.enumToString()); + // } catch (e) { + // log("error setting language english: ${e.toString()}"); + // } + // } + // String preVoice = ticket.ticketNoText; + // String postVoice = ticket.postVoiceText; + // if (preVoice.isNotEmpty) { + // preVoice = '$preVoice..'; + // } + // String ticketNo = ticket.queueNo!.trim().toString(); + // + // log("areLanguagesInstalled: ${await textToSpeechInstance.areLanguagesInstalled(["en", "ar"])}"); + // + // log("lang: $langEnum"); + // log("preVoice: $preVoice"); + // log("postVoice: $postVoice"); + // log("ticketNo: $ticketNo"); + // + // String patientAlpha = ""; + // String patientNumeric = ""; + // String clinicName = ""; + // + // bool isClinicNameAdded = (ticket.queueNo != ticket.callNoStr); + // + // if (isClinicNameAdded) { + // var queueNo = ""; + // var clinic = ticketNo.split(" "); + // if (clinic.length > 1) { + // clinicName = clinic[0]; + // queueNo = clinic[1]; + // } else { + // queueNo = ticketNo; + // } + // + // var queueNoArray = queueNo.split("-"); + // if (queueNoArray.length > 2) { + // patientAlpha = "${queueNoArray[0]} .. ${queueNoArray[1]}"; + // patientNumeric = queueNoArray[2]; + // } else { + // patientAlpha = queueNoArray[0]; + // patientNumeric = queueNoArray[1]; + // } + // } else { + // var queueNoArray = ticketNo.split("-"); + // if (queueNoArray.length > 2) { + // patientAlpha = "${queueNoArray[0]} .. ${queueNoArray[1]}"; + // patientNumeric = queueNoArray[2]; + // } else { + // patientAlpha = queueNoArray[0]; + // patientNumeric = queueNoArray[1]; + // } + // } + // + // patientAlpha = patientAlpha.split('').join(' .. '); + // String roomNo = ""; + // + // log("I will now all this:{ $preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo } "); + // + // if (langEnum == LanguageEnum.english) { + // await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo"); + // return; + // } + // + // if (isNeedToBreakVoiceForArabic) { + // await textToSpeechInstance.awaitSpeakCompletion(true); + // + // isSpeechCompleted = false; + // if (preVoice.isNotEmpty) { + // await textToSpeechInstance.speak("$preVoice "); + // } + // try { + // await textToSpeechInstance.setLanguage(LanguageEnum.english.enumToString()); + // } catch (e) { + // log("error setting language english: ${e.toString()}"); + // } + // await textToSpeechInstance.speak("$patientAlpha .. $patientNumeric"); + // + // try { + // await textToSpeechInstance.setLanguage(langEnum.enumToString()); + // } catch (e) { + // log("error setting language langEnum: ${e.toString()}"); + // } + // + // await textToSpeechInstance.speak("$postVoice $roomNo").whenComplete(() { + // isSpeechCompleted = true; + // }); + // } else { + // await textToSpeechInstance.speak("$preVoice .. $clinicName .. $patientAlpha .. $patientNumeric .. $postVoice $roomNo"); + // } + // } @override Future speechText({ @@ -151,7 +152,7 @@ class TextToSpeechServiceImp implements TextToSpeechService { required GlobalConfigurationsModel globalConfigurationsModel, bool isMute = false, }) async { - log("ticketdata i got: ${ticket.ticketModel.toString()}"); + log("ticket data i got: ${ticket.ticketModel.toString()}"); const ttsGoogleEngine = 'com.google.android.tts'; LanguageEnum langEnum = ticket.ticketModel!.voiceLanguageEnum; List engines = await textToSpeechInstance.getEngines; @@ -159,6 +160,7 @@ class TextToSpeechServiceImp implements TextToSpeechService { await textToSpeechInstance.setEngine(ttsGoogleEngine); } + log("engines: $engines"); await textToSpeechInstance.setVoice(arabicVoice); if (isMute) { @@ -166,6 +168,8 @@ class TextToSpeechServiceImp implements TextToSpeechService { } else { textToSpeechInstance.setVolume(1.0); } + + textToSpeechInstance.setSpeechRate(0.4); if (langEnum == LanguageEnum.arabic) { try { await textToSpeechInstance.setLanguage(LanguageEnum.arabic.enumToString()); diff --git a/lib/view_models/queuing_view_model.dart b/lib/view_models/queuing_view_model.dart index eadc77c..6671ca4 100644 --- a/lib/view_models/queuing_view_model.dart +++ b/lib/view_models/queuing_view_model.dart @@ -191,10 +191,6 @@ class QueuingViewModel extends ChangeNotifier { notifyListeners(); } - Future testSpeech() async { - textToSpeechService.speechTextTest(MockJsonRepo.ticket); - } - Future callTicketOnScreen({required TicketData? ticketData}) async { if (ticketData == null) return; ScreenConfigViewModel screenConfigViewModel = getIt.get(); diff --git a/lib/view_models/screen_config_view_model.dart b/lib/view_models/screen_config_view_model.dart index cd5263b..026e0e7 100644 --- a/lib/view_models/screen_config_view_model.dart +++ b/lib/view_models/screen_config_view_model.dart @@ -45,7 +45,7 @@ class ScreenConfigViewModel extends ChangeNotifier { await getLastTimeUpdatedFromCache(); await getLastTimeLogsClearedFromCache(); listenNetworkConnectivity(); - getTheWidgetsConfigurationsEveryMidnight(); + initializeTimer(); } Future onAppResumed() async { @@ -304,7 +304,7 @@ class ScreenConfigViewModel extends ChangeNotifier { DateTime lastChecked = DateTime.now(); Timer? _midnightTimer; - Future getTheWidgetsConfigurationsEveryMidnight() async { + Future initializeTimer() async { // Cancel any existing timer to avoid multiple timers running _midnightTimer?.cancel(); @@ -317,40 +317,46 @@ class ScreenConfigViewModel extends ChangeNotifier { return; } - _midnightTimer = Timer.periodic(const Duration(minutes: 10), (timer) async { - counter++; - DateTime now = DateTime.now(); - log("counterValue: $counter"); + _midnightTimer = Timer.periodic( + const Duration(minutes: 10), + (timer) async { + counter++; + DateTime now = DateTime.now(); + log("counterValue: $counter"); - // Every Two hour, update RSS feed if required - if (counter % 12 == 0 && globalConfigurationsModel.isRssFeedReq) { - await getRssFeedDetailsFromServer(); - } + if (globalConfigurationsModel.id == null) { + await getGlobalConfigurationsByIP(); + } - log("lastChecked: [${lastChecked.day}]"); - log("now: [${now.day}]"); - - // At midnight, update weather and prayer details if required - if (now.day != lastChecked.day) { - if (now.difference(now.copyWith(hour: 0, minute: 0, second: 0, millisecond: 0, microsecond: 0)).inMinutes >= 5) { - await nativeMethodChannelService.smartRestart(forceRestart: true, cleanupFirst: true); - - // if (globalConfigurationsModel.isRssFeedReq) { - // await getRssFeedDetailsFromServer(); - // } - // if (globalConfigurationsModel.isWeatherReq) { - // await getWeatherDetailsFromServer(); - // } - // if (globalConfigurationsModel.isPrayerTimeReq) { - // await getPrayerDetailsFromServer(); - // } - lastChecked = now; + // Every Two hour, update RSS feed if required + if (counter % 12 == 0 && globalConfigurationsModel.isRssFeedReq) { + await getRssFeedDetailsFromServer(); } - } - getNextPrayerToShow(); - syncHubConnectionState(); - }); + log("lastChecked: [${lastChecked.day}]"); + log("now: [${now.day}]"); + + // At midnight, update weather and prayer details if required + if (now.day != lastChecked.day) { + if (now.difference(now.copyWith(hour: 0, minute: 0, second: 0, millisecond: 0, microsecond: 0)).inMinutes >= 5) { + await nativeMethodChannelService.smartRestart(forceRestart: true, cleanupFirst: true); + + // if (globalConfigurationsModel.isRssFeedReq) { + // await getRssFeedDetailsFromServer(); + // } + // if (globalConfigurationsModel.isWeatherReq) { + // await getWeatherDetailsFromServer(); + // } + // if (globalConfigurationsModel.isPrayerTimeReq) { + // await getPrayerDetailsFromServer(); + // } + lastChecked = now; + } + } + getNextPrayerToShow(); + syncHubConnectionState(); + }, + ); } @override diff --git a/lib/views/common_widgets/app_footer.dart b/lib/views/common_widgets/app_footer.dart index a87f69e..b073f7e 100644 --- a/lib/views/common_widgets/app_footer.dart +++ b/lib/views/common_widgets/app_footer.dart @@ -308,23 +308,20 @@ class _AppFooterState extends State { children: [ Padding( padding: EdgeInsets.only(top: SizeConfig.getHeightMultiplier()! * 0.1), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - AppText( - AppStrings.poweredBy, - fontSize: SizeConfig.getWidthMultiplier()! * 1.5, - fontWeight: FontWeight.w400, - color: AppColors.darkGreyTextColor, - ), - AppText( - "v${screenConfigVM.currentScreenIP.replaceAll(".", "").replaceAll("0", "-")}(${AppConstants.currentBuildVersion})", - fontSize: SizeConfig.getWidthMultiplier()! * 1, - fontWeight: FontWeight.w400, - color: AppColors.darkGreyTextColor, - ), - ], - ), + child: Column(mainAxisAlignment: MainAxisAlignment.center, children: [ + AppText( + AppStrings.poweredBy, + fontSize: SizeConfig.getWidthMultiplier()! * 1.5, + fontWeight: FontWeight.w400, + color: AppColors.darkGreyTextColor, + ), + AppText( + "v${screenConfigVM.currentScreenIP.replaceAll(".", "-")}(${AppConstants.currentBuildVersion})", + fontSize: SizeConfig.getWidthMultiplier()! * 1, + fontWeight: FontWeight.w400, + color: AppColors.darkGreyTextColor, + ), + ]), ), SizedBox(width: SizeConfig.getWidthMultiplier()!), Padding( diff --git a/lib/views/main_queue_screen/main_queue_screen.dart b/lib/views/main_queue_screen/main_queue_screen.dart index 238fc81..a4fa336 100644 --- a/lib/views/main_queue_screen/main_queue_screen.dart +++ b/lib/views/main_queue_screen/main_queue_screen.dart @@ -167,11 +167,12 @@ class _MainQueueScreenState extends State { // ) // ], Expanded( - flex: 10, - child: Padding( - padding: EdgeInsets.symmetric(horizontal: SizeConfig.getWidthMultiplier()! * 4), - child: dataContent(context: context), - )), + flex: 10, + child: Padding( + padding: EdgeInsets.symmetric(horizontal: SizeConfig.getWidthMultiplier()! * 4), + child: dataContent(context: context), + ), + ), ], ); },