TP-19481 | VKYC Meeting Room Configuration (#5486)

* make agent-name, location, date-time BE configurable

* navi_agent -> navi_executive
This commit is contained in:
Shivam Goyal
2023-02-27 15:55:06 +05:30
committed by GitHub Enterprise
parent 3f702ae771
commit 961e819981
4 changed files with 127 additions and 94 deletions

View File

@@ -9,6 +9,7 @@ package com.navi.common.model.vkyc
import android.os.Parcelable
import com.google.gson.annotations.SerializedName
import com.navi.common.model.StyledTextWithIconCode
import kotlinx.parcelize.Parcelize
class VkycSettingsResponse {
@@ -21,5 +22,14 @@ data class VkycSettings(
@SerializedName("userName") val userName: String? = null,
@SerializedName("authToken") val authToken: String? = null,
@SerializedName("referenceId") val referenceId: String? = null,
@SerializedName("previewPutUrl") val previewPutUrl: String? = null
@SerializedName("previewPutUrl") val previewPutUrl: String? = null,
@SerializedName("agentName") val agentName: StyledTextWithIconCode? = null,
@SerializedName("meetingRoomSettings") val meetingRoomSettings: MeetingRoomSettings? = null
) : Parcelable
@Parcelize
data class MeetingRoomSettings(
@SerializedName("dateTimeVisible") val dateTimeVisible: Boolean? = false,
@SerializedName("latitudeVisible") val latitudeVisible: Boolean? = false,
@SerializedName("longitudeVisible") val longitudeVisible: Boolean? = false
) : Parcelable

View File

@@ -11,6 +11,7 @@ import android.annotation.SuppressLint
import android.net.Uri
import android.os.Bundle
import android.view.*
import androidx.core.view.isVisible
import androidx.lifecycle.ViewModelProvider
import androidx.lifecycle.lifecycleScope
import com.google.gson.Gson
@@ -49,6 +50,10 @@ import com.navi.vkyc.presentation.view.NaviHeaderView
import com.navi.vkyc.presentation.viewmodel.VKYCViewModel
import com.navi.vkyc.utils.VkycNaviAnalytics
import dagger.hilt.android.AndroidEntryPoint
import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
import kotlinx.coroutines.*
import live.hms.video.error.HMSException
import live.hms.video.media.settings.HMSVideoTrackSettings
@@ -67,10 +72,6 @@ import okhttp3.MediaType.Companion.toMediaTypeOrNull
import okhttp3.RequestBody.Companion.asRequestBody
import org.webrtc.RendererCommon
import timber.log.Timber
import java.io.*
import java.text.SimpleDateFormat
import java.util.*
import javax.inject.Inject
@AndroidEntryPoint
class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListener {
@@ -106,25 +107,9 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
}
private fun initUi() {
binding?.tvLatitude?.text =
String.format(getString(R.string.latitude_1_f), arguments?.getDouble(LATITUDE, 0.0))
binding?.tvLongitude?.text =
String.format(getString(R.string.longitude_1_f), arguments?.getDouble(LONGITUDE, 0.0))
try {
val date = Date()
val dateFormatter = SimpleDateFormat("dd/MM/yyyy HH:mm:ss a", Locale.getDefault())
val time = dateFormatter.format(date)
binding?.tvTime?.text = String.format(getString(R.string.time_1_s), time)
} catch (ex: Exception) {
binding?.tvTime?.visibility = View.GONE
}
Timber.d("Video call initiated")
binding?.videoSurfaceView?.keepScreenOn = true
}
private fun initObservers() {
vkycViewModel.vkycSettingsResponse.observe(viewLifecycleOwner) {
it?.settings?.let { settings ->
@@ -133,6 +118,38 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
previewPutUrl = settings.previewPutUrl
vkycReferenceId = settings.referenceId
hmsSdk.join(config, hmsListener)
binding?.apply {
settings.agentName?.let { it -> tvAgentName.spannableString(it) }
settings.meetingRoomSettings?.let { meetingSettings ->
meetingSettings.dateTimeVisible?.let { it -> tvTime.isVisible = it }
meetingSettings.latitudeVisible?.let { it -> tvLatitude.isVisible = it }
meetingSettings.longitudeVisible?.let { it -> tvLongitude.isVisible = it }
}
tvLatitude.text =
String.format(
getString(R.string.latitude_1_f),
arguments?.getDouble(LATITUDE, 0.0)
)
tvLongitude.text =
String.format(
getString(R.string.longitude_1_f),
arguments?.getDouble(LONGITUDE, 0.0)
)
try {
val date = Date()
val dateFormatter =
SimpleDateFormat("dd/MM/yyyy hh:mm:ss a", Locale.getDefault())
val time = dateFormatter.format(date)
tvTime.text = String.format(getString(R.string.time_1_s), time)
} catch (ex: Exception) {
tvTime.visibility = View.GONE
}
}
}
}
@@ -161,7 +178,6 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
private fun setListener() {
binding?.ivSwitchCamera?.setOnClickListener {
hmsSdk
.getLocalPeer()
?.videoTrack
@@ -181,10 +197,8 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
binding?.surfaceViewContainer?.isClickable = true
binding?.videoSurfaceView?.isClickable = true
binding?.videoSurfaceView?.setOnTouchListener(onTouchListener)
}
fun leaveRoom() {
hmsSdk.leave()
}
@@ -249,13 +263,12 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
private val hmSMessageResultListener by lazy {
object : HMSMessageResultListener {
override fun onError(error: HMSException) {
//no-op
// no-op
}
override fun onSuccess(hmsMessage: HMSMessage) {
//no-op
// no-op
}
}
}
@@ -267,13 +280,15 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
override fun onError(error: HMSException) {
Timber.e(error)
if (error.isTerminal && activity != null && isAdded) {
CommonNaviAnalytics.naviAnalytics.Errors().onAppDowntime(
reason = error.name,
statusCode = error.code,
networkType = getNetworkType(requireActivity()),
screenName = screenName,
moduleName = (requireActivity() as BaseActivity).getCurrentModuleName()
)
CommonNaviAnalytics.naviAnalytics
.Errors()
.onAppDowntime(
reason = error.name,
statusCode = error.code,
networkType = getNetworkType(requireActivity()),
screenName = screenName,
moduleName = (requireActivity() as BaseActivity).getCurrentModuleName()
)
(requireActivity() as VKYCActivity).navigateToScreen(
VkycScreens.VKYC_STATUS_CHECK_SCREEN
)
@@ -282,13 +297,16 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
override fun onJoin(room: HMSRoom) {
Timber.d("room Joined ${room.name}")
if (FirebaseRemoteConfigHelper.getBoolean("hundred_ms_setting_for_auto_resize")
if (
FirebaseRemoteConfigHelper.getBoolean("hundred_ms_setting_for_auto_resize")
.orFalse()
) {
lifecycleScope.launch {
room.localPeer?.videoTrack?.setSettings(
HMSVideoTrackSettings.Builder().disableAutoResize(true).build()
)
room.localPeer
?.videoTrack
?.setSettings(
HMSVideoTrackSettings.Builder().disableAutoResize(true).build()
)
}
}
}
@@ -302,21 +320,25 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
timestamp to System.currentTimeMillis().toString()
)
)
if (message.message.equals(PAN_CAPTURE_INITIATE, true) || message.message.equals(
PAN_CAPTURE_INITIATE_WITH_QUOTES, true)) {
if (
message.message.equals(PAN_CAPTURE_INITIATE, true) ||
message.message.equals(PAN_CAPTURE_INITIATE_WITH_QUOTES, true)
) {
captureAndUploadImage(ImageType.PAN)
} else if (message.message.equals(SELFIE_CAPTURE_INITIATE, true) || message.message.equals(
SELFIE_CAPTURE_INITIATE_WITH_QUOTES, true)) {
} else if (
message.message.equals(SELFIE_CAPTURE_INITIATE, true) ||
message.message.equals(SELFIE_CAPTURE_INITIATE_WITH_QUOTES, true)
) {
captureAndUploadImage(ImageType.SELFIE)
}
Timber.d("Message is ${message.message}")
}
override fun onPeerUpdate(type: HMSPeerUpdate, peer: HMSPeer) {
addVideo()
naviAnalyticsEventTracker.updateNetworkQualityEvent(hmsSdk.getLocalPeer()?.networkQuality?.downlinkQuality)
naviAnalyticsEventTracker.updateNetworkQualityEvent(
hmsSdk.getLocalPeer()?.networkQuality?.downlinkQuality
)
}
override fun onRoleChangeRequest(request: HMSRoleChangeRequest) {}
@@ -362,27 +384,30 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
}
@SuppressLint("ClickableViewAccessibility")
private val onTouchListener = View.OnTouchListener { _, event ->
when (event.action) {
MotionEvent.ACTION_UP -> {
val videoTrack = hmsSdk.getLocalPeer()?.videoTrack
if (videoTrack?.getCameraControl()?.isTapToFocusSupported() == true)
videoTrack.getCameraControl()?.setTapToFocusAt(
event.x,
event.y,
viewWidth = binding?.videoSurfaceView?.width ?: 0,
viewHeight = binding?.videoSurfaceView?.height ?: 0
)
return@OnTouchListener false
private val onTouchListener =
View.OnTouchListener { _, event ->
when (event.action) {
MotionEvent.ACTION_UP -> {
val videoTrack = hmsSdk.getLocalPeer()?.videoTrack
if (videoTrack?.getCameraControl()?.isTapToFocusSupported() == true)
videoTrack
.getCameraControl()
?.setTapToFocusAt(
event.x,
event.y,
viewWidth = binding?.videoSurfaceView?.width ?: 0,
viewHeight = binding?.videoSurfaceView?.height ?: 0
)
return@OnTouchListener false
}
}
false
}
false
}
private suspend fun uploadImage(file: File, imageType: ImageType) {
previewPutUrl?.let { url ->
val compressedFile = fileHelper.compressImage(requireContext(), file, getCompressionNumber())
val compressedFile =
fileHelper.compressImage(requireContext(), file, getCompressionNumber())
val uri = Uri.parse(url)
val indexOfQuestionMark = url.indexOf(Constants.QUESTION_MARK)
@@ -396,11 +421,7 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
}
val requestFile = compressedFile.asRequestBody(MIME_TYPE_IMAGE.toMediaTypeOrNull())
val response = UserDataRepository().postImage(
baseUrl.toString(),
queryMap,
requestFile
)
val response = UserDataRepository().postImage(baseUrl.toString(), queryMap, requestFile)
if (response.isSuccessful) {
Timber.d("File upload success")
@@ -414,11 +435,11 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
sendFailedEvent(imageType)
}
deleteFile(compressedFile)
} ?: run {
Timber.d("File upload failed")
sendFailedEvent(imageType)
}
?: run {
Timber.d("File upload failed")
sendFailedEvent(imageType)
}
}
private fun deleteFile(file: File) {
@@ -454,14 +475,13 @@ class VKYCMeetingRoomFragment : BaseFragment(), NaviHeaderView.InteractionListen
FirebaseRemoteConfigHelper.getString(VKYC_IMAGE_COMPRESSION_CONFIG),
object : TypeToken<MutableList<ImageCompressionConfig>>() {}.type
)
networkQualityToNetwork.find {
it.networkType == network
}.let {
return it?.quality ?: 80
}
networkQualityToNetwork
.find { it.networkType == network }
.let {
return it?.quality ?: 80
}
} catch (e: Exception) {
return 80
}
}
}

View File

@@ -2,7 +2,7 @@
<!--
~
~ * Copyright © 2022 by Navi Technologies Limited
~ * Copyright © 2022-2023 by Navi Technologies Limited
~ * All rights reserved. Strictly confidential
~
-->
@@ -11,10 +11,6 @@
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<data>
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
@@ -53,13 +49,12 @@
app:srcCompat="@drawable/ic_agent_icon" />
<com.navi.design.textview.NaviTextView
android:id="@+id/tv_agent_name"
style="@style/Title4TextStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/layout_dp_12"
android:text="@string/navi_agent"
android:text="@string/navi_executive"
android:textColor="@color/grey_charcoal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toEndOf="@id/iv_agent_icon"
@@ -67,7 +62,7 @@
</androidx.constraintlayout.widget.ConstraintLayout>
<com.navi.design.textview.NaviTextView
<com.navi.design.textview.NaviTextView
android:id="@+id/tv_time"
style="@style/Subtitle3TextStyle"
android:layout_width="@dimen/layout_dp_0"
@@ -76,9 +71,12 @@
android:layout_marginTop="@dimen/layout_dp_24"
android:gravity="center"
android:textColor="@color/description_colour_seven"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/card_view" />
app:layout_constraintTop_toBottomOf="@id/card_view"
tools:text="@string/time_1_s"
tools:visibility="visible" />
<androidx.cardview.widget.CardView
@@ -102,24 +100,24 @@
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/surface_view_container"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/rounded_rect_8dp_border_1dp"
android:clickable="true"
android:focusable="true">
<org.webrtc.SurfaceViewRenderer
android:id="@+id/videoSurfaceView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:focusable="true"
android:layout_margin="@dimen/layout_dp_2" />
android:layout_margin="@dimen/layout_dp_2"
android:focusable="true" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.cardview.widget.CardView>
<com.navi.design.textview.NaviTextView
<com.navi.design.textview.NaviTextView
android:id="@+id/tv_latitude"
style="@style/Subtitle3TextStyle"
android:layout_width="wrap_content"
@@ -127,10 +125,12 @@
android:layout_marginTop="@dimen/layout_dp_24"
android:text="@string/latitude_1_f"
android:textColor="@color/description_colour_seven"
android:visibility="gone"
app:layout_constraintStart_toStartOf="@id/surface_view_container_card"
app:layout_constraintTop_toBottomOf="@id/surface_view_container_card" />
app:layout_constraintTop_toBottomOf="@id/surface_view_container_card"
tools:visibility="visible" />
<com.navi.design.textview.NaviTextView
<com.navi.design.textview.NaviTextView
android:id="@+id/tv_longitude"
style="@style/Subtitle3TextStyle"
android:layout_width="wrap_content"
@@ -138,8 +138,10 @@
android:layout_marginTop="@dimen/layout_dp_24"
android:text="@string/longitude_1_f"
android:textColor="@color/description_colour_seven"
android:visibility="gone"
app:layout_constraintEnd_toEndOf="@id/surface_view_container_card"
app:layout_constraintTop_toBottomOf="@id/surface_view_container_card" />
app:layout_constraintTop_toBottomOf="@id/surface_view_container_card"
tools:visibility="visible" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/iv_switch_camera"
@@ -153,4 +155,5 @@
app:srcCompat="@drawable/ic_switch_camera" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
</layout>

View File

@@ -30,7 +30,7 @@
<string name="vkyc_no">No</string>
<string name="are_you_sure_you_want_to_exit">Are you sure you want to exit?</string>
<string name="you_will_have_to_start_again_if_you_leave_right_now">You will have to start your VKYC again if you leave right now.</string>
<string name="navi_agent">Navi agent</string>
<string name="navi_executive">Navi executive</string>
<string name="taking_longer_waiting_screen_description">Its taking longer than usual. Hang on while we connect you to an executive.</string>
<string name="latitude_1_f">Latitude: %1$f</string>
<string name="longitude_1_f">Longitude: %1$f</string>