Skip to content

Commit

Permalink
Some fixes (#473)
Browse files Browse the repository at this point in the history
* fix: sound button position

* fix: cutout problem

* fix: visibility checker problem due to transparent navigation bar #475

* fix: open measurement sdk import problem

* fix: video outstream watch again problem #475

* fix: add min size property to display interstitial example #475

* fix: mraid resize example  #475

* fix: open measurement sdk visibility problem  #475

* fix: device ext field  #475
  • Loading branch information
ValentinPostindustria committed Jun 9, 2022
1 parent 1c18bb6 commit e10e018
Show file tree
Hide file tree
Showing 15 changed files with 129 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

package org.prebid.mobile.renderingtestapp.plugplay.bidding.ppm

import org.prebid.mobile.AdSize
import org.prebid.mobile.api.data.AdUnitFormat
import org.prebid.mobile.api.rendering.InterstitialAdUnit
import org.prebid.mobile.renderingtestapp.plugplay.bidding.base.BaseBidInterstitialFragment
Expand All @@ -35,5 +36,6 @@ open class PpmInterstitialFragment : BaseBidInterstitialFragment() {
InterstitialAdUnit(requireContext(), configId)
}
interstitialAdUnit?.setInterstitialAdUnitListener(this)
interstitialAdUnit?.setMinSizePercentage(AdSize(30, 30))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -225,15 +225,25 @@ protected void setAdViewManagerValues() throws AdException {
}

protected InternalFriendlyObstruction[] formInterstitialObstructionsArray() {
InternalFriendlyObstruction[] obstructionArray = new InternalFriendlyObstruction[3];
InternalFriendlyObstruction[] obstructionArray = new InternalFriendlyObstruction[5];

View closeInterstitial = findViewById(R.id.iv_close_interstitial);
View skipInterstitial = findViewById(R.id.iv_skip);
View countDownTimer = findViewById(R.id.rl_count_down);
View actionButton = findViewById(R.id.tv_learn_more);

obstructionArray[0] = new InternalFriendlyObstruction(closeInterstitial, InternalFriendlyObstruction.Purpose.CLOSE_AD, null);
obstructionArray[1] = new InternalFriendlyObstruction(countDownTimer, InternalFriendlyObstruction.Purpose.OTHER, "CountDownTimer");
obstructionArray[2] = new InternalFriendlyObstruction(actionButton, InternalFriendlyObstruction.Purpose.OTHER, "Action button");
obstructionArray[1] = new InternalFriendlyObstruction(skipInterstitial, InternalFriendlyObstruction.Purpose.CLOSE_AD, null);
obstructionArray[2] = new InternalFriendlyObstruction(countDownTimer, InternalFriendlyObstruction.Purpose.OTHER, "CountDownTimer");
obstructionArray[3] = new InternalFriendlyObstruction(actionButton, InternalFriendlyObstruction.Purpose.OTHER, "Action button");

if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) {
View dialogRoot = closeInterstitial.getRootView();
View navigationBar = dialogRoot.findViewById(android.R.id.navigationBarBackground);
obstructionArray[4] = new InternalFriendlyObstruction(navigationBar, InternalFriendlyObstruction.Purpose.OTHER, "Bottom navigation bar");
} else {
obstructionArray[4] = null;
}

return obstructionArray;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,14 +115,21 @@ private List<Rect> buildObstructionsRectList() {
return pickedObstructionList;
}

private boolean visitParent(ViewGroup parentView, View childView) {
/**
* Checks whether the parent view is visible
* and whether children are not covered by any obstruction.
*/
private boolean visitParent(
ViewGroup parentView,
View childView
) {
if (parentView.getVisibility() != View.VISIBLE || isViewTransparent(parentView)) {
return false;
}

boolean clip = isClippedToBounds(parentView);
boolean childrenAreClippedToParent = isClippedToBounds(parentView);

if (clip) {
if (childrenAreClippedToParent) {
Rect bounds = new Rect();
parentView.getDrawingRect(bounds);
Rect convertRect = convertRect(bounds, parentView, testedViewWeakReference.get());
Expand Down Expand Up @@ -152,8 +159,13 @@ private boolean visitParent(ViewGroup parentView, View childView) {

// don't test child if it is viewGroup and transparent
private boolean isFriendlyObstruction(View child) {
return (child instanceof ImageView && child.getId() == R.id.iv_close_interstitial)
|| child.getId() == R.id.rl_count_down;
boolean result = (child instanceof ImageView && child.getId() == R.id.iv_close_interstitial)
|| (child instanceof ImageView && child.getId() == R.id.iv_skip)
|| child.getId() == R.id.rl_count_down;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
result = result || child.getId() == android.R.id.navigationBarBackground;
}
return result;
}

private void collectObstructionsFrom(View child) {
Expand Down Expand Up @@ -291,7 +303,8 @@ private void fragmentize(Rect valueRect, Rect aroundRect, List<Rect> destList) {
new Rect(trimmedRect.right,
valueRect.top,
valueRect.right,
valueRect.top + valueRect.height())
valueRect.top + valueRect.height()
)
};

for (Rect rect : subRectArray) {
Expand All @@ -301,14 +314,23 @@ private void fragmentize(Rect valueRect, Rect aroundRect, List<Rect> destList) {
}
}

/**
* Returns whether ViewGroup's children are clipped to their bounds.
* <p>
* {@link ViewGroup#getClipChildren()}
*/
private boolean isClippedToBounds(ViewGroup viewGroup) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
return viewGroup.getClipChildren();
}
return false;
}

private Rect convertRect(Rect fromRect, View fromView, View toView) {
private Rect convertRect(
Rect fromRect,
View fromView,
View toView
) {
if (fromRect == null || fromView == null || toView == null) {
LogUtil.debug(TAG, "convertRect: Failed. One of the provided param is null. Returning empty rect.");
return new Rect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,9 @@ public static View createSoundView(Context context) {
ViewGroup.LayoutParams.WRAP_CONTENT
);
params.gravity = Gravity.END | Gravity.BOTTOM;
params.bottomMargin += 150;
view.setLayoutParams(params);
InsetsUtils.addCutoutAndNavigationInsets(view);
return view;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package org.prebid.mobile.rendering.views;

import android.content.Context;
import android.os.Build;
import android.util.Log;
import android.view.View;
import android.view.ViewGroup;
Expand Down Expand Up @@ -50,6 +51,8 @@ public class AdViewManager implements CreativeViewListener, TransactionManagerLi

private static final String TAG = AdViewManager.class.getSimpleName();

private boolean builtInVideoFirstStart = true;

private final InterstitialManager interstitialManager;

private AdUnitConfiguration adConfiguration = new AdUnitConfiguration();
Expand Down Expand Up @@ -218,7 +221,12 @@ public AdUnitConfiguration getAdConfiguration() {
}

public boolean isAutoDisplayOnLoad() {
return adConfiguration.isAdType(AdFormat.BANNER) || adConfiguration.isBuiltInVideo();
boolean result = adConfiguration.isAdType(AdFormat.BANNER);
if (builtInVideoFirstStart) {
builtInVideoFirstStart = false;
result = result || adConfiguration.isBuiltInVideo();
}
return result;
}

public void destroy() {
Expand Down Expand Up @@ -444,7 +452,20 @@ private void addHtmlInterstitialObstructions(ViewGroup rootViewGroup) {
return;
}
View closeButtonView = rootViewGroup.findViewById(R.id.iv_close_interstitial);
addObstructions(new InternalFriendlyObstruction(closeButtonView, InternalFriendlyObstruction.Purpose.CLOSE_AD, null));

InternalFriendlyObstruction[] obstructionArray = new InternalFriendlyObstruction[2];
obstructionArray[0] = new InternalFriendlyObstruction(closeButtonView, InternalFriendlyObstruction.Purpose.CLOSE_AD, null);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
View dialogRoot = closeButtonView.getRootView();
View navigationBarView = dialogRoot.findViewById(android.R.id.navigationBarBackground);
InternalFriendlyObstruction obstruction = new InternalFriendlyObstruction(navigationBarView, InternalFriendlyObstruction.Purpose.OTHER, "Bottom navigation bar");
obstructionArray[1] = obstruction;
} else {
obstructionArray[1] = null;
}

addObstructions(obstructionArray);
}

private void processTransaction(Transaction transaction) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.Log;
import android.view.WindowManager;
import android.webkit.WebSettings;
import android.webkit.WebSettings.LayoutAlgorithm;
Expand Down Expand Up @@ -86,7 +87,11 @@ protected void initializeWebSettings() {
screenHeight = Utils.getScreenHeight(windowManager);
}

calculateScaleForResize(screenWidth, screenHeight, width, height);
if (this instanceof WebViewInterstitial) {
calculateScaleForResize(screenWidth, screenHeight, width, height);
} else {
webSettings.setLoadWithOverviewMode(true);
}

initBaseWebSettings(webSettings);
if (Utils.atLeastKitKat()) {
Expand Down Expand Up @@ -128,7 +133,9 @@ private void calculateScaleForResize(
factor = newCreativeWidth / scaledScreenWidth;
}

setInitialScale((int) (initialScale / factor * 100));
int scaleInPercent = (int) (initialScale / factor * 100);
setInitialScale(scaleInPercent);
Log.d(TAG, "Using custom WebView scale: " + scaleInPercent);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,14 @@
package org.prebid.mobile.rendering.views.webview;

import android.content.Context;
import android.text.TextUtils;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import org.prebid.mobile.LogUtil;
import org.prebid.mobile.PrebidMobile;
import org.prebid.mobile.rendering.interstitial.AdBaseDialog;
import org.prebid.mobile.rendering.models.internal.MraidVariableContainer;
import org.prebid.mobile.rendering.sdk.JSLibraryManager;
import org.prebid.mobile.rendering.utils.helpers.Utils;
import org.prebid.mobile.rendering.views.webview.mraid.BaseJSInterface;

import java.util.regex.Matcher;
Expand Down Expand Up @@ -330,28 +327,12 @@ private String buildViewportMetaTag() {
//

String scale = getInitialScaleValue();
StringBuilder metaTag;
if (!TextUtils.isEmpty(scale)) {

if (Utils.atLeastKitKat()) {
LogUtil.debug(TAG, "Metatag is set correctly");
metaTag = new StringBuilder("<meta name='viewport' content='width=device-width, initial-scale=" + scale + ", minimum-scale=0.01' />");

meta = metaTag.toString();
}
else {
metaTag = new StringBuilder("<meta name='viewport' content='width=device-width, maximum-scale=%1$s, minimum-scale=%1$s, user-scalable=yes' />");

meta = String.format(metaTag.toString(), scale);
}
}
else {
LogUtil.debug(TAG, "Scale is null. Please check");
metaTag = new StringBuilder("<meta name='viewport' content='width=device-width' />");

meta = metaTag.toString();
String metaTag;
if (scale != null && !scale.isEmpty()) {
metaTag = "<meta name='viewport' content='width=device-width, initial-scale=" + scale + ", minimum-scale=0.01' />";
} else {
metaTag = "<meta name='viewport' content='width=device-width' />";
}

return meta;
return metaTag;
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:tools="http://schemas.android.com/tools">
<resources>

<style name="FullScreenDialogTheme" parent="android:Theme.Material.NoActionBar.Fullscreen">
<!-- Display in cutout mode -->
<item name="android:windowLayoutInDisplayCutoutMode" tools:targetApi="o_mr1">always</item>

<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
Expand Down
18 changes: 18 additions & 0 deletions PrebidMobile/PrebidMobile-core/src/main/res/values-v28/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="FullScreenDialogTheme" parent="android:Theme.Material.NoActionBar.Fullscreen">
<!-- Display in cutout mode -->
<item name="android:windowLayoutInDisplayCutoutMode">shortEdges</item>

<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:colorBackground">@android:color/black</item>

<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>

</resources>
18 changes: 18 additions & 0 deletions PrebidMobile/PrebidMobile-core/src/main/res/values-v30/styles.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>

<style name="FullScreenDialogTheme" parent="android:Theme.Material.NoActionBar.Fullscreen">
<!-- Display in cutout mode -->
<item name="android:windowLayoutInDisplayCutoutMode">always</item>

<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowFullscreen">true</item>
<item name="android:colorBackground">@android:color/black</item>

<item name="android:windowTranslucentNavigation">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:navigationBarColor">@android:color/transparent</item>
</style>

</resources>
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ext {

artifactGroupId = "org.prebid"
artifactFolder = "${buildDir}/generated-artifacts"
omSdkVersion = "1.3.34"
omSdkVersion = "1.3.34.1"
omSdkModuleName = "omsdk-android"
}

Expand All @@ -31,6 +31,7 @@ allprojects {
mavenCentral()
maven { url 'https://maven.google.com' }
maven { url 'https://jitpack.io' }
maven { url "https://oss.sonatype.org/content/repositories/orgprebid-1084" }
maven { url "https://oss.sonatype.org/content/repositories/orgprebid-1089" }
maven { url "https://oss.sonatype.org/content/repositories/orgprebid-1090" }
}
}
2 changes: 1 addition & 1 deletion scripts/Maven/PrebidMobile-core-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<dependency>
<groupId>org.prebid</groupId>
<artifactId>prebid-mobile-sdk-open-measurement</artifactId>
<version>1.3.34</version>
<version>1.3.34.1</version>
<scope>compile</scope>
</dependency>

Expand Down
2 changes: 1 addition & 1 deletion scripts/Maven/PrebidMobile-open-measurement-pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.prebid</groupId>
<artifactId>prebid-mobile-sdk-open-measurement</artifactId>
<version>1.3.34</version>
<version>1.3.34.1</version>

<packaging>jar</packaging>
<name>Prebid Mobile Android SDK</name>
Expand Down
6 changes: 3 additions & 3 deletions scripts/buildPrebidMobile.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,14 @@ if [ "$1" != "-nojar" ]; then
cd $TEMPDIR
mkdir output
cd output
cp -a "$BASEDIR/PrebidMobile/omsdk-android/omsdk-android-1.3.34.aar" "$TEMPDIR/output"
unzip -q -o omsdk-android-1.3.34.aar
cp -a "$BASEDIR/PrebidMobile/omsdk-android/omsdk-android-1.3.34.1.aar" "$TEMPDIR/output"
unzip -q -o omsdk-android-1.3.34.1.aar
# Delete all files instead classes.jar
find . ! -name 'classes.jar' -type f -exec rm -f {} +
unzip -q -o classes.jar
rm classes.jar

jar cf omsdk.jar com*
jar cf omsdk.jar com* a* b* c* d* e* f* g* h*
mv omsdk.jar $OUTDIR
cd $LIBDIR
rm -r $TEMPDIR
Expand Down

0 comments on commit e10e018

Please sign in to comment.