Skip to content

Commit

Permalink
Migration: Prebid Demo Kotlin to pbs on aws (#412)
Browse files Browse the repository at this point in the history
* removed mopub dependencies from internal test app

* removed mopub dependencies from prebid demo kotlin

* removed mopub dependencies from internal test app android tests

* removed mopub declarations in manifest in demo apps

* removed mopub dependencies in prebid demo java

* removed mopub dependencies from prebid demo java tests

* removed al mopub references from demo apps and Dr.Prebid

* removed mopub dependencies from prebid mobile core

* removed mopub dependencies from prebid mobile core tests

* removed prebid mobile mopub adapters

* removed mopub adapters from scripts

* configured banner 320x50 in-app prebid demo kotlin

* configured in-app cases

* removed mopub cases

* configured gam cases

* configured admob cases

* added gam video interstitial example

* applied appropriate gam video interstitial

* added video base parameters for gam video interstitial ad unit

* configured ad unit for prebid banner 300x250

* removed setStoredAuctionResponse(null) function from ads creators
  • Loading branch information
MaksPetrukhnoPI authored Apr 15, 2022
1 parent 98bdf52 commit 7962804
Show file tree
Hide file tree
Showing 23 changed files with 288 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import android.app.Application;
import android.content.Intent;
import android.os.Bundle;

import org.prebid.mobile.PrebidMobile;

import static android.view.WindowManager.LayoutParams.*;
Expand All @@ -28,6 +29,7 @@ public class CustomApplication extends Application {
@Override
public void onCreate() {
super.onCreate();

//set Prebid Mobile global Settings
//region PrebidMobile API

Expand Down
3 changes: 2 additions & 1 deletion Example/PrebidDemoKotlin/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<activity android:name=".DemoActivity"/>



</application>

</manifest>
</manifest>
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import org.prebid.mobile.Host
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.prebidkotlindemo.ads.GamBanner
import org.prebid.mobile.prebidkotlindemo.ads.GamInterstitial
import org.prebid.mobile.prebidkotlindemo.ads.GamVideoInterstitial

import org.prebid.mobile.prebidkotlindemo.ads.inapp.*
import org.prebid.mobile.prebidkotlindemo.ads.inappadmob.InAppAdMobBanner
import org.prebid.mobile.prebidkotlindemo.ads.inappadmob.InAppAdMobInterstitial
Expand All @@ -21,53 +23,67 @@ object AdTypesRepository {
AdType(
"Banner 320x50",
onCreate = { _, wrapper, autoRefreshTime ->
useTestServer()
PrebidMobile.setStoredAuctionResponse("response-prebid-banner-320-50")
GamBanner.create(
wrapper, autoRefreshTime,
320, 50,
// TODO: Problem with ids
"/5300653/pavliuchyk_test_adunit_1x1_puc",
"imp-prebid-banner-320-50"
"/21808260008/prebid_demo_app_original_api_banner",
"imp-prebid-banner-320-50",
"response-prebid-banner-320-50"
)
},
onDestroy = { GamBanner.destroy() }
),
AdType(
"Banner 300x250",
onCreate = { _, wrapper, autoRefreshTime ->
useAppNexusServer()
GamBanner.create(
wrapper, autoRefreshTime,
300, 250,
"/5300653/pavliuchyk_test_adunit_1x1_puc",
"6ace8c7d-88c0-4623-8117-75bc3f0a2e45"
"/21808260008/prebid_demo_app_original_api_banner_300x250_order",
"imp-prebid-banner-300-250",
"response-prebid-banner-300-250"
)
},
onDestroy = { GamBanner.destroy() }
),
AdType(
"Interstitial",
"Display Interstitial",
onCreate = { activity, _, autoRefreshTime ->
useAppNexusServer()
GamInterstitial.create(
activity, autoRefreshTime,
// TODO: Problem with ids
"/5300653/pavliuchyk_test_adunit_1x1_puc",
"625c6125-f19e-4d5b-95c5-55501526b2a4"
"/21808260008/prebid-demo-app-original-api-display-interstitial",
"imp-prebid-display-interstitial-320-480",
"response-prebid-display-interstitial-320-480"
)
},
onDestroy = { GamInterstitial.destroy() }
),
AdType(
"Video Interstitial",
onCreate = { activity, _, _ ->
GamVideoInterstitial.create(
activity,
"/21808260008/prebid-demo-app-original-api-video-interstitial",
"imp-prebid-video-interstitial-320-480",
"response-prebid-video-interstitial-320-480"
)
},
onDestroy = { GamInterstitial.destroy() }
)
),


"In-App" to listOf(
AdType(
"Banner 320x50",
onCreate = { _, wrapper, autoRefreshTime ->
InAppBanner.create(
wrapper, autoRefreshTime / 1000,
320, 50,
"50699c03-0910-477c-b4a4-911dbe2b9d42"
"imp-prebid-banner-320-50",
"response-prebid-banner-320-50"
)
},
onDestroy = { InAppBanner.destroy() }
Expand All @@ -78,7 +94,8 @@ object AdTypesRepository {
InAppInterstitial.create(
context,
30, 30,
"5a4b8dcf-f984-4b04-9448-6529908d6cb6"
"imp-prebid-display-interstitial-320-480",
"response-prebid-display-interstitial-320-480"
)
},
onDestroy = { InAppInterstitial.destroy() }
Expand All @@ -89,7 +106,8 @@ object AdTypesRepository {
InAppVideoBanner.create(
wrapper, autoRefreshTime / 1000,
300, 250,
"9007b76d-c73c-49c6-b0a8-1c7890a84b33"
"imp-prebid-video-outstream",
"response-prebid-video-outstream"
)
},
onDestroy = { InAppVideoBanner.destroy() }
Expand All @@ -99,7 +117,8 @@ object AdTypesRepository {
onCreate = { context, _, _ ->
InAppVideoInterstitial.create(
context,
"12f58bc2-b664-4672-8d19-638bcc96fd5c"
"imp-prebid-video-interstitial-320-480",
"response-prebid-video-interstitial-320-480"
)
},
onDestroy = { InAppVideoInterstitial.destroy() }
Expand All @@ -109,7 +128,8 @@ object AdTypesRepository {
onCreate = { context, _, _ ->
InAppRewardedInterstitial.create(
context,
"12f58bc2-b664-4672-8d19-638bcc96fd5c"
"imp-prebid-video-rewarded-320-480",
"response-prebid-video-rewarded-320-480"
)
},
onDestroy = { InAppRewardedInterstitial.destroy() }
Expand All @@ -124,7 +144,8 @@ object AdTypesRepository {
wrapper, autoRefreshTime / 1000,
320, 50,
"/21808260008/prebid_oxb_320x50_banner",
"50699c03-0910-477c-b4a4-911dbe2b9d42"
"imp-prebid-banner-320-50",
"response-prebid-banner-320-50"
)
},
onDestroy = { InAppGamBanner.destroy() }
Expand All @@ -136,7 +157,8 @@ object AdTypesRepository {
context,
30, 30,
"/21808260008/prebid_oxb_html_interstitial",
"5a4b8dcf-f984-4b04-9448-6529908d6cb6"
"imp-prebid-display-interstitial-320-480",
"response-prebid-display-interstitial-320-480"
)
},
onDestroy = { InAppGamInterstitial.destroy() }
Expand All @@ -148,7 +170,8 @@ object AdTypesRepository {
wrapper, autoRefreshTime / 1000,
300, 250,
"/21808260008/prebid_oxb_300x250_banner",
"9007b76d-c73c-49c6-b0a8-1c7890a84b33"
"imp-prebid-video-outstream",
"response-prebid-video-outstream"
)
},
onDestroy = { InAppGamVideoBanner.destroy() }
Expand All @@ -158,8 +181,9 @@ object AdTypesRepository {
onCreate = { activity, _, _ ->
InAppGamVideoInterstitial.create(
activity,
"/21808260008/prebid_oxb_320x480_interstitial_video_static",
"28259226-68de-49f8-88d6-f0f2fab846e3"
"/21808260008/prebid-demo-app-original-api-video-interstitial",
"imp-prebid-video-interstitial-320-480",
"response-prebid-video-interstitial-320-480"
)
},
onDestroy = { InAppGamVideoInterstitial.destroy() }
Expand All @@ -170,7 +194,8 @@ object AdTypesRepository {
InAppGamRewardedInterstitial.create(
activity,
"/21808260008/prebid_oxb_rewarded_video_test",
"12f58bc2-b664-4672-8d19-638bcc96fd5c"
"imp-prebid-video-rewarded-320-480",
"response-prebid-video-rewarded-320-480"
)
},
onDestroy = { InAppGamRewardedInterstitial.destroy() }
Expand All @@ -185,7 +210,8 @@ object AdTypesRepository {
activity, wrapper, autoRefreshTime,
320, 50,
"ca-app-pub-1875909575462531/3793078260",
"50699c03-0910-477c-b4a4-911dbe2b9d42"
"imp-prebid-banner-320-50",
"response-prebid-banner-320-50"
)
},
onDestroy = { InAppAdMobBanner.destroy() }
Expand All @@ -196,8 +222,9 @@ object AdTypesRepository {
InAppAdMobInterstitial.create(
activity,
"ca-app-pub-1875909575462531/6393291067",
"5a4b8dcf-f984-4b04-9448-6529908d6cb6",
EnumSet.of(AdUnitFormat.DISPLAY)
"imp-prebid-display-interstitial-320-480",
EnumSet.of(AdUnitFormat.DISPLAY),
"response-prebid-display-interstitial-320-480"
)
},
onDestroy = { InAppAdMobInterstitial.destroy() }
Expand All @@ -208,8 +235,9 @@ object AdTypesRepository {
InAppAdMobInterstitial.create(
activity,
"ca-app-pub-1875909575462531/6393291067",
"12f58bc2-b664-4672-8d19-638bcc96fd5c",
EnumSet.of(AdUnitFormat.VIDEO)
"imp-prebid-video-interstitial-320-480",
EnumSet.of(AdUnitFormat.VIDEO),"" +
"response-prebid-video-interstitial-320-480"
)
},
onDestroy = { InAppAdMobInterstitial.destroy() }
Expand All @@ -220,7 +248,8 @@ object AdTypesRepository {
InAppAdMobRewarded.create(
activity,
"ca-app-pub-1875909575462531/1908212572",
"9007b76d-c73c-49c6-b0a8-1c7890a84b33"
"imp-prebid-video-rewarded-320-480",
"response-prebid-video-rewarded-320-480"
)
},
onDestroy = { InAppAdMobRewarded.destroy() }
Expand All @@ -232,7 +261,8 @@ object AdTypesRepository {
InAppAdMobNative.create(
wrapper,
"ca-app-pub-1875909575462531/9720985924",
"51fe68ba-aff2-401e-9e15-f3ed89d5c036"
"imp-prebid-banner-native-styles",
"response-prebid-banner-native-styles"
)
},
onDestroy = {
Expand All @@ -242,19 +272,10 @@ object AdTypesRepository {
)
)

fun useOpenXServer() {
PrebidMobile.setPrebidServerAccountId("0689a263-318d-448b-a3d4-b02e8a709d9d")
PrebidMobile.setPrebidServerHost(Host.createCustomHost("https://prebid.openx.net/openrtb2/auction"))
}

private fun useTestServer() {
fun usePrebidServer() {
PrebidMobile.setPrebidServerAccountId("0689a263-318d-448b-a3d4-b02e8a709d9d")
PrebidMobile.setPrebidServerHost(Host.createCustomHost("https://prebid-server-test-j.prebid.org/openrtb2/auction"))
}

private fun useAppNexusServer() {
PrebidMobile.setPrebidServerAccountId("bfa84af2-bd16-4d35-96ad-31c6bb888df0")
PrebidMobile.setPrebidServerHost(Host.APPNEXUS)
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity
import androidx.databinding.DataBindingUtil
import androidx.preference.PreferenceManager
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.prebidkotlindemo.databinding.ActivityDemoBinding

class DemoActivity : AppCompatActivity() {
Expand Down Expand Up @@ -55,7 +56,7 @@ class DemoActivity : AppCompatActivity() {
super.onCreate(savedInstanceState)
binding = DataBindingUtil.setContentView(this, R.layout.activity_demo)

AdTypesRepository.useOpenXServer()
AdTypesRepository.usePrebidServer()
useFakeGDPR()
parseArguments()
initViews()
Expand All @@ -65,6 +66,7 @@ class DemoActivity : AppCompatActivity() {
override fun onDestroy() {
super.onDestroy()
currentAdType.onDestroy?.let { it() }
PrebidMobile.setStoredAuctionResponse(null)
}

private fun parseArguments() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import com.google.android.gms.ads.admanager.AdManagerAdRequest
import com.google.android.gms.ads.admanager.AdManagerAdView
import org.prebid.mobile.AdUnit
import org.prebid.mobile.BannerAdUnit
import org.prebid.mobile.PrebidMobile
import org.prebid.mobile.addendum.AdViewUtils
import org.prebid.mobile.addendum.PbFindSizeError

Expand All @@ -25,10 +26,12 @@ object GamBanner {
width: Int,
height: Int,
adUnitId: String,
configId: String
configId: String,
storedAuctionResponse: String
) {
val adView = AdManagerAdView(wrapper.context)
adView.adUnitId = adUnitId
PrebidMobile.setStoredAuctionResponse(storedAuctionResponse)

adView.adListener = object : AdListener() {
override fun onAdLoaded() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,25 @@ import com.google.android.gms.ads.admanager.AdManagerInterstitialAd
import com.google.android.gms.ads.admanager.AdManagerInterstitialAdLoadCallback
import org.prebid.mobile.AdUnit
import org.prebid.mobile.InterstitialAdUnit
import org.prebid.mobile.PrebidMobile

object GamInterstitial {

private const val TAG = "GamInterstitial"

private var adUnit: AdUnit? = null

fun create(activity: Activity, autoRefreshTime: Int, adUnitId: String, configId: String) {
fun create(
activity: Activity,
autoRefreshTime: Int,
adUnitId: String,
configId: String,
storedAuctionResponse: String
) {
val requestBuilder = AdManagerAdRequest.Builder()
val request = requestBuilder.build()
PrebidMobile.setStoredAuctionResponse(storedAuctionResponse)

adUnit = InterstitialAdUnit(configId)
adUnit?.setAutoRefreshPeriodMillis(autoRefreshTime)
adUnit?.fetchDemand(request) { resultCode ->
Expand Down Expand Up @@ -56,6 +65,7 @@ object GamInterstitial {

fun destroy() {
adUnit?.stopAutoRefresh()

adUnit = null
}

Expand Down
Loading

0 comments on commit 7962804

Please sign in to comment.