Skip to content
Open
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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@
[submodule "kits/revealmobile-kit"]
path = kits/revealmobile-kit
url = [email protected]:mparticle-integrations/mparticle-android-integration-revealmobile.git
[submodule "kits/rokt-kit"]
path = kits/rokt-kit
url = [email protected]:mparticle-integrations/mparticle-android-integration-rokt.git
[submodule "kits/singular-kit"]
path = kits/singular-kit
url = [email protected]:mparticle-integrations/mparticle-android-integration-singular.git
Expand Down
4 changes: 2 additions & 2 deletions android-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,8 @@ dependencies {

androidTestImplementation project(':testutils')
if (useOrchestrator()) {
androidTestImplementation 'androidx.test:runner:1.4.0'
androidTestUtil 'androidx.test:orchestrator:1.4.2'
androidTestImplementation 'androidx.test:runner:1.5.2'
androidTestUtil 'androidx.test:orchestrator:1.5.0'
}
androidTestImplementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
androidTestImplementation "org.jetbrains.kotlin:kotlin-test-junit:$kotlin_version"
Expand Down
50 changes: 49 additions & 1 deletion android-core/src/main/java/com/mparticle/MParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.location.Location;
import android.location.LocationManager;
import android.net.Uri;
Expand Down Expand Up @@ -51,12 +52,13 @@
import com.mparticle.media.MediaCallbacks;
import com.mparticle.messaging.MPMessagingAPI;
import com.mparticle.messaging.ProviderCloudMessage;
import com.mparticle.segmentation.SegmentListener;
import com.mparticle.rokt.RoktEmbeddedView;

import org.jetbrains.annotations.NotNull;
import org.json.JSONObject;

import java.io.File;
import java.lang.ref.WeakReference;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -111,6 +113,7 @@ public class MParticle {
protected boolean locationTrackingEnabled = false;
@NonNull
protected Internal mInternal = new Internal();
protected Rokt rokt = new Rokt();
private IdentityStateListener mDeferredModifyPushRegistrationListener;
@NonNull
private WrapperSdkVersion wrapperSdkVersion = new WrapperSdkVersion(WrapperSdk.WrapperNone, null);
Expand Down Expand Up @@ -1170,6 +1173,10 @@ public void logNotificationOpened(@NonNull Intent intent) {
public Internal Internal() {
return mInternal;
}
@NonNull
public Rokt Rokt() {
return rokt;
}

void refreshConfiguration() {
Logger.debug("Refreshing configuration...");
Expand Down Expand Up @@ -1703,6 +1710,7 @@ public interface ServiceProviders {
int SWRVE = 1145;
int BLUESHIFT = 1144;
int NEURA = 147;
int ROKT = 181;
@NonNull
String BROADCAST_ACTIVE = "MPARTICLE_SERVICE_PROVIDER_ACTIVE_";
@NonNull
Expand Down Expand Up @@ -1774,6 +1782,46 @@ public interface ResetListener {
}


/**
* Rokt Integration
* */
public class Rokt{
protected Rokt(){

}
public void selectPlacements(String viewName,
Map<String, String> attributes,
Runnable onUnload,
Runnable onLoad,
Runnable onShouldHideLoadingIndicator,
Runnable onShouldShowLoadingIndicator,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces) {
if (mConfigManager.isEnabled()) {
mKitManager.execute(viewName,
attributes,
onUnload,
onLoad,
onShouldHideLoadingIndicator,
onShouldShowLoadingIndicator,
placeHolders,
fontTypefaces);
}
}
public void selectPlacements(String viewName,
Map<String, String> attributes) {
if (mConfigManager.isEnabled()) {
mKitManager.execute(viewName,
attributes,
null,
null,
null,
null,
null,
null);
}
}
}
/**
* @hidden
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -19,6 +20,7 @@
import com.mparticle.identity.IdentityApiRequest;
import com.mparticle.identity.MParticleUser;
import com.mparticle.internal.listeners.InternalListenerManager;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONArray;

Expand Down Expand Up @@ -646,6 +648,27 @@ public void reset() {
}
}

@Override
public void execute(String viewName,
Map<String, String> attributes,
Runnable onUnload,
Runnable onLoad,
Runnable onShouldHideLoadingIndicator,
Runnable onShouldShowLoadingIndicator,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces) {
if (mKitManager != null) {
mKitManager.execute(viewName,
attributes,
onUnload,
onLoad,
onShouldHideLoadingIndicator,
onShouldShowLoadingIndicator,
placeHolders,
fontTypefaces);
}
}

static class CoreCallbacksImpl implements CoreCallbacks {
KitFrameworkWrapper mKitFrameworkWrapper;
ConfigManager mConfigManager;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -17,6 +18,7 @@
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.IdentityApiRequest;
import com.mparticle.identity.MParticleUser;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONArray;

Expand Down Expand Up @@ -120,6 +122,15 @@ public interface KitManager {

void reset();

void execute(String viewName,
Map<String, String> attributes,
Runnable onUnload,
Runnable onLoad,
Runnable onShouldHideLoadingIndicator,
Runnable onShouldShowLoadingIndicator,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces);

enum KitStatus {
NOT_CONFIGURED,
STOPPED,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package com.mparticle.rokt

import android.content.Context
import android.util.AttributeSet
import android.widget.FrameLayout

class RoktEmbeddedView : FrameLayout {
constructor(context: Context) : super(context)

constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)

constructor(context: Context, attrs: AttributeSet?, defStyleAttr: Int) : super(context, attrs, defStyleAttr)
}
55 changes: 55 additions & 0 deletions android-core/src/test/kotlin/com/mparticle/MParticleTest.kt
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.mparticle

import android.graphics.Typeface
import android.os.Looper
import android.os.SystemClock
import android.webkit.WebView
Expand All @@ -17,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.RoktEmbeddedView
import com.mparticle.testutils.AndroidUtils
import com.mparticle.testutils.RandomUtils
import org.junit.Assert
Expand All @@ -25,10 +27,16 @@ import org.junit.Test
import org.junit.runner.RunWith
import org.mockito.ArgumentCaptor
import org.mockito.ArgumentMatchers
import org.mockito.ArgumentMatchers.any
import org.mockito.Mockito
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.powermock.api.mockito.PowerMockito
import org.powermock.core.classloader.annotations.PrepareForTest
import org.powermock.modules.junit4.PowerMockRunner
import java.lang.ref.WeakReference
import java.util.LinkedList
import java.util.concurrent.ExecutorService
import java.util.concurrent.Executors
Expand Down Expand Up @@ -461,6 +469,53 @@ class MParticleTest {
}
}

@Test
fun testSelectPlacements_withFullParams_whenEnabled() {
var instance: MParticle = InnerMockMParticle()
MParticle.setInstance(instance)
`when`(instance.mConfigManager.isEnabled).thenReturn(true)

val attributes = mutableMapOf<String, String>()
attributes["key"] = "value"

val placeholders: Map<String, WeakReference<RoktEmbeddedView>> = HashMap()
val fonts: Map<String, WeakReference<Typeface>> = HashMap()

val onLoad: Runnable = mock(Runnable::class.java)
val onUnload: Runnable = mock(Runnable::class.java)
val onHide: Runnable = mock(Runnable::class.java)
val onShow: Runnable = mock(Runnable::class.java)

instance.rokt!!.selectPlacements("testView", attributes, onUnload, onLoad, onHide, onShow, placeholders, fonts)

verify(instance.mKitManager)?.execute("testView", attributes, onUnload, onLoad, onHide, onShow, placeholders, fonts)
}

@Test
fun testSelectPlacements_withBasicParams_whenEnabled() {
var instance: MParticle = InnerMockMParticle()
MParticle.setInstance(instance)
`when`(instance.mConfigManager.isEnabled()).thenReturn(true)

val attributes = mutableMapOf<String, String>()
attributes.put("a", "b")

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

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

@Test
fun testSelectPlacements_withBasicParams_whenDisabled() {
var instance: MParticle = InnerMockMParticle()
MParticle.setInstance(instance)
`when`(instance.mConfigManager.isEnabled()).thenReturn(false)

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

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

inner class InnerMockMParticle : MParticle() {
init {
mConfigManager = ConfigManager(MockContext())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ApiVisibilityTest {
publicMethodCount++
}
}
Assert.assertEquals(65, publicMethodCount)
Assert.assertEquals(66, publicMethodCount)
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.location.Location;
import android.net.Uri;
import android.os.Bundle;
Expand All @@ -17,6 +18,7 @@
import com.mparticle.commerce.CommerceEvent;
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.MParticleUser;
import com.mparticle.rokt.RoktEmbeddedView;

import org.json.JSONObject;

Expand Down Expand Up @@ -608,4 +610,16 @@ public interface UserAttributeListener {
public interface BatchListener {
List<ReportingMessage> logBatch(JSONObject jsonObject);
}

public interface RoktListener {
void execute(String viewName,
Map<String, String> attributes,
Runnable onUnload,
Runnable onLoad,
Runnable onShouldHideLoadingIndicator,
Runnable onShouldShowLoadingIndicator,
Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
Map<String, WeakReference<Typeface>> fontTypefaces,
FilteredMParticleUser user);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ private void setupKnownIntegrations() {
knownIntegrations.put(MParticle.ServiceProviders.SWRVE, "com.mparticle.kits.SwrveKit");
knownIntegrations.put(MParticle.ServiceProviders.BLUESHIFT, "com.mparticle.kits.BlueshiftKit");
knownIntegrations.put(MParticle.ServiceProviders.NEURA, "com.mparticle.kits.NeuraKit");
knownIntegrations.put(MParticle.ServiceProviders.ROKT, "com.mparticle.kits.RoktKit");
}

public KitIntegration createInstance(KitManagerImpl manager, KitConfiguration configuration) throws JSONException, ClassNotFoundException {
Expand Down
Loading
Loading