@@ -22,10 +22,13 @@ import io.verloop.sdk.VerloopNotification
2222import io.verloop.sdk.api.VerloopAPI
2323import io.verloop.sdk.api.VerloopServiceBuilder.buildService
2424import io.verloop.sdk.model.ClientInfo
25+ import io.verloop.sdk.model.LogEvent
26+ import io.verloop.sdk.model.LogLevel
2527import io.verloop.sdk.repository.VerloopRepository
2628import io.verloop.sdk.utils.CommonUtils
2729import io.verloop.sdk.viewmodel.MainViewModel
2830import io.verloop.sdk.viewmodel.MainViewModelFactory
31+ import org.json.JSONObject
2932
3033class VerloopActivity : AppCompatActivity () {
3134
@@ -55,11 +58,16 @@ class VerloopActivity : AppCompatActivity() {
5558 BlendModeCompat .SRC_ATOP
5659 )
5760
58- val config: VerloopConfig ? = intent.getParcelableExtra(" config" )
61+ val config = if (Build .VERSION .SDK_INT >= Build .VERSION_CODES .TIRAMISU ) {
62+ intent.getParcelableExtra(" config" , VerloopConfig ::class .java)
63+ } else {
64+ @Suppress(" DEPRECATION" ) intent.getParcelableExtra(" config" )
65+ }
5966 configKey = intent.getStringExtra(" configKey" )
6067 this .config = config
6168
6269 if (config != null ) {
70+ logEvent(LogLevel .DEBUG , " $TAG :onCreate" , null )
6371 val baseUrl =
6472 if (config.isStaging) " https://${config.clientId} .stage.verloop.io"
6573 else " https://${config.clientId} .verloop.io"
@@ -82,20 +90,19 @@ class VerloopActivity : AppCompatActivity() {
8290 }
8391
8492 override fun onResume () {
85- Log .d(TAG , " onResume" )
8693 super .onResume()
8794 setActivityActive(true )
8895 VerloopNotification .cancelNotification(this )
8996 }
9097
9198 override fun onPause () {
92- Log .d(TAG , " onPause" )
9399 super .onPause()
94100 setActivityActive(false )
95101 }
96102
97103 override fun onDestroy () {
98104 Log .d(TAG , " onDestroy" )
105+ logEvent(LogLevel .DEBUG , " $TAG :onDestroy" , null )
99106 super .onDestroy()
100107 eventListeners.remove(configKey)
101108 }
@@ -111,13 +118,15 @@ class VerloopActivity : AppCompatActivity() {
111118
112119 private fun addFragment () {
113120 Log .d(TAG , " addFragment" )
121+ logEvent(LogLevel .DEBUG , " $TAG :addFragment" , null )
114122 verloopFragment = VerloopFragment .newInstance(configKey, config)
115123 val ft = supportFragmentManager.beginTransaction()
116124 ft.add(R .id.verloop_layout, verloopFragment, " VerloopActivity#Fragment" ).commit()
117125 }
118126
119127 private fun updateClientInfo (clientInfo : ClientInfo ) {
120128 Log .d(TAG , " updateClientInfo" )
129+ logEvent(LogLevel .DEBUG , " $TAG :updateClientInfo" , null )
121130 toolbar?.title = clientInfo.title
122131 toolbar?.setBackgroundColor(Color .parseColor(clientInfo.bgColor ? : " #FFFFFF" ))
123132 toolbar?.setTitleTextColor(Color .parseColor(CommonUtils .getExpandedColorHex(clientInfo.textColor)))
@@ -130,6 +139,7 @@ class VerloopActivity : AppCompatActivity() {
130139 public override fun onActivityResult (requestCode : Int , resultCode : Int , data : Intent ? ) {
131140 super .onActivityResult(requestCode, resultCode, data)
132141 Log .d(TAG , " onActivityResult" )
142+ logEvent(LogLevel .DEBUG , " $TAG :onActivityResult" , null )
133143 verloopFragment.fileUploadResult(requestCode, resultCode, data)
134144 }
135145
@@ -142,4 +152,10 @@ class VerloopActivity : AppCompatActivity() {
142152 // Permission not granted. Notifications will be disabled.
143153 }
144154 }
155+
156+ private fun logEvent (level : LogLevel , message : String , params : JSONObject ? ) {
157+ if (config?.logLevel?.ordinal!! >= level.ordinal) {
158+ viewModel?.logEvent(LogEvent (level.name, message, params))
159+ }
160+ }
145161}
0 commit comments