|
|
|
@ -17,16 +17,19 @@ import androidx.core.app.NotificationCompat
|
|
|
|
import androidx.core.app.NotificationManagerCompat
|
|
|
|
import androidx.core.app.NotificationManagerCompat
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.content.ContextCompat
|
|
|
|
import androidx.core.view.GestureDetectorCompat
|
|
|
|
import androidx.core.view.GestureDetectorCompat
|
|
|
|
|
|
|
|
import com.hmg.hmgDr.MainActivity
|
|
|
|
import com.hmg.hmgDr.R
|
|
|
|
import com.hmg.hmgDr.R
|
|
|
|
import com.hmg.hmgDr.model.*
|
|
|
|
import com.hmg.hmgDr.model.*
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallContract
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallContract
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallPresenterImpl
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallPresenterImpl
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
import com.hmg.hmgDr.ui.VideoCallResponseListener
|
|
|
|
|
|
|
|
import com.hmg.hmgDr.util.DateUtils
|
|
|
|
import com.hmg.hmgDr.util.DynamicVideoRenderer
|
|
|
|
import com.hmg.hmgDr.util.DynamicVideoRenderer
|
|
|
|
import com.hmg.hmgDr.util.NotificationUtil
|
|
|
|
import com.hmg.hmgDr.util.NotificationUtil
|
|
|
|
import com.hmg.hmgDr.util.ViewsUtil
|
|
|
|
import com.hmg.hmgDr.util.ViewsUtil
|
|
|
|
import com.hmg.hmgDr.util.audio.CustomAudioDevice
|
|
|
|
import com.hmg.hmgDr.util.audio.CustomAudioDevice
|
|
|
|
import com.opentok.android.*
|
|
|
|
import com.opentok.android.*
|
|
|
|
|
|
|
|
import java.util.*
|
|
|
|
import kotlin.math.ceil
|
|
|
|
import kotlin.math.ceil
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -53,8 +56,18 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
const val ACTION_START_CALL = "com.hmg.hmgDr.Service.action.startCall"
|
|
|
|
const val ACTION_START_CALL = "com.hmg.hmgDr.Service.action.startCall"
|
|
|
|
const val ACTION_MINIMIZE_CALL = "com.hmg.hmgDr.Service.action.minimizeCall"
|
|
|
|
const val ACTION_MINIMIZE_CALL = "com.hmg.hmgDr.Service.action.minimizeCall"
|
|
|
|
const val ACTION_END_CALL = "com.hmg.hmgDr.Service.action.endCall"
|
|
|
|
const val ACTION_END_CALL = "com.hmg.hmgDr.Service.action.endCall"
|
|
|
|
|
|
|
|
const val ACTION_CHANGE_EXPANDED_COLLAPSED =
|
|
|
|
|
|
|
|
"com.hmg.hmgDr.Service.action.changeExpandedCollapsed"
|
|
|
|
|
|
|
|
const val NOTIFICATION_IS_EXPANDED = "is_expanded"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var arguments: Bundle? = null
|
|
|
|
|
|
|
|
var serviceRunning: Boolean = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val serviceBinder: IBinder = VideoStreamBinder()
|
|
|
|
|
|
|
|
private lateinit var videoCallPresenter: VideoCallContract.VideoCallPresenter
|
|
|
|
|
|
|
|
var videoCallResponseListener: VideoCallResponseListener? = null
|
|
|
|
|
|
|
|
|
|
|
|
private lateinit var windowManagerParams: WindowManager.LayoutParams
|
|
|
|
private lateinit var windowManagerParams: WindowManager.LayoutParams
|
|
|
|
private var mWindowManager: WindowManager? = null
|
|
|
|
private var mWindowManager: WindowManager? = null
|
|
|
|
private val szWindow = Point()
|
|
|
|
private val szWindow = Point()
|
|
|
|
@ -86,10 +99,8 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
private lateinit var mspeckerBtn: ImageView
|
|
|
|
private lateinit var mspeckerBtn: ImageView
|
|
|
|
private lateinit var mMicBtn: ImageView
|
|
|
|
private lateinit var mMicBtn: ImageView
|
|
|
|
private lateinit var patientName: TextView
|
|
|
|
private lateinit var patientName: TextView
|
|
|
|
private lateinit var cmTimer: Chronometer
|
|
|
|
private lateinit var tvTimer: TextView
|
|
|
|
|
|
|
|
// private lateinit var cmTimer: Chronometer
|
|
|
|
private lateinit var videoCallPresenter: VideoCallContract.VideoCallPresenter
|
|
|
|
|
|
|
|
var videoCallResponseListener: VideoCallResponseListener? = null
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var mSession: Session? = null
|
|
|
|
private var mSession: Session? = null
|
|
|
|
private var mPublisher: Publisher? = null
|
|
|
|
private var mPublisher: Publisher? = null
|
|
|
|
@ -101,6 +112,10 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
private var mConnectedRunnable: Runnable? = null
|
|
|
|
private var mConnectedRunnable: Runnable? = null
|
|
|
|
private var isConnected = false
|
|
|
|
private var isConnected = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var mCallTimerHandler: Handler? = null
|
|
|
|
|
|
|
|
private var mCallTimerRunnable: Runnable? = null
|
|
|
|
|
|
|
|
private var mCallFirstTime: Date = Date()
|
|
|
|
|
|
|
|
|
|
|
|
private var sessionStatusModel: GetSessionStatusModel? = null
|
|
|
|
private var sessionStatusModel: GetSessionStatusModel? = null
|
|
|
|
private lateinit var mDetector: GestureDetectorCompat
|
|
|
|
private lateinit var mDetector: GestureDetectorCompat
|
|
|
|
|
|
|
|
|
|
|
|
@ -119,30 +134,15 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
private var formattedCallTime: String = "00:00"
|
|
|
|
private var formattedCallTime: String = "00:00"
|
|
|
|
private lateinit var notificationData: NotificationVideoModel
|
|
|
|
private lateinit var notificationData: NotificationVideoModel
|
|
|
|
|
|
|
|
|
|
|
|
private val mVideoPLRatio = 0.0
|
|
|
|
|
|
|
|
private val mVideoBw: Long = 0
|
|
|
|
|
|
|
|
private val mAudioPLRatio = 0.0
|
|
|
|
|
|
|
|
private val mAudioBw: Long = 0
|
|
|
|
|
|
|
|
private val mPrevVideoPacketsLost: Long = 0
|
|
|
|
|
|
|
|
private val mPrevVideoPacketsRcvd: Long = 0
|
|
|
|
|
|
|
|
private val mPrevVideoTimestamp = 0.0
|
|
|
|
|
|
|
|
private val mPrevVideoBytes: Long = 0
|
|
|
|
|
|
|
|
private val mPrevAudioPacketsLost: Long = 0
|
|
|
|
|
|
|
|
private val mPrevAudioPacketsRcvd: Long = 0
|
|
|
|
|
|
|
|
private val mPrevAudioTimestamp = 0.0
|
|
|
|
|
|
|
|
private val mPrevAudioBytes: Long = 0
|
|
|
|
|
|
|
|
private val mStartTestTime: Long = 0
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val audioOnly = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private var resume = false
|
|
|
|
private var resume = false
|
|
|
|
var isFullScreen: Boolean = true
|
|
|
|
var isFullScreen: Boolean = true
|
|
|
|
private var isCircle: Boolean = false
|
|
|
|
private var isCircle: Boolean = false
|
|
|
|
|
|
|
|
lateinit var customAudioDevice: CustomAudioDevice
|
|
|
|
|
|
|
|
|
|
|
|
var arguments: Bundle? = null
|
|
|
|
|
|
|
|
var serviceRunning: Boolean = false
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private val serviceBinder: IBinder = VideoStreamBinder()
|
|
|
|
// notification's layout
|
|
|
|
|
|
|
|
private lateinit var mRemoteViews: RemoteViews
|
|
|
|
|
|
|
|
private lateinit var mRemoteViewsExpand: RemoteViews
|
|
|
|
|
|
|
|
|
|
|
|
// Notification variables
|
|
|
|
// Notification variables
|
|
|
|
private var mNotificationManagerCompat: NotificationManagerCompat? = null
|
|
|
|
private var mNotificationManagerCompat: NotificationManagerCompat? = null
|
|
|
|
@ -189,6 +189,26 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
} else if (action == ACTION_MINIMIZE_CALL) {
|
|
|
|
} else if (action == ACTION_MINIMIZE_CALL) {
|
|
|
|
if (!isFullScreen)
|
|
|
|
if (!isFullScreen)
|
|
|
|
onMinimizedClicked()
|
|
|
|
onMinimizedClicked()
|
|
|
|
|
|
|
|
} else if (action == ACTION_CHANGE_EXPANDED_COLLAPSED) {
|
|
|
|
|
|
|
|
val isExpanded = intent.extras!!.getBoolean(NOTIFICATION_IS_EXPANDED)
|
|
|
|
|
|
|
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
|
|
|
|
|
|
// No use channel importance
|
|
|
|
|
|
|
|
if (isExpanded) {
|
|
|
|
|
|
|
|
notificationCompatBuilder.priority = Notification.PRIORITY_LOW
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
notificationCompatBuilder.priority = Notification.PRIORITY_HIGH
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
if (isExpanded) {
|
|
|
|
|
|
|
|
notificationCompatBuilder.priority = Notification.PRIORITY_LOW
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
notificationCompatBuilder.priority = Notification.PRIORITY_HIGH
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mNotificationManagerCompat?.notify(
|
|
|
|
|
|
|
|
ONGOING_NOTIFICATION_ID,
|
|
|
|
|
|
|
|
notificationCompatBuilder.build()
|
|
|
|
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -216,9 +236,18 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun stopService() {
|
|
|
|
private fun stopService() {
|
|
|
|
|
|
|
|
// customAudioDevice.setRendererMute(false)
|
|
|
|
|
|
|
|
AudioDeviceManager.getAudioDevice().onPause()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// cmTimer.stop()
|
|
|
|
|
|
|
|
mCallTimerRunnable?.let {
|
|
|
|
|
|
|
|
mCallTimerHandler?.removeCallbacks(it)
|
|
|
|
|
|
|
|
mCallTimerHandler = null
|
|
|
|
|
|
|
|
mCallTimerRunnable = null
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// because problem that timer still continue longer a bit than service so notification called again
|
|
|
|
// because problem that timer still continue longer a bit than service so notification called again
|
|
|
|
mNotificationManagerCompat = null
|
|
|
|
mNotificationManagerCompat = null
|
|
|
|
cmTimer.stop()
|
|
|
|
|
|
|
|
stopForeground(true)
|
|
|
|
stopForeground(true)
|
|
|
|
stopSelf()
|
|
|
|
stopSelf()
|
|
|
|
videoCallResponseListener?.minimizeVideoEvent(false)
|
|
|
|
videoCallResponseListener?.minimizeVideoEvent(false)
|
|
|
|
@ -302,10 +331,10 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
recordContainer.visibility = View.GONE
|
|
|
|
recordContainer.visibility = View.GONE
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
cmTimer.format = "mm:ss"
|
|
|
|
cmTimer.format = "mm:ss"
|
|
|
|
cmTimer.onChronometerTickListener =
|
|
|
|
cmTimer.onChronometerTickListener =
|
|
|
|
Chronometer.OnChronometerTickListener { arg0: Chronometer? ->
|
|
|
|
Chronometer.OnChronometerTickListener { arg0: Chronometer ->
|
|
|
|
// val f: NumberFormat = DecimalFormat("00")
|
|
|
|
// val f: NumberFormat = DecimalFormat("00")
|
|
|
|
// f.format(minutes)
|
|
|
|
// f.format(minutes)
|
|
|
|
val minutes: Long
|
|
|
|
val minutes: Long
|
|
|
|
@ -321,38 +350,14 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
val format = "%1$02d:%2$02d" // two digits
|
|
|
|
val format = "%1$02d:%2$02d" // two digits
|
|
|
|
formattedCallTime = String.format(format, minutes, seconds)
|
|
|
|
formattedCallTime = String.format(format, minutes, seconds)
|
|
|
|
arg0?.text = formattedCallTime
|
|
|
|
arg0.text = formattedCallTime
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
notificationCompatBuilder.contentView.setChronometer(
|
|
|
|
|
|
|
|
R.id.notify_timer,
|
|
|
|
|
|
|
|
cmTimer.base,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
notificationCompatBuilder.bigContentView.setChronometer(
|
|
|
|
|
|
|
|
R.id.notify_timer,
|
|
|
|
|
|
|
|
cmTimer.base,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for change notification timer
|
|
|
|
|
|
|
|
if (mNotificationManagerCompat != null) {
|
|
|
|
|
|
|
|
val bigTextStyle = setNotificationBigStyle()
|
|
|
|
|
|
|
|
notificationCompatBuilder.setStyle(bigTextStyle)
|
|
|
|
|
|
|
|
mNotificationManagerCompat?.notify(
|
|
|
|
|
|
|
|
ONGOING_NOTIFICATION_ID,
|
|
|
|
|
|
|
|
notificationCompatBuilder.build()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
videoCallPresenter = VideoCallPresenterImpl(this, baseUrl)
|
|
|
|
videoCallPresenter = VideoCallPresenterImpl(this, baseUrl)
|
|
|
|
|
|
|
|
|
|
|
|
checkClientConnected()
|
|
|
|
checkClientConnected()
|
|
|
|
|
|
|
|
setCallStartTimer()
|
|
|
|
handleVideoViewHeight()
|
|
|
|
handleVideoViewHeight()
|
|
|
|
|
|
|
|
|
|
|
|
mDetector = GestureDetectorCompat(
|
|
|
|
mDetector = GestureDetectorCompat(
|
|
|
|
@ -363,18 +368,17 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
// Add a custom audio device before session initialization
|
|
|
|
// Add a custom audio device before session initialization
|
|
|
|
|
|
|
|
customAudioDevice = CustomAudioDevice(this)
|
|
|
|
// Add a custom audio device before session initialization
|
|
|
|
customAudioDevice.setRendererMute(false)
|
|
|
|
val customAudioDevice = CustomAudioDevice(
|
|
|
|
if (AudioDeviceManager.getAudioDevice() == null) {
|
|
|
|
this
|
|
|
|
AudioDeviceManager.setAudioDevice(customAudioDevice)
|
|
|
|
)
|
|
|
|
} else {
|
|
|
|
customAudioDevice.setRendererMute(true)
|
|
|
|
AudioDeviceManager.getAudioDevice().onResume()
|
|
|
|
AudioDeviceManager.setAudioDevice(customAudioDevice)
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mSession = Session.Builder(this, apiKey, sessionId).build()
|
|
|
|
mSession = Session.Builder(this, apiKey, sessionId).build()
|
|
|
|
mSession!!.setSessionListener(this)
|
|
|
|
mSession!!.setSessionListener(this)
|
|
|
|
mSession!!.connect(token)
|
|
|
|
mSession!!.connect(token)
|
|
|
|
|
|
|
|
|
|
|
|
mSession!!.setReconnectionListener(object : Session.ReconnectionListener {
|
|
|
|
mSession!!.setReconnectionListener(object : Session.ReconnectionListener {
|
|
|
|
override fun onReconnecting(session: Session?) {
|
|
|
|
override fun onReconnecting(session: Session?) {
|
|
|
|
|
|
|
|
|
|
|
|
@ -406,7 +410,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
mSubscriberViewContainer = view.findViewById(R.id.remote_video_view_container)
|
|
|
|
mSubscriberViewContainer = view.findViewById(R.id.remote_video_view_container)
|
|
|
|
|
|
|
|
|
|
|
|
patientName = view.findViewById(R.id.patient_name)
|
|
|
|
patientName = view.findViewById(R.id.patient_name)
|
|
|
|
cmTimer = view.findViewById(R.id.cmTimer)
|
|
|
|
tvTimer = view.findViewById(R.id.tv_timer)
|
|
|
|
|
|
|
|
|
|
|
|
controlPanel = view.findViewById(R.id.control_panel)
|
|
|
|
controlPanel = view.findViewById(R.id.control_panel)
|
|
|
|
mCallBtn = view.findViewById(R.id.btn_call)
|
|
|
|
mCallBtn = view.findViewById(R.id.btn_call)
|
|
|
|
@ -430,6 +434,45 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private fun setCallStartTimer() {
|
|
|
|
|
|
|
|
mCallTimerHandler = Handler((Looper.getMainLooper()))
|
|
|
|
|
|
|
|
mCallTimerRunnable = Runnable {
|
|
|
|
|
|
|
|
formattedCallTime = DateUtils.differentDateTimeBetweenDateAndNow(mCallFirstTime)
|
|
|
|
|
|
|
|
tvTimer.text = formattedCallTime
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
|
|
|
// comment it because I deleted remoteView
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
notificationCompatBuilder.contentView.setChronometer(
|
|
|
|
|
|
|
|
R.id.notify_timer,
|
|
|
|
|
|
|
|
cmTimer.base,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
notificationCompatBuilder.bigContentView.setChronometer(
|
|
|
|
|
|
|
|
R.id.notify_timer,
|
|
|
|
|
|
|
|
cmTimer.base,
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
true
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
} catch (e: Exception) {
|
|
|
|
|
|
|
|
print(e)
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// for change notification timer
|
|
|
|
|
|
|
|
if (mNotificationManagerCompat != null) {
|
|
|
|
|
|
|
|
val bigTextStyle = setNotificationBigStyle()
|
|
|
|
|
|
|
|
notificationCompatBuilder.setStyle(bigTextStyle)
|
|
|
|
|
|
|
|
mNotificationManagerCompat?.notify(
|
|
|
|
|
|
|
|
ONGOING_NOTIFICATION_ID,
|
|
|
|
|
|
|
|
notificationCompatBuilder.build()
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
mCallTimerHandler!!.postDelayed(mCallTimerRunnable!!, 1000L)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private fun handleVideoViewHeight() {
|
|
|
|
private fun handleVideoViewHeight() {
|
|
|
|
val layoutNameParam: ConstraintLayout.LayoutParams =
|
|
|
|
val layoutNameParam: ConstraintLayout.LayoutParams =
|
|
|
|
layoutName.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
layoutName.layoutParams as ConstraintLayout.LayoutParams
|
|
|
|
@ -698,7 +741,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
isMicClicked = !isMicClicked
|
|
|
|
isMicClicked = !isMicClicked
|
|
|
|
mPublisher!!.publishAudio = !isMicClicked
|
|
|
|
mPublisher!!.publishAudio = !isMicClicked
|
|
|
|
val res = if (isMicClicked) R.drawable.mic_disabled else R.drawable.mic_enabled
|
|
|
|
val res = if (isMicClicked) R.drawable.mic_disabled else R.drawable.mic_enabled
|
|
|
|
mMicBtn!!.setImageResource(res)
|
|
|
|
mMicBtn.setImageResource(res)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -796,10 +839,10 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
|
|
|
|
|
|
|
|
mSession!!.publish(mPublisher)
|
|
|
|
mSession!!.publish(mPublisher)
|
|
|
|
|
|
|
|
|
|
|
|
if (!resume) {
|
|
|
|
// start call timer to show on top
|
|
|
|
cmTimer.base = SystemClock.elapsedRealtime()
|
|
|
|
mCallFirstTime = Date()
|
|
|
|
}
|
|
|
|
mCallTimerHandler!!.postDelayed(mCallTimerRunnable!!, 1000L)
|
|
|
|
cmTimer.start()
|
|
|
|
|
|
|
|
videoCallResponseListener?.minimizeVideoEvent(true)
|
|
|
|
videoCallResponseListener?.minimizeVideoEvent(true)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -823,6 +866,7 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
TAG,
|
|
|
|
TAG,
|
|
|
|
"onStreamReceived: New stream " + stream.streamId + " in session " + session.sessionId
|
|
|
|
"onStreamReceived: New stream " + stream.streamId + " in session " + session.sessionId
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
if (mSubscriber != null) {
|
|
|
|
if (mSubscriber != null) {
|
|
|
|
isConnected = true
|
|
|
|
isConnected = true
|
|
|
|
return
|
|
|
|
return
|
|
|
|
@ -1111,24 +1155,57 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
)
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// notification's layout
|
|
|
|
|
|
|
|
val mRemoteViews = RemoteViews(packageName, R.layout.notifi_video_view)
|
|
|
|
/*
|
|
|
|
|
|
|
|
mRemoteViews = RemoteViews(packageName, R.layout.notifi_video_view)
|
|
|
|
|
|
|
|
mRemoteViewsExpand = RemoteViews(packageName, R.layout.notifi_video_view_expand)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
val changeCollapsedIntent: PendingIntent =
|
|
|
|
|
|
|
|
Intent(this, VideoStreamFloatingWidgetService::class.java).apply {
|
|
|
|
|
|
|
|
action = ACTION_CHANGE_EXPANDED_COLLAPSED
|
|
|
|
|
|
|
|
val extras = Bundle()
|
|
|
|
|
|
|
|
extras.putBoolean(NOTIFICATION_IS_EXPANDED, false)
|
|
|
|
|
|
|
|
putExtras(extras)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.let { notificationIntent ->
|
|
|
|
|
|
|
|
PendingIntent.getService(this, 0, notificationIntent, 0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
val changeExpandedIntent: PendingIntent =
|
|
|
|
|
|
|
|
Intent(this, VideoStreamFloatingWidgetService::class.java).apply {
|
|
|
|
|
|
|
|
action = ACTION_CHANGE_EXPANDED_COLLAPSED
|
|
|
|
|
|
|
|
val extras = Bundle()
|
|
|
|
|
|
|
|
extras.putBoolean(NOTIFICATION_IS_EXPANDED, true)
|
|
|
|
|
|
|
|
putExtras(extras)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
.let { notificationIntent ->
|
|
|
|
|
|
|
|
PendingIntent.getService(this, 0, notificationIntent, 0)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
mRemoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher)
|
|
|
|
mRemoteViews.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher)
|
|
|
|
// notification's title
|
|
|
|
// notification's title
|
|
|
|
mRemoteViews.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
|
|
|
|
mRemoteViews.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
|
|
|
|
// notification's content
|
|
|
|
// notification's content
|
|
|
|
mRemoteViews.setTextViewText(R.id.notify_content, notificationData.mContentText)
|
|
|
|
mRemoteViews.setTextViewText(R.id.notify_content, notificationData.mContentText)
|
|
|
|
val mRemoteViewsExpand = RemoteViews(packageName, R.layout.notifi_video_view_expand)
|
|
|
|
mRemoteViews.setOnClickPendingIntent(R.id.iv_Arrow, changeCollapsedIntent)
|
|
|
|
|
|
|
|
mRemoteViews.setChronometer(
|
|
|
|
|
|
|
|
R.id.notify_timer,
|
|
|
|
|
|
|
|
SystemClock.elapsedRealtime(),
|
|
|
|
|
|
|
|
null,
|
|
|
|
|
|
|
|
false
|
|
|
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
|
|
mRemoteViewsExpand.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher)
|
|
|
|
mRemoteViewsExpand.setImageViewResource(R.id.iv_icon, R.mipmap.ic_launcher)
|
|
|
|
mRemoteViewsExpand.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
|
|
|
|
mRemoteViewsExpand.setTextViewText(R.id.notify_title, notificationData.mContentTitle)
|
|
|
|
mRemoteViewsExpand.setTextViewText(R.id.notify_content, notificationData.mContentText)
|
|
|
|
mRemoteViewsExpand.setTextViewText(R.id.notify_content, notificationData.mContentText)
|
|
|
|
mRemoteViewsExpand.setOnClickPendingIntent(R.id.btn_end, endCallPendingIntent)
|
|
|
|
mRemoteViewsExpand.setOnClickPendingIntent(R.id.btn_end, endCallPendingIntent)
|
|
|
|
|
|
|
|
mRemoteViewsExpand.setOnClickPendingIntent(R.id.iv_Arrow, changeExpandedIntent)
|
|
|
|
mRemoteViewsExpand.setChronometer(
|
|
|
|
mRemoteViewsExpand.setChronometer(
|
|
|
|
R.id.notify_timer,
|
|
|
|
R.id.notify_timer,
|
|
|
|
SystemClock.elapsedRealtime(),
|
|
|
|
SystemClock.elapsedRealtime(),
|
|
|
|
null,
|
|
|
|
null,
|
|
|
|
false
|
|
|
|
false
|
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
notificationCompatBuilder
|
|
|
|
notificationCompatBuilder
|
|
|
|
// BIG_TEXT_STYLE sets title and content for API 16 (4.1 and after).
|
|
|
|
// BIG_TEXT_STYLE sets title and content for API 16 (4.1 and after).
|
|
|
|
@ -1144,8 +1221,8 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
R.mipmap.ic_launcher
|
|
|
|
R.mipmap.ic_launcher
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
)
|
|
|
|
.setCustomContentView(mRemoteViews)
|
|
|
|
/*.setCustomContentView(mRemoteViews)
|
|
|
|
.setCustomBigContentView(mRemoteViewsExpand)
|
|
|
|
.setCustomBigContentView(mRemoteViewsExpand)*/
|
|
|
|
.setContentIntent(pendingIntent)
|
|
|
|
.setContentIntent(pendingIntent)
|
|
|
|
// .setDefaults(NotificationCompat.DEFAULT_ALL)
|
|
|
|
// .setDefaults(NotificationCompat.DEFAULT_ALL)
|
|
|
|
// Set primary color (important for Wear 2.0 Notifications).
|
|
|
|
// Set primary color (important for Wear 2.0 Notifications).
|
|
|
|
@ -1153,11 +1230,15 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
.setCategory(Notification.CATEGORY_SERVICE)
|
|
|
|
.setCategory(Notification.CATEGORY_SERVICE)
|
|
|
|
.setPriority(notificationData.mPriority)
|
|
|
|
.setPriority(notificationData.mPriority)
|
|
|
|
.setVisibility(notificationData.mChannelLockscreenVisibility)
|
|
|
|
.setVisibility(notificationData.mChannelLockscreenVisibility)
|
|
|
|
// .addAction(endCallAction)
|
|
|
|
.addAction(endCallAction) // for version code < O, or for all versions if RemoteViews not used
|
|
|
|
.setUsesChronometer(true)
|
|
|
|
.setUsesChronometer(true)
|
|
|
|
.setWhen(elapsedTime)
|
|
|
|
.setWhen(elapsedTime)
|
|
|
|
.setOnlyAlertOnce(true) // This will ensure that updates to an existing notification won't sound/vibrate https://stackoverflow.com/a/52349466/6246772
|
|
|
|
.setOnlyAlertOnce(true) // This will ensure that updates to an existing notification won't sound/vibrate https://stackoverflow.com/a/52349466/6246772
|
|
|
|
.setSound(null)
|
|
|
|
.setSound(null)
|
|
|
|
|
|
|
|
.setOngoing(true)
|
|
|
|
|
|
|
|
.setCategory(NotificationCompat.CATEGORY_SERVICE)
|
|
|
|
|
|
|
|
.setColorized(true)
|
|
|
|
|
|
|
|
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC) //to show content in lock screen
|
|
|
|
|
|
|
|
|
|
|
|
val notification = notificationCompatBuilder
|
|
|
|
val notification = notificationCompatBuilder
|
|
|
|
.build()
|
|
|
|
.build()
|
|
|
|
@ -1236,11 +1317,6 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
private val dragListener: View.OnTouchListener = View.OnTouchListener { _, event ->
|
|
|
|
private val dragListener: View.OnTouchListener = View.OnTouchListener { _, event ->
|
|
|
|
mDetector.onTouchEvent(event)
|
|
|
|
mDetector.onTouchEvent(event)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (floatingWidgetView!!.layoutParams is WindowManager.LayoutParams) {
|
|
|
|
|
|
|
|
var asd = "";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Get Floating widget view params
|
|
|
|
//Get Floating widget view params
|
|
|
|
val layoutParams: WindowManager.LayoutParams =
|
|
|
|
val layoutParams: WindowManager.LayoutParams =
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
floatingWidgetView!!.layoutParams as WindowManager.LayoutParams
|
|
|
|
@ -1382,6 +1458,4 @@ class VideoStreamFloatingWidgetService : Service(), Session.SessionListener,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}.start()
|
|
|
|
}.start()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|