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
9 changes: 7 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,13 @@ jobs:
#script: ./gradlew :android-core:cAT :android-kit-base:cAT --stacktrace
script: |
# Disable benchmark tests as they do not work on emulators
adb uninstall com.mparticle.kits.test; ./gradlew connectedCheck --stacktrace
./gradlew :android-core:cAT :android-kit-base:cAT -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=none
adb uninstall com.mparticle.kits.test || true
adb uninstall com.mparticle.testutils.test || true
./gradlew connectedCheck --stacktrace

adb uninstall com.mparticle.kits.test || true
adb uninstall com.mparticle.testutils.test || true
./gradlew :android-core:cAT :android-kit-base:cAT -Pandroid.testInstrumentationRunnerArguments.androidx.benchmark.enabledRules=none
- name: "Archive Instrumented Tests Results"
uses: actions/upload-artifact@v4
if: always()
Expand Down
27 changes: 26 additions & 1 deletion android-core/proguard.pro
Original file line number Diff line number Diff line change
Expand Up @@ -198,6 +198,20 @@
-keep public class com.mparticle.rokt.* {
*;
}

# Additional Rokt-specific rules to preserve all classes and method signatures
-keep class com.mparticle.rokt.RoktConfig { *; }
-keep class com.mparticle.rokt.RoktConfig$Builder { *; }
-keep class com.mparticle.rokt.RoktConfig$ColorMode { *; }
-keep class com.mparticle.rokt.CacheConfig { *; }
-keep class com.mparticle.rokt.RoktEmbeddedView { *; }
-keep class com.mparticle.rokt.RoktLayoutDimensionCallBack { *; }

# Preserve all method signatures in the Rokt class to prevent overload resolution issues
-keepclassmembers class com.mparticle.Rokt {
public void selectPlacements(...);
public void purchaseFinalized(...);
}
-keep public class com.mparticle.audience.* {
*;
}
Expand All @@ -223,4 +237,15 @@

-keepnames class * implements android.os.Parcelable {
public static final ** CREATOR;
}
}

-keepclassmembers class com.mparticle.Rokt {
<init>(...);
void *(...);
void *$default(...);
<fields>;
}

-keep interface com.mparticle.MpRoktEventCallback { *; }
-keep interface com.mparticle.UnloadReasons { *; }
-keep class com.mparticle.UnloadReasons { *; }
137 changes: 2 additions & 135 deletions android-core/src/main/java/com/mparticle/MParticle.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
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 @@ -52,14 +51,11 @@
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;
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 @@ -114,7 +110,7 @@ public class MParticle {
protected boolean locationTrackingEnabled = false;
@NonNull
protected Internal mInternal = new Internal();
protected Rokt rokt = new Rokt();
protected Rokt rokt;
private IdentityStateListener mDeferredModifyPushRegistrationListener;
@NonNull
private WrapperSdkVersion wrapperSdkVersion = new WrapperSdkVersion(WrapperSdk.WrapperNone, null);
Expand Down Expand Up @@ -194,6 +190,7 @@ private static MParticle getInstance(@NonNull Context context, @NonNull MParticl
instance = new MParticle(options);
instance.mKitManager = new KitFrameworkWrapper(options.getContext(), instance.mMessageManager, instance.Internal().getConfigManager(), instance.Internal().getAppStateManager(), options);
instance.mIdentityApi = new IdentityApi(options.getContext(), instance.mInternal.getAppStateManager(), instance.mMessageManager, instance.mConfigManager, instance.mKitManager, options.getOperatingSystem());
instance.rokt = new Rokt(instance.mConfigManager, instance.mKitManager);

// Check if we've switched workspaces on startup
UploadSettings lastUploadSettings = instance.mConfigManager.getLastUploadSettings();
Expand Down Expand Up @@ -1788,136 +1785,6 @@ public interface ResetListener {
void onReset();
}

/**
* ### Optional callback events for when the view loads and unloads.
*/
public interface MpRoktEventCallback {
/**
* onLoad Callback will be triggered immediately when the View displays.
*/
void onLoad();

/**
* onUnLoad Callback will be triggered if the View failed to show or it closed.
*/
void onUnload(UnloadReasons reason);

/**
* onShouldShowLoadingIndicator callback will be triggered if View start processing
*/
void onShouldShowLoadingIndicator();

/**
* onShouldHideLoadingIndicator callback will be triggered if View end processing
*/
void onShouldHideLoadingIndicator();
}

/**
* Enum representing the reasons for unloading.
*/
public enum UnloadReasons {
/**
* Called when there are no offers to display so the view does not get loaded in.
*/
NO_OFFERS,

/**
* View has been rendered and has been completed.
*/
FINISHED,

/**
* Operation to fetch view took too long to resolve.
*/
TIMEOUT,

/**
* Some error has occurred regarding the network.
*/
NETWORK_ERROR,

/**
* View is empty.
*/
NO_WIDGET,

/**
* Init request was not successful.
*/
INIT_FAILED,

/**
* Placeholder string mismatch.
*/
UNKNOWN_PLACEHOLDER,

/**
* Catch-all for all issues.
*/
UNKNOWN;

/**
* Returns the enum constant matching the provided string.
* If no match is found, UNKNOWN is returned.
*
* @param value the name of the enum constant to look up
* @return the corresponding UnloadReasons constant or UNKNOWN if no match is found
*/
public static UnloadReasons from(String value) {
for (UnloadReasons reason : UnloadReasons.values()) {
if (reason.name().equals(value)) {
return reason;
}
}
return UNKNOWN;
}
}


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

}

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 RoktConfig config) {
if (mConfigManager.isEnabled()) {
mKitManager.execute(viewName,
attributes,
callbacks,
placeHolders,
fontTypefaces,
config);
}
}

