From 1834d9f7766d8bc0a63aca09b490cc2f25ff4f00 Mon Sep 17 00:00:00 2001 From: mosazaid Date: Thu, 10 Jun 2021 16:01:27 +0300 Subject: [PATCH 1/2] change video streaming design --- .../main/kotlin/com/hmg/hmgDr/MainActivity.kt | 3 +- .../hmgDr/Model/GetSessionStatusModel.java | 18 +- .../com/hmg/hmgDr/ui/VideoCallActivity.java | 40 ++- android/app/src/main/res/drawable/ic_mini.xml | 16 ++ .../src/main/res/drawable/shape_capsule.xml | 7 + .../main/res/layout/activity_video_call.xml | 234 +++++++++--------- android/app/src/main/res/values/colors.xml | 6 + android/app/src/main/res/values/dimens.xml | 19 +- lib/screens/live_care/end_call_screen.dart | 1 + lib/screens/live_care/video_call.dart | 1 + .../patient_profile_screen.dart | 1 + lib/util/VideoChannel.dart | 3 +- 12 files changed, 231 insertions(+), 118 deletions(-) create mode 100644 android/app/src/main/res/drawable/ic_mini.xml create mode 100644 android/app/src/main/res/drawable/shape_capsule.xml diff --git a/android/app/src/main/kotlin/com/hmg/hmgDr/MainActivity.kt b/android/app/src/main/kotlin/com/hmg/hmgDr/MainActivity.kt index 612118c9..ddecef6e 100644 --- a/android/app/src/main/kotlin/com/hmg/hmgDr/MainActivity.kt +++ b/android/app/src/main/kotlin/com/hmg/hmgDr/MainActivity.kt @@ -45,8 +45,9 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler val tokenID = call.argument("TokenID") val generalId = call.argument("generalId") val doctorId = call.argument("DoctorId") + val patientName = call.argument("patientName") - val sessionStatusModel = GetSessionStatusModel(VC_ID, tokenID, generalId, doctorId) + val sessionStatusModel = GetSessionStatusModel(VC_ID, tokenID, generalId, doctorId, patientName) openVideoCall(apiKey, sessionId, token, appLang, baseUrl, sessionStatusModel) diff --git a/android/app/src/main/kotlin/com/hmg/hmgDr/Model/GetSessionStatusModel.java b/android/app/src/main/kotlin/com/hmg/hmgDr/Model/GetSessionStatusModel.java index d41aa146..60350539 100644 --- a/android/app/src/main/kotlin/com/hmg/hmgDr/Model/GetSessionStatusModel.java +++ b/android/app/src/main/kotlin/com/hmg/hmgDr/Model/GetSessionStatusModel.java @@ -20,15 +20,19 @@ public class GetSessionStatusModel implements Parcelable { @SerializedName("DoctorId") @Expose private Integer doctorId; + @SerializedName("PatientName") + @Expose + private String patientName; public GetSessionStatusModel() { } - public GetSessionStatusModel(Integer vCID, String tokenID, String generalid, Integer doctorId) { + public GetSessionStatusModel(Integer vCID, String tokenID, String generalid, Integer doctorId, String patientName) { this.vCID = vCID; this.tokenID = tokenID; this.generalid = generalid; this.doctorId = doctorId; + this.patientName = patientName; } protected GetSessionStatusModel(Parcel in) { @@ -44,6 +48,7 @@ public class GetSessionStatusModel implements Parcelable { } else { doctorId = in.readInt(); } + patientName = in.readString(); } public static final Creator CREATOR = new Creator() { @@ -90,6 +95,16 @@ public class GetSessionStatusModel implements Parcelable { this.doctorId = doctorId; } + public String getPatientName() { + if (patientName == null) + patientName = "-"; + return patientName; + } + + public void setPatientName(String patientName) { + this.patientName = patientName; + } + @Override public int describeContents() { return 0; @@ -111,5 +126,6 @@ public class GetSessionStatusModel implements Parcelable { dest.writeByte((byte) 1); dest.writeInt(doctorId); } + dest.writeString(patientName); } } diff --git a/android/app/src/main/kotlin/com/hmg/hmgDr/ui/VideoCallActivity.java b/android/app/src/main/kotlin/com/hmg/hmgDr/ui/VideoCallActivity.java index 26560967..be4ebfb8 100644 --- a/android/app/src/main/kotlin/com/hmg/hmgDr/ui/VideoCallActivity.java +++ b/android/app/src/main/kotlin/com/hmg/hmgDr/ui/VideoCallActivity.java @@ -11,8 +11,10 @@ import android.opengl.GLSurfaceView; import android.os.Bundle; import android.os.CountDownTimer; import android.os.Handler; +import android.os.SystemClock; import android.util.Log; import android.view.View; +import android.widget.Chronometer; import android.widget.FrameLayout; import android.widget.ImageView; import android.widget.ProgressBar; @@ -75,7 +77,13 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi private boolean isSpeckerClicked; private boolean isMicClicked; + private TextView patientName; + private Chronometer cmTimer; + long elapsedTime; + Boolean resume = false; + private ImageView mCallBtn; + private ImageView btnMinimize; private ImageView mCameraBtn; private ImageView mSwitchCameraBtn; private ImageView mspeckerBtn; @@ -128,7 +136,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi @Override protected void onDestroy() { disconnectSession(); - + cmTimer.stop(); super.onDestroy(); } @@ -148,8 +156,28 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi videoCallPresenter = new VideoCallPresenterImpl(this, baseUrl); + patientName = findViewById(R.id.patient_name); + patientName.setText(sessionStatusModel.getPatientName()); + + cmTimer = findViewById(R.id.cmTimer); + cmTimer.setFormat("mm:ss"); + cmTimer.setOnChronometerTickListener(arg0 -> { + long minutes; + long seconds; + if (!resume) { + minutes = ((SystemClock.elapsedRealtime() - cmTimer.getBase()) / 1000) / 60; + seconds = ((SystemClock.elapsedRealtime() - cmTimer.getBase()) / 1000) % 60; + elapsedTime = SystemClock.elapsedRealtime(); + } else { + minutes = ((elapsedTime - cmTimer.getBase()) / 1000) / 60; + seconds = ((elapsedTime - cmTimer.getBase()) / 1000) % 60; + elapsedTime = elapsedTime + 1000; + } + Log.d(TAG, "onChronometerTick: " + minutes + " : " + seconds); + }); mCallBtn = findViewById(R.id.btn_call); + btnMinimize = findViewById(R.id.btn_minimize); mCameraBtn = findViewById(R.id.btn_camera); mSwitchCameraBtn = findViewById(R.id.btn_switch_camera); mspeckerBtn = findViewById(R.id.btn_specker); @@ -252,6 +280,11 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi } mSession.publish(mPublisher); + + if (!resume) { + cmTimer.setBase(SystemClock.elapsedRealtime()); + } + cmTimer.start(); } @Override @@ -259,6 +292,7 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi Log.d(TAG, "onDisconnected: disconnected from session " + session.getSessionId()); mSession = null; + cmTimer.stop(); } @Override @@ -377,6 +411,10 @@ public class VideoCallActivity extends AppCompatActivity implements EasyPermissi finish(); } + public void onMinimizedClicked(View view) { + + } + public void onSwitchCameraClicked(View view) { if (mPublisher != null) { isSwitchCameraClicked = !isSwitchCameraClicked; diff --git a/android/app/src/main/res/drawable/ic_mini.xml b/android/app/src/main/res/drawable/ic_mini.xml new file mode 100644 index 00000000..29df8da2 --- /dev/null +++ b/android/app/src/main/res/drawable/ic_mini.xml @@ -0,0 +1,16 @@ + + + + + diff --git a/android/app/src/main/res/drawable/shape_capsule.xml b/android/app/src/main/res/drawable/shape_capsule.xml new file mode 100644 index 00000000..a5dcdd09 --- /dev/null +++ b/android/app/src/main/res/drawable/shape_capsule.xml @@ -0,0 +1,7 @@ + + + + + + + \ No newline at end of file diff --git a/android/app/src/main/res/layout/activity_video_call.xml b/android/app/src/main/res/layout/activity_video_call.xml index 2dcf2ba4..a3c2ced1 100644 --- a/android/app/src/main/res/layout/activity_video_call.xml +++ b/android/app/src/main/res/layout/activity_video_call.xml @@ -1,169 +1,181 @@ - + android:background="@color/text_color" + android:orientation="vertical"> + - - + + + + + android:layout_alignParentEnd="true" + android:background="@drawable/shape_capsule" + android:padding="@dimen/padding_space_small"> + + + + - + android:layout_height="0dp" + android:layout_weight="1" + tools:context=".ui.VideoCallActivity"> + + + + + + + + + android:background="@color/remoteBackground"> + - - - + - - + + + + + + + android:padding="@dimen/padding_space_big_2"> + android:src="@drawable/ic_mini" /> + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/android/app/src/main/res/values/colors.xml b/android/app/src/main/res/values/colors.xml index d1d2a305..29782be0 100644 --- a/android/app/src/main/res/values/colors.xml +++ b/android/app/src/main/res/values/colors.xml @@ -8,4 +8,10 @@ #827b92 #484258 + #FF2E303A + + #fff + #000 + #389842 + #d51e26 diff --git a/android/app/src/main/res/values/dimens.xml b/android/app/src/main/res/values/dimens.xml index 79f3d269..2d53d554 100644 --- a/android/app/src/main/res/values/dimens.xml +++ b/android/app/src/main/res/values/dimens.xml @@ -8,7 +8,11 @@ 60dp 54dp + 64dp + + 24dp + 25dp 88dp 117dp @@ -16,7 +20,16 @@ 100dp 90dp - - 24dp - 25dp + + 14sp + 16sp + 24sp + + + 4dp + 8sp + 16dp + 24dp + + diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index 617eef34..83a2d0f5 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -65,6 +65,7 @@ class _EndCallScreenState extends State { kSessionId: liveCareModel.startCallRes.openSessionID, kApiKey: '46209962', vcId: widget.patient.vcId, + patientName: widget.patient.fullName ?? widget.patient.firstName != null ? "${widget.patient.firstName} ${widget.patient.lastName}" : "-", tokenID: await liveCareModel.getToken(), generalId: GENERAL_ID, doctorId: liveCareModel.doctorProfile.doctorID, diff --git a/lib/screens/live_care/video_call.dart b/lib/screens/live_care/video_call.dart index c6f9a885..07de1943 100644 --- a/lib/screens/live_care/video_call.dart +++ b/lib/screens/live_care/video_call.dart @@ -66,6 +66,7 @@ class _VideoCallPageState extends State { //'1_MX40NjgwMzIyNH5-MTU5MzY4MzYzODYwM35ucExWYVRVSm5Hcy9uWGZmM1lOa3czZHV-fg', kApiKey: '46209962', vcId: widget.patientData.vcId, + patientName: widget.patientData.fullName ?? widget.patientData.firstName != null ? "${widget.patientData.firstName} ${widget.patientData.lastName}" : "-", tokenID: token, //"hfkjshdf347r8743", generalId: "Cs2020@2016\$2958", doctorId: doctorprofile['DoctorID'], diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart index d9aa7d8d..69bbb97a 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -327,6 +327,7 @@ class _PatientProfileScreenState extends State kSessionId: model.startCallRes.openSessionID, kApiKey: '46209962', vcId: patient.vcId, + patientName: patient.fullName ?? patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-", tokenID: await model.getToken(), generalId: GENERAL_ID, doctorId: model.doctorProfile.doctorID, diff --git a/lib/util/VideoChannel.dart b/lib/util/VideoChannel.dart index a0962010..0104f55b 100644 --- a/lib/util/VideoChannel.dart +++ b/lib/util/VideoChannel.dart @@ -10,7 +10,7 @@ class VideoChannel{ /// channel name static const _channel = const MethodChannel("Dr.cloudSolution/videoCall"); static openVideoCallScreen( - {kApiKey, kSessionId, kToken, callDuration, warningDuration,int vcId,String tokenID,String generalId,int doctorId, Function() onCallEnd , Function(SessionStatusModel sessionStatusModel) onCallNotRespond ,Function(String error) onFailure}) async { + {kApiKey, kSessionId, kToken, callDuration, warningDuration,int vcId,String tokenID,String generalId,int doctorId, String patientName, Function() onCallEnd , Function(SessionStatusModel sessionStatusModel) onCallNotRespond ,Function(String error) onFailure}) async { var result; try { result = await _channel.invokeMethod( @@ -25,6 +25,7 @@ class VideoChannel{ "TokenID": tokenID, "generalId": generalId, "DoctorId": doctorId , + "patientName": patientName, }, ); if(result['callResponse'] == 'CallEnd') { From 726d3ab885f5bcee72b55d18e9d88761749df4f6 Mon Sep 17 00:00:00 2001 From: Mohammad Aljammal Date: Thu, 10 Jun 2021 16:52:16 +0300 Subject: [PATCH 2/2] Fix video call issue android --- android/app/build.gradle | 2 +- lib/config/config.dart | 4 ++-- lib/screens/live_care/end_call_screen.dart | 2 +- .../profile/profile_screen/patient_profile_screen.dart | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 16960d54..e18e8ae5 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -39,7 +39,7 @@ android { defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.hmg.hmgDr" - minSdkVersion 18 + minSdkVersion 21 targetSdkVersion 30 versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/config/config.dart b/lib/config/config.dart index 4bbbd40e..eb946dea 100644 --- a/lib/config/config.dart +++ b/lib/config/config.dart @@ -5,8 +5,8 @@ const ONLY_NUMBERS = "[0-9]"; const ONLY_LETTERS = "[a-zA-Z &'\"]"; const ONLY_DATE = "[0-9/]"; const BASE_URL_LIVE_CARE = 'https://livecare.hmg.com/'; -const BASE_URL = 'https://hmgwebservices.com/'; -// const BASE_URL = 'https://uat.hmgwebservices.com/'; +// const BASE_URL = 'https://hmgwebservices.com/'; +const BASE_URL = 'https://uat.hmgwebservices.com/'; const PHARMACY_ITEMS_URL = "Services/Lists.svc/REST/GetPharmcyItems_Region_enh"; const PHARMACY_LIST_URL = "Services/Patients.svc/REST/GetPharmcyList"; const PATIENT_PROGRESS_NOTE_URL = "Services/DoctorApplication.svc/REST/GetProgressNoteForInPatient"; diff --git a/lib/screens/live_care/end_call_screen.dart b/lib/screens/live_care/end_call_screen.dart index 83a2d0f5..b7383703 100644 --- a/lib/screens/live_care/end_call_screen.dart +++ b/lib/screens/live_care/end_call_screen.dart @@ -65,7 +65,7 @@ class _EndCallScreenState extends State { kSessionId: liveCareModel.startCallRes.openSessionID, kApiKey: '46209962', vcId: widget.patient.vcId, - patientName: widget.patient.fullName ?? widget.patient.firstName != null ? "${widget.patient.firstName} ${widget.patient.lastName}" : "-", + patientName: widget.patient.fullName ?? (widget.patient.firstName != null ? "${widget.patient.firstName} ${widget.patient.lastName}" : "-"), tokenID: await liveCareModel.getToken(), generalId: GENERAL_ID, doctorId: liveCareModel.doctorProfile.doctorID, diff --git a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart index 69bbb97a..298e7d18 100644 --- a/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart +++ b/lib/screens/patients/profile/profile_screen/patient_profile_screen.dart @@ -327,7 +327,7 @@ class _PatientProfileScreenState extends State kSessionId: model.startCallRes.openSessionID, kApiKey: '46209962', vcId: patient.vcId, - patientName: patient.fullName ?? patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-", + patientName: patient.fullName ?? (patient.firstName != null ? "${patient.firstName} ${patient.lastName}" : "-"), tokenID: await model.getToken(), generalId: GENERAL_ID, doctorId: model.doctorProfile.doctorID,