Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
[versions]
glide = "5.0.7"
kotlin = "2.3.20"
core-ktx = "1.19.0"
kotlin = "2.3.21"
core-ktx = "1.18.0"
appcompat = "1.7.1"
material = "1.14.0"
lifecycle-runtime-ktx = "2.10.0"
lifecycle-runtime-ktx = "2.11.0"
coroutines-ktx = "1.11.0"
activity-ktx = "1.13.0"
fragment-ktx = "1.8.9"
lifecycle-viewmodel-ktx = "2.10.0"
lifecycle-viewmodel-ktx = "2.11.0"
browser = "1.10.0"
recycler = "1.4.0"
constraint-layout = "2.2.1"
firebase-bom = "34.14.1"
firebase-bom = "34.16.0"
datastore-preferences = "1.2.1"
coil = "2.7.0"
media3 = "1.10.1"
work-manager = "2.11.2"
play-services-location = "21.3.0"
play-services-location = "21.4.0"
junit = "4.13.2"
junit-jupiter = "6.1.0"
junit-jupiter = "6.1.2"
mockk = "1.14.11"
truth = "1.4.5"
json = "20260522"
Expand All @@ -29,7 +29,7 @@ androidx-test-junit = "1.3.0"
androidx-test-espresso = "3.7.0"
androidx-test-core = "1.7.0"
androidx-test-mockk = "1.14.11"
lifecycle-process = "2.10.0"
lifecycle-process = "2.11.0"
mapp-engage="7.1.1"

