diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/admob/AdMobVideoRewardedActivity.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/admob/AdMobVideoRewardedActivity.kt index 73f4c8348..6d9702ec3 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/admob/AdMobVideoRewardedActivity.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/admob/AdMobVideoRewardedActivity.kt @@ -60,7 +60,9 @@ class AdMobVideoRewardedActivity : BaseAdActivity() { override fun onAdLoaded(ad: RewardedAd) { Log.d("AdMobRewarded", "Ad was loaded.") rewardedAd = ad - rewardedAd?.show(this@AdMobVideoRewardedActivity) {} + rewardedAd?.show(this@AdMobVideoRewardedActivity) { + Log.d("AdExample", "User earned reward: ${it.amount} ${it.type}") + } } override fun onAdFailedToLoad(adError: LoadAdError) { diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/applovin/AppLovinMaxVideoRewardedActivity.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/applovin/AppLovinMaxVideoRewardedActivity.kt index 6c7f5d132..97295925f 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/applovin/AppLovinMaxVideoRewardedActivity.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/applovin/AppLovinMaxVideoRewardedActivity.kt @@ -16,6 +16,7 @@ package org.prebid.mobile.prebidkotlindemo.activities.ads.applovin import android.os.Bundle +import android.util.Log import com.applovin.mediation.MaxAd import com.applovin.mediation.MaxError import com.applovin.mediation.MaxReward @@ -56,7 +57,9 @@ class AppLovinMaxVideoRewardedActivity : BaseAdActivity() { override fun onAdDisplayFailed(ad: MaxAd?, error: MaxError?) {} override fun onRewardedVideoStarted(ad: MaxAd?) {} override fun onRewardedVideoCompleted(ad: MaxAd?) {} - override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) {} + override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) { + Log.d("AdExample", "User earned reward: $reward") + } }) val mediationUtils = MaxMediationRewardedUtils(maxRewardedAd) diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/gam/rendering/GamRenderingApiVideoRewardedActivity.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/gam/rendering/GamRenderingApiVideoRewardedActivity.kt index 7e69f8ff7..bb50a2481 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/gam/rendering/GamRenderingApiVideoRewardedActivity.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/gam/rendering/GamRenderingApiVideoRewardedActivity.kt @@ -16,11 +16,13 @@ package org.prebid.mobile.prebidkotlindemo.activities.ads.gam.rendering import android.os.Bundle +import android.util.Log import org.prebid.mobile.api.exceptions.AdException import org.prebid.mobile.api.rendering.RewardedAdUnit import org.prebid.mobile.api.rendering.listeners.RewardedAdUnitListener import org.prebid.mobile.eventhandlers.GamRewardedEventHandler import org.prebid.mobile.prebidkotlindemo.activities.BaseAdActivity +import org.prebid.mobile.rendering.interstitial.rewarded.Reward class GamRenderingApiVideoRewardedActivity : BaseAdActivity() { @@ -32,7 +34,7 @@ class GamRenderingApiVideoRewardedActivity : BaseAdActivity() { private var adUnit: RewardedAdUnit? = null - override fun onCreate(savedInstanceState: Bundle?) { + override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) createAd() @@ -50,7 +52,9 @@ class GamRenderingApiVideoRewardedActivity : BaseAdActivity() { override fun onAdFailed(rewardedAdUnit: RewardedAdUnit?, exception: AdException?) {} override fun onAdClicked(rewardedAdUnit: RewardedAdUnit?) {} override fun onAdClosed(rewardedAdUnit: RewardedAdUnit?) {} - override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?) {} + override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) { + Log.d("AdExample", "User earned reward: $reward") + } }) adUnit?.loadAd() } diff --git a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/inapp/InAppVideoRewardedActivity.kt b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/inapp/InAppVideoRewardedActivity.kt index c0c53dfbb..1d3e565f4 100644 --- a/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/inapp/InAppVideoRewardedActivity.kt +++ b/Example/PrebidDemoKotlin/src/main/java/org/prebid/mobile/prebidkotlindemo/activities/ads/inapp/InAppVideoRewardedActivity.kt @@ -16,10 +16,12 @@ package org.prebid.mobile.prebidkotlindemo.activities.ads.inapp import android.os.Bundle +import android.util.Log import org.prebid.mobile.api.exceptions.AdException import org.prebid.mobile.api.rendering.RewardedAdUnit import org.prebid.mobile.api.rendering.listeners.RewardedAdUnitListener import org.prebid.mobile.prebidkotlindemo.activities.BaseAdActivity +import org.prebid.mobile.rendering.interstitial.rewarded.Reward class InAppVideoRewardedActivity : BaseAdActivity() { @@ -47,7 +49,9 @@ class InAppVideoRewardedActivity : BaseAdActivity() { override fun onAdFailed(rewardedAdUnit: RewardedAdUnit?, exception: AdException?) {} override fun onAdClicked(rewardedAdUnit: RewardedAdUnit?) {} override fun onAdClosed(rewardedAdUnit: RewardedAdUnit?) {} - override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?) {} + override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) { + Log.d("InAppVideoRewarded", "User earned reward: $reward") + } }) adUnit?.loadAd() } diff --git a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/InternalTestApplication.kt b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/InternalTestApplication.kt index 909a52576..6ae722c31 100644 --- a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/InternalTestApplication.kt +++ b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/InternalTestApplication.kt @@ -86,7 +86,7 @@ class InternalTestApplication : MultiDexApplication() { } fun clearAdConfigSettings() { - PreferenceManager.getDefaultSharedPreferences(this).edit().clear().apply() + PreferenceManager.getDefaultSharedPreferences(this).edit().remove(getString(R.string.key_keep_settings)).apply() } private fun checkKeepConsentSettingsFlag() { diff --git a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/admob/AdMobRewardedFragment.kt b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/admob/AdMobRewardedFragment.kt index 4345e9f2b..b72ac1706 100644 --- a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/admob/AdMobRewardedFragment.kt +++ b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/admob/AdMobRewardedFragment.kt @@ -3,8 +3,6 @@ package org.prebid.mobile.renderingtestapp.plugplay.bidding.admob import android.os.Bundle import android.util.Log import android.view.View -import android.widget.Button -import android.widget.TextView import com.google.android.gms.ads.AdError import com.google.android.gms.ads.AdRequest import com.google.android.gms.ads.FullScreenContentCallback @@ -19,7 +17,6 @@ import org.prebid.mobile.renderingtestapp.R import org.prebid.mobile.renderingtestapp.databinding.FragmentAdmobRewardedBinding import org.prebid.mobile.renderingtestapp.plugplay.config.AdConfiguratorDialogFragment import org.prebid.mobile.renderingtestapp.utils.BaseEvents -import org.prebid.mobile.renderingtestapp.widgets.EventCounterView open class AdMobRewardedFragment : AdFragment() { @@ -76,6 +73,9 @@ open class AdMobRewardedFragment : AdFragment() { rewardedAd = ad rewardedAd?.fullScreenContentCallback = createFullScreenContentCallback() + rewardedAd?.setOnPaidEventListener { + Log.d(TAG, "User earned reward: $it") + } } override fun onAdFailedToLoad(adError: LoadAdError) { @@ -115,6 +115,7 @@ open class AdMobRewardedFragment : AdFragment() { val rewardAmount = rewardItem.amount val rewardType = rewardItem.type Log.d(TAG, "User earned the reward ($rewardAmount, $rewardType)") + events.rewarded(true) } binding.btnLoad.text = getString(R.string.text_retry) } else if (binding.btnLoad.text == getString(R.string.text_retry)) { @@ -155,6 +156,7 @@ open class AdMobRewardedFragment : AdFragment() { fun impression(b: Boolean) = enable(R.id.btnAdImpression, b) fun clicked(b: Boolean) = enable(R.id.btnAdClicked, b) fun failed(b: Boolean) = enable(R.id.btnAdFailed, b) + fun rewarded(b: Boolean) = enable(R.id.btnUserRewarded, b) fun showed(b: Boolean) = enable(R.id.btnAdShowed, b) fun dismissed(b: Boolean) = enable(R.id.btnAdDismissed, b) diff --git a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/base/BaseBidRewardedFragment.kt b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/base/BaseBidRewardedFragment.kt index 16f00a75b..ed174724f 100644 --- a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/base/BaseBidRewardedFragment.kt +++ b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/base/BaseBidRewardedFragment.kt @@ -19,25 +19,24 @@ package org.prebid.mobile.renderingtestapp.plugplay.bidding.base import android.os.Bundle import android.util.Log import android.view.View -import android.widget.Button import org.prebid.mobile.api.exceptions.AdException import org.prebid.mobile.api.rendering.RewardedAdUnit import org.prebid.mobile.api.rendering.listeners.RewardedAdUnitListener +import org.prebid.mobile.rendering.interstitial.rewarded.Reward import org.prebid.mobile.renderingtestapp.AdFragment import org.prebid.mobile.renderingtestapp.R -import org.prebid.mobile.renderingtestapp.databinding.FragmentBiddingInterstitialBinding +import org.prebid.mobile.renderingtestapp.databinding.FragmentBiddingRewardedBinding import org.prebid.mobile.renderingtestapp.plugplay.config.AdConfiguratorDialogFragment import org.prebid.mobile.renderingtestapp.utils.BaseEvents -import org.prebid.mobile.renderingtestapp.widgets.EventCounterView abstract class BaseBidRewardedFragment : AdFragment() { private val TAG = BaseBidRewardedFragment::class.java.simpleName - override val layoutRes = R.layout.fragment_bidding_interstitial + override val layoutRes = R.layout.fragment_bidding_rewarded protected var rewardedAdUnit: RewardedAdUnit? = null - protected val binding: FragmentBiddingInterstitialBinding + protected val binding: FragmentBiddingRewardedBinding get() = getBinding() protected lateinit var events: Events @@ -84,11 +83,10 @@ abstract class BaseBidRewardedFragment : AdFragment() { } } - protected fun createRewardedAdUnitListener() = object : - RewardedAdUnitListener { + protected fun createRewardedAdUnitListener() = object : RewardedAdUnitListener { override fun onAdLoaded(rewardedAdUnit: RewardedAdUnit?) { - Log.d(TAG, "onAdLoaded() called with: reward = [${rewardedAdUnit?.userReward}]") + Log.d(TAG, "onAdLoaded() called") events.loaded(true) binding.btnLoad.setText(R.string.text_show) binding.btnLoad.isEnabled = true @@ -115,8 +113,9 @@ abstract class BaseBidRewardedFragment : AdFragment() { events.closed(true) } - override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?) { - Log.d(TAG, "onUserEarnedReward() called with: reward = [${rewardedAdUnit?.userReward}]") + override fun onUserEarnedReward(rewardedAdUnit: RewardedAdUnit?, reward: Reward?) { + Log.d(TAG, "User earned reward: $reward") + events.reward(true) } } @@ -128,6 +127,7 @@ abstract class BaseBidRewardedFragment : AdFragment() { fun clicked(b: Boolean) = enable(R.id.btnAdClicked, b) fun closed(b: Boolean) = enable(R.id.btnAdClosed, b) fun failed(b: Boolean) = enable(R.id.btnAdFailed, b) + fun reward(b: Boolean) = enable(R.id.btnReward, b) fun displayed(b: Boolean) = enable(R.id.btnAdDisplayed, b) diff --git a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/max/MaxRewardedFragment.kt b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/max/MaxRewardedFragment.kt index 0aa2fc6b6..08cc638c5 100644 --- a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/max/MaxRewardedFragment.kt +++ b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/plugplay/bidding/max/MaxRewardedFragment.kt @@ -3,8 +3,6 @@ package org.prebid.mobile.renderingtestapp.plugplay.bidding.max import android.os.Bundle import android.util.Log import android.view.View -import android.widget.Button -import android.widget.TextView import com.applovin.mediation.MaxAd import com.applovin.mediation.MaxError import com.applovin.mediation.MaxReward @@ -17,7 +15,6 @@ import org.prebid.mobile.renderingtestapp.R import org.prebid.mobile.renderingtestapp.databinding.FragmentBiddingRewardedApplovinMaxBinding import org.prebid.mobile.renderingtestapp.plugplay.config.AdConfiguratorDialogFragment import org.prebid.mobile.renderingtestapp.utils.BaseEvents -import org.prebid.mobile.renderingtestapp.widgets.EventCounterView open class MaxRewardedFragment : AdFragment() { @@ -139,6 +136,7 @@ open class MaxRewardedFragment : AdFragment() { } override fun onUserRewarded(ad: MaxAd?, reward: MaxReward?) { + Log.d(TAG, "User earned reward: ${reward?.label} ${reward?.amount}") events.userRewarded(true) } } diff --git a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/utils/DemoItemProvider.kt b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/utils/DemoItemProvider.kt index 5afe44381..1c7f7756b 100644 --- a/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/utils/DemoItemProvider.kt +++ b/Example/PrebidInternalTestApp/src/main/java/org/prebid/mobile/renderingtestapp/utils/DemoItemProvider.kt @@ -1129,6 +1129,125 @@ class DemoItemProvider private constructor() { ) ) + // Rewarded + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_display_rewarded_time), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_display_rewarded_time, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_display_rewarded_event), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_display_rewarded_event, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_display_rewarded_default), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_display_rewarded_default, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_time), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_time, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_event), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_event, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_default), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_default, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_endcard_time), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_endcard_time, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_endcard_event), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_endcard_event, + null, + 320, + 480 + ) + ) + ) + demoList.add( + DemoItem( + getString(R.string.demo_bidding_in_app_video_rewarded_endcard_default), + ppmRewardedAction, + ppmVideoTagList, + createBannerBundle( + R.string.imp_prebid_id_video_rewarded_endcard_default, + null, + 320, + 480 + ) + ) + ) + // Native demoList.add( DemoItem( diff --git a/Example/PrebidInternalTestApp/src/main/res/layout/events_admob_rewarded.xml b/Example/PrebidInternalTestApp/src/main/res/layout/events_admob_rewarded.xml index 27a7f18aa..4248b8e5b 100644 --- a/Example/PrebidInternalTestApp/src/main/res/layout/events_admob_rewarded.xml +++ b/Example/PrebidInternalTestApp/src/main/res/layout/events_admob_rewarded.xml @@ -69,4 +69,11 @@ android:text="@string/event_admob_failed" android:layout_marginTop="@dimen/event_top_margin"/> + + \ No newline at end of file diff --git a/Example/PrebidInternalTestApp/src/main/res/layout/events_rewarded.xml b/Example/PrebidInternalTestApp/src/main/res/layout/events_rewarded.xml new file mode 100644 index 000000000..1740524b9 --- /dev/null +++ b/Example/PrebidInternalTestApp/src/main/res/layout/events_rewarded.xml @@ -0,0 +1,85 @@ + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Example/PrebidInternalTestApp/src/main/res/layout/fragment_bidding_rewarded.xml b/Example/PrebidInternalTestApp/src/main/res/layout/fragment_bidding_rewarded.xml new file mode 100644 index 000000000..2328738ed --- /dev/null +++ b/Example/PrebidInternalTestApp/src/main/res/layout/fragment_bidding_rewarded.xml @@ -0,0 +1,60 @@ + + + + + + +