Nana Amoah 2023-05-12 12:17:23 -07:00 коммит произвёл GitHub
Родитель dd0bb715be
Коммит 306ce96844
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
7 изменённых файлов: 0 добавлений и 585 удалений

2
Custom Adapters/Tappx/.gitignore поставляемый
Просмотреть файл

@ -1,2 +0,0 @@
/target
/build

Просмотреть файл

@ -1,28 +0,0 @@
# Changelog
## 3.2.3.8
* Add support for [enabling test mode](https://docs.google.com/document/d/12EXo3f0qbUnDqrjBPORZwaxhpGfWn6tkQjX93AvNkNI/edit?usp=sharing) with `setLocalExtraParameter()` API.
## 3.2.3.7
* Update ad display failed error code.
## 3.2.3.6
* Remove `<receiver>` and `<meta-data>` tags from adapter's Android Manifest.
## 3.2.3.5
* Add support for null `Activity` context for interstitials, rewarded videos and regular banner/MRECs.
## 3.2.3.4
* Add "native" as the SDK type.
## 3.2.3.3
* Add custom parameters support for "test" as a key to enable test mode.
## 3.2.3.2
* Add custom parameters support for "is_testing" and "endpoint".
## 3.2.3.1
* Add "applovin" as the mediator.
## 3.2.3.0
* Initial commit.

Просмотреть файл

@ -1 +0,0 @@
# Tappx Adapter

Просмотреть файл

@ -1,63 +0,0 @@
plugins {
id("signing")
id("maven-publish")
}
private val versionMajor = 3
private val versionMinor = 2
private val versionPatch = 3
private val versionAdapterPatch = 8
val libraryVersionName by extra("${versionMajor}.${versionMinor}.${versionPatch}.${versionAdapterPatch}")
val libraryVersionCode by extra((versionMajor * 1000000) + (versionMinor * 10000) + (versionPatch * 100) + versionAdapterPatch)
val libraryArtifactId by extra("tappx-adapter")
val libraryGroupId by extra("com.applovin.mediation")
var libraryVersions = rootProject.extra["versions"] as Map<*, *>
android.defaultConfig.versionCode = libraryVersionCode
android.defaultConfig.versionName = libraryVersionName
dependencies {
implementation("com.tappx.sdk.android:tappx-sdk:${libraryVersions["tappx"]}")
}
publishing {
publications {
create<MavenPublication>(extra["publicationName"] as String) {
//The publication doesn't know about our dependencies, so we have to manually add them to the pom
pom.withXml {
asNode().apply {
appendNode("name", libraryArtifactId)
appendNode("description", "Tappx adapter for AppLovin MAX mediation")
appendNode("url", "https://www.applovin.com/")
appendNode("licenses")
.appendNode("license").apply {
appendNode("name", "AppLovin Corporation Mediation Adapter EULA")
appendNode("url", "https://www.applovin.com/eula")
}
appendNode("scm").apply {
appendNode("connection", "scm:git:github.com/AppLovin/AppLovin-MAX-SDK-Android.git")
appendNode("developerConnection", "scm:git:ssh://github.com/AppLovin/AppLovin-MAX-SDK-Android.git")
appendNode("url", "https://github.com/AppLovin/AppLovin-MAX-SDK-Android")
}
appendNode("developers")
.appendNode("developer").apply {
appendNode("name", "AppLovin")
appendNode("url", "https://www.applovin.com")
}
// Add Tappx to list of dependencies.
appendNode("dependencies")
.appendNode("dependency").apply {
appendNode("groupId", "com.tappx.sdk.android")
appendNode("artifactId", "tappx-sdk")
appendNode("version", libraryVersions["tappx"])
appendNode("type", "aar")
appendNode("scope", "compile")
}
}
}
}
}
}

20
Custom Adapters/Tappx/proguard-rules.pro поставляемый
Просмотреть файл

@ -1,20 +0,0 @@
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/basil/Library/Android/sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
-keep public class com.tappx.sdk.android.** { *; }

Просмотреть файл

@ -1,5 +0,0 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.applovin.mediation.adapters.tappx">
</manifest>

Просмотреть файл

@ -1,466 +0,0 @@
package com.applovin.mediation.adapters;
import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.text.TextUtils;
import com.applovin.mediation.MaxAdFormat;
import com.applovin.mediation.MaxReward;
import com.applovin.mediation.adapter.MaxAdViewAdapter;
import com.applovin.mediation.adapter.MaxAdapterError;
import com.applovin.mediation.adapter.MaxInterstitialAdapter;
import com.applovin.mediation.adapter.MaxRewardedAdapter;
import com.applovin.mediation.adapter.listeners.MaxAdViewAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxInterstitialAdapterListener;
import com.applovin.mediation.adapter.listeners.MaxRewardedAdapterListener;
import com.applovin.mediation.adapter.parameters.MaxAdapterInitializationParameters;
import com.applovin.mediation.adapter.parameters.MaxAdapterParameters;
import com.applovin.mediation.adapter.parameters.MaxAdapterResponseParameters;
import com.applovin.mediation.adapters.tappx.BuildConfig;
import com.applovin.sdk.AppLovinSdk;
import com.tappx.sdk.android.AdRequest;
import com.tappx.sdk.android.Tappx;
import com.tappx.sdk.android.TappxAdError;
import com.tappx.sdk.android.TappxBanner;
import com.tappx.sdk.android.TappxBannerListener;
import com.tappx.sdk.android.TappxInterstitial;
import com.tappx.sdk.android.TappxInterstitialListener;
import com.tappx.sdk.android.TappxRewardedVideo;
import com.tappx.sdk.android.TappxRewardedVideoListener;
import java.util.Map;
import androidx.annotation.Nullable;
import static com.applovin.sdk.AppLovinSdkUtils.runOnUiThread;
/**
* This is a mediation adapter for Tappx
* <p>
* Created by Joe Chen on January 19 2022
*/
public class TappxMediationAdapter
extends MediationAdapterBase
implements MaxInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter
{
private TappxInterstitial interstitialAd;
private TappxRewardedVideo rewardedAd;
private TappxBanner adView;
// Explicit default constructor declaration
public TappxMediationAdapter(final AppLovinSdk sdk) { super( sdk ); }
//region MaxAdapter Methods
@Override
public void initialize(final MaxAdapterInitializationParameters parameters, final Activity activity, final OnCompletionListener onCompletionListener)
{
onCompletionListener.onCompletion( InitializationStatus.DOES_NOT_APPLY, null );
}
@Override
public String getSdkVersion()
{
return Tappx.getVersion();
}
@Override
public String getAdapterVersion()
{
return BuildConfig.VERSION_NAME;
}
@Override
public void onDestroy()
{
if ( interstitialAd != null )
{
interstitialAd.setListener( null );
interstitialAd.destroy();
interstitialAd = null;
}
if ( rewardedAd != null )
{
rewardedAd.setListener( null );
rewardedAd.destroy();
rewardedAd = null;
}
if ( adView != null )
{
adView.setListener( null );
adView.destroy();
adView = null;
}
}
//endregion
//region MaxInterstitialAdapter Methods
@Override
public void loadInterstitialAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxInterstitialAdapterListener listener)
{
runOnUiThread( new Runnable()
{
@Override
public void run()
{
final String appKey = parameters.getThirdPartyAdPlacementId();
log( "Loading interstitial ad: " + appKey + "..." );
interstitialAd = new TappxInterstitial( getContext( activity ), appKey );
interstitialAd.setListener( new InterstitialListener( listener ) );
interstitialAd.loadAd( createAdRequest( parameters ) );
}
} );
}
@Override
public void showInterstitialAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxInterstitialAdapterListener listener)
{
runOnUiThread( new Runnable()
{
@Override
public void run()
{
final String appKey = parameters.getThirdPartyAdPlacementId();
log( "Showing interstitial ad: " + appKey + "..." );
if ( interstitialAd != null && interstitialAd.isReady() )
{
interstitialAd.show();
}
else
{
log( "Interstitial ad not ready" );
listener.onInterstitialAdDisplayFailed( new MaxAdapterError( -4205, "Ad Display Failed" ) );
}
}
} );
}
//endregion
//region MaxRewardedAdapter Methods
@Override
public void loadRewardedAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxRewardedAdapterListener listener)
{
runOnUiThread( new Runnable()
{
@Override
public void run()
{
final String appKey = parameters.getThirdPartyAdPlacementId();
log( "Loading rewarded ad: " + appKey + "..." );
rewardedAd = new TappxRewardedVideo( getContext( activity ), appKey );
rewardedAd.setListener( new RewardedAdListener( listener ) );
rewardedAd.loadAd( createAdRequest( parameters ) );
}
} );
}
@Override
public void showRewardedAd(final MaxAdapterResponseParameters parameters, final Activity activity, final MaxRewardedAdapterListener listener)
{
runOnUiThread( new Runnable()
{
@Override
public void run()
{
final String appKey = parameters.getThirdPartyAdPlacementId();
log( "Showing rewarded ad: " + appKey + "..." );
if ( rewardedAd != null && rewardedAd.isReady() )
{
// Configure userReward from server.
configureReward( parameters );
rewardedAd.show();
}
else
{
log( "Rewarded ad not ready" );
listener.onRewardedAdDisplayFailed( new MaxAdapterError( -4205, "Ad Display Failed" ) );
}
}
} );
}
//endregion
//region MaxAdViewAdapter Methods
@Override
public void loadAdViewAd(final MaxAdapterResponseParameters parameters, final MaxAdFormat adFormat, final Activity activity, final MaxAdViewAdapterListener listener)
{
runOnUiThread( new Runnable()
{
@Override
public void run()
{
final String appKey = parameters.getThirdPartyAdPlacementId();
log( "Loading " + adFormat.getLabel() + " ad: " + appKey + "..." );
adView = new TappxBanner( getContext( activity ), appKey );
adView.setListener( new AdViewListener( listener ) );
adView.setAdSize( toAdSize( adFormat ) );
adView.setEnableAutoRefresh( false );
adView.loadAd( createAdRequest( parameters ) );
}
} );
}
//endregion
private AdRequest createAdRequest(MaxAdapterParameters parameters)
{
AdRequest adRequest = new AdRequest();
adRequest.sdkType( "native" );
adRequest.mediator( "applovin" );
Bundle customParameters = parameters.getCustomParameters();
Map<String, Object> localExtraParameters = parameters.getLocalExtraParameters();
Object isTestingEnabledObj = localExtraParameters.get( "test" );
boolean isTestingEnabledLocalParam = false;
if ( isTestingEnabledObj instanceof Boolean )
{
isTestingEnabledLocalParam = (boolean) isTestingEnabledObj;
}
else if ( isTestingEnabledObj != null )
{
log( "Tappx test mode could not be enabled - Boolean type is required." );
}
boolean isTesting = parameters.isTesting() || customParameters.getBoolean( "is_testing" ) ||
customParameters.getBoolean( "test" ) || isTestingEnabledLocalParam;
adRequest.useTestAds( isTesting );
String endpoint = parameters.getCustomParameters().getString( "endpoint" );
if ( !TextUtils.isEmpty( endpoint ) )
{
adRequest.setEndpoint( endpoint );
}
return adRequest;
}
private static MaxAdapterError toMaxError(final TappxAdError tappxAdError)
{
MaxAdapterError adapterError = MaxAdapterError.UNSPECIFIED;
switch ( tappxAdError )
{
case NO_FILL:
adapterError = MaxAdapterError.NO_FILL;
break;
case SERVER_ERROR:
adapterError = MaxAdapterError.SERVER_ERROR;
break;
case DEVELOPER_ERROR:
adapterError = MaxAdapterError.INVALID_CONFIGURATION;
break;
case INTERNAL_ERROR:
adapterError = MaxAdapterError.INTERNAL_ERROR;
break;
case NETWORK_ERROR:
adapterError = MaxAdapterError.NO_CONNECTION;
break;
}
return new MaxAdapterError( adapterError.getErrorCode(), adapterError.getErrorMessage(), tappxAdError.ordinal(), tappxAdError.name() );
}
private TappxBanner.AdSize toAdSize(final MaxAdFormat adFormat)
{
if ( MaxAdFormat.BANNER == adFormat )
{
return TappxBanner.AdSize.BANNER_320x50;
}
else if ( MaxAdFormat.LEADER == adFormat )
{
return TappxBanner.AdSize.BANNER_728x90;
}
else if ( MaxAdFormat.MREC == adFormat )
{
return TappxBanner.AdSize.BANNER_300x250;
}
else
{
throw new IllegalArgumentException( "Unsupported ad format: " + adFormat );
}
}
private Context getContext(@Nullable Activity activity)
{
// NOTE: `activity` can only be null in 11.1.0+, and `getApplicationContext()` is introduced in 11.1.0
return ( activity != null ) ? activity.getApplicationContext() : getApplicationContext();
}
private class InterstitialListener
implements TappxInterstitialListener
{
private final MaxInterstitialAdapterListener listener;
public InterstitialListener(MaxInterstitialAdapterListener listener)
{
this.listener = listener;
}
@Override
public void onInterstitialLoaded(final TappxInterstitial tappxInterstitial)
{
log( "Interstitial ad loaded" );
listener.onInterstitialAdLoaded();
}
@Override
public void onInterstitialLoadFailed(final TappxInterstitial tappxInterstitial, final TappxAdError tappxAdError)
{
MaxAdapterError adapterError = new MaxAdapterError( -4205, "Ad Display Failed", tappxAdError.ordinal(), tappxAdError.name() );
log( "Interstitial failed to load: " + adapterError );
listener.onInterstitialAdDisplayFailed( adapterError );
}
@Override
public void onInterstitialShown(final TappxInterstitial tappxInterstitial)
{
log( "Interstitial shown" );
listener.onInterstitialAdDisplayed();
}
@Override
public void onInterstitialClicked(final TappxInterstitial tappxInterstitial)
{
log( "Interstitial clicked" );
listener.onInterstitialAdClicked();
}
@Override
public void onInterstitialDismissed(final TappxInterstitial tappxInterstitial)
{
log( "Interstitial dismissed" );
listener.onInterstitialAdHidden();
}
}
private class RewardedAdListener
implements TappxRewardedVideoListener
{
private final MaxRewardedAdapterListener listener;
private boolean hasGrantedReward;
public RewardedAdListener(MaxRewardedAdapterListener listener)
{
this.listener = listener;
}
@Override
public void onRewardedVideoLoaded(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad loaded" );
listener.onRewardedAdLoaded();
}
@Override
public void onRewardedVideoLoadFailed(final TappxRewardedVideo tappxRewardedVideo, final TappxAdError tappxAdError)
{
MaxAdapterError adapterError = toMaxError( tappxAdError );
log( "Rewarded ad failed with error code: " + adapterError );
listener.onRewardedAdLoadFailed( adapterError );
}
@Override
public void onRewardedVideoStart(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad started" );
listener.onRewardedAdDisplayed();
listener.onRewardedAdVideoStarted();
}
@Override
public void onRewardedVideoPlaybackFailed(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad playback failed" );
listener.onRewardedAdDisplayFailed( new MaxAdapterError( -4205, "Ad Display Failed" ) );
}
@Override
public void onRewardedVideoClicked(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad clicked" );
listener.onRewardedAdClicked();
}
@Override
public void onRewardedVideoCompleted(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad completed" );
listener.onRewardedAdVideoCompleted();
hasGrantedReward = true;
}
@Override
public void onRewardedVideoClosed(final TappxRewardedVideo tappxRewardedVideo)
{
log( "Rewarded ad closed" );
if ( hasGrantedReward || shouldAlwaysRewardUser() )
{
final MaxReward reward = getReward();
log( "Rewarded user with reward: " + reward );
listener.onUserRewarded( reward );
}
listener.onRewardedAdHidden();
}
}
private class AdViewListener
implements TappxBannerListener
{
private final MaxAdViewAdapterListener listener;
public AdViewListener(MaxAdViewAdapterListener listener)
{
this.listener = listener;
}
@Override
public void onBannerLoaded(final TappxBanner tappxBanner)
{
log( "AdView loaded" );
listener.onAdViewAdLoaded( adView );
}
@Override
public void onBannerLoadFailed(final TappxBanner tappxBanner, final TappxAdError tappxAdError)
{
MaxAdapterError adapterError = toMaxError( tappxAdError );
log( "AdView failed to load with error: " + adapterError );
listener.onAdViewAdLoadFailed( adapterError );
}
@Override
public void onBannerClicked(final TappxBanner tappxBanner)
{
log( "AdView clicked" );
listener.onAdViewAdClicked();
}
@Override
public void onBannerExpanded(final TappxBanner tappxBanner)
{
log( "AdView expanded" );
listener.onAdViewAdExpanded();
}
@Override
public void onBannerCollapsed(final TappxBanner tappxBanner)
{
log( "AdView collapsed" );
listener.onAdViewAdCollapsed();
}
}
}