TP-23025 | Whatsapp login for all Business cards (#5907)
* TP-23025 | Whatsapp login for all Business cards * TP-23025 | UI logic moved to onviewcreated
This commit is contained in:
committed by
GitHub Enterprise
parent
351be3334c
commit
e81f7e36f0
@@ -20,6 +20,7 @@ data class LoginSettings(
|
||||
@SerializedName("migration") val migration: MigrationResponse? = null,
|
||||
@SerializedName("redirectToOtherApp") val redirectToOtherApp: Boolean? = null,
|
||||
@SerializedName("showReferralLottie") val showReferralLottie: Boolean? = null,
|
||||
@SerializedName("whatsappLoginConfig") val whatsappLoginConfig: WhatsappLoginConfig? = null
|
||||
)
|
||||
|
||||
data class Warning(
|
||||
@@ -36,3 +37,16 @@ data class Feature(
|
||||
data class AppConfig(
|
||||
@SerializedName("locationFetchDuration") val locationFetchDuration: Int? = null
|
||||
)
|
||||
|
||||
data class WhatsappLoginConfig(
|
||||
@SerializedName("inHouse")
|
||||
val inHouse: Boolean? = null,
|
||||
@SerializedName("otpLess")
|
||||
val otpLess: Boolean? = null,
|
||||
@SerializedName("sources")
|
||||
val listOfSources: List<String>? = null,
|
||||
@SerializedName("text")
|
||||
val text: String? = null,
|
||||
@SerializedName("phone")
|
||||
val phone: String? = null
|
||||
)
|
||||
|
||||
@@ -15,5 +15,6 @@ data class OtpResponse(
|
||||
@SerializedName("sessionToken") val sessionToken: String?,
|
||||
@SerializedName("notificationAuthToken") val authToken: String? = null,
|
||||
@SerializedName("externalCustomerId") val externalCustomerId: String? = null,
|
||||
@SerializedName("nextCta") val nextCta: CtaData? = null
|
||||
@SerializedName("nextCta") val nextCta: CtaData? = null,
|
||||
@SerializedName("phone") val phoneNumber: String? = null
|
||||
)
|
||||
@@ -26,6 +26,8 @@ import com.navi.base.model.LineItem
|
||||
import com.navi.base.sharedpref.CommonPrefConstants
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.USER_EXTERNAL_ID
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.USER_ID
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.WHATS_APP_LOGIN_CONFIG
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.WHATS_APP_LOGIN_CONFIG_PARAMETERS
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.base.utils.BaseUtils
|
||||
import com.navi.common.firebasedb.FirebaseStatusType.SUCCESS
|
||||
@@ -36,6 +38,7 @@ import com.navi.common.ui.activity.BaseActivity
|
||||
import com.navi.common.utils.*
|
||||
import com.navi.common.utils.Constants
|
||||
import com.navi.common.utils.Constants.DIALOG_DISMISS
|
||||
import com.navi.common.utils.Constants.LOGIN_SOURCE
|
||||
import com.navi.naviwidgets.models.LottieFieldData
|
||||
import com.navi.naviwidgets.utils.LottieEnums
|
||||
import com.naviapp.R
|
||||
@@ -51,6 +54,7 @@ import com.naviapp.common.navigator.ScreenNavigator
|
||||
import com.naviapp.dashboard.listeners.FragmentInteractionListener
|
||||
import com.naviapp.databinding.RegistrationActivityBinding
|
||||
import com.naviapp.models.TrueProfileData
|
||||
import com.naviapp.models.WhatsappLoginConfig
|
||||
import com.naviapp.models.request.LoginType
|
||||
import com.naviapp.models.request.OtpRequest
|
||||
import com.naviapp.models.response.Medium
|
||||
@@ -67,6 +71,7 @@ import com.naviapp.registration.viewmodel.RegistrationVM
|
||||
import com.naviapp.utils.*
|
||||
import com.naviapp.utils.Constants.AUTH_VIA_LINK
|
||||
import com.naviapp.utils.Constants.REDIRECT_STATUS
|
||||
import com.naviapp.utils.Constants.WhatsAppPkg
|
||||
import com.truecaller.android.sdk.ITrueCallback
|
||||
import com.truecaller.android.sdk.TrueError
|
||||
import com.truecaller.android.sdk.TrueProfile
|
||||
@@ -96,12 +101,31 @@ class RegistrationActivity :
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.registration_activity)
|
||||
source = intent.getStringExtra(Constants.LOGIN_SOURCE)
|
||||
source = intent.getStringExtra(LOGIN_SOURCE)
|
||||
channel = intent.getStringExtra(Constants.CHANNEL)
|
||||
grootReferenceId = intent.getStringExtra(Constants.IDENTIFIER)
|
||||
super.setContentView(binding.root)
|
||||
redirectStatus = intent.getStringExtra(REDIRECT_STATUS) ?: LOGIN_SCREEN
|
||||
isTrueCallerEnabled = PreferenceManager.getBooleanPreference(TRUECALLER_ENABLED).orFalse()
|
||||
if (redirectStatus != AUTH_VIA_LINK) {
|
||||
PreferenceManager.setStringPreference(LOGIN_SOURCE, source.toString())
|
||||
PreferenceManager.setObjectPreference(WHATS_APP_LOGIN_CONFIG_PARAMETERS, getParameters())
|
||||
if (isAppInstalled(this, WhatsAppPkg)) {
|
||||
PreferenceManager.getObjectPrefrences(
|
||||
WHATS_APP_LOGIN_CONFIG,
|
||||
WhatsappLoginConfig::class.java
|
||||
)?.let { whatsappLoginConfig ->
|
||||
if (whatsappLoginConfig.inHouse == true || whatsappLoginConfig.otpLess == true) {
|
||||
whatsappLoginConfig.listOfSources?.forEach { sourceName ->
|
||||
if (sourceName == source) {
|
||||
redirectStatus = WhatsAppLoginFragment.TAG
|
||||
return@forEach
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isTrueCallerEnabled.orFalse() && redirectStatus !in listOf(
|
||||
AUTH_VIA_LINK,
|
||||
WhatsAppLoginFragment.TAG
|
||||
@@ -136,7 +160,11 @@ class RegistrationActivity :
|
||||
OtpRequest(
|
||||
loginType = LoginType.DEEPLINK.name,
|
||||
deviceDetail = getDeviceDetails(null),
|
||||
parameters = getParameters(),
|
||||
source = PreferenceManager.getStringPreference(LOGIN_SOURCE),
|
||||
parameters = PreferenceManager.getListObjectReference(
|
||||
WHATS_APP_LOGIN_CONFIG_PARAMETERS,
|
||||
LineItem::class.java
|
||||
),
|
||||
installDeeplinkData =
|
||||
PreferenceManager.getSecureString(
|
||||
Constants.OFFER_VALUE
|
||||
@@ -176,6 +204,9 @@ class RegistrationActivity :
|
||||
if (otpTokenFailure) analyticsTracker.onOTPDeliveryFailure(source)
|
||||
}
|
||||
registrationVM.deepLinkAuthResponse.observeNonNull(this) {
|
||||
it.phoneNumber?.let { phoneNumber ->
|
||||
BaseUtils.savePhoneNumber(phoneNumber)
|
||||
}
|
||||
updateApiLoader(
|
||||
LottieFieldData(
|
||||
LottieEnums.LOGIN_SUCCESSFUL.name,
|
||||
|
||||
@@ -39,6 +39,7 @@ import com.navi.analytics.utils.NaviTrackEvent
|
||||
import com.navi.base.model.CtaData
|
||||
import com.navi.base.model.LineItem
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.USER_EXTERNAL_ID
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.WHATS_APP_LOGIN_CONFIG
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.base.utils.BaseUtils
|
||||
import com.navi.base.utils.orZero
|
||||
@@ -312,6 +313,9 @@ class SplashActivity : BaseActivity(), DeepLinkListener {
|
||||
|
||||
private fun loginSettingsObserver() {
|
||||
configVM.loginSettings.observeNullable(this) {
|
||||
it?.whatsappLoginConfig?.let { whatsAppLoginConfig ->
|
||||
PreferenceManager.setObjectPreference(WHATS_APP_LOGIN_CONFIG, whatsAppLoginConfig)
|
||||
}
|
||||
it?.let { loginSetting ->
|
||||
loginSetting.features?.forEach { feature ->
|
||||
PreferenceManager.setBooleanPreference(
|
||||
|
||||
@@ -20,6 +20,8 @@ import androidx.core.content.ContextCompat
|
||||
import androidx.core.view.isVisible
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.WHATS_APP_LOGIN_CONFIG
|
||||
import com.navi.base.sharedpref.PreferenceManager
|
||||
import com.navi.common.firebaseremoteconfig.FirebaseRemoteConfigHelper
|
||||
import com.navi.common.ui.fragment.BaseFragment
|
||||
import com.navi.common.utils.Constants.LOGIN_SOURCE
|
||||
@@ -31,6 +33,7 @@ import com.naviapp.analytics.utils.NaviAnalytics
|
||||
import com.naviapp.common.listeners.FragmentStateListener
|
||||
import com.naviapp.dashboard.listeners.FragmentInteractionListener
|
||||
import com.naviapp.databinding.WhatsappLoginFragmentBinding
|
||||
import com.naviapp.models.WhatsappLoginConfig
|
||||
import com.naviapp.network.ApiConstants
|
||||
import com.naviapp.registration.viewmodel.RegistrationVM
|
||||
import com.naviapp.utils.Constants
|
||||
@@ -53,6 +56,7 @@ class WhatsAppLoginFragment : BaseFragment(), View.OnClickListener {
|
||||
private var source: String? = null
|
||||
private var isCheckBoxNeedToShow = false
|
||||
private var isNoCallDisclaimerEnabled = false
|
||||
private var whatsAppLoginConfig: WhatsappLoginConfig? = null
|
||||
|
||||
override fun onCreateView(
|
||||
inflater: LayoutInflater,
|
||||
@@ -63,7 +67,6 @@ class WhatsAppLoginFragment : BaseFragment(), View.OnClickListener {
|
||||
DataBindingUtil.inflate(inflater, R.layout.whatsapp_login_fragment, container, false)
|
||||
initError(registrationVM, showNewDesignSystemFragment = true)
|
||||
source = arguments?.getString(LOGIN_SOURCE)
|
||||
initUi()
|
||||
return binding.root
|
||||
}
|
||||
|
||||
@@ -72,6 +75,15 @@ class WhatsAppLoginFragment : BaseFragment(), View.OnClickListener {
|
||||
activity?.window?.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE)
|
||||
}
|
||||
|
||||
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
||||
super.onViewCreated(view, savedInstanceState)
|
||||
whatsAppLoginConfig = PreferenceManager.getObjectPrefrences(
|
||||
WHATS_APP_LOGIN_CONFIG,
|
||||
WhatsappLoginConfig::class.java
|
||||
)
|
||||
initUi()
|
||||
}
|
||||
|
||||
private fun initUi() {
|
||||
var tncTxt: String? = null
|
||||
source?.let { loginSource ->
|
||||
@@ -166,11 +178,13 @@ class WhatsAppLoginFragment : BaseFragment(), View.OnClickListener {
|
||||
private fun openWhatsApp() {
|
||||
val intent = Intent(
|
||||
Intent.ACTION_VIEW, Uri.parse(
|
||||
Constants.WHATSAPP_URI + FirebaseRemoteConfigHelper.getString(
|
||||
ANDROID_WHATSAPP_LOGIN_NUMBER
|
||||
) + Constants.WHATSAPP_URI_TEXT + FirebaseRemoteConfigHelper.getString(
|
||||
ANDROID_WHATSAPP_LOGIN_MESSAGE
|
||||
).replace("\\n", "\n")
|
||||
Constants.WHATSAPP_URI + (whatsAppLoginConfig?.phone
|
||||
?: FirebaseRemoteConfigHelper.getString(
|
||||
ANDROID_WHATSAPP_LOGIN_NUMBER
|
||||
)) + Constants.WHATSAPP_URI_TEXT + (whatsAppLoginConfig?.text
|
||||
?: FirebaseRemoteConfigHelper.getString(
|
||||
ANDROID_WHATSAPP_LOGIN_MESSAGE
|
||||
)).replace("\\n", "\n")
|
||||
)
|
||||
)
|
||||
intent.setPackage(WhatsAppPkg)
|
||||
|
||||
@@ -27,4 +27,6 @@ object CommonPrefConstants {
|
||||
const val APP_BASE_URL = "appBaseUrl"
|
||||
const val PULSE_BASE_URL = "pulseBaseUrl"
|
||||
const val UPDATED_PULSE_BASE_URL = "updatedPulseBaseUrl"
|
||||
const val WHATS_APP_LOGIN_CONFIG = "WHATS_APP_LOGIN_CONFIG"
|
||||
const val WHATS_APP_LOGIN_CONFIG_PARAMETERS = "WHATS_APP_LOGIN_CONFIG_PARAMETERS"
|
||||
}
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.os.Build
|
||||
import androidx.security.crypto.EncryptedSharedPreferences
|
||||
import androidx.security.crypto.MasterKey
|
||||
import com.google.gson.Gson
|
||||
import com.google.gson.reflect.TypeToken
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.CURRENT_USER
|
||||
import com.navi.base.sharedpref.CommonPrefConstants.IS_LOAN_JOURNEY_DATA_DELETED
|
||||
import timber.log.Timber
|
||||
@@ -131,6 +132,23 @@ object PreferenceManager {
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> getListObjectReference(key: String, model: Class<T>): List<T>? {
|
||||
return run {
|
||||
val json = sharedPreferencesForSession.getString(key, "")
|
||||
if (key == CURRENT_USER && json.isNullOrBlank()) {
|
||||
return null
|
||||
}
|
||||
try {
|
||||
val listOfObjects: List<T>?
|
||||
val type = TypeToken.getParameterized(List::class.java, model).type
|
||||
listOfObjects = gson.fromJson(json, type)
|
||||
listOfObjects
|
||||
} catch (e: Exception) {
|
||||
null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun clearPrefDataSession() {
|
||||
try {
|
||||
sharedPreferencesForSession.edit().clear().apply()
|
||||
|
||||
Reference in New Issue
Block a user