Skip to content

Commit

Permalink
Merge pull request #345 from radarlabs/track-verified-config
Browse files Browse the repository at this point in the history
pass status to getConfig() callback, fetch Google Play project number on trackVerified()
  • Loading branch information
nickpatrick authored Mar 13, 2024
2 parents bd0636c + 9413062 commit 2b77fbd
Show file tree
Hide file tree
Showing 6 changed files with 292 additions and 267 deletions.
2 changes: 1 addition & 1 deletion sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ apply plugin: "org.jetbrains.dokka"
apply plugin: 'io.radar.mvnpublish'

ext {
radarVersion = '3.9.6'
radarVersion = '3.9.7'
}

String buildNumber = ".${System.currentTimeMillis()}"
Expand Down
8 changes: 1 addition & 7 deletions sdk/src/main/java/io/radar/sdk/Radar.kt
Original file line number Diff line number Diff line change
Expand Up @@ -535,15 +535,9 @@ object Radar {
}
val usage = "initialize"
this.apiClient.getConfig(usage, false, object : RadarApiClient.RadarGetConfigApiCallback {
override fun onComplete(config: RadarConfig) {
override fun onComplete(status: RadarStatus, config: RadarConfig) {
locationManager.updateTrackingFromMeta(config?.meta)
RadarSettings.setFeatureSettings(context, config?.meta.featureSettings)
if (config?.googlePlayProjectNumber != null) {
RadarSettings.setGooglePlayProjectNumber(
context,
config?.googlePlayProjectNumber
)
}
}
})

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ internal class RadarActivityLifecycleCallbacks(
if (updated) {
val usage = "resume"
Radar.apiClient.getConfig(usage, false, object : RadarApiClient.RadarGetConfigApiCallback {
override fun onComplete(config: RadarConfig) {
override fun onComplete(status: Radar.RadarStatus, config: RadarConfig) {
Radar.locationManager.updateTrackingFromMeta(config.meta)
RadarSettings.setFeatureSettings(activity.applicationContext, config.meta.featureSettings)
}
Expand Down
4 changes: 2 additions & 2 deletions sdk/src/main/java/io/radar/sdk/RadarApiClient.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ internal class RadarApiClient(
}

interface RadarGetConfigApiCallback {
fun onComplete(config: RadarConfig)
fun onComplete(status: RadarStatus, config: RadarConfig)
}

interface RadarTripApiCallback {
Expand Down Expand Up @@ -138,7 +138,7 @@ internal class RadarApiClient(
if (status == RadarStatus.SUCCESS) {
Radar.flushLogs()
}
callback?.onComplete(RadarConfig.fromJson(res))
callback?.onComplete(status, RadarConfig.fromJson(res))
}
}, false, true, verified)
}
Expand Down
9 changes: 0 additions & 9 deletions sdk/src/main/java/io/radar/sdk/RadarSettings.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ internal object RadarSettings {
private const val KEY_VERIFIED_HOST = "verified_host"
private const val KEY_LAST_APP_OPEN_TIME = "last_app_open_time"
private const val KEY_SHARING = "sharing"
private const val KEY_GOOGLE_PLAY_PROJECT_NUMBER = "google_play_project_number"
private const val KEY_X_PLATFORM_SDK_TYPE = "x_platform_sdk_type"
private const val KEY_X_PLATFORM_SDK_VERSION = "x_platform_sdk_version"

Expand Down Expand Up @@ -376,14 +375,6 @@ internal object RadarSettings {
getSharedPreferences(context).edit { putBoolean(KEY_SHARING, sharing) }
}

internal fun getGooglePlayProjectNumber(context: Context): Long {
return getSharedPreferences(context).getLong(KEY_GOOGLE_PLAY_PROJECT_NUMBER, 0)
}

internal fun setGooglePlayProjectNumber(context: Context, googlePlayProjectNumber: Long) {
getSharedPreferences(context).edit { putLong(KEY_GOOGLE_PLAY_PROJECT_NUMBER, googlePlayProjectNumber) }
}

internal fun isXPlatform(context: Context): Boolean {
return getSharedPreferences(context).contains(KEY_X_PLATFORM_SDK_TYPE) &&
getSharedPreferences(context).contains(KEY_X_PLATFORM_SDK_VERSION)
Expand Down
Loading

0 comments on commit 2b77fbd

Please sign in to comment.