diff --git a/Examples/IronsourceInterstitialAdapterExample/app/build.gradle b/Examples/IronsourceInterstitialAdapterExample/app/build.gradle index 31671e06..5d73c497 100644 --- a/Examples/IronsourceInterstitialAdapterExample/app/build.gradle +++ b/Examples/IronsourceInterstitialAdapterExample/app/build.gradle @@ -39,8 +39,8 @@ dependencies { implementation 'androidx.multidex:multidex:2.0.1' implementation 'androidx.appcompat:appcompat:1.2.0' - implementation 'com.yandex.android:mobmetricalib:4.0.0' + implementation 'com.yandex.android:mobmetricalib:4.1.1' implementation 'com.yandex.android:mobileads:4.5.0' - implementation 'com.yandex.ads.adapter:ironsource-mobileads:4.5.0.0' - implementation 'com.ironsource.sdk:mediationsdk:7.1.10' + implementation 'com.yandex.ads.adapter:ironsource-mobileads:4.5.0.2' + implementation 'com.ironsource.sdk:mediationsdk:7.1.14' } diff --git a/Examples/IronsourceRewardedAdapterExample/.gitignore b/Examples/IronsourceRewardedAdapterExample/.gitignore new file mode 100644 index 00000000..2d9be3a5 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/.gitignore @@ -0,0 +1,35 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/** +gen/** +out/** +gen-external-apklibs/** + +# Local configuration file (sdk path, etc) +local.properties + +# IntellijJ IDEA +*.iml +*.ipr +*.iws +.idea/** +classes/** +target/** + +# Mac OS +.DS_Store + +# Gradle +gradle-app.setting +.gradletasknamecache +.gradle/** +build/** \ No newline at end of file diff --git a/Examples/IronsourceRewardedAdapterExample/app/.gitignore b/Examples/IronsourceRewardedAdapterExample/app/.gitignore new file mode 100644 index 00000000..2d9be3a5 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/.gitignore @@ -0,0 +1,35 @@ +# built application files +*.apk +*.ap_ + +# files for the dex VM +*.dex + +# Java class files +*.class + +# generated files +bin/** +gen/** +out/** +gen-external-apklibs/** + +# Local configuration file (sdk path, etc) +local.properties + +# IntellijJ IDEA +*.iml +*.ipr +*.iws +.idea/** +classes/** +target/** + +# Mac OS +.DS_Store + +# Gradle +gradle-app.setting +.gradletasknamecache +.gradle/** +build/** \ No newline at end of file diff --git a/Examples/IronsourceRewardedAdapterExample/app/build.gradle b/Examples/IronsourceRewardedAdapterExample/app/build.gradle new file mode 100644 index 00000000..5d73c497 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/build.gradle @@ -0,0 +1,46 @@ +/* + * This file is a part of the Yandex Advertising Network + * + * Version for Android (C) 2021 YANDEX + * + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ + */ + +apply plugin: 'com.android.application' + +android { + compileSdkVersion 30 + buildToolsVersion '30.0.2' + + defaultConfig { + applicationId "com.yandex.ironsourceadapter.interstitial.sample" + minSdkVersion 19 + targetSdkVersion 30 + versionCode 1 + versionName "1.0" + multiDexEnabled true + } + + compileOptions { + sourceCompatibility JavaVersion.VERSION_1_8 + targetCompatibility JavaVersion.VERSION_1_8 + } + + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' + } + } +} + +dependencies { + implementation 'androidx.multidex:multidex:2.0.1' + implementation 'androidx.appcompat:appcompat:1.2.0' + + implementation 'com.yandex.android:mobmetricalib:4.1.1' + implementation 'com.yandex.android:mobileads:4.5.0' + implementation 'com.yandex.ads.adapter:ironsource-mobileads:4.5.0.2' + implementation 'com.ironsource.sdk:mediationsdk:7.1.14' +} diff --git a/Examples/IronsourceRewardedAdapterExample/app/proguard-rules.pro b/Examples/IronsourceRewardedAdapterExample/app/proguard-rules.pro new file mode 100644 index 00000000..cbc1b539 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/proguard-rules.pro @@ -0,0 +1,17 @@ +# Add project specific ProGuard rules here. +# By default, the flags in this file are appended to flags specified +# in /Users/satsakul/ADT/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 *; +#} diff --git a/Examples/IronsourceRewardedAdapterExample/app/src/main/AndroidManifest.xml b/Examples/IronsourceRewardedAdapterExample/app/src/main/AndroidManifest.xml new file mode 100644 index 00000000..5cb7e72a --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/src/main/AndroidManifest.xml @@ -0,0 +1,36 @@ + + + + + + + + + + + + + + + + + + + + diff --git a/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/Application.java b/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/Application.java new file mode 100644 index 00000000..866db684 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/Application.java @@ -0,0 +1,33 @@ +/* + * This file is a part of the Yandex Advertising Network + * + * Version for Android (C) 2021 YANDEX + * + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ + */ +package com.yandex.ironsourceadapter.rewarded.sample; + +import android.util.Log; + +import androidx.multidex.MultiDexApplication; + +import com.yandex.mobile.ads.common.InitializationListener; +import com.yandex.mobile.ads.common.MobileAds; + +public class Application extends MultiDexApplication { + + private static final String YANDEX_MOBILE_ADS_TAG = "YandexMobileAds"; + + @Override + public void onCreate() { + super.onCreate(); + + MobileAds.initialize(this, new InitializationListener() { + @Override + public void onInitializationCompleted() { + Log.d(YANDEX_MOBILE_ADS_TAG, "SDK initialized"); + } + }); + } +} diff --git a/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/MainActivity.java b/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/MainActivity.java new file mode 100644 index 00000000..7c2d751e --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/src/main/java/com/yandex/ironsourceadapter/rewarded/sample/MainActivity.java @@ -0,0 +1,142 @@ +/* + * This file is a part of the Yandex Advertising Network + * + * Version for Android (C) 2021 YANDEX + * + * You may not use this file except in compliance with the License. + * You may obtain a copy of the License at https://legal.yandex.com/partner_ch/ + */ +package com.yandex.ironsourceadapter.rewarded.sample; + +import android.os.Bundle; +import android.util.Log; +import android.view.View; +import android.widget.Button; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; + +import com.ironsource.mediationsdk.IronSource; +import com.ironsource.mediationsdk.integration.IntegrationHelper; +import com.ironsource.mediationsdk.logger.IronSourceError; +import com.ironsource.mediationsdk.model.Placement; +import com.ironsource.mediationsdk.sdk.RewardedVideoListener; + +public class MainActivity extends AppCompatActivity { + + private static final String APP_KEY = "85460dcd"; + private static final String TAG = "MainActivity"; + + private Button mLoadRewardedAdButton; + private Button mShowRewardedAdButton; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_main); + + mLoadRewardedAdButton = findViewById(R.id.load_rewarded_button); + mLoadRewardedAdButton.setOnClickListener(mLoadRewardedClickListener); + + mShowRewardedAdButton = findViewById(R.id.show_rewarded_button); + mShowRewardedAdButton.setOnClickListener(mShowRewardedClickListener); + mShowRewardedAdButton.setEnabled(false); + + IntegrationHelper.validateIntegration(this); + + IronSource.init(this, APP_KEY, IronSource.AD_UNIT.INTERSTITIAL); + } + + @Override + protected void onResume() { + super.onResume(); + IronSource.onResume(this); + } + + @Override + protected void onPause() { + super.onPause(); + IronSource.onPause(this); + } + + @Override + protected void onDestroy() { + IronSource.setInterstitialListener(null); + super.onDestroy(); + } + + private final View.OnClickListener mLoadRewardedClickListener = new View.OnClickListener() { + @Override + public void onClick(@NonNull final View v) { + mLoadRewardedAdButton.setEnabled(false); + mLoadRewardedAdButton.setText(getResources().getText(R.string.start_load_rewarded_button)); + + IronSource.setRewardedVideoListener(new IronSourceRewardedListener()); + IronSource.loadRewardedVideo(); + } + }; + + private final View.OnClickListener mShowRewardedClickListener = new View.OnClickListener() { + @Override + public void onClick(@NonNull final View v) { + if (IronSource.isInterstitialReady()) { + IronSource.showInterstitial(); + } + + mShowRewardedAdButton.setEnabled(false); + } + }; + + private class IronSourceRewardedListener implements RewardedVideoListener { + + @Override + public void onRewardedVideoAdOpened() { + mShowRewardedAdButton.post(() -> { + mShowRewardedAdButton.setEnabled(true); + mLoadRewardedAdButton.setEnabled(true); + mLoadRewardedAdButton.setText(getResources().getText(R.string.load_rewarded_button)); + }); + } + + @Override + public void onRewardedVideoAdClosed() { + Log.d(TAG, "onRewardedVideoAdClosed()"); + } + + @Override + public void onRewardedVideoAvailabilityChanged(boolean b) { + Log.d(TAG, "onRewardedVideoAvailabilityChanged()"); + } + + @Override + public void onRewardedVideoAdStarted() { + Log.d(TAG, "onRewardedVideoAdStarted()"); + } + + @Override + public void onRewardedVideoAdEnded() { + Log.d(TAG, "onRewardedVideoAdEnded()"); + } + + @Override + public void onRewardedVideoAdRewarded(Placement placement) { + Log.d(TAG, "onRewardedVideoAdRewarded()"); + } + + @Override + public void onRewardedVideoAdShowFailed(IronSourceError ironSourceError) { + final String errorMessage = String.format("onRewardedVideoAdShowFailed() code = %s, message = %s", + ironSourceError.getErrorCode(), ironSourceError.getErrorMessage()); + Log.d(TAG, errorMessage); + mLoadRewardedAdButton.post(() -> { + mLoadRewardedAdButton.setEnabled(true); + mLoadRewardedAdButton.setText(getResources().getText(R.string.load_rewarded_button)); + }); + } + + @Override + public void onRewardedVideoAdClicked(Placement placement) { + Log.d(TAG, "onRewardedVideoAdClicked()"); + } + } +} diff --git a/Examples/IronsourceRewardedAdapterExample/app/src/main/res/layout/activity_main.xml b/Examples/IronsourceRewardedAdapterExample/app/src/main/res/layout/activity_main.xml new file mode 100644 index 00000000..f1bbaf15 --- /dev/null +++ b/Examples/IronsourceRewardedAdapterExample/app/src/main/res/layout/activity_main.xml @@ -0,0 +1,34 @@ + + + + +