|
|
|
|
@ -11,6 +11,7 @@ import android.graphics.Point
|
|
|
|
|
import android.graphics.drawable.ColorDrawable
|
|
|
|
|
import android.opengl.GLSurfaceView
|
|
|
|
|
import android.os.*
|
|
|
|
|
import android.util.DisplayMetrics
|
|
|
|
|
import android.util.Log
|
|
|
|
|
import android.view.*
|
|
|
|
|
import android.widget.*
|
|
|
|
|
@ -29,20 +30,20 @@ import com.hmg.hmgDr.ui.VideoCallContract.VideoCallView
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallPresenterImpl
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
|
import com.hmg.hmgDr.util.DynamicVideoRenderer
|
|
|
|
|
import com.hmg.hmgDr.util.ViewsUtil
|
|
|
|
|
import com.opentok.android.*
|
|
|
|
|
import com.opentok.android.PublisherKit.PublisherListener
|
|
|
|
|
import pub.devrel.easypermissions.AfterPermissionGranted
|
|
|
|
|
import pub.devrel.easypermissions.AppSettingsDialog
|
|
|
|
|
import pub.devrel.easypermissions.EasyPermissions
|
|
|
|
|
import pub.devrel.easypermissions.EasyPermissions.PermissionCallbacks
|
|
|
|
|
import java.text.DecimalFormat
|
|
|
|
|
import java.text.NumberFormat
|
|
|
|
|
import kotlin.math.ceil
|
|
|
|
|
|
|
|
|
|
// check this if it works to solve keyboard not work when dialog is opened
|
|
|
|
|
// https://stackoverflow.com/questions/55066977/how-to-prevent-custom-dialogfragment-from-hiding-keyboard-when-being-shown
|
|
|
|
|
class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.SessionListener, PublisherListener,
|
|
|
|
|
SubscriberKit.VideoListener, VideoCallView {
|
|
|
|
|
class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.SessionListener,
|
|
|
|
|
PublisherListener,
|
|
|
|
|
SubscriberKit.VideoListener, VideoCallView {
|
|
|
|
|
|
|
|
|
|
private var isFullScreen: Boolean = true
|
|
|
|
|
private var isCircle: Boolean = false
|
|
|
|
|
@ -66,6 +67,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
private var mConnectedRunnable: Runnable? = null
|
|
|
|
|
|
|
|
|
|
private lateinit var thumbnail_container: FrameLayout
|
|
|
|
|
private lateinit var activity_clingo_video_call: RelativeLayout
|
|
|
|
|
private lateinit var mPublisherViewContainer: FrameLayout
|
|
|
|
|
private lateinit var mPublisherViewIcon: View
|
|
|
|
|
private lateinit var mSubscriberViewContainer: FrameLayout
|
|
|
|
|
@ -119,30 +121,36 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
override fun onStart() {
|
|
|
|
|
super.onStart()
|
|
|
|
|
|
|
|
|
|
// val params: ViewGroup.LayoutParams = dialog!!.window!!.attributes
|
|
|
|
|
// params.width = WindowManager.LayoutParams.MATCH_PARENT
|
|
|
|
|
// params.height = WindowManager.LayoutParams.MATCH_PARENT
|
|
|
|
|
// dialog!!.window!!.attributes = params as WindowManager.LayoutParams
|
|
|
|
|
|
|
|
|
|
dialog?.window?.setLayout(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT
|
|
|
|
|
)
|
|
|
|
|
val parentLayoutParam: FrameLayout.LayoutParams = /*parentView.layoutParams as*/ FrameLayout.LayoutParams(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT
|
|
|
|
|
)
|
|
|
|
|
parentView.layoutParams = parentLayoutParam
|
|
|
|
|
// val parentLayoutParam: FrameLayout.LayoutParams = /*parentView.layoutParams as*/ FrameLayout.LayoutParams(
|
|
|
|
|
// LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
// LinearLayout.LayoutParams.MATCH_PARENT
|
|
|
|
|
// )
|
|
|
|
|
// parentView.layoutParams = parentLayoutParam
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun getTheme(): Int {
|
|
|
|
|
return R.style.dialogTheme
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onCreateDialog(@Nullable savedInstanceState: Bundle?): Dialog {
|
|
|
|
|
override fun onCreateDialog(@Nullable savedInstanceState: Bundle?): Dialog {// FullScreenVideoTheme
|
|
|
|
|
val layoutInflater = activity!!.layoutInflater
|
|
|
|
|
this.parentView = onCreateView(layoutInflater, null)
|
|
|
|
|
|
|
|
|
|
val alertDialogBuilder: AlertDialog.Builder = AlertDialog.Builder(requireContext())
|
|
|
|
|
val alertDialogBuilder: AlertDialog.Builder =
|
|
|
|
|
AlertDialog.Builder(requireContext(), R.style.dialogTheme)
|
|
|
|
|
// .setTitle(android.R.string.select_a_color)
|
|
|
|
|
.setView(this.parentView)
|
|
|
|
|
.setView(this.parentView)
|
|
|
|
|
// .setPositiveButton(android.R.string.ok, { dialogInterface, i -> })
|
|
|
|
|
alertDialogBuilder.setOnKeyListener{ _, keyCode, keyEvent ->
|
|
|
|
|
alertDialogBuilder.setOnKeyListener { _, keyCode, keyEvent ->
|
|
|
|
|
// getAction to make sure this doesn't double fire
|
|
|
|
|
if (keyCode == KeyEvent.KEYCODE_BACK && keyEvent.action == KeyEvent.ACTION_UP) {
|
|
|
|
|
videoCallResponseListener?.onBackHandle()
|
|
|
|
|
@ -181,8 +189,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
// Make the dialog possible to be outside touch
|
|
|
|
|
dialogWindow!!.setFlags(
|
|
|
|
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
|
|
|
|
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
|
|
|
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
|
|
|
|
|
WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL
|
|
|
|
|
)
|
|
|
|
|
dialogWindow.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND)
|
|
|
|
|
requireView().invalidate()
|
|
|
|
|
@ -214,13 +222,18 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
requestPermissions()
|
|
|
|
|
|
|
|
|
|
handleDragDialog()
|
|
|
|
|
mDetector = GestureDetectorCompat(context, MyGestureListener({ showControlPanelTemporarily() }, { miniCircleDoubleTap() }))
|
|
|
|
|
mDetector = GestureDetectorCompat(
|
|
|
|
|
context,
|
|
|
|
|
MyGestureListener({ showControlPanelTemporarily() }, { miniCircleDoubleTap() })
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
return view
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?): View {
|
|
|
|
|
override fun onCreateView(
|
|
|
|
|
inflater: LayoutInflater, container: ViewGroup?,
|
|
|
|
|
savedInstanceState: Bundle?
|
|
|
|
|
): View {
|
|
|
|
|
return this.parentView
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -252,9 +265,12 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
|
private fun initUI(view: View) {
|
|
|
|
|
videoCallContainer = view.findViewById(R.id.video_call_ll)
|
|
|
|
|
|
|
|
|
|
layoutName = view.findViewById(R.id.layout_name)
|
|
|
|
|
layoutMini = view.findViewById(R.id.layout_mini)
|
|
|
|
|
icMini = view.findViewById(R.id.ic_mini)
|
|
|
|
|
activity_clingo_video_call = view.findViewById(R.id.activity_clingo_video_call)
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
@ -266,25 +282,26 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
cmTimer = view.findViewById(R.id.cmTimer)
|
|
|
|
|
cmTimer.format = "mm:ss"
|
|
|
|
|
cmTimer.onChronometerTickListener = Chronometer.OnChronometerTickListener { arg0: Chronometer? ->
|
|
|
|
|
cmTimer.onChronometerTickListener =
|
|
|
|
|
Chronometer.OnChronometerTickListener { arg0: Chronometer? ->
|
|
|
|
|
// val f: NumberFormat = DecimalFormat("00")
|
|
|
|
|
// f.format(minutes)
|
|
|
|
|
val minutes: Long
|
|
|
|
|
val seconds: Long
|
|
|
|
|
if (!resume) {
|
|
|
|
|
minutes = (SystemClock.elapsedRealtime() - cmTimer.base) / 1000 / 60
|
|
|
|
|
seconds = (SystemClock.elapsedRealtime() - cmTimer.base) / 1000 % 60
|
|
|
|
|
elapsedTime = SystemClock.elapsedRealtime()
|
|
|
|
|
} else {
|
|
|
|
|
minutes = (elapsedTime - cmTimer.base) / 1000 / 60
|
|
|
|
|
seconds = (elapsedTime - cmTimer.base) / 1000 % 60
|
|
|
|
|
elapsedTime += 1000
|
|
|
|
|
}
|
|
|
|
|
val format = "%1$02d:%2$02d" // two digits
|
|
|
|
|
val minutes: Long
|
|
|
|
|
val seconds: Long
|
|
|
|
|
if (!resume) {
|
|
|
|
|
minutes = (SystemClock.elapsedRealtime() - cmTimer.base) / 1000 / 60
|
|
|
|
|
seconds = (SystemClock.elapsedRealtime() - cmTimer.base) / 1000 % 60
|
|
|
|
|
elapsedTime = SystemClock.elapsedRealtime()
|
|
|
|
|
} else {
|
|
|
|
|
minutes = (elapsedTime - cmTimer.base) / 1000 / 60
|
|
|
|
|
seconds = (elapsedTime - cmTimer.base) / 1000 % 60
|
|
|
|
|
elapsedTime += 1000
|
|
|
|
|
}
|
|
|
|
|
val format = "%1$02d:%2$02d" // two digits
|
|
|
|
|
|
|
|
|
|
arg0?.text = String.format(format, minutes, seconds)
|
|
|
|
|
Log.d(TAG, "onChronometerTick: $minutes : $seconds")
|
|
|
|
|
}
|
|
|
|
|
arg0?.text = String.format(format, minutes, seconds)
|
|
|
|
|
Log.d(TAG, "onChronometerTick: $minutes : $seconds")
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
icMini.setOnClickListener {
|
|
|
|
|
onMiniCircleClicked()
|
|
|
|
|
@ -322,6 +339,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
// progressBar.setVisibility(View.GONE);
|
|
|
|
|
// hiddenButtons()
|
|
|
|
|
checkClientConnected()
|
|
|
|
|
handleVideoViewHeight(true)
|
|
|
|
|
|
|
|
|
|
if (appLang == "ar") {
|
|
|
|
|
progressBarLayout!!.layoutDirection = View.LAYOUT_DIRECTION_RTL
|
|
|
|
|
@ -344,7 +362,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)
|
|
|
|
|
}
|
|
|
|
|
@ -357,19 +379,25 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
Log.d(TAG, "onPermissionsDenied:" + requestCode + ":" + perms.size)
|
|
|
|
|
if (EasyPermissions.somePermissionPermanentlyDenied(this, perms)) {
|
|
|
|
|
AppSettingsDialog.Builder(this)
|
|
|
|
|
.setTitle(getString(R.string.title_settings_dialog))
|
|
|
|
|
.setRationale(getString(R.string.rationale_ask_again))
|
|
|
|
|
.setPositiveButton(getString(R.string.setting))
|
|
|
|
|
.setNegativeButton(getString(R.string.cancel))
|
|
|
|
|
.setRequestCode(RC_SETTINGS_SCREEN_PERM)
|
|
|
|
|
.build()
|
|
|
|
|
.show()
|
|
|
|
|
.setTitle(getString(R.string.title_settings_dialog))
|
|
|
|
|
.setRationale(getString(R.string.rationale_ask_again))
|
|
|
|
|
.setPositiveButton(getString(R.string.setting))
|
|
|
|
|
.setNegativeButton(getString(R.string.cancel))
|
|
|
|
|
.setRequestCode(RC_SETTINGS_SCREEN_PERM)
|
|
|
|
|
.build()
|
|
|
|
|
.show()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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()
|
|
|
|
|
@ -379,7 +407,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
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -388,7 +421,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
mPublisher = Publisher.Builder(requireContext())
|
|
|
|
|
// .name("publisher")
|
|
|
|
|
// .renderer(ThumbnailCircleVideoRenderer(requireContext()))
|
|
|
|
|
.build()
|
|
|
|
|
.build()
|
|
|
|
|
mPublisher!!.setPublisherListener(this)
|
|
|
|
|
if (mPublisher!!.view is GLSurfaceView) {
|
|
|
|
|
(mPublisher!!.view as GLSurfaceView).setZOrderOnTop(true)
|
|
|
|
|
@ -421,7 +454,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
|
|
|
|
|
@ -430,11 +466,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
|
|
|
|
|
}
|
|
|
|
|
@ -461,7 +508,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()
|
|
|
|
|
@ -527,8 +577,8 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
private fun subscribeToStream(stream: Stream) {
|
|
|
|
|
mSubscriber = Subscriber.Builder(requireContext(), stream)
|
|
|
|
|
.renderer(DynamicVideoRenderer(requireContext()))
|
|
|
|
|
.build()
|
|
|
|
|
.renderer(DynamicVideoRenderer(requireContext()))
|
|
|
|
|
.build()
|
|
|
|
|
mSubscriber!!.setVideoListener(this)
|
|
|
|
|
mSession!!.subscribe(mSubscriber)
|
|
|
|
|
}
|
|
|
|
|
@ -556,7 +606,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()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -596,13 +654,13 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
private fun onMiniCircleClicked() {
|
|
|
|
|
if (isCircle) {
|
|
|
|
|
dialog?.window?.setLayout(
|
|
|
|
|
400,
|
|
|
|
|
600
|
|
|
|
|
400,
|
|
|
|
|
600
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
dialog?.window?.setLayout(
|
|
|
|
|
300,
|
|
|
|
|
300
|
|
|
|
|
300,
|
|
|
|
|
300
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
isCircle = !isCircle
|
|
|
|
|
@ -611,11 +669,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
|
|
|
|
|
)
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -626,18 +696,20 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
controlPanel.visibility = View.VISIBLE
|
|
|
|
|
layoutMini.visibility = View.VISIBLE
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
handleVideoViewHeight(isFullScreen)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun onMinimizedClicked(view: View?) {
|
|
|
|
|
if (isFullScreen) {
|
|
|
|
|
dialog?.window?.setLayout(
|
|
|
|
|
400,
|
|
|
|
|
600
|
|
|
|
|
400,
|
|
|
|
|
600
|
|
|
|
|
)
|
|
|
|
|
} else {
|
|
|
|
|
dialog?.window?.setLayout(
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT,
|
|
|
|
|
LinearLayout.LayoutParams.MATCH_PARENT
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
isFullScreen = !isFullScreen
|
|
|
|
|
@ -650,26 +722,36 @@ 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 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 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 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 miniLayoutParam: ConstraintLayout.LayoutParams = layoutMini.layoutParams as ConstraintLayout.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
|
|
|
|
|
@ -688,7 +770,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
|
|
|
|
|
@ -716,7 +798,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
|
|
|
|
|
@ -744,6 +826,82 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
btnMinimize.layoutParams = btnMinimizeLayoutParam
|
|
|
|
|
mCallBtn.layoutParams = mCallBtnLayoutParam
|
|
|
|
|
|
|
|
|
|
handleVideoViewHeight(isFullScreen)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun handleVideoViewHeight(isFullScreen: Boolean) {
|
|
|
|
|
val layoutNameParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
layoutName.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
val layoutMiniParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
layoutMini.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
val controlPanelParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
controlPanel.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
val layoutNameHeight: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.layout_name_height).toInt()
|
|
|
|
|
val layoutMiniHeight: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.layout_mini_height).toInt()
|
|
|
|
|
val panelHeight: Int = context!!.resources.getDimension(R.dimen.layout_panel_height).toInt()
|
|
|
|
|
val panelHeightSmall: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.layout_panel_height_small).toInt()
|
|
|
|
|
|
|
|
|
|
val panelPadding: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.padding_space_big).toInt()
|
|
|
|
|
val panelPaddingMedium: Int =
|
|
|
|
|
context!!.resources.getDimension(R.dimen.padding_space_medium).toInt()
|
|
|
|
|
|
|
|
|
|
val temp = getStatusBarHeight() / 2
|
|
|
|
|
|
|
|
|
|
val screenWidth: Float
|
|
|
|
|
val screenHeight: Float
|
|
|
|
|
|
|
|
|
|
if (isFullScreen) {
|
|
|
|
|
screenWidth = ViewsUtil.getWidthDp(requireContext())
|
|
|
|
|
screenHeight = ViewsUtil.getHeightDp(requireContext())
|
|
|
|
|
|
|
|
|
|
layoutNameParam.height = layoutNameHeight + temp
|
|
|
|
|
layoutMiniParam.height = 0
|
|
|
|
|
controlPanelParam.height = panelHeight + temp
|
|
|
|
|
|
|
|
|
|
controlPanel.setPadding(panelPadding, panelPadding, panelPadding, panelPadding)
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if (isCircle) {
|
|
|
|
|
screenWidth = 300F
|
|
|
|
|
screenHeight = 300F
|
|
|
|
|
|
|
|
|
|
layoutNameParam.height = 0
|
|
|
|
|
layoutMiniParam.height = 0
|
|
|
|
|
controlPanelParam.height = 0
|
|
|
|
|
} else {
|
|
|
|
|
screenWidth = 400F
|
|
|
|
|
screenHeight = 600F
|
|
|
|
|
|
|
|
|
|
layoutNameParam.height = 0
|
|
|
|
|
layoutMiniParam.height = layoutMiniHeight
|
|
|
|
|
controlPanelParam.height = panelHeightSmall
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
controlPanel.setPadding(panelPaddingMedium, panelPaddingMedium, panelPaddingMedium, panelPaddingMedium)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
layoutName.layoutParams = layoutNameParam
|
|
|
|
|
layoutMini.layoutParams = layoutMiniParam
|
|
|
|
|
controlPanel.layoutParams = controlPanelParam
|
|
|
|
|
|
|
|
|
|
var videoStreamHeight =
|
|
|
|
|
screenHeight - controlPanelParam.height - layoutNameParam.height - layoutMiniParam.height
|
|
|
|
|
|
|
|
|
|
if (isFullScreen){
|
|
|
|
|
// videoStreamHeight -= getStatusBarHeight() / 2
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
val callLayoutParam: ConstraintLayout.LayoutParams =
|
|
|
|
|
activity_clingo_video_call.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
|
|
|
|
|
|
callLayoutParam.height = videoStreamHeight.toInt()
|
|
|
|
|
callLayoutParam.width = screenWidth.toInt()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun onCameraClicked(view: View?) {
|
|
|
|
|
@ -872,7 +1030,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
var mParams: WindowManager.LayoutParams = dialog!!.window!!.attributes
|
|
|
|
|
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord - videoCallContainer.width).toInt()
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
dialog!!.window!!.attributes = mParams
|
|
|
|
|
val x = szWindow.x - current_x_cord
|
|
|
|
|
@ -883,9 +1041,9 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
val step = (500 - t) / 5
|
|
|
|
|
// mParams.x = 0 - (current_x_cord * current_x_cord * step).toInt()
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
dialog!!.window!!.attributes = mParams
|
|
|
|
|
dialog?.window?.attributes = mParams
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFinish() {
|
|
|
|
|
@ -909,7 +1067,7 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
override fun onTick(t: Long) {
|
|
|
|
|
val step = (500 - t) / 5
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x + current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
(szWindow.x + current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
dialog!!.window!!.attributes = mParams
|
|
|
|
|
}
|
|
|
|
|
@ -924,17 +1082,20 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
|
|
|
|
|
private fun getWindowManagerDefaultDisplay() {
|
|
|
|
|
mWindowManager.getDefaultDisplay()
|
|
|
|
|
.getSize(szWindow)
|
|
|
|
|
.getSize(szWindow)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* return status bar height on basis of device display metrics */
|
|
|
|
|
private fun getStatusBarHeight(): Int {
|
|
|
|
|
return ceil(
|
|
|
|
|
(25 * requireActivity().applicationContext.resources.displayMetrics.density).toDouble()
|
|
|
|
|
(25 * requireActivity().applicationContext.resources.displayMetrics.density).toDouble()
|
|
|
|
|
).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()
|
|
|
|
|
@ -951,9 +1112,9 @@ class VideoCallFragment : DialogFragment(), PermissionCallbacks, Session.Session
|
|
|
|
|
companion object {
|
|
|
|
|
@JvmStatic
|
|
|
|
|
fun newInstance(args: Bundle) =
|
|
|
|
|
VideoCallFragment().apply {
|
|
|
|
|
arguments = args
|
|
|
|
|
}
|
|
|
|
|
VideoCallFragment().apply {
|
|
|
|
|
arguments = args
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val TAG = VideoCallFragment::class.java.simpleName
|
|
|
|
|
|
|
|
|
|
|