From 79446a20e84e5b4bb0229cd61b5d852dad5a7e9a Mon Sep 17 00:00:00 2001 From: Aamir Date: Mon, 18 Dec 2023 12:22:17 +0300 Subject: [PATCH] Android Native Change For Call --- .../VideoStreamFloatingWidgetService.kt | 4 +- lib/core/service/VideoCallService.dart | 6 +- .../live_care/live_care_patient_screen.dart | 66 ++++++++++--------- .../patients/patient_card/ShowTimer.dart | 2 +- 4 files changed, 41 insertions(+), 37 deletions(-) diff --git a/android/app/src/main/kotlin/com/hmg/hmgDr/Service/VideoStreamFloatingWidgetService.kt b/android/app/src/main/kotlin/com/hmg/hmgDr/Service/VideoStreamFloatingWidgetService.kt index f82eae3d..35e4974b 100644 --- a/android/app/src/main/kotlin/com/hmg/hmgDr/Service/VideoStreamFloatingWidgetService.kt +++ b/android/app/src/main/kotlin/com/hmg/hmgDr/Service/VideoStreamFloatingWidgetService.kt @@ -996,7 +996,7 @@ class VideoStreamFloatingWidgetService : BaseMovingFloatingWidget(), Session.Ses Intent(this, VideoStreamFloatingWidgetService::class.java) .let { notificationIntent -> notificationIntent.action = ACTION_MINIMIZE_CALL - PendingIntent.getService(this, 0, notificationIntent, 0) + PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE ) } // 4. Create additional Actions (Intents) for the Notification. @@ -1006,7 +1006,7 @@ class VideoStreamFloatingWidgetService : BaseMovingFloatingWidget(), Session.Ses action = ACTION_END_CALL } .let { notificationIntent -> - PendingIntent.getService(this, 0, notificationIntent, 0) + PendingIntent.getService(this, 0, notificationIntent, PendingIntent.FLAG_MUTABLE) } val endCallAction = NotificationCompat.Action.Builder( R.drawable.ic_end_call, diff --git a/lib/core/service/VideoCallService.dart b/lib/core/service/VideoCallService.dart index 666b5ce1..3ef7f970 100644 --- a/lib/core/service/VideoCallService.dart +++ b/lib/core/service/VideoCallService.dart @@ -31,9 +31,9 @@ class VideoCallService extends BaseService { kToken: startCallRes.openTokenID, kSessionId: startCallRes.openSessionID, // - // kToken: "T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9NzE0MGE4YzM0ZTU2YjQ5NmQzOTgwOTNkYmU1NzEzMmQxYTdkMDliZTpzZXNzaW9uX2lkPTFfTVg0ME5qSXdPVGsyTW41LU1UWTVNakkxTkRjMU1EUTRObjVCVFZsM2MwODFNV1ZhTjFsUlEyZGxiRFZxZVZjNWNHMS1mbjQmY3JlYXRlX3RpbWU9MTY5MjI1NDc1MCZub25jZT0wLjY5OTQyNzkzMTg1NDg4NSZyb2xlPW1vZGVyYXRvciZleHBpcmVfdGltZT0xNjkyMjU2NTUwJmluaXRpYWxfbGF5b3V0X2NsYXNzX2xpc3Q9", - // kSessionId: "1_MX40NjIwOTk2Mn5-MTY5MjI1NDc1MDQ4Nn5BTVl3c081MWVaN1lRQ2dlbDVqeVc5cG1-fn4", - + // kToken: + // "T1==cGFydG5lcl9pZD00NjIwOTk2MiZzaWc9Y2YwYWY5YWMyNjg5ZTljODUyN2QwMmI5YzVhZmQxMTE4M2M3OGNmNDpzZXNzaW9uX2lkPTJfTVg0ME5qSXdPVGsyTW41LU1UY3dNamc0TmpjNU5qa3hPWDVuVTFCcmRDOTRVbk5MUTBoYVJYUjVWVE5xWkRGdVl5dC1mbjQmY3JlYXRlX3RpbWU9MTcwMjg4Njc5NyZub25jZT0wLjE5NDM0MzQyMTAyOTg4MjY3JnJvbGU9bW9kZXJhdG9yJmV4cGlyZV90aW1lPTE3MDM0OTE1OTcmaW5pdGlhbF9sYXlvdXRfY2xhc3NfbGlzdD0=", + // kSessionId: "2_MX40NjIwOTk2Mn5-MTcwMjg4Njc5NjkxOX5nU1BrdC94UnNLQ0haRXR5VTNqZDFuYyt-fn4", vcId: patient.vcId!, isRecording: isRecording, patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"), diff --git a/lib/screens/live_care/live_care_patient_screen.dart b/lib/screens/live_care/live_care_patient_screen.dart index c5e882d8..d03378f1 100644 --- a/lib/screens/live_care/live_care_patient_screen.dart +++ b/lib/screens/live_care/live_care_patient_screen.dart @@ -1,23 +1,21 @@ import 'dart:async'; +import 'dart:convert'; import 'package:doctor_app_flutter/core/enum/view_state.dart'; import 'package:doctor_app_flutter/core/model/patient/patiant_info_model.dart'; +import 'package:doctor_app_flutter/core/service/VideoCallService.dart'; import 'package:doctor_app_flutter/core/viewModel/LiveCarePatientViewModel.dart'; import 'package:doctor_app_flutter/icons_app/doctor_app_icons.dart'; -import 'package:doctor_app_flutter/routes.dart'; +import 'package:doctor_app_flutter/locator.dart'; import 'package:doctor_app_flutter/screens/base/base_view.dart'; import 'package:doctor_app_flutter/screens/patients/patient_search/patient_search_header.dart'; -import 'package:doctor_app_flutter/utils/translations_delegate_base_utils.dart'; +import 'package:doctor_app_flutter/utils/notification_permission_utils.dart'; import 'package:doctor_app_flutter/widgets/patients/patient_card/PatientCard.dart'; import 'package:doctor_app_flutter/widgets/shared/app_loader_widget.dart'; import 'package:doctor_app_flutter/widgets/shared/app_scaffold_widget.dart'; -import 'package:doctor_app_flutter/widgets/shared/errors/error_message.dart'; import 'package:doctor_app_flutter/widgets/shared/text_fields/app_text_field_custom_serach.dart'; import 'package:flutter/material.dart'; -import '../../utils/translations_delegate_base_utils.dart'; -import '../../widgets/shared/errors/error_message.dart'; - class LiveCarePatientScreen extends StatefulWidget { @override _LiveCarePatientScreenState createState() => _LiveCarePatientScreenState(); @@ -93,16 +91,20 @@ class _LiveCarePatientScreenState extends State { model.state == ViewState.Idle ? Expanded( child: Container( - child: model.filterData.isEmpty - ? Center( - child: ErrorMessage( - error: TranslationBase.of(context).youDontHaveAnyPatient, - ), - ) - : ListView.builder( + child: + // + // model.filterData.isEmpty + // ? Center( + // child: ErrorMessage( + // error: TranslationBase.of(context).youDontHaveAnyPatient, + // ), + // ) + // : + + ListView.builder( scrollDirection: Axis.vertical, shrinkWrap: true, - itemCount: model.filterData.length, + itemCount: 1, // model.filterData.length, itemBuilder: (BuildContext ctxt, int index) { // @@ -168,14 +170,16 @@ class _LiveCarePatientScreenState extends State { } '''; - // Map jsonObject = json.decode(jsonString); + Map jsonObject = json.decode(jsonString); // return Padding( padding: EdgeInsets.all(8.0), child: PatientCard( - patientInfo: PatiantInformtion.fromJson(model.filterData[index].toJson()), + patientInfo: PatiantInformtion.fromJson(jsonObject + // model.filterData[index].toJson() + ), patientType: "0", arrivalType: "0", isFromSearch: false, @@ -183,22 +187,22 @@ class _LiveCarePatientScreenState extends State { isFromLiveCare: true, onTap: () { // TODO change the parameter to daynamic - Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { - "patient": PatiantInformtion.fromJson(model.filterData[index].toJson()), - "patientType": "0", - "isSearch": false, - "isInpatient": false, - "arrivalType": "0", - "isSearchAndOut": false, - "isFromLiveCare": true, - }); + // Navigator.of(context).pushNamed(PATIENTS_PROFILE, arguments: { + // "patient": PatiantInformtion.fromJson(model.filterData[index].toJson()), + // "patientType": "0", + // "isSearch": false, + // "isInpatient": false, + // "arrivalType": "0", + // "isSearchAndOut": false, + // "isFromLiveCare": true, + // }); - // AppPermissionsUtils.requestVideoCallPermission( - // context: context, - // onTapGrant: () { - // locator().openVideo(model.startCallRes!, PatiantInformtion.fromJson(model.filterData[index].toJson()), - // model.startCallRes != null ? model.startCallRes!.isRecording! : true, callConnected, callDisconnected); - // }); + AppPermissionsUtils.requestVideoCallPermission( + context: context, + onTapGrant: () { + locator().openVideo(model.startCallRes!, PatiantInformtion.fromJson(jsonObject), + model.startCallRes != null ? model.startCallRes!.isRecording! : true, callConnected, callDisconnected); + }); }, // isFromSearch: widget.isSearch, ), diff --git a/lib/widgets/patients/patient_card/ShowTimer.dart b/lib/widgets/patients/patient_card/ShowTimer.dart index 8ed72425..067b9583 100644 --- a/lib/widgets/patients/patient_card/ShowTimer.dart +++ b/lib/widgets/patients/patient_card/ShowTimer.dart @@ -48,7 +48,7 @@ class _ShowTimerState extends State { generateShowTimerString() { DateTime now = DateTime.now(); - DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime!); + DateTime liveCareDate = DateTime.parse(widget.patientInfo.arrivalTime); String timer = AppDateUtils.differenceBetweenDateAndCurrent(liveCareDate, context, isShowSecond: true, isShowDays: false); return timer;