|
|
|
@ -1,14 +1,17 @@
|
|
|
|
package com.hmg.hmgDr
|
|
|
|
package com.hmg.hmgDr
|
|
|
|
|
|
|
|
|
|
|
|
import android.app.Activity
|
|
|
|
import android.app.Activity
|
|
|
|
|
|
|
|
import android.content.ComponentName
|
|
|
|
import android.content.Intent
|
|
|
|
import android.content.Intent
|
|
|
|
|
|
|
|
import android.content.ServiceConnection
|
|
|
|
import android.os.Bundle
|
|
|
|
import android.os.Bundle
|
|
|
|
|
|
|
|
import android.os.IBinder
|
|
|
|
import android.util.Log
|
|
|
|
import android.util.Log
|
|
|
|
import android.widget.Toast
|
|
|
|
|
|
|
|
import androidx.annotation.NonNull
|
|
|
|
import androidx.annotation.NonNull
|
|
|
|
import com.google.gson.GsonBuilder
|
|
|
|
import com.google.gson.GsonBuilder
|
|
|
|
import com.hmg.hmgDr.Model.GetSessionStatusModel
|
|
|
|
import com.hmg.hmgDr.Model.GetSessionStatusModel
|
|
|
|
import com.hmg.hmgDr.Model.SessionStatusModel
|
|
|
|
import com.hmg.hmgDr.Model.SessionStatusModel
|
|
|
|
|
|
|
|
import com.hmg.hmgDr.Service.VideoStreamContainerService
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
import com.hmg.hmgDr.ui.fragment.VideoCallFragment
|
|
|
|
import com.hmg.hmgDr.ui.fragment.VideoCallFragment
|
|
|
|
import io.flutter.embedding.android.FlutterFragmentActivity
|
|
|
|
import io.flutter.embedding.android.FlutterFragmentActivity
|
|
|
|
@ -26,6 +29,10 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
private var call: MethodCall? = null
|
|
|
|
private var call: MethodCall? = null
|
|
|
|
private val LAUNCH_VIDEO: Int = 1
|
|
|
|
private val LAUNCH_VIDEO: Int = 1
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var serviceIntent: Intent? = null
|
|
|
|
|
|
|
|
private var videoStreamService: VideoStreamContainerService? = null
|
|
|
|
|
|
|
|
private var bound = false
|
|
|
|
|
|
|
|
|
|
|
|
private var dialogFragment: VideoCallFragment? = null
|
|
|
|
private var dialogFragment: VideoCallFragment? = null
|
|
|
|
|
|
|
|
|
|
|
|
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
|
|
|
override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) {
|
|
|
|
@ -74,7 +81,6 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun openVideoCall(apiKey: String?, sessionId: String?, token: String?, appLang: String?, baseUrl: String?, sessionStatusModel: GetSessionStatusModel) {
|
|
|
|
private fun openVideoCall(apiKey: String?, sessionId: String?, token: String?, appLang: String?, baseUrl: String?, sessionStatusModel: GetSessionStatusModel) {
|
|
|
|
if (dialogFragment == null) {
|
|
|
|
|
|
|
|
val arguments = Bundle()
|
|
|
|
val arguments = Bundle()
|
|
|
|
arguments.putString("apiKey", apiKey)
|
|
|
|
arguments.putString("apiKey", apiKey)
|
|
|
|
arguments.putString("sessionId", sessionId)
|
|
|
|
arguments.putString("sessionId", sessionId)
|
|
|
|
@ -83,6 +89,16 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
arguments.putString("baseUrl", baseUrl)
|
|
|
|
arguments.putString("baseUrl", baseUrl)
|
|
|
|
arguments.putParcelable("sessionStatusModel", sessionStatusModel)
|
|
|
|
arguments.putParcelable("sessionStatusModel", sessionStatusModel)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// start service
|
|
|
|
|
|
|
|
serviceIntent = Intent(this@MainActivity, VideoStreamContainerService::class.java)
|
|
|
|
|
|
|
|
serviceIntent?.run {
|
|
|
|
|
|
|
|
putExtras(arguments)
|
|
|
|
|
|
|
|
startService(this)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
VideoStreamContainerService.videoCallResponseListener = this
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dialogFragment == null) {
|
|
|
|
val transaction = supportFragmentManager.beginTransaction()
|
|
|
|
val transaction = supportFragmentManager.beginTransaction()
|
|
|
|
dialogFragment = VideoCallFragment.newInstance(arguments)
|
|
|
|
dialogFragment = VideoCallFragment.newInstance(arguments)
|
|
|
|
dialogFragment?.let {
|
|
|
|
dialogFragment?.let {
|
|
|
|
@ -93,8 +109,6 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
it.show(transaction, "dialog")
|
|
|
|
it.show(transaction, "dialog")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else if (!dialogFragment!!.isVisible) {
|
|
|
|
} else if (!dialogFragment!!.isVisible) {
|
|
|
|
val transaction = supportFragmentManager.beginTransaction()
|
|
|
|
val transaction = supportFragmentManager.beginTransaction()
|
|
|
|
@ -102,7 +116,6 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
|
/* override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
|
super.onActivityResult(requestCode, resultCode, data)
|
|
|
|
var asd = "";
|
|
|
|
var asd = "";
|
|
|
|
@ -175,4 +188,40 @@ class MainActivity : FlutterFragmentActivity(), MethodChannel.MethodCallHandler,
|
|
|
|
super.onBackPressed()
|
|
|
|
super.onBackPressed()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onStart() {
|
|
|
|
|
|
|
|
super.onStart()
|
|
|
|
|
|
|
|
bindService()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onStop() {
|
|
|
|
|
|
|
|
super.onStop()
|
|
|
|
|
|
|
|
unbindService()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun bindService() {
|
|
|
|
|
|
|
|
bindService(serviceIntent, serviceConnection, Context.BIND_AUTO_CREATE)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun unbindService() {
|
|
|
|
|
|
|
|
if (bound) {
|
|
|
|
|
|
|
|
gpsService.registerCallBack(null) // unregister
|
|
|
|
|
|
|
|
unbindService(serviceConnection)
|
|
|
|
|
|
|
|
bound = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val serviceConnection: ServiceConnection = object : ServiceConnection {
|
|
|
|
|
|
|
|
override fun onServiceConnected(name: ComponentName?, service: IBinder?) {
|
|
|
|
|
|
|
|
val binder: VideoStreamContainerService.GPSBinder = service as GPSService.GPSBinder
|
|
|
|
|
|
|
|
gpsService = binder.getService()
|
|
|
|
|
|
|
|
bound = true
|
|
|
|
|
|
|
|
gpsService.registerCallBack(this@YourActivity) // register
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
override fun onServiceDisconnected(name: ComponentName?) {
|
|
|
|
|
|
|
|
bound = false
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|