|
|
|
|
@ -1,6 +1,5 @@
|
|
|
|
|
package com.hmg.hmgDr.Service
|
|
|
|
|
|
|
|
|
|
import android.Manifest
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
|
|
import android.app.Activity
|
|
|
|
|
import android.app.Service
|
|
|
|
|
@ -23,13 +22,9 @@ import com.hmg.hmgDr.R
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallContract
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallPresenterImpl
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
|
import com.hmg.hmgDr.ui.fragment.VideoCallFragment
|
|
|
|
|
import com.hmg.hmgDr.util.DynamicVideoRenderer
|
|
|
|
|
import com.hmg.hmgDr.util.ViewsUtil
|
|
|
|
|
import com.opentok.android.*
|
|
|
|
|
import pub.devrel.easypermissions.AfterPermissionGranted
|
|
|
|
|
import pub.devrel.easypermissions.AppSettingsDialog
|
|
|
|
|
import pub.devrel.easypermissions.EasyPermissions
|
|
|
|
|
import kotlin.math.ceil
|
|
|
|
|
|
|
|
|
|
class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
@ -46,7 +41,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private lateinit var windowManagerParams : WindowManager.LayoutParams
|
|
|
|
|
private lateinit var windowManagerParams: WindowManager.LayoutParams
|
|
|
|
|
private var mWindowManager: WindowManager? = null
|
|
|
|
|
private val szWindow = Point()
|
|
|
|
|
private var floatingWidgetView: View? = null
|
|
|
|
|
@ -116,7 +111,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
|
|
|
|
|
private val serviceBinder: IBinder = VideoStreamBinder()
|
|
|
|
|
|
|
|
|
|
override fun onBind(intent: Intent?): IBinder? {
|
|
|
|
|
override fun onBind(intent: Intent?): IBinder {
|
|
|
|
|
return serviceBinder
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -157,7 +152,8 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onDestroy() {
|
|
|
|
|
disconnectSession()
|
|
|
|
|
mWindowManager?.removeView(floatingWidgetView)
|
|
|
|
|
// disconnectSession()
|
|
|
|
|
cmTimer.stop()
|
|
|
|
|
super.onDestroy()
|
|
|
|
|
}
|
|
|
|
|
@ -196,7 +192,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
init(floatingWidgetView!!)
|
|
|
|
|
|
|
|
|
|
//Add the view to the window
|
|
|
|
|
mWindowManager!!.addView(floatingWidgetView, windowManagerParams)
|
|
|
|
|
mWindowManager?.addView(floatingWidgetView, windowManagerParams)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@SuppressLint("ClickableViewAccessibility")
|
|
|
|
|
@ -312,7 +308,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
videoCallPresenter.callClintConnected(sessionStatusModel)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
mConnectedHandler!!.postDelayed(mConnectedRunnable!!, (55 * 1000).toLong())
|
|
|
|
|
mConnectedHandler!!.postDelayed(mConnectedRunnable!!, (10 * 1000).toLong()) // TODO MOSA return from 10 to 55
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun handleVideoViewHeight() {
|
|
|
|
|
@ -511,13 +507,13 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
windowManagerParams.width = 400
|
|
|
|
|
windowManagerParams.height = 600
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
recordContainer.visibility = View.GONE
|
|
|
|
|
} else {
|
|
|
|
|
windowManagerParams.width = WindowManager.LayoutParams.MATCH_PARENT
|
|
|
|
|
windowManagerParams.height = WindowManager.LayoutParams.MATCH_PARENT
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
|
|
|
|
|
if (isRecording) {
|
|
|
|
|
recordContainer.visibility = View.VISIBLE
|
|
|
|
|
@ -583,12 +579,12 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
windowManagerParams.width = 400
|
|
|
|
|
windowManagerParams.height = 600
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
} else {
|
|
|
|
|
windowManagerParams.width = 300
|
|
|
|
|
windowManagerParams.height = 300
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, windowManagerParams)
|
|
|
|
|
}
|
|
|
|
|
isCircle = !isCircle
|
|
|
|
|
|
|
|
|
|
@ -642,7 +638,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fun closeVideoCall(){
|
|
|
|
|
fun closeVideoCall() {
|
|
|
|
|
onCallClicked()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -730,7 +726,6 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
private fun disconnectSession() {
|
|
|
|
|
if (mSession == null) {
|
|
|
|
|
videoCallResponseListener?.onCallFinished(Activity.RESULT_CANCELED)
|
|
|
|
|
// requireActivity().setResult(Activity.RESULT_CANCELED)
|
|
|
|
|
stopSelf()
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
@ -867,8 +862,8 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
if (sessionStatusModel.sessionStatus == 2 || sessionStatusModel.sessionStatus == 3) {
|
|
|
|
|
val returnIntent = Intent()
|
|
|
|
|
returnIntent.putExtra("sessionStatusNotRespond", sessionStatusModel)
|
|
|
|
|
disconnectSession()
|
|
|
|
|
videoCallResponseListener?.onCallFinished(Activity.RESULT_OK, returnIntent)
|
|
|
|
|
// requireActivity().setResult(Activity.RESULT_OK, returnIntent)
|
|
|
|
|
stopSelf()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -929,12 +924,13 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
mDetector.onTouchEvent(event)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if(floatingWidgetView!!.layoutParams is WindowManager.LayoutParams){
|
|
|
|
|
if (floatingWidgetView!!.layoutParams is WindowManager.LayoutParams) {
|
|
|
|
|
var asd = "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//Get Floating widget view params
|
|
|
|
|
val layoutParams: WindowManager.LayoutParams = floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
val layoutParams: WindowManager.LayoutParams =
|
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
//get the touch location coordinates
|
|
|
|
|
val x_cord = event.rawX.toInt()
|
|
|
|
|
val y_cord = event.rawY.toInt()
|
|
|
|
|
@ -981,7 +977,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
layoutParams.y = y_cord_Destination
|
|
|
|
|
|
|
|
|
|
//Update the layout with new X & Y coordinate
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, layoutParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, layoutParams)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
true
|
|
|
|
|
@ -999,16 +995,18 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
/* Method to move the Floating widget view to Left */
|
|
|
|
|
private fun moveToLeft(current_x_cord: Int) {
|
|
|
|
|
|
|
|
|
|
val mParams: WindowManager.LayoutParams = floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
val mParams: WindowManager.LayoutParams =
|
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
val x = szWindow.x - current_x_cord
|
|
|
|
|
object : CountDownTimer(500, 5) {
|
|
|
|
|
//get params of Floating Widget view
|
|
|
|
|
val mParams: WindowManager.LayoutParams = floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
val mParams: WindowManager.LayoutParams =
|
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
|
|
|
|
|
override fun onTick(t: Long) {
|
|
|
|
|
val step = (500 - t) / 5
|
|
|
|
|
@ -1016,13 +1014,13 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x - current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFinish() {
|
|
|
|
|
mParams.x = -(szWindow.x - videoCallContainer.width)
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
}
|
|
|
|
|
}.start()
|
|
|
|
|
}
|
|
|
|
|
@ -1036,19 +1034,21 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
// dialog!!.window!!.attributes = mParams
|
|
|
|
|
object : CountDownTimer(500, 5) {
|
|
|
|
|
//get params of Floating Widget view
|
|
|
|
|
val mParams: WindowManager.LayoutParams = floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
val mParams: WindowManager.LayoutParams =
|
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
|
|
|
|
|
|
override fun onTick(t: Long) {
|
|
|
|
|
val step = (500 - t) / 5
|
|
|
|
|
mParams.x =
|
|
|
|
|
(szWindow.x + current_x_cord * current_x_cord * step - videoCallContainer.width).toInt()
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onFinish() {
|
|
|
|
|
mParams.x = szWindow.x - videoCallContainer.width
|
|
|
|
|
|
|
|
|
|
mWindowManager!!.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
mWindowManager?.updateViewLayout(floatingWidgetView, mParams)
|
|
|
|
|
}
|
|
|
|
|
}.start()
|
|
|
|
|
}
|
|
|
|
|
|