From 75ae37fe8fb553eadab09522c8e5f4a4904440ba Mon Sep 17 00:00:00 2001 From: Abhas Vohra Date: Tue, 20 Sep 2022 16:27:59 +0000 Subject: [PATCH 1/2] MS-5080 Added support for High Impact media Squashed commit of the following: commit 3543c4e69741c196c7426b0b25587c218e83f728 Author: Abhas Vohra Date: Mon Sep 19 14:17:00 2022 +0530 Fixed duplication of banner_frameworks for HighImpact media commit 7eae1f42122d789b892a50bc070659a547afa002 Author: Abhas Vohra Date: Fri Sep 16 17:31:48 2022 +0530 Correction: frameworks key changed to banner_frameworks commit 44ee29f1225e140a9d9ef2cc72e21b48380baea1 Author: Abhas Vohra Date: Thu Sep 15 18:31:52 2022 +0530 Exposed API for supporting High Impact --- sdk/res/values/errors.xml | 1 + .../com/appnexus/opensdk/BannerAdView.java | 21 ++++++ .../opensdk/ut/UTRequestParameters.java | 16 +++++ .../BannerAdToRequestParametersTest.java | 70 +++++++++++++++++++ 4 files changed, 108 insertions(+) diff --git a/sdk/res/values/errors.xml b/sdk/res/values/errors.xml index 70719054..4519e595 100644 --- a/sdk/res/values/errors.xml +++ b/sdk/res/values/errors.xml @@ -72,6 +72,7 @@ setAllowVideo() to %b setAllowBanner() to %b setAllowNative() to %b + setAllowHighImpact() to %b setCountImpressionOnAdLoad() to %b WebView loading body: %s loadAd() called for interstitial. diff --git a/sdk/src/com/appnexus/opensdk/BannerAdView.java b/sdk/src/com/appnexus/opensdk/BannerAdView.java index 58f83f56..39d7482d 100644 --- a/sdk/src/com/appnexus/opensdk/BannerAdView.java +++ b/sdk/src/com/appnexus/opensdk/BannerAdView.java @@ -852,6 +852,18 @@ public void setAllowNativeDemand(boolean enabled) { requestParameters.setBannerNativeEnabled(enabled); } + /** + * Sets whether or not High Impact media(AppNexus Media Type:11) can serve on this Ad object. + * This overrides the value set in console. + * + * @param enabled whether to enable High Impact media or not. default is false + */ + public void setAllowHighImpactDemand(boolean enabled) { + Clog.d(Clog.publicFunctionsLogTag, Clog.getString( + R.string.set_allow_high_impact, enabled)); + requestParameters.setHighImpactEnabled(enabled); + } + /** * Check whether Video Ad is enabled on this ad view @@ -872,6 +884,15 @@ public boolean getAllowNativeDemand() { return requestParameters.isBannerNativeEnabled(); } + /** + * Check whether High Impact media is enabled on this ad view + * + * @return If true, High Impact Ad can be loaded on the ad view. + */ + public boolean getAllowHighImpactDemand() { + return requestParameters.isHighImpactEnabled(); + } + @Override protected void onWindowVisibilityChanged(int visibility) { diff --git a/sdk/src/com/appnexus/opensdk/ut/UTRequestParameters.java b/sdk/src/com/appnexus/opensdk/ut/UTRequestParameters.java index 09413ac1..5863842f 100644 --- a/sdk/src/com/appnexus/opensdk/ut/UTRequestParameters.java +++ b/sdk/src/com/appnexus/opensdk/ut/UTRequestParameters.java @@ -72,6 +72,7 @@ public class UTRequestParameters { private boolean isBannerVideoEnabled = false; private boolean isBannerEnabled = true; private boolean isBannerNativeEnabled = false; + private boolean isHighImpactEnabled = false; private String extInvCode; private float reserve = 0.00f; private String age; @@ -176,6 +177,7 @@ public class UTRequestParameters { private static final int ALLOWED_TYPE_BANNER = 1; private static final int ALLOWED_TYPE_INTERSTITIAL = 3; private static final int ALLOWED_TYPE_VIDEO = 4; + private static final int ALLOWED_TYPE_HIGH_IMPACT = 11; private static final int ALLOWED_TYPE_NATIVE = 12; private static final String os = "android"; @@ -697,6 +699,12 @@ private JSONArray getTagsObject(JSONObject postData) { tag.put(VIDEO_FRAMEWORKS, omidFrameworksValue); } } + if (utRequestParameters.isHighImpactEnabled) { + allowedMediaAdTypes.put(ALLOWED_TYPE_HIGH_IMPACT); + if(!utRequestParameters.isBannerEnabled && SDKSettings.getOMEnabled()) { + tag.put(BANNER_FRAMEWORKS, omidFrameworksValue); + } + } if (utRequestParameters.isBannerNativeEnabled) { allowedMediaAdTypes.put(ALLOWED_TYPE_NATIVE); if(SDKSettings.getOMEnabled()) { @@ -1177,4 +1185,12 @@ public int getPublisherId() { public void setPublisherId(int publisherId) { this.publisherId = publisherId; } + + public boolean isHighImpactEnabled() { + return isHighImpactEnabled; + } + + public void setHighImpactEnabled(boolean highImpactEnabled) { + isHighImpactEnabled = highImpactEnabled; + } } \ No newline at end of file diff --git a/sdk/test/com/appnexus/opensdk/BannerAdToRequestParametersTest.java b/sdk/test/com/appnexus/opensdk/BannerAdToRequestParametersTest.java index baf935ff..3c95e9df 100644 --- a/sdk/test/com/appnexus/opensdk/BannerAdToRequestParametersTest.java +++ b/sdk/test/com/appnexus/opensdk/BannerAdToRequestParametersTest.java @@ -156,6 +156,12 @@ public void testSetAllowBanner(){ bannerPostData = getRequestParametersPostData(); assertTrue(bannerPostData.contains("\"allowed_media_types\":[1,12]")); + bannerAdView.setAllowHighImpactDemand(true); + bannerAdView.setAllowNativeDemand(false); + assertEquals(true,bannerAdView.getAllowHighImpactDemand()); + bannerPostData = getRequestParametersPostData(); + assertTrue(bannerPostData.contains("\"allowed_media_types\":[1,11]")); + } @@ -191,7 +197,71 @@ public void testSetAllowVideoAndNative(){ assertTrue(bannerNativePostData.contains("\"allowed_media_types\":[1,4,12]")); } + // Test setAllowHighImpact + @Test + public void testSetAllowHighImpact(){ + assertEquals(false,bannerAdView.getAllowHighImpactDemand()); + String bannerPostData = getRequestParametersPostData(); + assertTrue(bannerPostData.contains("\"allowed_media_types\":[1]")); + + bannerAdView.setAllowHighImpactDemand(true); + assertEquals(true,bannerAdView.getAllowHighImpactDemand()); + String bannerNativePostData = getRequestParametersPostData(); + assertTrue(bannerNativePostData.contains("\"allowed_media_types\":[1,11]")); + } + + // Test setAllowNative and setAllowHighImpact + @Test + public void testSetAllowNativeAndHighImpact(){ + assertEquals(false,bannerAdView.getAllowNativeDemand()); + assertEquals(false,bannerAdView.getAllowHighImpactDemand()); + String bannerPostData = getRequestParametersPostData(); + assertTrue(bannerPostData.contains("\"allowed_media_types\":[1]")); + + + bannerAdView.setAllowNativeDemand(true); + bannerAdView.setAllowHighImpactDemand(true); + assertEquals(true,bannerAdView.getAllowNativeDemand()); + assertEquals(true,bannerAdView.getAllowHighImpactDemand()); + String bannerNativePostData = getRequestParametersPostData(); + assertTrue(bannerNativePostData.contains("\"allowed_media_types\":[1,11,12]")); + } + + // Test setAllowVideo and setAllowHighImpact + @Test + public void testSetAllowVideoAndHighImpact(){ + assertEquals(false,bannerAdView.getAllowVideoDemand()); + assertEquals(false,bannerAdView.getAllowHighImpactDemand()); + String bannerPostData = getRequestParametersPostData(); + assertTrue(bannerPostData.contains("\"allowed_media_types\":[1]")); + + + bannerAdView.setAllowVideoDemand(true); + bannerAdView.setAllowHighImpactDemand(true); + assertEquals(true,bannerAdView.getAllowVideoDemand()); + assertEquals(true,bannerAdView.getAllowHighImpactDemand()); + String bannerNativePostData = getRequestParametersPostData(); + assertTrue(bannerNativePostData.contains("\"allowed_media_types\":[1,4,11]")); + } + + // Test setAllowVideo and setAllowHighImpact + @Test + public void testSetAllowVideoNativeAndHighImpact(){ + assertEquals(false,bannerAdView.getAllowNativeDemand()); + assertEquals(false,bannerAdView.getAllowVideoDemand()); + assertEquals(false,bannerAdView.getAllowHighImpactDemand()); + String bannerPostData = getRequestParametersPostData(); + assertTrue(bannerPostData.contains("\"allowed_media_types\":[1]")); + bannerAdView.setAllowNativeDemand(true); + bannerAdView.setAllowVideoDemand(true); + bannerAdView.setAllowHighImpactDemand(true); + assertEquals(true,bannerAdView.getAllowNativeDemand()); + assertEquals(true,bannerAdView.getAllowVideoDemand()); + assertEquals(true,bannerAdView.getAllowHighImpactDemand()); + String bannerNativePostData = getRequestParametersPostData(); + assertTrue(bannerNativePostData.contains("\"allowed_media_types\":[1,4,11,12]")); + } // Setting MAX size should reset all the other size params set earlier From b26adf1618ab8e39e92d7983616160d19108692f Mon Sep 17 00:00:00 2001 From: Abhas Vohra Date: Sat, 8 Oct 2022 01:43:40 +0530 Subject: [PATCH 2/2] Updated versionCode, versionName and RELEASE-NOTES --- RELEASE-NOTES.md | 5 +++++ instreamvideo/build.gradle | 4 ++-- sdk/build.gradle | 4 ++-- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/RELEASE-NOTES.md b/RELEASE-NOTES.md index 9e26d14b..47adccaa 100644 --- a/RELEASE-NOTES.md +++ b/RELEASE-NOTES.md @@ -1,3 +1,8 @@ +## 8.1 + +### Improvement/Bug Fixes ++ MS-5080 Enable support for high impact media type creatives in BannerAdView + ## 8.0.1 ### Improvement/Bug Fixes diff --git a/instreamvideo/build.gradle b/instreamvideo/build.gradle index 3c74f104..180dcb20 100644 --- a/instreamvideo/build.gradle +++ b/instreamvideo/build.gradle @@ -1,5 +1,5 @@ // Project Properties -version = "1.38.1" // Instream SDK version +version = "1.39" // Instream SDK version apply plugin: 'com.android.library' @@ -10,7 +10,7 @@ android { defaultConfig { minSdkVersion 14 targetSdkVersion 32 - versionCode 37 // An integer value that represents the version of the code, relative to other versions. Increase for each release. + versionCode 38 // An integer value that represents the version of the code, relative to other versions. Increase for each release. versionName version consumerProguardFiles 'proguard-project.txt' } diff --git a/sdk/build.gradle b/sdk/build.gradle index 97cdc34c..2aa4d5ff 100644 --- a/sdk/build.gradle +++ b/sdk/build.gradle @@ -1,5 +1,5 @@ // Project properties -version = "8.0.1" +version = "8.1" group='com.appnexus.opensdk' // Android build @@ -9,7 +9,7 @@ android { compileSdkVersion 32 buildToolsVersion '32.0.0' defaultConfig { - versionCode 96 // An integer value that represents the version of the code, relative to other versions. Increase for each release. + versionCode 97 // An integer value that represents the version of the code, relative to other versions. Increase for each release. versionName version consumerProguardFiles 'proguard-project.txt' minSdkVersion 14