use of com.adcolony.sdk.AdColonyAppOptions in project mopub-android-mediation by mopub.
the class AdColonyAdapterConfiguration method getAdColonyAppOptionsAndSetConsent.
protected static AdColonyAppOptions getAdColonyAppOptionsAndSetConsent(String clientOptions) {
AdColonyAppOptions adColonyAppOptions = AdColonyAppOptions.getMoPubAppOptions(clientOptions);
// Pass the user consent from the MoPub SDK to AdColony as per GDPR
PersonalInfoManager personalInfoManager = MoPub.getPersonalInformationManager();
boolean canCollectPersonalInfo = MoPub.canCollectPersonalInformation();
boolean shouldAllowLegitimateInterest = MoPub.shouldAllowLegitimateInterest();
adColonyAppOptions = adColonyAppOptions == null ? new AdColonyAppOptions() : adColonyAppOptions;
adColonyAppOptions.setMediationNetwork("MoPub", ADAPTER_VERSION);
if (personalInfoManager != null && personalInfoManager.gdprApplies() == Boolean.TRUE) {
adColonyAppOptions.setPrivacyFrameworkRequired(AdColonyAppOptions.GDPR, true);
if (shouldAllowLegitimateInterest) {
if (personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.EXPLICIT_NO || personalInfoManager.getPersonalInfoConsentStatus() == ConsentStatus.DNT) {
adColonyAppOptions.setPrivacyConsentString(AdColonyAppOptions.GDPR, "0");
} else {
adColonyAppOptions.setPrivacyConsentString(AdColonyAppOptions.GDPR, "1");
}
} else if (canCollectPersonalInfo) {
adColonyAppOptions.setPrivacyConsentString(AdColonyAppOptions.GDPR, "1");
} else {
adColonyAppOptions.setPrivacyConsentString(AdColonyAppOptions.GDPR, "0");
}
}
return adColonyAppOptions;
}
use of com.adcolony.sdk.AdColonyAppOptions in project mopub-android-mediation by mopub.
the class AdColonyAdapterConfiguration method initializeNetwork.
@Override
public void initializeNetwork(@NonNull final Context context, @Nullable final Map<String, String> configuration, @NonNull final OnNetworkInitializationFinishedListener listener) {
Preconditions.checkNotNull(context);
Preconditions.checkNotNull(listener);
boolean networkInitializationSucceeded = false;
synchronized (AdColonyAdapterConfiguration.class) {
try {
if (isAdColonyConfigured()) {
networkInitializationSucceeded = true;
} else if (configuration != null && !configuration.isEmpty()) {
String clientOptions = configuration.get(CLIENT_OPTIONS_KEY);
if (clientOptions == null)
clientOptions = "";
final String appId = getAdColonyParameter(APP_ID_KEY, configuration);
final String[] allZoneIds = Json.jsonArrayToStringArray(getAdColonyParameter(ALL_ZONE_IDS_KEY, configuration));
// Check if mandatory parameters are valid, abort otherwise
if (appId == null) {
logAndFail("initialization", APP_ID_KEY);
} else if (allZoneIds.length == 0) {
logAndFail("initialization", ALL_ZONE_IDS_KEY);
} else {
AdColonyAppOptions adColonyAppOptions = getAdColonyAppOptionsAndSetConsent(clientOptions);
AdColony.configure((Application) context.getApplicationContext(), adColonyAppOptions, appId, allZoneIds);
networkInitializationSucceeded = true;
previousAdColonyAllZoneIds = allZoneIds;
}
}
} catch (Exception e) {
MoPubLog.log(CUSTOM_WITH_THROWABLE, "Initializing AdColony has encountered " + "an exception.", e);
}
}
if (networkInitializationSucceeded) {
listener.onNetworkInitializationFinished(AdColonyAdapterConfiguration.class, MoPubErrorCode.ADAPTER_INITIALIZATION_SUCCESS);
} else {
listener.onNetworkInitializationFinished(AdColonyAdapterConfiguration.class, MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
}
}
use of com.adcolony.sdk.AdColonyAppOptions in project mopub-android-mediation by mopub.
the class AdColonyInterstitial method loadInterstitial.
@Override
protected void loadInterstitial(@NonNull Context context, @NonNull CustomEventInterstitialListener customEventInterstitialListener, @Nullable Map<String, Object> localExtras, @NonNull Map<String, String> serverExtras) {
if (context == null || !(context instanceof Activity) || customEventInterstitialListener == null || serverExtras == null) {
customEventInterstitialListener.onInterstitialFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
return;
}
String clientOptions = DEFAULT_CLIENT_OPTIONS;
String appId = DEFAULT_APP_ID;
String[] allZoneIds = DEFAULT_ALL_ZONE_IDS;
String zoneId = DEFAULT_ZONE_ID;
mCustomEventInterstitialListener = customEventInterstitialListener;
if (extrasAreValid(serverExtras)) {
clientOptions = serverExtras.get(CLIENT_OPTIONS_KEY);
appId = serverExtras.get(APP_ID_KEY);
allZoneIds = extractAllZoneIds(serverExtras);
zoneId = serverExtras.get(ZONE_ID_KEY);
}
AdColonyAppOptions adColonyAppOptions = AdColonyAppOptions.getMoPubAppOptions(clientOptions);
mAdColonyInterstitialListener = getAdColonyInterstitialListener();
if (!isAdColonyConfigured()) {
AdColony.configure((Activity) context, adColonyAppOptions, appId, allZoneIds);
} else if ((shouldReconfigure(previousAdColonyAllZoneIds, allZoneIds))) {
// Need to check the zone IDs sent from the MoPub portal and reconfigure if they are
// different than the zones we initially called AdColony.configure() with
AdColony.configure((Activity) context, adColonyAppOptions, appId, allZoneIds);
previousAdColonyAllZoneIds = allZoneIds;
}
AdColony.requestInterstitial(zoneId, mAdColonyInterstitialListener);
}
use of com.adcolony.sdk.AdColonyAppOptions in project mopub-android-mediation by mopub.
the class AdColonyAdapterConfiguration method checkAndConfigureAdColonyIfNecessary.
protected static void checkAndConfigureAdColonyIfNecessary(Context context, String clientOptions, String appId, String[] allZoneIds) {
if (TextUtils.isEmpty(appId)) {
MoPubLog.log(CUSTOM, null, "AdColony cannot configure without a valid appId parameter. " + "Please ensure you enter a valid appId.");
return;
}
AdColonyAppOptions mAdColonyAppOptions = getAdColonyAppOptionsAndSetConsent(clientOptions);
if (!isAdColonyConfigured()) {
configureAdColony(context, mAdColonyAppOptions, appId, allZoneIds);
previousAdColonyAllZoneIds = allZoneIds;
} else if (shouldAdColonyReconfigure(previousAdColonyAllZoneIds, allZoneIds)) {
configureAdColony(context, mAdColonyAppOptions, appId, allZoneIds);
previousAdColonyAllZoneIds = allZoneIds;
} else {
// If the state of consent has changed and we aren't calling configure again, we need
// to pass this via setAppOptions()
AdColony.setAppOptions(mAdColonyAppOptions);
}
}
Aggregations