Skip to content

Commit

Permalink
Merge pull request #189 from qonversion/release/3.0.3
Browse files Browse the repository at this point in the history
Release/3.0.3
  • Loading branch information
Maria-Bordunova authored Jul 30, 2021
2 parents 894b8b8 + 84538f0 commit cd0aef8
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 2 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
buildscript {
ext {
release = [
versionName: "3.0.2",
versionName: "3.0.3",
versionCode: 1
]
}
Expand Down
7 changes: 7 additions & 0 deletions sdk/src/main/java/com/qonversion/android/sdk/AppState.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.qonversion.android.sdk

enum class AppState {
None,
Foreground,
Background
}
21 changes: 21 additions & 0 deletions sdk/src/main/java/com/qonversion/android/sdk/Qonversion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,24 +26,39 @@ object Qonversion : LifecycleDelegate {
private var logger = ConsoleLogger()
private var isDebugMode = false
private val mainHandler = Handler(Looper.getMainLooper())
private var pendingAppState = AppState.None

init {
val lifecycleHandler = AppLifecycleHandler(this)
postToMainThread { ProcessLifecycleOwner.get().lifecycle.addObserver(lifecycleHandler) }
}

override fun onAppBackground() {
if (!QDependencyInjector.isAppComponentInitialized()) {
pendingAppState = AppState.Background
return
}

userPropertiesManager?.onAppBackground()
productCenterManager?.onAppBackground()
automationsManager?.onAppBackground()
attributionManager?.onAppBackground()

pendingAppState = AppState.None
}

override fun onAppForeground() {
if (!QDependencyInjector.isAppComponentInitialized()) {
pendingAppState = AppState.Foreground
return
}

userPropertiesManager?.onAppForeground()
productCenterManager?.onAppForeground()
automationsManager?.onAppForeground()
attributionManager?.onAppForeground()

pendingAppState = AppState.None
}

/**
Expand Down Expand Up @@ -96,6 +111,12 @@ object Qonversion : LifecycleDelegate {
userInfoService,
identityManager
)
when (pendingAppState) {
AppState.Foreground -> onAppForeground()
AppState.Background-> onAppBackground()
else -> {}
}

productCenterManager?.launch(object : QonversionLaunchCallback {
override fun onSuccess(launchResult: QLaunchResult) =
postToMainThread { callback?.onSuccess(launchResult) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,6 @@ class AppModule(
}

companion object {
private const val SDK_VERSION = "3.0.2"
private const val SDK_VERSION = "3.0.3"
}
}

0 comments on commit cd0aef8

Please sign in to comment.