public void selectPlacements(@NonNull String viewName,
@NonNull Map<String, String> attributes) {
if (mConfigManager.isEnabled()) {
mKitManager.execute(viewName,
attributes,
null,
null,
null,
null
);
}
}

public void purchaseFinalized(@NonNull String placementId, @NonNull String catalogItemId, boolean status) {
if (mConfigManager.isEnabled()) {
mKitManager.purchaseFinalized(placementId, catalogItemId, status);
}
}
}
/**
* @hidden
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import com.mparticle.MPEvent;
import com.mparticle.MParticle;
import com.mparticle.MParticleOptions;
import com.mparticle.MpRoktEventCallback;
import com.mparticle.WrapperSdkVersion;
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.IdentityApiRequest;
Expand Down Expand Up @@ -654,7 +655,7 @@ public void reset() {
@Override
public void execute(@NonNull String viewName,
@NonNull Map<String, String> attributes,
@Nullable MParticle.MpRoktEventCallback mpRoktEventCallback,
@Nullable MpRoktEventCallback mpRoktEventCallback,
@Nullable Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
@Nullable Map<String, WeakReference<Typeface>> fontTypefaces,
@Nullable RoktConfig config) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import com.mparticle.MPEvent;
import com.mparticle.MParticle;
import com.mparticle.MParticleOptions;
import com.mparticle.MpRoktEventCallback;
import com.mparticle.WrapperSdkVersion;
import com.mparticle.consent.ConsentState;
import com.mparticle.identity.IdentityApiRequest;
Expand Down Expand Up @@ -125,10 +126,10 @@ public interface KitManager {

void reset();

void execute(@NonNull String viewName,
void execute(@NonNull String identifier,
@NonNull Map<String, String> attributes,
@Nullable MParticle.MpRoktEventCallback mpRoktEventCallback,
@Nullable Map<String, WeakReference<RoktEmbeddedView>> placeHolders,
@Nullable MpRoktEventCallback mpRoktEventCallback,
@Nullable Map<String, WeakReference<RoktEmbeddedView>> embeddedViews,
@Nullable Map<String, WeakReference<Typeface>> fontTypefaces,
@Nullable RoktConfig config);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.mparticle

/**
* ### Optional callback events for when the view loads and unloads.
*/
interface MpRoktEventCallback {

/**
* onLoad Callback will be triggered immediately when the View displays.
*/
fun onLoad()

/**
* onUnLoad Callback will be triggered if the View failed to show or it closed.
*/
fun onUnload(reason: UnloadReasons)

/**
* onShouldShowLoadingIndicator callback will be triggered if View starts processing.
*/
fun onShouldShowLoadingIndicator()

/**
* onShouldHideLoadingIndicator callback will be triggered if View ends processing.
*/
fun onShouldHideLoadingIndicator()
}

/**
* Enum representing the reasons for unloading.
*/
enum class UnloadReasons {
/**
* Called when there are no offers to display so the view does not get loaded in.
*/
NO_OFFERS,

/**
* View has been rendered and has been completed.
*/
FINISHED,

/**
* Operation to fetch view took too long to resolve.
*/
TIMEOUT,

/**
* Some error has occurred regarding the network.
*/
NETWORK_ERROR,

/**
* View is empty.
*/
NO_WIDGET,

/**
* Init request was not successful.
*/
INIT_FAILED,

/**
* Placeholder string mismatch.
*/
UNKNOWN_PLACEHOLDER,

/**
* Catch-all for all issues.
*/
UNKNOWN;

companion object {
/**
* Returns the enum constant matching the provided string.
* If no match is found, UNKNOWN is returned.
*
* @param value the name of the enum constant to look up
* @return the corresponding UnloadReasons constant or UNKNOWN if no match is found
*/
fun from(value: String): UnloadReasons {
return try {
valueOf(value)
} catch (e: IllegalArgumentException) {
UNKNOWN
}
}
}
}
36 changes: 36 additions & 0 deletions android-core/src/main/kotlin/com/mparticle/Rokt.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.mparticle

import android.graphics.Typeface
import com.mparticle.internal.ConfigManager
import com.mparticle.internal.KitManager
import com.mparticle.internal.listeners.ApiClass
import com.mparticle.rokt.RoktConfig
import com.mparticle.rokt.RoktEmbeddedView
import java.lang.ref.WeakReference

@ApiClass
class Rokt internal constructor(
private val mConfigManager: ConfigManager,
private val mKitManager: KitManager
) {

@JvmOverloads
fun selectPlacements(
identifier: String,
attributes: Map<String, String>,
callbacks: MpRoktEventCallback? = null,
embeddedViews: Map<String, WeakReference<RoktEmbeddedView>>? = null,
fontTypefaces: Map<String, WeakReference<Typeface>>? = null,
config: RoktConfig? = null
) {
if (mConfigManager.isEnabled) {
mKitManager.execute(identifier, attributes, callbacks, embeddedViews, fontTypefaces, config)
}
}

fun purchaseFinalized(placementId: String, catalogItemId: String, status: Boolean) {
if (mConfigManager.isEnabled) {
mKitManager.purchaseFinalized(placementId, catalogItemId, status)
}
}
}
Loading
Loading