|
|
|
|
@ -16,6 +16,7 @@ import com.hmg.hmgDr.Model.GetSessionStatusModel
|
|
|
|
|
import com.hmg.hmgDr.Model.SessionStatusModel
|
|
|
|
|
import com.hmg.hmgDr.Service.VideoStreamContainerService
|
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
|
import com.hmg.hmgDr.ui.fragment.VideoCallFragment
|
|
|
|
|
import io.flutter.embedding.android.FlutterFragmentActivity
|
|
|
|
|
import io.flutter.embedding.engine.FlutterEngine
|
|
|
|
|
import io.flutter.plugin.common.MethodCall
|
|
|
|
|
@ -32,6 +33,7 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
|
private var call: MethodCall? = null
|
|
|
|
|
private val LAUNCH_VIDEO: Int = 1
|
|
|
|
|
|
|
|
|
|
private var dialogFragment: VideoCallFragment? = null
|
|
|
|
|
private var serviceIntent: Intent? = null
|
|
|
|
|
private var videoStreamService: VideoStreamContainerService? = null
|
|
|
|
|
private var bound = false
|
|
|
|
|
@ -105,7 +107,7 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
|
putExtras(arguments)
|
|
|
|
|
startService(this)
|
|
|
|
|
}
|
|
|
|
|
bindService()
|
|
|
|
|
// bindService()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
|
|
@ -135,9 +137,8 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
override fun onCallFinished(resultCode: Int, intent: Intent?) {
|
|
|
|
|
// TODO uncomment it
|
|
|
|
|
|
|
|
|
|
/*if (resultCode == Activity.RESULT_OK) {
|
|
|
|
|
if (resultCode == Activity.RESULT_OK) {
|
|
|
|
|
val result: SessionStatusModel? = intent?.getParcelableExtra("sessionStatusNotRespond")
|
|
|
|
|
val callResponse: HashMap<String, String> = HashMap()
|
|
|
|
|
|
|
|
|
|
@ -162,10 +163,10 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
|
Log.e("onVideoCallFinished", "${e.message}.")
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
*/
|
|
|
|
|
stopService(serviceIntent)
|
|
|
|
|
unbindService()
|
|
|
|
|
videoStreamService!!.serviceRunning = false
|
|
|
|
|
|
|
|
|
|
// stopService(serviceIntent)
|
|
|
|
|
// unbindService()
|
|
|
|
|
// videoStreamService!!.serviceRunning = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun minimizeVideoEvent(isMinimize: Boolean) {
|
|
|
|
|
@ -189,40 +190,40 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
|
// unbindService()
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
private fun bindService() {
|
|
|
|
|
serviceIntent?.run {
|
|
|
|
|
if (videoStreamService != null && !videoStreamService!!.serviceRunning){
|
|
|
|
|
startService(this)
|
|
|
|
|
}
|
|
|
|
|
bindService(this, serviceConnection, Context.BIND_AUTO_CREATE)
|
|
|
|
|
videoStreamService?.serviceRunning = true
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private fun unbindService() {
|
|
|
|
|
if (bound) {
|
|
|
|
|
videoStreamService!!.videoCallResponseListener = null // unregister
|
|
|
|
|
videoStreamService!!.mActivity = null
|
|
|
|
|
unbindService(serviceConnection)
|
|
|
|
|
bound = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private val serviceConnection: ServiceConnection = object : ServiceConnection {
|
|
|
|
|
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
|
|
|
|
val binder: VideoStreamContainerService.VideoStreamBinder =
|
|
|
|
|
service as VideoStreamContainerService.VideoStreamBinder
|
|
|
|
|
videoStreamService = binder.service
|
|
|
|
|
bound = true
|
|
|
|
|
videoStreamService!!.videoCallResponseListener = this@MainActivity // register
|
|
|
|
|
videoStreamService!!.mActivity = this@MainActivity // register
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
override fun onServiceDisconnected(name: ComponentName?) {
|
|
|
|
|
bound = false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
// private fun bindService() {
|
|
|
|
|
// serviceIntent?.run {
|
|
|
|
|
// if (videoStreamService != null && !videoStreamService!!.serviceRunning){
|
|
|
|
|
// startService(this)
|
|
|
|
|
// }
|
|
|
|
|
// bindService(this, serviceConnection, Context.BIND_AUTO_CREATE)
|
|
|
|
|
// videoStreamService?.serviceRunning = true
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private fun unbindService() {
|
|
|
|
|
// if (bound) {
|
|
|
|
|
// videoStreamService!!.videoCallResponseListener = null // unregister
|
|
|
|
|
// videoStreamService!!.mActivity = null
|
|
|
|
|
// unbindService(serviceConnection)
|
|
|
|
|
// bound = false
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// private val serviceConnection: ServiceConnection = object : ServiceConnection {
|
|
|
|
|
// override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
|
|
|
|
// val binder: VideoStreamContainerService.VideoStreamBinder =
|
|
|
|
|
// service as VideoStreamContainerService.VideoStreamBinder
|
|
|
|
|
// videoStreamService = binder.service
|
|
|
|
|
// bound = true
|
|
|
|
|
// videoStreamService!!.videoCallResponseListener = this@MainActivity // register
|
|
|
|
|
// videoStreamService!!.mActivity = this@MainActivity // register
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// override fun onServiceDisconnected(name: ComponentName?) {
|
|
|
|
|
// bound = false
|
|
|
|
|
// }
|
|
|
|
|
//
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// code to hide soft keyboard
|
|
|
|
|
fun hideSoftKeyBoard(editBox: EditText?) {
|
|
|
|
|
|