|
|
|
@ -38,7 +38,8 @@ import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks
|
|
|
|
|
import kotlin.math.ceil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.SessionListener, PublisherListener,
|
|
|
|
|
class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.SessionListener,
|
|
|
|
|
PublisherListener,
|
|
|
|
|
SubscriberKit.VideoListener, VideoCallView {
|
|
|
|
|
|
|
|
|
|
private var isFullScreen: Boolean = true
|
|
|
|
@ -62,6 +63,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
private var mVolRunnable: Runnable? = null
|
|
|
|
|
private var mConnectedRunnable: Runnable? = null
|
|
|
|
|
|
|
|
|
|
private lateinit var recordContainer: FrameLayout
|
|
|
|
|
private lateinit var thumbnail_container: FrameLayout
|
|
|
|
|
private lateinit var mPublisherViewContainer: FrameLayout
|
|
|
|
|
private lateinit var mPublisherViewIcon: View
|
|
|
|
@ -74,6 +76,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
private var token: String? = null
|
|
|
|
|
private var appLang: String? = null
|
|
|
|
|
private var baseUrl: String? = null
|
|
|
|
|
private var isRecording: Boolean = true
|
|
|
|
|
|
|
|
|
|
private var isSwitchCameraClicked = false
|
|
|
|
|
private var isCameraClicked = false
|
|
|
|
@ -168,8 +171,10 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
this.videoCallResponseListener = videoCallResponseListener
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?): View {
|
|
|
|
|
override fun onCreateView(
|
|
|
|
|
inflater: LayoutInflater, container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
|
): View {
|
|
|
|
|
|
|
|
|
|
parentView = inflater.inflate(R.layout.activity_video_call, container, false)
|
|
|
|
|
|
|
|
|
@ -181,12 +186,17 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
appLang = getString("appLang")
|
|
|
|
|
baseUrl = getString("baseUrl")
|
|
|
|
|
sessionStatusModel = getParcelable("sessionStatusModel")
|
|
|
|
|
if (sessionStatusModel != null)
|
|
|
|
|
isRecording = sessionStatusModel!!.isRecording
|
|
|
|
|
}
|
|
|
|
|
initUI(parentView)
|
|
|
|
|
requestPermissions()
|
|
|
|
|
|
|
|
|
|
handleDragDialog()
|
|
|
|
|
mDetector = GestureDetectorCompat(context, MyGestureListener({ showControlPanelTemporarily() }, { miniCircleDoubleTap() }))
|
|
|
|
|
mDetector = GestureDetectorCompat(
|
|
|
|
|
context,
|
|
|
|
|
MyGestureListener({ showControlPanelTemporarily() }, { miniCircleDoubleTap() })
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return parentView
|
|
|
|
|
}
|
|
|
|
@ -223,6 +233,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
layoutName = view.findViewById(R.id.layout_name)
|
|
|
|
|
layoutMini = view.findViewById(R.id.layout_mini)
|
|
|
|
|
icMini = view.findViewById(R.id.ic_mini)
|
|
|
|
|
recordContainer = view.findViewById(R.id.record_container)
|
|
|
|
|
thumbnail_container = view.findViewById(R.id.thumbnail_container)
|
|
|
|
|
mPublisherViewContainer = view.findViewById(R.id.local_video_view_container)
|
|
|
|
|
mPublisherViewIcon = view.findViewById(R.id.local_video_view_icon)
|
|
|
|
@ -232,9 +243,16 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
patientName = view.findViewById<TextView>(R.id.patient_name)
|
|
|
|
|
patientName.text = sessionStatusModel!!.patientName
|
|
|
|
|
|
|
|
|
|
if (isRecording) {
|
|
|
|
|
recordContainer.visibility = View.VISIBLE
|
|
|
|
|
} else {
|
|
|
|
|
recordContainer.visibility = View.GONE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cmTimer = view.findViewById<Chronometer>(R.id.cmTimer)
|
|
|
|
|
cmTimer.format = "mm:ss"
|
|
|
|
|
cmTimer.onChronometerTickListener = Chronometer.OnChronometerTickListener { arg0: Chronometer? ->
|
|
|
|
|
cmTimer.onChronometerTickListener =
|
|
|
|
|
Chronometer.OnChronometerTickListener { arg0: Chronometer? ->
|
|
|
|
|
val minutes: Long
|
|
|
|
|
val seconds: Long
|
|
|
|
|
if (!resume) {
|
|
|
|
@ -310,7 +328,11 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
mVolHandler!!.postDelayed(mVolRunnable!!, (5 * 1000).toLong())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onRequestPermissionsResult(requestCode: Int, permissions: Array<String?>, grantResults: IntArray) {
|
|
|
|
|
override fun onRequestPermissionsResult(
|
|
|
|
|
requestCode: Int,
|
|
|
|
|
permissions: Array<String?>,
|
|
|
|
|
grantResults: IntArray
|
|
|
|
|
) {
|
|
|
|
|
super.onRequestPermissionsResult(requestCode, permissions, grantResults)
|
|
|
|
|
EasyPermissions.onRequestPermissionsResult(requestCode, permissions, grantResults, this)
|
|
|
|
|
}
|
|
|
|
@ -335,7 +357,13 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
@AfterPermissionGranted(RC_VIDEO_APP_PERM)
|
|
|
|
|
private fun requestPermissions() {
|
|
|
|
|
val perms = arrayOf(Manifest.permission.INTERNET, Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO, Manifest.permission.MODIFY_AUDIO_SETTINGS, Manifest.permission.CALL_PHONE)
|
|
|
|
|
val perms = arrayOf(
|
|
|
|
|
Manifest.permission.INTERNET,
|
|
|
|
|
Manifest.permission.CAMERA,
|
|
|
|
|
Manifest.permission.RECORD_AUDIO,
|
|
|
|
|
Manifest.permission.MODIFY_AUDIO_SETTINGS,
|
|
|
|
|
Manifest.permission.CALL_PHONE
|
|
|
|
|
)
|
|
|
|
|
if (EasyPermissions.hasPermissions(requireContext(), *perms)) {
|
|
|
|
|
try {
|
|
|
|
|
mSession = Session.Builder(context, apiKey, sessionId).build()
|
|
|
|
@ -345,7 +373,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
e.printStackTrace()
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
EasyPermissions.requestPermissions(this, getString(R.string.remaining_ar), RC_VIDEO_APP_PERM, *perms)
|
|
|
|
|
EasyPermissions.requestPermissions(
|
|
|
|
|
this,
|
|
|
|
|
getString(R.string.remaining_ar),
|
|
|
|
|
RC_VIDEO_APP_PERM,
|
|
|
|
|
*perms
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -387,7 +420,10 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onStreamReceived(session: Session, stream: Stream) {
|
|
|
|
|
Log.d(TAG, "onStreamReceived: New stream " + stream.streamId + " in session " + session.sessionId)
|
|
|
|
|
Log.d(
|
|
|
|
|
TAG,
|
|
|
|
|
"onStreamReceived: New stream " + stream.streamId + " in session " + session.sessionId
|
|
|
|
|
)
|
|
|
|
|
if (mSubscriber != null) {
|
|
|
|
|
isConnected = true
|
|
|
|
|
return
|
|
|
|
@ -396,11 +432,22 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
subscribeToStream(stream)
|
|
|
|
|
if (mConnectedHandler != null && mConnectedRunnable != null)
|
|
|
|
|
mConnectedHandler!!.removeCallbacks(mConnectedRunnable!!)
|
|
|
|
|
videoCallPresenter.callChangeCallStatus(ChangeCallStatusRequestModel(3, sessionStatusModel!!.doctorId, sessionStatusModel!!.generalid, token, sessionStatusModel!!.vcid))
|
|
|
|
|
videoCallPresenter.callChangeCallStatus(
|
|
|
|
|
ChangeCallStatusRequestModel(
|
|
|
|
|
3,
|
|
|
|
|
sessionStatusModel!!.doctorId,
|
|
|
|
|
sessionStatusModel!!.generalid,
|
|
|
|
|
token,
|
|
|
|
|
sessionStatusModel!!.vcid
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onStreamDropped(session: Session, stream: Stream) {
|
|
|
|
|
Log.d(TAG, "onStreamDropped: Stream " + stream.streamId + " dropped from session " + session.sessionId)
|
|
|
|
|
Log.d(
|
|
|
|
|
TAG,
|
|
|
|
|
"onStreamDropped: Stream " + stream.streamId + " dropped from session " + session.sessionId
|
|
|
|
|
)
|
|
|
|
|
if (mSubscriber == null) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
@ -427,7 +474,10 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onVideoDataReceived(subscriberKit: SubscriberKit?) {
|
|
|
|
|
mSubscriber!!.setStyle(BaseVideoRenderer.STYLE_VIDEO_SCALE, BaseVideoRenderer.STYLE_VIDEO_FILL)
|
|
|
|
|
mSubscriber!!.setStyle(
|
|
|
|
|
BaseVideoRenderer.STYLE_VIDEO_SCALE,
|
|
|
|
|
BaseVideoRenderer.STYLE_VIDEO_FILL
|
|
|
|
|
)
|
|
|
|
|
(mSubscriber!!.renderer as DynamicVideoRenderer).enableThumbnailCircle(false)
|
|
|
|
|
mSubscriberViewContainer.addView(mSubscriber!!.view)
|
|
|
|
|
// switchToThumbnailCircle()
|
|
|
|
@ -506,7 +556,15 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
mSession!!.disconnect()
|
|
|
|
|
countDownTimer?.cancel()
|
|
|
|
|
|
|
|
|
|
videoCallPresenter.callChangeCallStatus(ChangeCallStatusRequestModel(16, sessionStatusModel!!.doctorId, sessionStatusModel!!.generalid, token, sessionStatusModel!!.vcid))
|
|
|
|
|
videoCallPresenter.callChangeCallStatus(
|
|
|
|
|
ChangeCallStatusRequestModel(
|
|
|
|
|
16,
|
|
|
|
|
sessionStatusModel!!.doctorId,
|
|
|
|
|
sessionStatusModel!!.generalid,
|
|
|
|
|
token,
|
|
|
|
|
sessionStatusModel!!.vcid
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
dialog?.dismiss()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -561,11 +619,23 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
(mSubscriber!!.renderer as DynamicVideoRenderer).enableThumbnailCircle(isCircle)
|
|
|
|
|
} else {
|
|
|
|
|
if (isCircle) {
|
|
|
|
|
videoCallContainer.background = ContextCompat.getDrawable(requireContext(), R.drawable.circle_shape)
|
|
|
|
|
mSubscriberViewContainer.background = ContextCompat.getDrawable(requireContext(), R.drawable.circle_shape)
|
|
|
|
|
videoCallContainer.background =
|
|
|
|
|
ContextCompat.getDrawable(requireContext(), R.drawable.circle_shape)
|
|
|
|
|
mSubscriberViewContainer.background =
|
|
|
|
|
ContextCompat.getDrawable(requireContext(), R.drawable.circle_shape)
|
|
|
|
|
} else {
|
|
|
|
|
videoCallContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.text_color))
|
|
|
|
|
mSubscriberViewContainer.setBackgroundColor(ContextCompat.getColor(requireContext(), R.color.remoteBackground))
|
|
|
|
|
videoCallContainer.setBackgroundColor(
|
|
|
|
|
ContextCompat.getColor(
|
|
|
|
|
requireContext(),
|
|
|
|
|
R.color.text_color
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
mSubscriberViewContainer.setBackgroundColor(
|
|
|
|
|
ContextCompat.getColor(
|
|
|
|
|
requireContext(),
|
|
|
|
|
R.color.remoteBackground
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
@ -602,24 +672,34 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
private fun setViewsVisibility() {
|
|
|
|
|
val iconSize: Int = context!!.resources.getDimension(R.dimen.video_icon_size).toInt()
|
|
|
|
|
val iconSizeSmall: Int = context!!.resources.getDimension(R.dimen.video_icon_size_small).toInt()
|
|
|
|
|
val btnMinimizeLayoutParam: ConstraintLayout.LayoutParams = btnMinimize.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
val mCallBtnLayoutParam: ConstraintLayout.LayoutParams = mCallBtn.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
val localPreviewMargin: Int = context!!.resources.getDimension(R.dimen.local_preview_margin_top).toInt()
|
|
|
|
|
val localPreviewWidth: Int = context!!.resources.getDimension(R.dimen.local_preview_width).toInt()
|
|
|
|
|
val localPreviewHeight: Int = context!!.resources.getDimension(R.dimen.local_preview_height).toInt()
|
|
|
|
|
val iconSizeSmall: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.video_icon_size_small).toInt()
|
|
|
|
|
val btnMinimizeLayoutParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
btnMinimize.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
val mCallBtnLayoutParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
mCallBtn.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
val localPreviewMargin: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.local_preview_margin_top).toInt()
|
|
|
|
|
val localPreviewWidth: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.local_preview_width).toInt()
|
|
|
|
|
val localPreviewHeight: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.local_preview_height).toInt()
|
|
|
|
|
// val localPreviewIconSize: Int = context!!.resources.getDimension(R.dimen.local_back_icon_size).toInt()
|
|
|
|
|
// val localPreviewMarginSmall : Int = context!!.resources.getDimension(R.dimen.local_preview_margin_small).toInt()
|
|
|
|
|
// val localPreviewWidthSmall : Int = context!!.resources.getDimension(R.dimen.local_preview_width_small).toInt()
|
|
|
|
|
// val localPreviewHeightSmall : Int = context!!.resources.getDimension(R.dimen.local_preview_height_small).toInt()
|
|
|
|
|
// val localPreviewIconSmall: Int = context!!.resources.getDimension(R.dimen.local_back_icon_size_small).toInt()
|
|
|
|
|
// val localPreviewLayoutIconParam : FrameLayout.LayoutParams
|
|
|
|
|
val localPreviewLayoutParam: RelativeLayout.LayoutParams = mPublisherViewContainer.layoutParams as RelativeLayout.LayoutParams
|
|
|
|
|
val localPreviewLayoutParam: RelativeLayout.LayoutParams =
|
|
|
|
|
mPublisherViewContainer.layoutParams as RelativeLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
val remotePreviewIconSize: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size).toInt()
|
|
|
|
|
val remotePreviewIconSizeSmall: Int = context!!.resources.getDimension(R.dimen.remote_back_icon_size_small).toInt()
|
|
|
|
|
val remotePreviewLayoutParam: FrameLayout.LayoutParams = mSubscriberViewIcon.layoutParams as FrameLayout.LayoutParams
|
|
|
|
|
val remotePreviewIconSize: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.remote_back_icon_size).toInt()
|
|
|
|
|
val remotePreviewIconSizeSmall: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.remote_back_icon_size_small).toInt()
|
|
|
|
|
val remotePreviewLayoutParam: FrameLayout.LayoutParams =
|
|
|
|
|
mSubscriberViewIcon.layoutParams as FrameLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
if (isFullScreen) {
|
|
|
|
|
layoutName.visibility = View.VISIBLE
|
|
|
|
@ -638,7 +718,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
localPreviewLayoutParam.width = localPreviewWidth
|
|
|
|
|
localPreviewLayoutParam.height = localPreviewHeight
|
|
|
|
|
localPreviewLayoutParam.setMargins(0, localPreviewMargin, localPreviewMargin, 0)
|
|
|
|
|
if (mPublisher != null && mPublisher!!.view.parent == null){
|
|
|
|
|
if (mPublisher != null && mPublisher!!.view.parent == null) {
|
|
|
|
|
mPublisherViewContainer.addView(mPublisher!!.view)
|
|
|
|
|
}
|
|
|
|
|
mPublisherViewContainer.visibility = View.VISIBLE
|
|
|
|
@ -666,7 +746,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
localPreviewLayoutParam.height = 0
|
|
|
|
|
localPreviewLayoutParam.setMargins(0, localPreviewMargin / 2, localPreviewMargin / 2, 0)
|
|
|
|
|
|
|
|
|
|
if (mPublisher != null){
|
|
|
|
|
if (mPublisher != null) {
|
|
|
|
|
mPublisherViewContainer.removeView(mPublisher!!.view)
|
|
|
|
|
}
|
|
|
|
|
mPublisherViewContainer.visibility = View.GONE
|
|
|
|
@ -876,7 +956,10 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
).toInt()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private class MyGestureListener(val onTabCall: () -> Unit, val miniCircleDoubleTap: () -> Unit) : GestureDetector.SimpleOnGestureListener() {
|
|
|
|
|
private class MyGestureListener(
|
|
|
|
|
val onTabCall: () -> Unit,
|
|
|
|
|
val miniCircleDoubleTap: () -> Unit
|
|
|
|
|
) : GestureDetector.SimpleOnGestureListener() {
|
|
|
|
|
|
|
|
|
|
override fun onSingleTapConfirmed(event: MotionEvent): Boolean {
|
|
|
|
|
// onTabCall()
|
|
|
|
|