-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'refs/heads/master' into SUITEDEV-35599-MultiID-for-predict
- Loading branch information
Showing
23 changed files
with
168 additions
and
173 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,9 @@ | ||
# What's changed | ||
### [Emarsys](https://github.com/emartech/android-emarsys-sdk/wiki#contents) | ||
* Changed error handling in database operations to receive more detailed information. | ||
# What's fixed | ||
|
||
### [Geofence](https://github.com/emartech/android-emarsys-sdk/wiki#8-geofence) | ||
|
||
* Fixed a compatibility issue with Android 14 (API level 34) and above. | ||
|
||
### [In-App](https://github.com/emartech/android-emarsys-sdk/wiki#3-inapp) | ||
|
||
* Fixed an edge-case when the Activity was not found for the given In-App message to display. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 0 additions & 67 deletions
67
core/src/androidTest/java/com/emarsys/core/activity/CurrentActivityWatchdogTest.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,18 @@ | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||
xmlns:tools="http://schemas.android.com/tools"> | ||
|
||
<uses-permission android:name="android.permission.INTERNET" /> | ||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> | ||
|
||
<application> | ||
<provider | ||
android:name="androidx.startup.InitializationProvider" | ||
android:authorities="${applicationId}.androidx-startup" | ||
android:exported="false" | ||
tools:node="merge"> | ||
<meta-data | ||
android:name="com.emarsys.EmarsysSdkInitializer" | ||
android:value="androidx.startup" /> | ||
</provider> | ||
</application> | ||
</manifest> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package com.emarsys | ||
|
||
import android.app.Activity | ||
import android.app.Application | ||
import android.app.Application.ActivityLifecycleCallbacks | ||
import android.content.Context | ||
import android.os.Bundle | ||
import androidx.startup.Initializer | ||
import kotlinx.coroutines.CoroutineScope | ||
import kotlinx.coroutines.Dispatchers | ||
import kotlinx.coroutines.Job | ||
import kotlinx.coroutines.SupervisorJob | ||
import kotlinx.coroutines.delay | ||
import kotlinx.coroutines.flow.MutableStateFlow | ||
import kotlinx.coroutines.flow.first | ||
import kotlinx.coroutines.launch | ||
import java.lang.ref.WeakReference | ||
|
||
internal var currentActivityFlow: MutableStateFlow<WeakReference<Activity?>?> = | ||
MutableStateFlow(null) | ||
private set | ||
|
||
suspend fun getCurrentActivity(): Activity { | ||
return currentActivityFlow.first { activity -> activity != null }!!.get()!! | ||
} | ||
|
||
class EmarsysSdkInitializer : Initializer<Unit> { | ||
private val scope = CoroutineScope(SupervisorJob() + Dispatchers.Default) | ||
private var setActivityJob: Job? = null | ||
|
||
override fun create(context: Context) { | ||
(context.applicationContext as Application).registerActivityLifecycleCallbacks(object : | ||
ActivityLifecycleCallbacks { | ||
|
||
override fun onActivityCreated(activity: Activity, savedInstanceState: Bundle?) { | ||
currentActivityFlow.value = null | ||
} | ||
|
||
override fun onActivityStarted(activity: Activity) { | ||
currentActivityFlow.value = null | ||
} | ||
|
||
override fun onActivityResumed(activity: Activity) { | ||
setActivityJob = scope.launch { | ||
delay(500) | ||
currentActivityFlow.value = WeakReference(activity) | ||
} | ||
} | ||
|
||
override fun onActivityPaused(activity: Activity) { | ||
if (activity == currentActivityFlow.value) { | ||
currentActivityFlow.value = null | ||
setActivityJob?.cancel() | ||
} | ||
} | ||
|
||
override fun onActivityStopped(activity: Activity) { | ||
if (activity == currentActivityFlow.value) { | ||
currentActivityFlow.value = null | ||
setActivityJob?.cancel() | ||
} | ||
} | ||
|
||
override fun onActivitySaveInstanceState(activity: Activity, outState: Bundle) { | ||
if (activity == currentActivityFlow.value) { | ||
currentActivityFlow.value = null | ||
setActivityJob?.cancel() | ||
} | ||
} | ||
|
||
override fun onActivityDestroyed(activity: Activity) { | ||
if (activity == currentActivityFlow.value) { | ||
currentActivityFlow.value = null | ||
setActivityJob?.cancel() | ||
} | ||
} | ||
}) | ||
} | ||
|
||
override fun dependencies(): List<Class<out Initializer<*>>> { | ||
return emptyList() | ||
} | ||
} | ||
|
27 changes: 0 additions & 27 deletions
27
core/src/main/java/com/emarsys/core/activity/CurrentActivityWatchdog.kt
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.