NTP-58543 | Naman Khurmi | GPS popup on exp. (#16007)

This commit is contained in:
Naman Khurmi
2025-05-05 17:04:00 +05:30
committed by GitHub
parent bdbd9b7ccb
commit e88fb271e8
5 changed files with 55 additions and 15 deletions

View File

@@ -273,6 +273,13 @@ class NaviAnalytics private constructor() {
inner class Home {
fun sendGpsPopupStatus(isGpsPopupEnabled: Boolean) {
NaviTrackEvent.trackEventOnClickStream(
HOME_GPS_EVENT,
mapOf(Pair(IS_GPS_ENABLED, isGpsPopupEnabled.toString())),
)
}
fun onHomePageLand() {
NaviTrackEvent.trackEvent(NEW_HOME)
}
@@ -1228,6 +1235,8 @@ class NaviAnalytics private constructor() {
const val BANK_DETAILS = "bank_details"
const val HOME = "home"
const val NEW_HOME = "NaviApp_HomePage_Lands"
const val IS_GPS_ENABLED = "is_gps_enabled"
const val HOME_GPS_EVENT = "NaviApp_HomePage_Gps_Event"
const val NEW_DASHBOARD = "NaviApp_Dashboard_Lands"
const val POSITION = "position"
const val NEW_HOME_CLICKED = "NaviApp_Nav_HomePage_Clicked"

View File

@@ -281,6 +281,10 @@ class HomePageActivity :
}
}
private val shouldTriggerGpsIntentOnFailure by lazy {
FirebaseRemoteConfigHelper.getBoolean(FirebaseRemoteConfigHelper.IS_GPS_POPUP_ENABLED)
}
override val screenName: String
get() = NaviAnalytics.NEW_HOME_ACTIVITY
@@ -452,7 +456,15 @@ class HomePageActivity :
bottomNavBarVM.setBottomNudge(false)
}
}
sendLocationUpdates(postLocation = false, shouldSkipLastUpdatedAtCheck = false)
}
override fun postLocationData() {
locationManager.postLocationData(this, shouldTriggerGpsIntentOnFailure)
}
override fun handleLocationUpdates() {
naviAnalyticsEventTracker.sendGpsPopupStatus(shouldTriggerGpsIntentOnFailure)
sendLocationUpdates(false, false, shouldTriggerGpsIntentOnFailure)
}
override fun onStop() {
@@ -807,7 +819,6 @@ class HomePageActivity :
if (BaseUtils.isUserLoggedIn()) {
naviAnalyticsEventTracker.onHomePageCreated()
sendFCEvent()
sendLocationUpdates()
}
}

View File

