|
2 | 2 |
|
3 | 3 | import android.app.Activity; |
4 | 4 | import android.content.Context; |
| 5 | +import android.os.Build; |
5 | 6 | import android.util.DisplayMetrics; |
6 | 7 | import android.util.Log; |
7 | 8 | import android.view.Gravity; |
@@ -102,21 +103,23 @@ public void showBanner(final PluginCall call) { |
102 | 103 | break; |
103 | 104 | } |
104 | 105 |
|
105 | | - // set Safe Area |
106 | | - View rootView = activitySupplier.get().getWindow().getDecorView(); |
107 | | - rootView.setOnApplyWindowInsetsListener((v, insets) -> { |
108 | | - int bottomInset = insets.getSystemWindowInsetBottom(); |
109 | | - int topInset = insets.getSystemWindowInsetTop(); |
110 | | - |
111 | | - if ("TOP_CENTER".equals(adOptions.position)) { |
112 | | - mAdViewLayoutParams.setMargins(0, topInset, 0, 0); |
113 | | - } else { |
114 | | - mAdViewLayoutParams.setMargins(0, 0, 0, bottomInset); |
115 | | - } |
| 106 | + // set Safe Area only for Android 15+ |
| 107 | + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.VANILLA_ICE_CREAM) { |
| 108 | + View rootView = activitySupplier.get().getWindow().getDecorView(); |
| 109 | + rootView.setOnApplyWindowInsetsListener((v, insets) -> { |
| 110 | + int bottomInset = insets.getSystemWindowInsetBottom(); |
| 111 | + int topInset = insets.getSystemWindowInsetTop(); |
| 112 | + |
| 113 | + if ("TOP_CENTER".equals(adOptions.position)) { |
| 114 | + mAdViewLayoutParams.setMargins(0, topInset, 0, 0); |
| 115 | + } else { |
| 116 | + mAdViewLayoutParams.setMargins(0, 0, 0, bottomInset); |
| 117 | + } |
116 | 118 |
|
117 | | - mAdViewLayout.setLayoutParams(mAdViewLayoutParams); |
118 | | - return insets; |
119 | | - }); |
| 119 | + mAdViewLayout.setLayoutParams(mAdViewLayoutParams); |
| 120 | + return insets; |
| 121 | + }); |
| 122 | + } |
120 | 123 |
|
121 | 124 | mAdViewLayout.setLayoutParams(mAdViewLayoutParams); |
122 | 125 |
|
|
0 commit comments