@@ -8,6 +8,7 @@ import android.view.View
88import android.view.ViewGroup
99import android.webkit.ConsoleMessage
1010import android.widget.Toast
11+ import com.google.firebase.database.DatabaseReference
1112import com.google.firebase.database.FirebaseDatabase
1213import com.google.firebase.database.IgnoreExtraProperties
1314import com.google.firebase.database.PropertyName
@@ -28,9 +29,9 @@ class WebViewFragment: PermissionAwareWebViewFragment(), JSInterface.JSInterface
2829 private const val ARG_URL_STRING = " arg-url"
2930 private const val ARG_INTERACTION_TYPE = " arg-interaction-type"
3031
31- private var isTestUrl = false
32-
33- private lateinit var interactionType : InteractionType
32+ private const val RTDB_CHILD_CALL_DETAILS = " clDts "
33+ private const val RTDB_CHILD_PARTICIPANTS = " prtcpnts "
34+ private const val RTDB_VALUE_CALL_ENDED_AT = " clEdAt "
3435
3536 fun init (url : String , interactionType : InteractionType = InteractionType .IN_CALL ): WebViewFragment {
3637 return WebViewFragment ().apply {
@@ -42,16 +43,22 @@ class WebViewFragment: PermissionAwareWebViewFragment(), JSInterface.JSInterface
4243 }
4344 }
4445
46+ private var isTestUrl = false
47+
48+ private lateinit var interactionType: InteractionType
49+
4550 private lateinit var jsInterface: JSInterface
4651
52+ private lateinit var rtdbReference: DatabaseReference
53+
4754 private data class TestUserObject (
4855 val tstId : String ,
4956 val iPrv : Boolean = true ,
5057 val mod : String = " VOIP"
5158 )
5259
5360 @IgnoreExtraProperties
54- data class RTDBPreviewCallDetails (
61+ private data class RTDBPreviewCallDetails (
5562 @get:PropertyName("rtcClId")
5663 @set:PropertyName("rtcClId")
5764 var rtcCallId : String ,
@@ -82,14 +89,15 @@ class WebViewFragment: PermissionAwareWebViewFragment(), JSInterface.JSInterface
8289 val ref = database.getReference(" qtalkDebugAndStaging/calls" ).child(callId)
8390
8491 // store the participant info with the key as the user id
85- ref.child(" prtcpnts " ).child(selectedUser).setValue(TestUserObject (selectedUser))
92+ ref.child(RTDB_CHILD_PARTICIPANTS ).child(selectedUser).setValue(TestUserObject (selectedUser))
8693
8794 // store call details
88- ref.child(" clDts " ).setValue(RTDBPreviewCallDetails (
95+ ref.child(RTDB_CHILD_CALL_DETAILS ).setValue(RTDBPreviewCallDetails (
8996 callId,
9097 System .currentTimeMillis()
9198 ))
9299
100+ rtdbReference = ref
93101 }
94102
95103 override fun onCreateView (inflater : LayoutInflater , container : ViewGroup ? , savedInstanceState : Bundle ? ): View ? {
@@ -114,6 +122,13 @@ class WebViewFragment: PermissionAwareWebViewFragment(), JSInterface.JSInterface
114122 if (interactionType == InteractionType .WEB_SHARING ) {
115123 // write to QTalks RTDB here as participant information needs to be added in the array.
116124 writeParticipantInfoAndCallDetailsToRTDB()
125+
126+ endCallButton.visibility = View .VISIBLE
127+
128+ endCallButton.setOnClickListener{
129+ rtdbReference.child(RTDB_CHILD_CALL_DETAILS ).child(RTDB_VALUE_CALL_ENDED_AT ).setValue(System .currentTimeMillis())
130+ activity?.finish()
131+ }
117132 }
118133
119134 jsInterface = JSInterface (this )
0 commit comments