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
8 changes: 6 additions & 2 deletions android-core/src/main/java/com/mparticle/MParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import com.mparticle.media.MediaCallbacks;
import com.mparticle.messaging.MPMessagingAPI;
import com.mparticle.messaging.ProviderCloudMessage;
import com.mparticle.rokt.RoktConfig;
import com.mparticle.rokt.RoktEmbeddedView;

import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -1880,13 +1881,15 @@ public void selectPlacements(@NonNull String viewName,
@NonNull Map<String, String> attributes,
@Nullable MpRoktEventCallback callbacks,
@Nullable Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
@Nullable Map<String, WeakReference<Typeface>> fontTypefaces) {
@Nullable Map<String, WeakReference<Typeface>> fontTypefaces,
@Nullable RoktConfig config) {
if (mConfigManager.isEnabled()) {
mKitManager.execute(viewName,
attributes,
callbacks,
placeHolders,
fontTypefaces);
fontTypefaces,
config);
}
}
public void selectPlacements(@NonNull String viewName,
Expand All @@ -1896,6 +1899,7 @@ public void selectPlacements(@NonNull String viewName,
attributes,
null,
null,
null,
null
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import com.mparticle.identity.IdentityApiRequest;
import com.mparticle.identity.MParticleUser;
import com.mparticle.internal.listeners.InternalListenerManager;
import com.mparticle.rokt.RoktConfig;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONArray;
Expand Down Expand Up @@ -653,13 +654,15 @@ public void execute(String viewName,
Map<String, String> attributes,
MParticle.MpRoktEventCallback mpRoktEventCallback,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces) {
Map<String, WeakReference<Typeface>> fontTypefaces,
RoktConfig config) {
if (mKitManager != null) {
mKitManager.execute(viewName,
attributes,
mpRoktEventCallback,
placeHolders,
fontTypefaces);
fontTypefaces,
config);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.IdentityApiRequest;
import com.mparticle.identity.MParticleUser;
import com.mparticle.rokt.RoktConfig;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONArray;
Expand Down Expand Up @@ -126,7 +127,8 @@ void execute(String viewName,
Map<String, String> attributes,
MParticle.MpRoktEventCallback mpRoktEventCallback,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces);
Map<String, WeakReference<Typeface>> fontTypefaces,
RoktConfig config);

enum KitStatus {
NOT_CONFIGURED,
Expand Down
29 changes: 29 additions & 0 deletions android-core/src/main/kotlin/com/mparticle/rokt/RoktConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package com.mparticle.rokt

class RoktConfig private constructor(
val colorMode: ColorMode?,
val cacheConfig: CacheConfig?,
val edgeToEdgeDisplay: Boolean,
) {
data class Builder(
private var colorMode: ColorMode? = null,
private var cacheConfig: CacheConfig? = null,
private var edgeToEdgeDisplay: Boolean = true,
) {
fun colorMode(mode: ColorMode) = apply { this.colorMode = mode }
fun cacheConfig(cacheConfig: CacheConfig) = apply { this.cacheConfig = cacheConfig }
fun edgeToEdgeDisplay(edgeToEdgeDisplay: Boolean) = apply { this.edgeToEdgeDisplay = edgeToEdgeDisplay }
fun build(): RoktConfig = RoktConfig(colorMode, cacheConfig, edgeToEdgeDisplay)
}

enum class ColorMode { LIGHT, DARK, SYSTEM }
}

class CacheConfig(
val cacheDurationInSeconds: Long = DEFAULT_CACHE_DURATION_SECS,
val cacheAttributes: Map<String, String>? = null,
) {
companion object {
const val DEFAULT_CACHE_DURATION_SECS: Long = 90 * 60
}
}
11 changes: 7 additions & 4 deletions android-core/src/test/kotlin/com/mparticle/MParticleTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import com.mparticle.internal.MessageManager
import com.mparticle.media.MPMediaAPI
import com.mparticle.messaging.MPMessagingAPI
import com.mparticle.mock.MockContext
import com.mparticle.rokt.RoktConfig
import com.mparticle.rokt.RoktEmbeddedView
import com.mparticle.testutils.AndroidUtils
import com.mparticle.testutils.RandomUtils
Expand Down Expand Up @@ -481,6 +482,8 @@ class MParticleTest {
val placeholders: Map<String, WeakReference<RoktEmbeddedView>> = HashMap()
val fonts: Map<String, WeakReference<Typeface>> = HashMap()

val config = RoktConfig.Builder().colorMode(RoktConfig.ColorMode.DARK).build()

val callbacks = object : MParticle.MpRoktEventCallback {
override fun onLoad() {
println("View loaded")
Expand All @@ -498,9 +501,9 @@ class MParticleTest {
println("Hide loading indicator")
}
}
instance.rokt!!.selectPlacements("testView", attributes, callbacks, placeholders, fonts)
instance.rokt!!.selectPlacements("testView", attributes, callbacks, placeholders, fonts, config)

verify(instance.mKitManager)?.execute("testView", attributes, callbacks, placeholders, fonts)
verify(instance.mKitManager)?.execute("testView", attributes, callbacks, placeholders, fonts, config)
}

@Test
Expand All @@ -514,7 +517,7 @@ class MParticleTest {

instance.rokt.selectPlacements("basicView", attributes)

verify(instance.mKitManager).execute("basicView", attributes, null, null, null)
verify(instance.mKitManager).execute("basicView", attributes, null, null, null, null)
}

@Test
Expand All @@ -525,7 +528,7 @@ class MParticleTest {

instance.rokt.selectPlacements("basicView", HashMap())

verify(instance.mKitManager, never()).execute(any(), any(), any(), any(), any())
verify(instance.mKitManager, never()).execute(any(), any(), any(), any(), any(), any())
}

inner class InnerMockMParticle : MParticle() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import com.mparticle.commerce.CommerceEvent;
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.MParticleUser;
import com.mparticle.rokt.RoktConfig;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONObject;
Expand Down Expand Up @@ -617,6 +618,7 @@ void execute(String viewName,
MParticle.MpRoktEventCallback mpRoktEventCallback,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces,
FilteredMParticleUser user);
FilteredMParticleUser user,
RoktConfig config);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.mparticle.internal.MPUtility;
import com.mparticle.internal.ReportingManager;
import com.mparticle.kits.mappings.CustomMapping;
import com.mparticle.rokt.RoktConfig;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONArray;
Expand Down Expand Up @@ -1338,7 +1339,8 @@ public void execute(String viewName,
Map<String, String> attributes,
MParticle.MpRoktEventCallback mpRoktEventCallback,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces) {
Map<String, WeakReference<Typeface>> fontTypefaces,
RoktConfig config) {
for (KitIntegration provider : providers.values()) {
try {
if (provider instanceof KitIntegration.RoktListener && !provider.isDisabled()) {
Expand Down Expand Up @@ -1389,7 +1391,8 @@ public void execute(String viewName,
mpRoktEventCallback,
placeHolders,
fontTypefaces,
FilteredMParticleUser.getInstance(user.getId(), provider));
FilteredMParticleUser.getInstance(user.getId(), provider),
config);
});
}
} catch (Exception e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import com.mparticle.mock.MockContext
import com.mparticle.mock.MockKitConfiguration
import com.mparticle.mock.MockKitManagerImpl
import com.mparticle.mock.MockMParticle
import com.mparticle.rokt.RoktConfig
import com.mparticle.rokt.RoktEmbeddedView
import com.mparticle.testutils.TestingUtils
import junit.framework.TestCase
Expand Down Expand Up @@ -845,7 +846,7 @@ class KitManagerImplTest {
Pair("country", "US")
)

manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["no"])
Assert.assertEquals("55555", attributes["minorcatid"])
Expand Down Expand Up @@ -910,7 +911,7 @@ class KitManagerImplTest {
Pair("country", "US")
)

manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)

Assert.assertEquals("(123) 456-9898", attributes["call"])
Expand Down Expand Up @@ -976,7 +977,7 @@ class KitManagerImplTest {
Pair("country", "US")
)

manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["no"])
Assert.assertEquals("5-45555", attributes["minorcatid"])
Expand Down Expand Up @@ -1040,7 +1041,7 @@ class KitManagerImplTest {
Pair("country", "US")
)

manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["number"])
Assert.assertEquals("55555", attributes["customerId"])
Expand Down Expand Up @@ -1289,7 +1290,7 @@ class KitManagerImplTest {
Pair("customerId", "55555"),
Pair("country", "US")
)
manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["number"])
Assert.assertEquals("55555", attributes["customerId"])
Expand Down Expand Up @@ -1351,7 +1352,7 @@ class KitManagerImplTest {
Pair("customerId", "55555"),
Pair("country", "US")
)
manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["number"])
Assert.assertEquals("55555", attributes["customerId"])
Expand Down Expand Up @@ -1414,7 +1415,7 @@ class KitManagerImplTest {
Pair("country", "US"),
Pair("sandbox", "false")
)
manager.execute("Test", attributes, null, null, null)
manager.execute("Test", attributes, null, null, null, null)
Assert.assertEquals(6, attributes.size)
Assert.assertEquals("(123) 456-9898", attributes["number"])
Assert.assertEquals("55555", attributes["customerId"])
Expand Down Expand Up @@ -1445,7 +1446,8 @@ class KitManagerImplTest {
mpRoktEventCallback: MParticle.MpRoktEventCallback?,
placeHolders: MutableMap<String, WeakReference<RoktEmbeddedView>>?,
fontTypefaces: MutableMap<String, WeakReference<Typeface>>?,
user: FilteredMParticleUser?
user: FilteredMParticleUser?,
config: RoktConfig
) {
println("Executed with $attributes")
}
Expand Down
Loading