Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
# Conflicts:
#	changelog.md
  • Loading branch information
Andras Sarro committed Nov 14, 2022
2 parents b9995a7 + d0a042e commit 58162a2
Show file tree
Hide file tree
Showing 78 changed files with 1,613 additions and 1,021 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ android.enableJetifier: When set to true, the Android plugin automatically migra

### 2.2 Push Notifications

Starting from Android 13 (API level 33) the `POST_NOTIFICATIONS` runtime permission is required. In order to receive push notifications this permission must be granted by the user. [Android Dev](https://developer.android.com/about/versions/13/changes/notification-permission)

Emarsys SDK supports multiple push providers([Firebase](https://firebase.google.com/docs/cloud-messaging), [Huawei](https://developer.huawei.com/consumer/en/hms/huawei-pushkit/)). Integrating both, or one of them is necessary for using the Mobile Engage Push feature.

If you want to support both providers, you can include both of them in your application.
Expand Down
7 changes: 3 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@ buildscript {
gradlePluginPortal()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.8.5'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$Versions.kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-allopen:$Versions.kotlin_version"
classpath "com.github.ben-manes:gradle-versions-plugin:0.42.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.4.2"
classpath "com.github.ben-manes:gradle-versions-plugin:0.43.0"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.5.3"
classpath "io.github.gradle-nexus:publish-plugin:1.1.0"
}
}
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ buildscript {
}

dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.20"
}
}

plugins {
id 'org.jetbrains.kotlin.jvm' version '1.6.10'
id 'org.jetbrains.kotlin.jvm' version '1.7.20'
}

