Skip to content

Commit 08602b2

Browse files
committed
Version 3.13.1 of the Google Mobile Ads Unity plugin
1 parent d9196de commit 08602b2

File tree

3 files changed

+39
-1
lines changed

3 files changed

+39
-1
lines changed

ChangeLog.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
Google Mobile Ads Unity Plugin Change Log
22

3+
**************
4+
Version 3.13.1
5+
**************
6+
7+
Plugin:
8+
- Fixed issue where banner ads reposition to top of screen after a full
9+
screen ad is displayed.
10+
11+
Built and tested with:
12+
- Google Play services 12.0.1
13+
- Google Mobile Ads iOS SDK 7.30.0
14+
- Unity Jar Resolver 1.2.64.0
15+
316
**************
417
Version 3.13.0
518
**************

source/android-library/app/src/main/java/com/google/unity/ads/Banner.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,12 @@
1818
import android.app.Activity;
1919
import android.graphics.Color;
2020
import android.graphics.Point;
21+
import android.os.Build;
2122
import android.util.Log;
2223
import android.view.View;
2324
import android.view.ViewGroup;
2425
import android.view.ViewParent;
26+
import android.view.ViewTreeObserver;
2527
import android.view.WindowManager;
2628
import android.widget.PopupWindow;
2729

@@ -90,6 +92,12 @@ public class Banner {
9092
*/
9193
private View.OnLayoutChangeListener mLayoutChangeListener;
9294

95+
/**
96+
* A {@code ViewTreeObserver.OnGlobalLayoutListener} used to detect if a full screen ad was
97+
* shown while a banner ad was on screen.
98+
*/
99+
private ViewTreeObserver.OnGlobalLayoutListener mViewTreeLayoutChangeListener;
100+
93101

94102
/**
95103
* Creates an instance of {@code Banner}.
@@ -204,6 +212,16 @@ public void onLayoutChange(View v, int left, int top, int right, int bottom,
204212
};
205213
mUnityPlayerActivity.getWindow().getDecorView().getRootView()
206214
.addOnLayoutChangeListener(mLayoutChangeListener);
215+
216+
// Workaround for issue where ad view will be repositioned to the top of the screen after
217+
// a full screen ad is shown on some devices.
218+
mViewTreeLayoutChangeListener = new ViewTreeObserver.OnGlobalLayoutListener() {
219+
@Override
220+
public void onGlobalLayout() {
221+
updatePosition();
222+
}
223+
};
224+
mAdView.getViewTreeObserver().addOnGlobalLayoutListener(mViewTreeLayoutChangeListener);
207225
}
208226

209227
private void createPopupWindow() {
@@ -305,6 +323,13 @@ public void run() {
305323

306324
mUnityPlayerActivity.getWindow().getDecorView().getRootView()
307325
.removeOnLayoutChangeListener(mLayoutChangeListener);
326+
327+
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
328+
mAdView.getViewTreeObserver()
329+
.removeOnGlobalLayoutListener(mViewTreeLayoutChangeListener);
330+
} else {
331+
mAdView.getViewTreeObserver().removeGlobalOnLayoutListener(mViewTreeLayoutChangeListener);
332+
}
308333
}
309334

310335
/**

source/plugin/Assets/GoogleMobileAds/Api/AdRequest.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ namespace GoogleMobileAds.Api
2121
{
2222
public class AdRequest
2323
{
24-
public const string Version = "3.13.0";
24+
public const string Version = "3.13.1";
2525
public const string TestDeviceSimulator = "SIMULATOR";
2626

2727
private AdRequest(Builder builder)

0 commit comments

Comments
 (0)