@@ -306,6 +306,9 @@ object FirebaseRemoteConfigHelper {
// FESTIVE THEME
const val FESTIVE_RESOURCE_URL_LIST = "FESTIVE_RESOURCE_URL_LIST"
// HOME
const val IS_GPS_POPUP_ENABLED = "GPS_POPUP_VISIBILITY"
private fun getFirebaseRemoteConfig(): FirebaseRemoteConfig {
val remoteConfig = Firebase.remoteConfig
val configSettings = remoteConfigSettings {

View File

@@ -42,6 +42,7 @@ import com.navi.base.sharedpref.CommonPrefConstants.IS_MOCK_LOCATION
import com.navi.base.sharedpref.CommonPrefConstants.LOCATION_UPDATE_ENABLED
import com.navi.base.sharedpref.PreferenceManager
import com.navi.base.utils.BaseUtils
import com.navi.base.utils.TrustedTimeAccessor
import com.navi.base.utils.orElse
import com.navi.base.utils.orFalse
import com.navi.base.utils.orZero
@@ -294,6 +295,7 @@ class NaviLocationManager(
activity: Activity,
postLocation: Boolean = false,
shouldSkipLastUpdatedAtCheck: Boolean = true,
shouldTriggerGpsIntentOnFailure: Boolean = true,
) {
coroutineScope.launch {
if (!shouldSkipLastUpdatedAtCheck) {
@@ -331,7 +333,9 @@ class NaviLocationManager(
onSuccessLocationSettingsResponse(locationSettingsResponseTask, locationRequest)
onFailureLocationSettingsResponse(locationSettingsResponseTask, activity)
if (shouldTriggerGpsIntentOnFailure) {
onFailureLocationSettingsResponse(locationSettingsResponseTask, activity)
}
}
PreferenceManager.setLongPreference(
@@ -385,10 +389,14 @@ class NaviLocationManager(
}
}
fun postLocationData(activity: Activity) {
fun postLocationData(activity: Activity, shouldTriggerGpsIntentOnFailure: Boolean = true) {
if (isLocationNeedToUpdate()) {
analyticsTracker.onRequestAndSendLocation()
requestLocationUpdates(activity, true)
requestLocationUpdates(
activity = activity,
postLocation = true,
shouldTriggerGpsIntentOnFailure = shouldTriggerGpsIntentOnFailure,
)
} else analyticsTracker.onLocationNotSentThreshold()
}
@@ -408,8 +416,8 @@ class NaviLocationManager(
if (locationFetchDuration.orZero() > 0)
(locationFetchDuration.orZero().toLong()) * 60 * 60 * 1000
else LOCATION_UPDATE_PERIOD
if (System.currentTimeMillis() - lastUpdatedTime > locationFetchDurInMilliSec) return true
return false
return TrustedTimeAccessor.getCurrentTimeMillis() - lastUpdatedTime >
locationFetchDurInMilliSec
}
fun isLocationOn(context: Context): Boolean {

View File

@@ -131,7 +131,7 @@ abstract class BaseActivity :
private var permissionsManager: PermissionsManager? = null
private val locationPermission = arrayOf(Manifest.permission.ACCESS_FINE_LOCATION)
private val locationManager by lazy { NaviLocationManager(applicationContext) }
protected val locationManager by lazy { NaviLocationManager(applicationContext) }
private val analyticsErrorEventTracker = CommonNaviAnalytics.naviAnalytics.Errors()
private var layoutView: View? = null
@@ -170,6 +170,18 @@ abstract class BaseActivity :
layoutView = view
}
open fun postLocationData() {
locationManager.postLocationData(this)
}
open fun handleLocationUpdates() {
sendLocationUpdates(
postLocation = false,
shouldSkipLastUpdatedAtCheck = false,
shouldTriggerGpsIntentOnFailure = true,
)
}
private fun initUiTronSdkManager() {
if (!UiTronSdkManager.isInitialized()) {
UiTronSdkManager.init(UiTronDependencyProvider(applicationContext))
@@ -267,8 +279,7 @@ abstract class BaseActivity :
NaviTrackEvent.setSessionId(getSessionId().orEmpty())
}
timeStamp = System.currentTimeMillis()
sendLocationUpdates(postLocation = false, shouldSkipLastUpdatedAtCheck = false)
handleLocationUpdates()
}
override fun onPause() {
@@ -276,10 +287,6 @@ abstract class BaseActivity :
timeStamp = System.currentTimeMillis()
}
fun initV2Loader() {
showNewLoader = true
}
fun setupQueryMap(extras: Bundle?) {
queryMap.clear()
extras?.keySet()?.forEach { key -> queryMap[key] = "${extras.get(key)}" }
@@ -294,19 +301,21 @@ abstract class BaseActivity :
locationManager.setEventName(eventName)
locationManager.setBusinessVertical(businessVertical)
locationManager.setScreenName(screenName)
locationManager.postLocationData(this)
postLocationData()
}
}
fun sendLocationUpdates(
postLocation: Boolean = true,
shouldSkipLastUpdatedAtCheck: Boolean = true,
shouldTriggerGpsIntentOnFailure: Boolean = true,
) {
if (permissionsManager?.hasLocationPermissionAny().orFalse()) {
locationManager.requestLocationUpdates(
this,
postLocation = postLocation,
shouldSkipLastUpdatedAtCheck = shouldSkipLastUpdatedAtCheck,
shouldTriggerGpsIntentOnFailure = shouldTriggerGpsIntentOnFailure,
)
}
}