repositories {
Expand Down
2 changes: 1 addition & 1 deletion buildSrc/src/main/java/Config.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
object Config {
const val minApiLevel = 24
const val targetApiLevel = 31
const val targetApiLevel = 33
const val buildToolsVersion = Versions.buildToolsVersion
}
66 changes: 41 additions & 25 deletions buildSrc/src/main/java/Dependency.kt
Original file line number Diff line number Diff line change
@@ -1,55 +1,71 @@
object Versions {
const val kotlin_version = "1.6.10"
const val kotlin_version = "1.7.20"
const val kotlin_coroutines_version = "1.6.4"
const val kotlin_test_version = "3.4.2"
const val mockito_version = "4.6.1"
const val firebase_messaging_version = "23.0.5"
const val mockito_version = "4.8.1"
const val mockito_core_version = "4.8.0"
const val firebase_messaging_version = "23.1.0"
const val support_test_version = "1.4.0"
const val support_library = "1.4.2"
const val support_library = "1.5.1"
const val support_test_extensions = "1.1.3"
const val support_test_fragment = "1.4.1"
const val support_annotations = "1.3.0"
const val support_test_fragment = "1.5.3"
const val support_annotations = "1.5.0"
const val buildToolsVersion = "31.0.0"
const val multiDexVersion = "2.0.0"
const val kotlinMockito = "4.0.0"
const val location_services_version = "20.0.0"
const val location_services_version = "21.0.1"
const val espresso_idling_resources = "3.4.0"
const val archLifecycleVersion ="2.4.1"
const val java8LifecycleVersion ="2.4.1"
const val archLifecycleVersion = "2.5.1"
const val java8LifecycleVersion = "2.5.1"
const val securityCryptoVersion = "1.1.0-alpha03"
const val byte_buddy_version = "1.12.8"
const val google_tink_version = "1.6.1"
const val huawei_agconnect_core_version = "1.6.6.200"
const val huawei_hms_push_version = "6.3.0.304"
const val mockkVersion = "1.12.3"
const val byte_buddy_version = "1.12.18"
const val google_tink_version = "1.7.0"
const val huawei_agconnect_core_version = "1.7.2.300"
const val huawei_hms_push_version = "6.7.0.300"
const val mockkVersion = "1.13.2"
const val webkit = "1.5.0"
}

object Libs {
const val support_annotations = "androidx.annotation:annotation:${Versions.support_annotations}"
const val support_appcompat = "androidx.appcompat:appcompat:${Versions.support_library}"
const val firebase_messaging = "com.google.firebase:firebase-messaging:${Versions.firebase_messaging_version}"
const val espresso_idling_resources = "androidx.test.espresso:espresso-idling-resource:${Versions.espresso_idling_resources}"
const val firebase_messaging =
"com.google.firebase:firebase-messaging:${Versions.firebase_messaging_version}"
const val espresso_idling_resources =
"androidx.test.espresso:espresso-idling-resource:${Versions.espresso_idling_resources}"
const val kotlin = "org.jetbrains.kotlin:kotlin-stdlib:${Versions.kotlin_version}"
const val kotlin_reflect = "org.jetbrains.kotlin:kotlin-reflect:${Versions.kotlin_version}"
const val kotlin_stdlib_jdk7= "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin_version}"
const val location_services = "com.google.android.gms:play-services-location:${Versions.location_services_version}"
const val lifecycle_process = "androidx.lifecycle:lifecycle-process:${Versions.archLifecycleVersion}"
const val lifecycle_extension_java_8 = "androidx.lifecycle:lifecycle-common-java8:${Versions.java8LifecycleVersion}"
const val security_crypto = "androidx.security:security-crypto:${Versions.securityCryptoVersion}"
const val kotlin_stdlib_jdk7 =
"org.jetbrains.kotlin:kotlin-stdlib-jdk7:${Versions.kotlin_version}"
const val kotlin_coroutines =
"org.jetbrains.kotlinx:kotlinx-coroutines-android:${Versions.kotlin_coroutines_version}"
const val location_services =
"com.google.android.gms:play-services-location:${Versions.location_services_version}"
const val lifecycle_process =
"androidx.lifecycle:lifecycle-process:${Versions.archLifecycleVersion}"
const val lifecycle_extension_java_8 =
"androidx.lifecycle:lifecycle-common-java8:${Versions.java8LifecycleVersion}"
const val security_crypto =
"androidx.security:security-crypto:${Versions.securityCryptoVersion}"
const val google_tink = "com.google.crypto.tink:tink-android:${Versions.google_tink_version}"
const val huawei_agconnect_core = "com.huawei.agconnect:agconnect-core:${Versions.huawei_agconnect_core_version}"
const val webkit = "androidx.webkit:webkit:${Versions.webkit}"
const val huawei_agconnect_core =
"com.huawei.agconnect:agconnect-core:${Versions.huawei_agconnect_core_version}"
const val huawei_hms_push = "com.huawei.hms:push:${Versions.huawei_hms_push_version}"
}

object TestLibs {
const val kotlin_test = "io.kotlintest:kotlintest-runner-junit4:${Versions.kotlin_test_version}"
const val mockito_android = "org.mockito:mockito-android:${Versions.mockito_version}"
const val mockito_core = "org.mockito:mockito-core:${Versions.mockito_version}"
const val mockito_core = "org.mockito:mockito-core:${Versions.mockito_core_version}"
const val kotlin_mockito = "org.mockito.kotlin:mockito-kotlin:${Versions.kotlinMockito}"
const val byte_buddy = "net.bytebuddy:byte-buddy:${Versions.byte_buddy_version}"
const val support_test_runner = "androidx.test:runner:${Versions.support_test_version}"
const val support_test_rules = "androidx.test:rules:${Versions.support_test_version}"
const val support_test_extensions = "androidx.test.ext:junit:${Versions.support_test_extensions}"
const val support_test_fragment = "androidx.fragment:fragment-testing:${Versions.support_test_fragment}"
const val support_test_extensions =
"androidx.test.ext:junit:${Versions.support_test_extensions}"
const val support_test_fragment =
"androidx.fragment:fragment-testing:${Versions.support_test_fragment}"
const val multiDex = "androidx.multidex:multidex-instrumentation:${Versions.multiDexVersion}"
const val mockk = "io.mockk:mockk-android:${Versions.mockkVersion}"
const val mockk_agent = "io.mockk:mockk-agent-jvm:${Versions.mockkVersion}"
Expand Down
17 changes: 15 additions & 2 deletions changelog.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,19 @@
# What's new

### [InApp](https://github.com/emartech/android-emarsys-sdk/wiki#3-inapp)

* Added dark mode support for InApp and inline InApp messages. Please check the [GitHub wiki](https://github.com/emartech/android-emarsys-sdk/wiki#33-dark-mode) to see how to set up your application based on Android API level.

### [Push](https://github.com/emartech/android-emarsys-sdk/wiki#2-push)

* Added support for updatable and deletable push messages.

# What's fixed

### [DeepLink](https://github.com/emartech/android-emarsys-sdk/wiki#5-deeplink)

* DeepLink tracking now works without the Mobile Engage feature enabled (without setting an application code).

### [Push](https://github.com/emartech/android-emarsys-sdk/wiki#2-push)

* Fixed an issue what could cause opening the host Application from a Push Notification fail on
Android 12 and 13.
* Fixed an issue when sometimes interacting with a push message lasted for 5 seconds.
3 changes: 1 addition & 2 deletions core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
dependencies {
implementation project(':core-api')
implementation Libs.google_tink
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.2'

implementation Libs.kotlin_coroutines

androidTestImplementation project(':testUtils')
}
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ class DeviceInfoTest {
}
]"""

if (!AndroidVersionUtils.isOreoOrAbove()) {
if (!AndroidVersionUtils.isOreoOrAbove) {
channelSettings = "channelSettings: [{}]"
}
val expectedPayload = JSONObject("""{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class ConnectionWatchDog(

fun registerReceiver(connectionChangeListener: ConnectionChangeListener) {
try {
if (AndroidVersionUtils.isOreoOrAbove()) {
if (AndroidVersionUtils.isOreoOrAbove) {
this.connectionChangeListener = connectionChangeListener
connectivityManager.registerNetworkCallback(
networkRequest,
Expand Down
6 changes: 3 additions & 3 deletions core/src/main/java/com/emarsys/core/crypto/Crypto.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,13 @@ class Crypto(private val publicKey: PublicKey) {
private const val OLD_ITERATION_COUNT = 65536

fun getAlgorythm(): String {
return if (AndroidVersionUtils.isBelowOreo()) CRYPTO_ALGORITHM_BELOW_26 else CRYPTO_ALGORITHM_ABOVE_26
return if (AndroidVersionUtils.isBelowOreo) CRYPTO_ALGORITHM_BELOW_26 else CRYPTO_ALGORITHM_ABOVE_26
}
fun getIvSize(): Int {
return if (AndroidVersionUtils.isBelowOreo()) 16 else 12
return if (AndroidVersionUtils.isBelowOreo) 16 else 12
}
fun getKeyLength(): Int {
return if (AndroidVersionUtils.isBelowOreo()) 128 else 256
return if (AndroidVersionUtils.isBelowOreo) 128 else 256
}

}
Expand Down
16 changes: 8 additions & 8 deletions core/src/main/java/com/emarsys/core/device/DeviceInfo.kt
Original file line number Diff line number Diff line change
Expand Up @@ -78,16 +78,16 @@ data class DeviceInfo(
).toString()

private fun parseChannelSettings(): Pair<String, Any> {
return if (AndroidVersionUtils.isOreoOrAbove()) {
return if (AndroidVersionUtils.isOreoOrAbove) {
"channelSettings" to notificationSettings.channelSettings.map {
JSONObject(
mapOf(
"channelId" to it.channelId,
"importance" to it.importance,
"isCanBypassDnd" to it.isCanBypassDnd,
"isCanShowBadge" to it.isCanShowBadge,
"isShouldVibrate" to it.isShouldVibrate
)
mapOf(
"channelId" to it.channelId,
"importance" to it.importance,
"isCanBypassDnd" to it.isCanBypassDnd,
"isCanShowBadge" to it.isCanShowBadge,
"isShouldVibrate" to it.isShouldVibrate
)
)
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,14 @@ class EmarsysSecureSharedPreferences private constructor(
buffer.position(buffer.position() + subStringLength)
stringSet.add(StandardCharsets.UTF_8.decode(subStringSlice).toString())
}
returnValue = if (stringSet.size == 1 && NULL_VALUE == stringSet.valueAt(0)) {
null
} else {
stringSet
}
returnValue =
if (stringSet.size == 1 && NULL_VALUE == stringSet.valueAt(0)) {
null
} else {
stringSet
}
}
else -> {}
}
}
} catch (ex: GeneralSecurityException) {
Expand Down
22 changes: 0 additions & 22 deletions core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.java

This file was deleted.

16 changes: 16 additions & 0 deletions core/src/main/java/com/emarsys/core/util/AndroidVersionUtils.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.emarsys.core.util

import android.os.Build

object AndroidVersionUtils {
val isOreoOrAbove: Boolean
get() = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O
val isBelowTiramisu: Boolean
get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
val isBelowOreo: Boolean
get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.O
val isBelowQ: Boolean
get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.Q
val isBelowS: Boolean
get() = Build.VERSION.SDK_INT < Build.VERSION_CODES.S
}
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class FakeFirebaseDependencyContainer(
override val inAppInternal: InAppInternal = mock(),
override val loggingInAppInternal: InAppInternal = mock(),
override val deepLinkInternal: DeepLinkInternal = mock(),
override val loggingDeepLinkInternal: DeepLinkInternal = mock(),
override val pushInternal: PushInternal = mock(),
override val loggingPushInternal: PushInternal = mock(),
override val eventServiceInternal: EventServiceInternal = mock(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@ class FakeHuaweiDependencyContainer(
override val inAppInternal: InAppInternal = mock(),
override val loggingInAppInternal: InAppInternal = mock(),
override val deepLinkInternal: DeepLinkInternal = mock(),
override val loggingDeepLinkInternal: DeepLinkInternal = mock(),
override val pushInternal: PushInternal = mock(),
override val loggingPushInternal: PushInternal = mock(),
override val eventServiceInternal: EventServiceInternal = mock(),
Expand Down
14 changes: 0 additions & 14 deletions emarsys-sdk/src/androidTest/java/com/emarsys/EmarsysTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ import io.kotlintest.shouldNotBe
import org.junit.*
import org.junit.rules.TestRule
import org.mockito.kotlin.*
import java.util.*
import java.util.concurrent.CountDownLatch

class EmarsysTest {
Expand Down Expand Up @@ -228,7 +227,6 @@ class EmarsysTest {
mobileEngageInternal = mockMobileEngageInternal,
loggingMobileEngageInternal = mockMobileEngageInternal,
deepLinkInternal = mockDeepLinkInternal,
loggingDeepLinkInternal = mockDeepLinkInternal,
eventServiceInternal = mockEventServiceInternal,
loggingEventServiceInternal = mockEventServiceInternal,
clientService = mockClientServiceApi,
Expand All @@ -253,7 +251,6 @@ class EmarsysTest {
eventService = mockEventServiceApi,
loggingEventService = mockLoggingEventServiceApi,
deepLink = mockDeepLinkApi,
loggingDeepLink = mockLoggingDeepLinkApi,
logger = mock()
)
)
Expand Down Expand Up @@ -854,17 +851,6 @@ class EmarsysTest {
}
}

@Test
fun testTrackDeepLink_delegatesTo_loggingDeepLinkApi_whenMobileEngageIsNotEnabled() {
val mockActivity: Activity = mock()
val mockIntent: Intent = mock()
trackDeepLink(mockActivity, mockIntent)

runBlockingOnCoreSdkThread {
verify(mockLoggingDeepLinkApi).trackDeepLinkOpen(mockActivity, mockIntent, null)
}
}

@Test
fun testTrackCustomEventWithCompletionListener_delegatesTo_eventServiceApi() {
setup(createConfig().applicationCode(APPLICATION_CODE).build())
Expand Down
Loading

0 comments on commit 58162a2

Please sign in to comment.