TP-31577 | Vkyc Disconnect call initiation while app is in background (#6849)

* TP-31577 | added API call to cancel VKYC ticket and open it back onPause and onResume

* TP-31577 | added new function for same API

* TP-31577 | code refactor and additional pause and resume checks

* TP-31577 | added more checks on navigation edge cases

* TP-31577 | sdk downgrade

* TP-31577 | revert 100ms sdk downgrade

* TP-31577 | replaced hardcoded string with constant variable

* TP-31577 | redirecting user to previous page instead of reinitiating vkyc

* TP-31577 | added navigating boolean check

* TP-31577 | finished activity

* TP-31577 | changed postValue to .value =
This commit is contained in:
Shubhanjay Varma
2023-06-15 09:07:13 +05:30
committed by GitHub Enterprise
parent 71fc608456
commit 11cfc5fab6
2 changed files with 61 additions and 7 deletions

View File

@@ -16,7 +16,6 @@ import android.view.View
import android.view.View.GONE
import android.view.View.VISIBLE
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.content.res.ResourcesCompat
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
@@ -63,7 +62,7 @@ import org.joda.time.DateTimeConstants.SECONDS_PER_MINUTE
@AndroidEntryPoint
class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.InteractionListener,
WidgetCallback {
WidgetCallback, VkycExitConfirmationBottomSheetCallback {
override val screenName: String
get() = VkycNaviAnalytics.VKYC_WAITING_FOR_EXECUTIVE_SCREEN
private var binding: VkycWaitingForExecutiveBinding? = null
@@ -73,6 +72,8 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
private val naviAnalyticsEventTracker = VkycNaviAnalytics.naviAnalytics.AgentWaitingScreen()
private var startTime: Long = 0
private var redirectionJob: Job? = null
private var isNavigating: Boolean = false
private var isInitializing: Boolean = true
private var timer: CountDownTimer? = null
override fun onCreateView(
@@ -104,15 +105,42 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
private val vkycSettingsOnClickListener: View.OnClickListener =
View.OnClickListener { fetchVkycSettings() }
override fun onPause() {
if(isNavigating.not()) {
stopTimer()
stopVkycAgentPolling()
vkycViewModel.closeVkycTicket(arguments?.getString(Constants.MODULE_NAME).orEmpty())
}
super.onPause()
}
override fun onResume() {
if(isInitializing) {
isInitializing = false
} else {
isNavigating = true
activity?.finish() //Will not be called on first initialization, finishing the activity to go to KYC_V2 screen as per requirement
}
super.onResume()
}
override fun onDestroyView() {
super.onDestroyView()
binding = null
timer?.cancel()
timer = null
stopTimer()
}
override fun onDestroy() {
super.onDestroy()
stopVkycAgentPolling()
}
private fun stopTimer() {
timer?.cancel()
timer = null
}
private fun stopVkycAgentPolling() {
redirectionJob?.cancel()
redirectionJob = null
baseApiPollScheduler?.stopApiPoll()
@@ -352,6 +380,7 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
redirectionCta.parameters?.forEach { parameter ->
bundle.putString(parameter.key, parameter.value)
}
isNavigating = true
DeepLinkManager.getDeepLinkListener()?.navigateTo(
activity,
redirectionCta, true, bundle
@@ -375,14 +404,14 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
timeDiff,
vkycViewModel.vkycSettingsWithLocResponse.value?.vkycSettingsResponse?.kycSourceReferenceId
)
baseApiPollScheduler?.stopApiPoll()
redirectionJob?.cancel()
redirectionJob = null
isNavigating = true
stopVkycAgentPolling()
(requireActivity() as VKYCActivity).navigateToScreen(
VkycScreens.VKYC_MEETING_ROOM,
arguments
)
} else if (vkycAgentAssignmentFailureStates.contains(it.status)) {
isNavigating = true
baseApiPollScheduler?.stopApiPoll()
(requireActivity() as VKYCActivity).navigateToScreen(VkycScreens.VKYC_STATUS_CHECK_SCREEN)
}
@@ -411,6 +440,7 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
private fun redirectUserToWaitingForAgentLongScreen() {
isNavigating = true
(requireActivity() as VKYCActivity).navigateToScreen(
VkycScreens.VKYC_LONG_WAIT_FOR_EXECUTIVE_SCREEN,
arguments
@@ -527,6 +557,7 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
override fun onHelpButtonPressed() {
activity?.let {
isNavigating = true
DeepLinkManager.getDeepLinkListener()
?.navigateTo(
activity = it,
@@ -543,6 +574,11 @@ class VKYCWaitingForExecutiveFragment : BaseFragment(), NaviHeaderView.Interacti
}
override fun onBackButtonPressed() {
isNavigating = true
activity?.onBackPressed()
}
override fun onConfirmExit() {
isNavigating = true
}
}

View File

@@ -79,6 +79,10 @@ class VKYCViewModel @Inject constructor(val repository: VkycRepository,
val cancelVkycResponse: LiveData<VkycCancelStatus>
get() = _cancelVkycResponse
private val _closeVkycTicketResponse = MutableLiveData<VkycCancelStatus>()
val closeVkycTicketResponse: LiveData<VkycCancelStatus>
get() = _closeVkycTicketResponse
private val _vkycStatusResponse = MutableLiveData<VkycStatus>()
val vkycStatusResponse: LiveData<VkycStatus>
get() = _vkycStatusResponse
@@ -212,6 +216,20 @@ class VKYCViewModel @Inject constructor(val repository: VkycRepository,
}
}
fun closeVkycTicket(callingModule: String) {
viewModelScope.launch {
val response = repository.cancelVkyc(callingModule)
val cancelResponse = response.data
if(response.isValidResponse()) {
cancelResponse?.let {
_closeVkycTicketResponse.value = it
}
} else {
_closeVkycTicketResponse.value = VkycCancelStatus(Constants.FALSE)
}
}
}
fun fetchUiStatus(callingModule: String) {
viewModelScope.launch {
val response = repository.fetchUiStatus(callingModule)