Added facebook sdk for fb deeplink
This commit is contained in:
@@ -339,7 +339,7 @@ dependencies {
|
||||
})
|
||||
|
||||
// Facebook sdk
|
||||
implementation 'com.facebook.android:facebook-android-sdk:8.2.0'
|
||||
implementation 'com.facebook.android:facebook-applinks:[4,5)'
|
||||
|
||||
// for branch io deeplink
|
||||
implementation 'io.branch.sdk.android:library:5.+'
|
||||
|
||||
@@ -263,6 +263,10 @@
|
||||
tools:replace="android:resource" />
|
||||
</provider>
|
||||
|
||||
<provider android:authorities="com.facebook.app.FacebookContentProvider238258890720575"
|
||||
android:name="com.facebook.FacebookContentProvider"
|
||||
android:exported="true" />
|
||||
|
||||
<activity
|
||||
android:name="com.freshchat.consumer.sdk.activity.ChannelListActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
package com.naviapp.analytics.deeplink
|
||||
|
||||
import android.app.Activity
|
||||
import android.net.Uri
|
||||
import android.os.Bundle
|
||||
import com.navi.common.deeplink.util.DeeplinkConstants
|
||||
import com.navi.common.model.CtaData
|
||||
@@ -22,6 +23,7 @@ import com.naviapp.utils.Constants.URL
|
||||
import com.naviapp.utils.extractData
|
||||
import com.naviapp.utils.isPublicPage
|
||||
import com.naviapp.utils.log
|
||||
import com.naviapp.utils.orFalse
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
import kotlinx.coroutines.launch
|
||||
@@ -42,61 +44,41 @@ object DeeplinkManager {
|
||||
|
||||
fun handleDeeplinkData(
|
||||
activity: Activity,
|
||||
jsonObject: JSONObject,
|
||||
jsonObject: JSONObject? = null,
|
||||
uriData: Uri? = null,
|
||||
type: String,
|
||||
deepLinkValue: String? = null
|
||||
) {
|
||||
try {
|
||||
when (type) {
|
||||
DeeplinkType.APPSFLYER.name -> {
|
||||
val url = jsonObject.optString(URL).replace("-", "/")
|
||||
val source = jsonObject.optString(Constants.LOGIN_SOURCE)
|
||||
val additionalDataRequired = jsonObject.optBoolean(ADDITIONAL_DATA_NEEDED)
|
||||
if (CommonUtils.isUserLoggedIn()) {
|
||||
if (additionalDataRequired) {
|
||||
fetchData(activity, source, url)
|
||||
} else {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = url),
|
||||
bundle = extractData(jsonObject),
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
}
|
||||
} else if (isPublicPage(url)) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = url),
|
||||
bundle = extractData(jsonObject),
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
} else if (source.isNullOrEmpty().not()) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = DeeplinkConstants.REGISTRATION),
|
||||
bundle = extractData(jsonObject),
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
} else if (deepLinkValue.isNullOrEmpty().not()) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = DeeplinkConstants.REGISTRATION),
|
||||
bundle = Bundle().apply {
|
||||
putString(
|
||||
Constants.LOGIN_SOURCE,
|
||||
deepLinkValue
|
||||
)
|
||||
},
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
}
|
||||
val url = jsonObject?.optString(URL)?.replace("-", "/").orEmpty()
|
||||
val source = jsonObject?.optString(Constants.LOGIN_SOURCE)
|
||||
val additionalDataRequired = jsonObject?.optBoolean(ADDITIONAL_DATA_NEEDED)
|
||||
redirectToDestination(
|
||||
activity,
|
||||
url,
|
||||
source,
|
||||
additionalDataRequired,
|
||||
extractData(jsonObject),
|
||||
deepLinkValue
|
||||
)
|
||||
}
|
||||
DeeplinkType.FB.name -> {
|
||||
// handle deeplink data
|
||||
uriData?.let { uri ->
|
||||
val url = uri.getQueryParameter(URL).orEmpty()
|
||||
val source = uri.getQueryParameter(Constants.LOGIN_SOURCE)
|
||||
val additionalDataRequired =
|
||||
uri.getQueryParameter(ADDITIONAL_DATA_NEEDED)?.toBoolean()
|
||||
redirectToDestination(
|
||||
activity,
|
||||
url,
|
||||
source,
|
||||
additionalDataRequired,
|
||||
extractData(uri),
|
||||
deepLinkValue
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (ex: Exception) {
|
||||
@@ -104,6 +86,58 @@ object DeeplinkManager {
|
||||
}
|
||||
}
|
||||
|
||||
private fun redirectToDestination(
|
||||
activity: Activity,
|
||||
url: String,
|
||||
source: String?,
|
||||
additionalDataRequired: Boolean?,
|
||||
bundle: Bundle,
|
||||
deepLinkValue: String? = null
|
||||
) {
|
||||
if (CommonUtils.isUserLoggedIn()) {
|
||||
if (additionalDataRequired.orFalse()) {
|
||||
fetchData(activity, source, url)
|
||||
} else {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = url),
|
||||
bundle = bundle,
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
}
|
||||
} else if (isPublicPage(url)) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = url),
|
||||
bundle = bundle,
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
} else if (source.isNullOrEmpty().not()) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = DeeplinkConstants.REGISTRATION),
|
||||
bundle = bundle,
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
} else if (deepLinkValue.isNullOrEmpty().not()) {
|
||||
NaviDeepLinkNavigator.navigate(
|
||||
activity,
|
||||
CtaData(url = DeeplinkConstants.REGISTRATION),
|
||||
bundle = Bundle().apply {
|
||||
putString(
|
||||
Constants.LOGIN_SOURCE,
|
||||
deepLinkValue
|
||||
)
|
||||
},
|
||||
finish = true,
|
||||
clearTask = true
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun fetchData(activity: Activity, channel: String?, url: String) {
|
||||
coroutineScope.launch {
|
||||
val response: RepoResult<DeeplinkResponse> = if (channel == BranchManager.CHANNEL_GI) {
|
||||
|
||||
@@ -33,8 +33,7 @@ import com.naviapp.utils.getAppName
|
||||
object NaviSDKHelper {
|
||||
fun init(naviApplication: NaviApplication) {
|
||||
FirebaseRemoteConfigHelper.init()
|
||||
FacebookSdk.setAutoInitEnabled(true)
|
||||
FacebookSdk.fullyInitialize()
|
||||
FacebookSdk.sdkInitialize(naviApplication)
|
||||
val inAppOptOutScreens = mutableSetOf<Class<*>>()
|
||||
inAppOptOutScreens.add(SplashActivity::class.java)
|
||||
NaviTrackEvent.appInit(
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.facebook.applinks.AppLinkData
|
||||
import bolts.AppLinks
|
||||
import com.navi.amc.investorapp.constants.Constant
|
||||
import com.navi.analytics.appsflyer.AppsFlyerUtil
|
||||
import com.navi.analytics.appsflyer.DeepLinkListener
|
||||
@@ -246,11 +246,11 @@ class SplashActivity : BaseActivity(), DeepLinkListener {
|
||||
}
|
||||
|
||||
private fun fbDeeplink() {
|
||||
AppLinkData.fetchDeferredAppLinkData(this) { appData ->
|
||||
appData?.appLinkData?.let { appLinkData ->
|
||||
DeeplinkManager.handleDeeplinkData(this, appLinkData, DeeplinkType.FB.name)
|
||||
}
|
||||
}
|
||||
DeeplinkManager.handleDeeplinkData(
|
||||
this,
|
||||
uriData = AppLinks.getTargetUrlFromInboundIntent(this, intent),
|
||||
type = DeeplinkType.FB.name
|
||||
)
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
@@ -262,6 +262,11 @@ class SplashActivity : BaseActivity(), DeepLinkListener {
|
||||
get() = NaviAnalytics.SPLASH
|
||||
|
||||
override fun onDeepLinking(jsonObject: JSONObject, type: String, deepLinkValue: String?) {
|
||||
DeeplinkManager.handleDeeplinkData(this, jsonObject, type, deepLinkValue)
|
||||
DeeplinkManager.handleDeeplinkData(
|
||||
this,
|
||||
jsonObject,
|
||||
type = type,
|
||||
deepLinkValue = deepLinkValue
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -603,9 +603,9 @@ fun isPublicPage(screen: String?): Boolean {
|
||||
}
|
||||
}
|
||||
|
||||
fun extractData(jsonObject: JSONObject): Bundle {
|
||||
fun extractData(jsonObject: JSONObject?): Bundle {
|
||||
val bundle = Bundle()
|
||||
jsonObject.keys().forEach { key ->
|
||||
jsonObject?.keys()?.forEach { key ->
|
||||
val value = jsonObject.opt(key)
|
||||
try {
|
||||
when (value) {
|
||||
@@ -621,4 +621,12 @@ fun extractData(jsonObject: JSONObject): Bundle {
|
||||
}
|
||||
}
|
||||
return bundle
|
||||
}
|
||||
|
||||
fun extractData(uri: Uri?): Bundle {
|
||||
val bundle = Bundle()
|
||||
uri?.queryParameterNames?.forEach { key ->
|
||||
bundle.putString(key, uri.getQueryParameter(key))
|
||||
}
|
||||
return bundle
|
||||
}
|
||||
@@ -1,36 +0,0 @@
|
||||
package com.navi.amc.investorapp.ui.splash
|
||||
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.lifecycle.lifecycleScope
|
||||
import com.navi.amc.investorapp.R
|
||||
import com.navi.amc.investorapp.extension.goto
|
||||
import com.navi.amc.investorapp.extension.statusBarTransparent
|
||||
import com.navi.amc.investorapp.ui.home.HomeActivity
|
||||
import com.navi.amc.investorapp.utils.RootDeviceUtil
|
||||
import com.navi.analytics.utils.NaviTrackEvent
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
|
||||
class SplashActivity : AppCompatActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContentView(R.layout.activity_splash)
|
||||
init()
|
||||
}
|
||||
|
||||
private fun init() {
|
||||
if (!RootDeviceUtil.instance.isDeviceRooted()) {
|
||||
lifecycleScope.launch {
|
||||
delay(1000)
|
||||
try {
|
||||
goto(HomeActivity::class.java)
|
||||
} catch (e: Exception) {
|
||||
}
|
||||
}
|
||||
} else {
|
||||
NaviTrackEvent.trackEvent("THIS_USER_IS_ROOTED")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,8 +7,7 @@
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent"
|
||||
android:background="@color/white"
|
||||
tools:context=".ui.splash.SplashActivity">
|
||||
android:background="@color/white">
|
||||
|
||||
<androidx.appcompat.widget.AppCompatImageView
|
||||
android:id="@+id/splashLogo"
|
||||
|
||||
@@ -137,7 +137,6 @@ dependencies {
|
||||
implementation 'com.google.android.gms:play-services-location:17.1.0'
|
||||
|
||||
implementation 'com.facebook.shimmer:shimmer:0.5.0'
|
||||
implementation 'com.facebook.android:facebook-android-sdk:[8,9)'
|
||||
implementation 'in.payu:payu-checkout-pro:1.7.6'
|
||||
implementation 'com.google.android.play:core:1.10.0'
|
||||
|
||||
|
||||
@@ -33,10 +33,6 @@
|
||||
<!-- android:value="https://test.payu.in" />-->
|
||||
<!-- PAYU END-->
|
||||
|
||||
<activity
|
||||
android:name=".registration.SplashActivity"
|
||||
android:screenOrientation="portrait"
|
||||
android:theme="@style/GiAppTheme" />
|
||||
<activity
|
||||
android:name=".health.activity.SupportActivity"
|
||||
android:screenOrientation="portrait"
|
||||
|
||||
@@ -1,480 +0,0 @@
|
||||
/*
|
||||
* *
|
||||
* * Copyright (c) 2019 . All rights reserved @Navi
|
||||
*
|
||||
*/
|
||||
|
||||
package com.navi.insurance.registration
|
||||
|
||||
import android.app.Activity
|
||||
import android.content.Intent
|
||||
import android.os.Bundle
|
||||
import android.os.Handler
|
||||
import android.os.Looper
|
||||
import android.view.View
|
||||
import android.widget.Toast
|
||||
import androidx.databinding.DataBindingUtil
|
||||
import androidx.lifecycle.ViewModelProvider
|
||||
import com.facebook.applinks.AppLinkData
|
||||
import com.navi.common.utils.CommonUtils
|
||||
import com.navi.insurance.R
|
||||
import com.navi.insurance.analytics.InsuranceAnalyticsConstants
|
||||
import com.navi.insurance.analytics.NaviInsuranceAnalytics
|
||||
import com.navi.insurance.common.activity.UpdateAppActivity
|
||||
import com.navi.insurance.databinding.ActivitySplashScreenBinding
|
||||
import com.navi.insurance.health.activity.*
|
||||
import com.navi.insurance.health.viewmodel.OfferVM
|
||||
import com.navi.insurance.health.viewmodel.PolicyVM
|
||||
import com.navi.insurance.health.viewmodel.RegistrationVM
|
||||
import com.navi.insurance.models.response.CustomerPolicyDetails
|
||||
import com.navi.insurance.models.response.OfferDetail
|
||||
import com.navi.insurance.network.ApiConstants.ACCEPTED
|
||||
import com.navi.insurance.network.model.ErrorMessage
|
||||
import com.navi.insurance.payment.PaymentProcessingFragment
|
||||
import com.navi.insurance.registration.fragments.RootedDeviceErrorBottomSheet
|
||||
import com.navi.insurance.sharedpref.NaviPreferenceManager
|
||||
import com.navi.insurance.util.*
|
||||
import com.navi.insurance.util.Constants.POLICY_DETAILS_EXTRA
|
||||
import com.navi.insurance.util.Constants.PROPOSAL_EXTRA
|
||||
import com.navi.insurance.util.Constants.PROPOSAL_STATUS_EXTRA
|
||||
import com.navi.insurance.util.Constants.QUOTE_DETAILS_EXTRA
|
||||
import com.navi.insurance.util.Constants.REDIRECT_TO_QUOTE_SCREEN_EXTRA
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.Dispatchers
|
||||
|
||||
|
||||
class SplashActivity : BaseActivity() {
|
||||
private lateinit var binding: ActivitySplashScreenBinding
|
||||
|
||||
private var coroutineScope: CoroutineScope = CoroutineScope(Dispatchers.Default)
|
||||
|
||||
private val policyVM by lazy { ViewModelProvider(this).get(PolicyVM::class.java) }
|
||||
private val registrationVM by lazy { ViewModelProvider(this).get(RegistrationVM::class.java) }
|
||||
private val offerVM by lazy { ViewModelProvider(this).get(OfferVM::class.java) }
|
||||
|
||||
private var handler: Handler = Handler(Looper.getMainLooper())
|
||||
private val SPLASH_MAX_DELAY = 500L
|
||||
private val SOFT_UPGRADE_REQUEST_CODE = 10
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
checkForDeeplink()
|
||||
//postInstallData()
|
||||
|
||||
binding = DataBindingUtil.setContentView(this, R.layout.activity_splash_screen)
|
||||
if (FirebaseRemoteConfigUtils.getBoolean("ENABLE_ROOT_DEVICE_CHECK") && (RootDeviceUtil.instance.isDeviceRooted() || RootDeviceUtil.instance.rootedDeviceUsingFirebase(
|
||||
applicationContext
|
||||
))
|
||||
) {
|
||||
val rootedDeviceErrorBottomSheet = RootedDeviceErrorBottomSheet.newInstance()
|
||||
rootedDeviceErrorBottomSheet.isCancelable = false
|
||||
rootedDeviceErrorBottomSheet.show(
|
||||
supportFragmentManager,
|
||||
RootedDeviceErrorBottomSheet.TAG
|
||||
)
|
||||
return
|
||||
}
|
||||
initPreferences()
|
||||
//initThirdPartyServices()
|
||||
// initInAppUpdateConfig()
|
||||
initObservers()
|
||||
registrationVM.getAppSettingsData()
|
||||
}
|
||||
|
||||
private fun initObservers() {
|
||||
registrationVM.appSettings.observeNonNull(this) {
|
||||
it.features?.forEach {
|
||||
if (it.name == SUBSCRIPTION_POLICY_MODEL) {
|
||||
NaviPreferenceManager.setBooleanPreference(SUBSCRIPTION_POLICY_MODEL, true)
|
||||
}
|
||||
} ?: kotlin.run {
|
||||
NaviPreferenceManager.setBooleanPreference(SUBSCRIPTION_POLICY_MODEL, false)
|
||||
}
|
||||
//checkUpgrade()
|
||||
}
|
||||
|
||||
val errorObserver = { err: ErrorMessage ->
|
||||
val errorText =
|
||||
if (err.message.isNullOrEmpty()) "Something went wrong" else "Error: ${err.message}"
|
||||
Toast.makeText(
|
||||
this,
|
||||
errorText,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
|
||||
navigateToNextScreen()
|
||||
}
|
||||
registrationVM.errorMessage.observeNonNull(this) { err ->
|
||||
err.getContentIfNotHandled()?.run(errorObserver)
|
||||
}
|
||||
}
|
||||
|
||||
/*private fun checkUpgrade() {
|
||||
|
||||
val appUpdateInfoTask =
|
||||
appUpdateManager?.appUpdateInfo
|
||||
|
||||
appUpdateInfoTask?.addOnSuccessListener { appUpdateInfo ->
|
||||
if (appUpdateInfo.updateAvailability() == UpdateAvailability.UPDATE_AVAILABLE) {
|
||||
val updateType: String = FirebaseRemoteConfigUtils.getString("IN_APP_UPDATE_TYPE")
|
||||
if (updateType == "IMMEDIATE") {
|
||||
try {
|
||||
appUpdateManager?.startUpdateFlowForResult(
|
||||
appUpdateInfo,
|
||||
AppUpdateType.IMMEDIATE,
|
||||
this,
|
||||
APP_UPDATE_REQUEST_CODE
|
||||
)
|
||||
} catch (e: IntentSender.SendIntentException) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e)
|
||||
}
|
||||
} else {
|
||||
try {
|
||||
appUpdateManager?.startUpdateFlowForResult(
|
||||
appUpdateInfo,
|
||||
AppUpdateType.FLEXIBLE,
|
||||
this,
|
||||
APP_UPDATE_REQUEST_CODE
|
||||
)
|
||||
} catch (e: IntentSender.SendIntentException) {
|
||||
FirebaseCrashlytics.getInstance().recordException(e)
|
||||
}
|
||||
}
|
||||
} else if (appUpdateInfo.installStatus() == InstallStatus.DOWNLOADED) {
|
||||
launchRestartDialog(appUpdateManager!!)
|
||||
} else {
|
||||
checkAppUpdateAndProceed()
|
||||
}
|
||||
}
|
||||
|
||||
appUpdateInfoTask?.addOnFailureListener {
|
||||
checkAppUpdateAndProceed()
|
||||
}
|
||||
}*/
|
||||
|
||||
/* private fun initInAppUpdateConfig() {
|
||||
appUpdateManager = AppUpdateManagerFactory.create(this)
|
||||
listener = InstallStateUpdatedListener { installState ->
|
||||
if (installState.installStatus() == InstallStatus.DOWNLOADED) {
|
||||
launchRestartDialog(appUpdateManager!!)
|
||||
} else if (installState.installStatus() == InstallStatus.INSTALLED) {
|
||||
appUpdateManager?.unregisterListener(listener)
|
||||
} else if (installState.installStatus() == InstallStatus.DOWNLOADING) {
|
||||
navigateToNextScreen()
|
||||
}
|
||||
}
|
||||
appUpdateManager?.registerListener(listener)
|
||||
}*/
|
||||
|
||||
private fun checkAppUpdateAndProceed() {
|
||||
registrationVM.appSettings.value?.run {
|
||||
if (this.appUpgradeResponse?.hardUpgrade.orFalse() || this.appUpgradeResponse?.softUpgrade.orFalse()) {
|
||||
val intent = Intent(this@SplashActivity, UpdateAppActivity::class.java)
|
||||
intent.putExtra(Constants.APP_UPGRADE_EXTRA, this.appUpgradeResponse)
|
||||
if (this.appUpgradeResponse?.hardUpgrade.orFalse()) {
|
||||
//Needs forced update
|
||||
startActivity(intent)
|
||||
finish()
|
||||
} else {
|
||||
//Needs soft update
|
||||
startActivityForResult(intent, SOFT_UPGRADE_REQUEST_CODE)
|
||||
}
|
||||
} else {
|
||||
//No need of forced update, go with app flow
|
||||
handler.postDelayed({
|
||||
navigateToNextScreen()
|
||||
}, SPLASH_MAX_DELAY)
|
||||
}
|
||||
} ?: navigateToNextScreen()
|
||||
}
|
||||
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
when (requestCode) {
|
||||
SOFT_UPGRADE_REQUEST_CODE -> navigateToNextScreen()
|
||||
APP_UPDATE_REQUEST_CODE -> {
|
||||
if (resultCode != Activity.RESULT_OK) {
|
||||
navigateToNextScreen()
|
||||
}
|
||||
}
|
||||
}
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
}
|
||||
|
||||
private fun initPreferences() {
|
||||
NaviPreferenceManager.setStringPreference(USER_LOCATION_COUNTRY_CODE, "IN") //TODO
|
||||
}
|
||||
|
||||
private fun navigateToNextScreen() {
|
||||
var nextScreen = ""
|
||||
|
||||
when {
|
||||
|
||||
//Hit API to check if policies exist
|
||||
CommonUtils.isUserLoggedIn() -> {
|
||||
fetchUserPolicies()
|
||||
}
|
||||
|
||||
//Send user to Landing page if not logged in
|
||||
else -> {
|
||||
|
||||
launchLandingPage()
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun checkForDeeplink() {
|
||||
AppLinkData.fetchDeferredAppLinkData(
|
||||
this
|
||||
) {
|
||||
if (it != null) {
|
||||
NaviPreferenceManager.setBooleanPreference(IS_FROM_FB, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private fun redirectToQuoteScreen(od: OfferDetail) {
|
||||
var nextScreen = ""
|
||||
|
||||
val intent = Intent(this@SplashActivity, BuyInsuranceActivity::class.java)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.OFFER_FORM
|
||||
|
||||
intent.putExtra(REDIRECT_TO_QUOTE_SCREEN_EXTRA, true)
|
||||
intent.putExtra(QUOTE_DETAILS_EXTRA, od)
|
||||
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
private fun fetchUserPolicies() {
|
||||
policyVM.customerPolicies.observeNonNull(this) {
|
||||
observeLastQuote(it)
|
||||
offerVM.fetchQuoteIfExists()
|
||||
}
|
||||
|
||||
val errorObserver = { err: ErrorMessage ->
|
||||
if (!tryHandleError(err, null)) {
|
||||
val errorText =
|
||||
if (err.message.isNullOrEmpty()) "Something went wrong" else "Error: ${err.message}"
|
||||
Toast.makeText(
|
||||
this,
|
||||
errorText,
|
||||
Toast.LENGTH_LONG
|
||||
).show()
|
||||
}
|
||||
}
|
||||
|
||||
policyVM.errorMessage.observeNonNull(this) { err ->
|
||||
err.getContentIfNotHandled()?.run(errorObserver)
|
||||
}
|
||||
policyVM.fetchCustomerPolicies()
|
||||
}
|
||||
|
||||
private fun observeLastQuote(customerPolicyDetails: CustomerPolicyDetails) {
|
||||
offerVM.quoteDetail.observeNullable(this) {
|
||||
if (it?.status == PROCESSING_PAYMENT && it.paymentReferenceId != null) {
|
||||
binding.logoImage.visibility = View.GONE
|
||||
val paymentProcessingFragment =
|
||||
PaymentProcessingFragment.newInstance(it.paymentReferenceId)
|
||||
supportFragmentManager.beginTransaction()
|
||||
.setCustomAnimations(
|
||||
R.anim.slide_in_right,
|
||||
R.anim.slide_out_left,
|
||||
R.anim.slide_in_left,
|
||||
R.anim.slide_out_right
|
||||
)
|
||||
.replace(
|
||||
R.id.form_fragment,
|
||||
paymentProcessingFragment,
|
||||
PaymentProcessingFragment.TAG
|
||||
)
|
||||
.addToBackStack(PaymentProcessingFragment.TAG)
|
||||
.commit()
|
||||
} else if (!isNoPolicies()) {
|
||||
redirectToDashboard(customerPolicyDetails)
|
||||
} else {
|
||||
var nextScreen = ""
|
||||
if (it == null) {
|
||||
if (NaviPreferenceManager.getStringPreference(BOOK_INSURANCE_RESULT)
|
||||
.isNullOrBlank()
|
||||
) {
|
||||
//Redirect to landing page if no ongoing chat
|
||||
launchLandingPage()
|
||||
|
||||
} else {
|
||||
//Redirect to chat if chat already in progress
|
||||
val intent = Intent(this@SplashActivity, ChatActivity::class.java)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.INSURANCE_FORM
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
|
||||
}
|
||||
|
||||
} else if (it.quoteProcessType == Constants.NSTP) {
|
||||
if (!NaviPreferenceManager.getBooleanPreference(QUOTE_GENERATED_FOR_CURRENT_CHAT) && it.updateAllowed) {
|
||||
//Redirect to landing page if no ongoing chat
|
||||
val intent = Intent(this@SplashActivity, ChatActivity::class.java)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.CHAT_SCREEN
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
} else {
|
||||
val intent = Intent(this@SplashActivity, BuyInsuranceActivity::class.java)
|
||||
intent.putExtra(REDIRECT_TO_QUOTE_SCREEN_EXTRA, true)
|
||||
intent.putExtra(QUOTE_DETAILS_EXTRA, it as OfferDetail)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
}
|
||||
} else if (!NaviPreferenceManager.getBooleanPreference(
|
||||
QUOTE_GENERATED_FOR_CURRENT_CHAT
|
||||
)
|
||||
) {
|
||||
//Redirect to chat with quote details if there is incomplete chat
|
||||
val intent = Intent(this, ChatActivity::class.java)
|
||||
intent.putExtra(Constants.IS_QUOTE_DETAILS_EXTRA, true)
|
||||
intent.putExtra(QUOTE_DETAILS_EXTRA, it)
|
||||
startActivity(intent)
|
||||
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
} else {
|
||||
//Redirect to quote screen
|
||||
redirectToQuoteScreen(it)
|
||||
}
|
||||
|
||||
finish()
|
||||
}
|
||||
}
|
||||
|
||||
offerVM.proposalDetail.observeNonNull(this) {
|
||||
|
||||
var nextScreen = ""
|
||||
|
||||
if (!isNoPolicies()) {
|
||||
redirectToDashboard(customerPolicyDetails)
|
||||
} else if (it.status == ACCEPTED) {
|
||||
it.proposalId?.let { it1 -> offerVM.getQuoteFromProposal(it1) }
|
||||
} else {
|
||||
val intent = Intent(this@SplashActivity, ChatActivity::class.java)
|
||||
intent.putExtra(PROPOSAL_EXTRA, it)
|
||||
intent.putExtra(PROPOSAL_STATUS_EXTRA, it.status)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.INSURANCE_FORM
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
val errorObserver = { err: ErrorMessage ->
|
||||
if (!tryHandleError(err, null)) {
|
||||
showErrorMessageToast(this, err.message)
|
||||
}
|
||||
}
|
||||
|
||||
offerVM.errorMessage.observeNonNull(this) { err ->
|
||||
err.getContentIfNotHandled()?.run(errorObserver)
|
||||
}
|
||||
}
|
||||
|
||||
private fun launchLandingPage() {
|
||||
var nextScreen = ""
|
||||
if (FirebaseRemoteConfigUtils.getBoolean("AB_TEST_SKIP_INTRO_SCREEN")) {
|
||||
val intent = Intent(this@SplashActivity, RegisterActivity::class.java)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
intent.putExtra("sourceScreen", screenName)
|
||||
startActivity(intent)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.REGISTER_SCREEN
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
} else {
|
||||
val intent = Intent(this@SplashActivity, IntroActivityV3::class.java)
|
||||
intent.flags =
|
||||
Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
nextScreen = InsuranceAnalyticsConstants.INTRO_SCREEN
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private fun redirectToDashboard(customerPolicyDetails: CustomerPolicyDetails) {
|
||||
val intent = Intent(this@SplashActivity, DashboardActivity::class.java)
|
||||
|
||||
intent.putExtra(POLICY_DETAILS_EXTRA, customerPolicyDetails)
|
||||
intent.putExtra("sourceScreen", screenName)
|
||||
intent.putExtra("showBack", false)
|
||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_ACTIVITY_CLEAR_TASK
|
||||
startActivity(intent)
|
||||
|
||||
val nextScreen = InsuranceAnalyticsConstants.DASHBOARD_SCREEN
|
||||
NaviInsuranceAnalytics.postAnalyticsEvent(
|
||||
"HI_next_screen_$nextScreen",
|
||||
mapOf(Pair("screen", screenName))
|
||||
)
|
||||
}
|
||||
|
||||
private fun isNoPolicies(): Boolean {
|
||||
return policyVM.customerPolicies.value?.applications?.filter {
|
||||
checkProposalStatus(it.status)
|
||||
}?.size?.orZero() == 0
|
||||
&& policyVM.customerPolicies.value?.policies?.size?.orZero() == 0
|
||||
}
|
||||
|
||||
/*private fun initThirdPartyServices() {
|
||||
//Record session on UX Cam if non-debug build
|
||||
if (!DEBUG) {
|
||||
UXCam.startWithKey(getString(R.string.ux_cam_key))
|
||||
}
|
||||
}*/
|
||||
|
||||
/* private fun postDeviceDetailsToServer() {
|
||||
coroutineScope.launch {
|
||||
val userDeviceDetails: DeviceDetailsRequest? = getUserDeviceDetails(
|
||||
NaviInsuranceApplication.instance.applicationContext
|
||||
)
|
||||
|
||||
if (userDeviceDetails != null) {
|
||||
registrationVM.postUserDeviceDetailsPreLogin(userDeviceDetails)
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
override val screenName
|
||||
get() = InsuranceAnalyticsConstants.SPLASH_SCREEN
|
||||
}
|
||||
Reference in New Issue
Block a user