[libraries]
Expand Down
6 changes: 3 additions & 3 deletions mapp-engage-sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -118,11 +118,11 @@ fun isPlainDataClass(lines: List<String>, startIndex: Int): Boolean {

extensions.configure<LibraryExtension> {
namespace = "com.appoxee.sdk"
compileSdk = 37
buildToolsVersion = "37.0.0"
compileSdk = 36
buildToolsVersion = "36.1.0"

lint {
targetSdk = 37
targetSdk = 36
checkReleaseBuilds = false
}

Expand Down
2 changes: 1 addition & 1 deletion mapp-engage-sdk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
################
GROUP=com.mapp.sdk
POM_ARTIFACT_ID=engage-android
VERSION_NAME=7.1.1
VERSION_NAME=7.1.2

POM_NAME=Mapp Engage Android SDK
POM_DESCRIPTION=The Mapp Engage Android SDK (v7)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import com.appoxee.internal.container.PushContainer
import com.appoxee.internal.model.response.DefaultResponse
import com.appoxee.internal.model.response.DevicePayload
import com.appoxee.internal.model.response.ResponseData
import com.appoxee.internal.model.response.inbox.InboxMessage
import com.appoxee.internal.model.response.inbox.InboxMessageDto
import com.appoxee.internal.model.response.inbox.InboxMessagesResponse
import com.appoxee.internal.network.EngageApiImpl
import com.appoxee.internal.network.response.Response
Expand All @@ -16,6 +16,7 @@ import com.appoxee.internal.storage.Storage
import com.appoxee.internal.ui.push.base.PushManagerImpl
import com.appoxee.shared.AppoxeeObserver
import com.appoxee.shared.AppoxeeOptions
import com.appoxee.shared.InboxMessage
import com.appoxee.shared.MappResult
import com.google.common.truth.Truth
import com.google.firebase.messaging.RemoteMessage
Expand Down Expand Up @@ -121,7 +122,7 @@ class AppoxeeImplAndroidTest {
@Test
fun fetchInboxMessages() {
runBlocking {
val inboxMessage = mockk<InboxMessage>()
val inboxMessage = mockk<InboxMessageDto>()
coEvery { engageApiImpl.fetchInboxMessages(any()) } coAnswers {
Response.success(
200, InboxMessagesResponse("app_open", listOf(inboxMessage))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,17 @@ class NativeFactoryTest {
}
}

@Test
fun getDelay_returns_delay_in_milliseconds() {
val message = mockk<NativeInappMessage>(relaxed = true) {
every { behaviour } returns Behaviour(3, 0)
}

val result = factory.getDelay(message)

Truth.assertThat(result).isEqualTo(3000)
}

@Test
fun fullscreen_content_type_creates_fullscreen_template() {
// Arrange
Expand Down Expand Up @@ -201,4 +212,4 @@ class NativeFactoryTest {
// Assert
Truth.assertThat(result).isInstanceOf(BannerNativeTemplate::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,17 @@ class WebFactoryTest {
}
}

@Test
fun getDelay_returns_delay_in_milliseconds() {
val message = mockk<WebInappMessage>(relaxed = true) {
every { behaviour } returns Behaviour(3, 0)
}

val result = factory.getDelay(message)

Truth.assertThat(result).isEqualTo(3000)
}

@Test
fun fullscreen_message_type_creates_fullscreen_template() {
// Arrange
Expand Down Expand Up @@ -154,4 +165,4 @@ class WebFactoryTest {
// Assert
Truth.assertThat(result).isInstanceOf(BannerWebTemplate::class.java)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,20 @@ data class Location(
val width: Int
) {
companion object {
private const val DEFAULT_SIZE_PERCENT = 100

fun fromJSON(json: JSONObject): Location {
return Location(
bannerPosition = BannerPosition.fromValue(json.getLongOrDefault("position", 0).toInt()),
height = json.getLongOrDefault("height", 0).toInt(),
width = json.getLongOrDefault("width", 0).toInt()
height = json.getSizePercent("height"),
width = json.getSizePercent("width")
)
}

private fun JSONObject.getSizePercent(name: String): Int {
return getLongOrDefault(name, DEFAULT_SIZE_PERCENT.toLong())
.toInt()
.takeIf { it > 0 } ?: DEFAULT_SIZE_PERCENT
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.appoxee.internal.ui.inapp

internal const val DEFAULT_INAPP_SIZE_PERCENT = 100

internal fun Int?.inappSizePercentOrDefault(): Int {
return this?.takeIf { it > 0 } ?: DEFAULT_INAPP_SIZE_PERCENT
}
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ internal abstract class Template(
}
}

message.behaviour?.displaySeconds?.toLong()?.let { seconds ->
message.behaviour?.displaySeconds?.takeIf { it > 0 }?.toLong()?.let { seconds ->
job = scope.launch {
delay(TimeUnit.SECONDS.toMillis(seconds))
withContext(dispatchersProvider.mainDispatcher) {
Expand All @@ -104,4 +104,4 @@ internal abstract class Template(
}

abstract fun show()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@ internal class NativeFactory(
onMessageClosed: ((T, TrackingKey, TrackingParams) -> Unit)? = null
) {
val inappActionHandler = actionContainer.inappActionHandler
val delaySeconds = getDelay(message)
val delayMillis = getDelay(message)
var template: Template
job = scope.launch {
delay(TimeUnit.SECONDS.toMillis(delaySeconds))
delay(delayMillis)
withContext(dispatchersProvider.mainDispatcher) {
if (context.isDestroyed) return@withContext
template = createTemplate(
Expand Down Expand Up @@ -98,4 +98,4 @@ internal class NativeFactory(
val seconds = (message.behaviour?.delaySeconds ?: 0).toLong()
return TimeUnit.SECONDS.toMillis(seconds)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.appoxee.internal.model.response.inapp.NativeInappMessage
import com.appoxee.internal.model.response.inapp.TrackingParams
import com.appoxee.internal.ui.inapp.InappActionHandler
import com.appoxee.internal.ui.inapp.Template
import com.appoxee.internal.ui.inapp.inappSizePercentOrDefault
import com.appoxee.internal.util.DispatchersProvider
import com.appoxee.internal.util.LibraryExtensions.getDisplayMetrics
import com.appoxee.internal.util.LibraryExtensions.toColor
Expand Down Expand Up @@ -56,10 +57,12 @@ internal class StandardImageNativeTemplate<T : Message>(
val view = inflater.inflate(layoutRes, null)

width =
(activity.getDisplayMetrics().widthPixels * ((message.location?.width ?: 100) / 100f))
(activity.getDisplayMetrics().widthPixels *
(message.location?.width.inappSizePercentOrDefault() / 100f))
.toInt()
height =
(activity.getDisplayMetrics().heightPixels * ((message.location?.height ?: 100) / 100f))
(activity.getDisplayMetrics().heightPixels *
(message.location?.height.inappSizePercentOrDefault() / 100f))
.toInt()
alertDialog = AlertDialog.Builder(activity).create().apply {
onViewCreated(message, view) { onDismiss() }
Expand Down Expand Up @@ -145,4 +148,4 @@ internal class StandardImageNativeTemplate<T : Message>(
ColorStateList.valueOf((message as NativeInappMessage).templateBackgroundColor.toColor())
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import com.appoxee.internal.model.response.inapp.NativeInappMessage
import com.appoxee.internal.model.response.inapp.TrackingParams
import com.appoxee.internal.ui.inapp.InappActionHandler
import com.appoxee.internal.ui.inapp.Template
import com.appoxee.internal.ui.inapp.inappSizePercentOrDefault
import com.appoxee.internal.util.DispatchersProvider
import com.appoxee.internal.util.LibraryExtensions.getDisplayMetrics
import com.appoxee.internal.util.LibraryExtensions.toColor
Expand Down Expand Up @@ -56,10 +57,12 @@ internal class StandardNativeTemplate<T : Message>(
val view = inflater.inflate(layoutRes, null)

width =
(activity.getDisplayMetrics().widthPixels * ((message.location?.width ?: 100) / 100f))
(activity.getDisplayMetrics().widthPixels *
(message.location?.width.inappSizePercentOrDefault() / 100f))
.toInt()
height =
(activity.getDisplayMetrics().heightPixels * ((message.location?.height ?: 100) / 100f))
(activity.getDisplayMetrics().heightPixels *
(message.location?.height.inappSizePercentOrDefault() / 100f))
.toInt()
alertDialog = AlertDialog.Builder(activity).create().apply {
onViewCreated(message, view) { onDismiss() }
Expand Down Expand Up @@ -145,4 +148,4 @@ internal class StandardNativeTemplate<T : Message>(
ColorStateList.valueOf((message as NativeInappMessage).templateBackgroundColor.toColor())
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.appoxee.internal.model.response.inapp.WebInappMessage
import com.appoxee.internal.ui.custom.MappWebView
import com.appoxee.internal.ui.inapp.InappActionHandler
import com.appoxee.internal.ui.inapp.Template
import com.appoxee.internal.ui.inapp.inappSizePercentOrDefault
import com.appoxee.internal.util.DispatchersProvider
import com.appoxee.internal.util.LibraryExtensions.getDisplayMetrics
import com.appoxee.internal.util.Logger
Expand Down Expand Up @@ -49,10 +50,12 @@ internal class BannerWebTemplate<T : Message>(
val inflater = activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val position = BannerPosition.fromValue(message.location?.bannerPosition?.position ?: 0)
val width =
(activity.getDisplayMetrics().widthPixels * ((message.location?.width ?: 100) / 100f))
(activity.getDisplayMetrics().widthPixels *
(message.location?.width.inappSizePercentOrDefault() / 100f))
.toInt()
val height =
(activity.getDisplayMetrics().heightPixels * ((message.location?.height ?: 100) / 100f))
(activity.getDisplayMetrics().heightPixels *
(message.location?.height.inappSizePercentOrDefault() / 100f))
.toInt()
view = inflater.inflate(layoutRes, null)
windowManager = activity.getSystemService(Context.WINDOW_SERVICE) as WindowManager
Expand Down Expand Up @@ -120,4 +123,4 @@ internal class BannerWebTemplate<T : Message>(
job?.cancel()
onMessageClosed?.invoke(message, trackingKeyResult, trackingParams)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import com.appoxee.internal.model.response.inapp.WebInappMessage
import com.appoxee.internal.ui.custom.MappWebView
import com.appoxee.internal.ui.inapp.InappActionHandler
import com.appoxee.internal.ui.inapp.Template
import com.appoxee.internal.ui.inapp.inappSizePercentOrDefault
import com.appoxee.internal.util.DispatchersProvider
import com.appoxee.internal.util.LibraryExtensions.getDisplayMetrics
import com.appoxee.internal.util.LibraryExtensions.toPx
Expand Down Expand Up @@ -47,10 +48,10 @@ internal class StandardWebTemplate<T : Message>(
val inflater = activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE) as LayoutInflater
val view = inflater.inflate(layoutRes, null)

width = (activity.getDisplayMetrics().widthPixels * ((message.location?.width
?: 100) / 100f)).toInt()
height = (activity.getDisplayMetrics().heightPixels * ((message.location?.height
?: 100) / 100f)).toInt()
width = (activity.getDisplayMetrics().widthPixels *
(message.location?.width.inappSizePercentOrDefault() / 100f)).toInt()
height = (activity.getDisplayMetrics().heightPixels *
(message.location?.height.inappSizePercentOrDefault() / 100f)).toInt()
alertDialog = AlertDialog.Builder(activity).create().apply {
onViewCreated(message, view) { onDismiss() }
setupViews(activity, view, (message as WebInappMessage))
Expand Down Expand Up @@ -107,4 +108,4 @@ internal class StandardWebTemplate<T : Message>(
})
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ internal class WebFactory(
onMessageClosed: ((T, TrackingKey, TrackingParams) -> Unit)? = null
) {
val inappActionHandler = actionContainer.inappActionHandler
val delaySeconds = getDelay(message)
val delayMillis = getDelay(message)
var template: Template
job = scope.launch {
Logger.d(TAG, "createBanner: ${message.type.name}")
delay(TimeUnit.SECONDS.toMillis(delaySeconds))
delay(delayMillis)
withContext(dispatchersProvider.mainDispatcher) {
if (context.isDestroyed) return@withContext
template = createTemplate(context, inappActionHandler, message, onMessageClosed)
template.show()
onShow?.invoke(message)
Expand Down Expand Up @@ -95,4 +96,4 @@ internal class WebFactory(
val seconds = (message.behaviour?.delaySeconds ?: 0).toLong()
return TimeUnit.SECONDS.toMillis(seconds)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@ object LibraryExtensions {
internal fun Activity.getDisplayMetrics(): DisplayMetrics {
val displayMetrics = DisplayMetrics()
displayMetrics.widthPixels = this.window.decorView.width
.takeIf { it > 0 } ?: this.resources.displayMetrics.widthPixels
displayMetrics.heightPixels = this.window.decorView.height
.takeIf { it > 0 } ?: this.resources.displayMetrics.heightPixels
return displayMetrics
}

Expand Down Expand Up @@ -206,4 +208,4 @@ object LibraryExtensions {
null
}
}
}
}
Loading
Loading