react-native-applovin-max 5.3.0 → 5.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -35,8 +35,8 @@ android {
35
35
  defaultConfig {
36
36
  minSdkVersion 16
37
37
  targetSdkVersion getExtOrIntegerDefault('targetSdkVersion')
38
- versionCode 5030000
39
- versionName "5.3.0"
38
+ versionCode 5040000
39
+ versionName "5.4.0"
40
40
  }
41
41
 
42
42
  flavorDimensions("default")
@@ -4,6 +4,7 @@ import android.content.Context;
4
4
  import android.text.TextUtils;
5
5
  import android.view.View;
6
6
  import android.view.ViewGroup;
7
+ import android.widget.Button;
7
8
  import android.widget.ImageView;
8
9
 
9
10
  import com.applovin.mediation.MaxAd;
@@ -32,8 +33,15 @@ import static com.applovin.sdk.AppLovinSdkUtils.runOnUiThreadDelayed;
32
33
 
33
34
  public class AppLovinMAXNativeAdView
34
35
  extends ReactViewGroup
35
- implements MaxAdRevenueListener, View.OnLayoutChangeListener
36
+ implements MaxAdRevenueListener, View.OnLayoutChangeListener, ViewGroup.OnHierarchyChangeListener
36
37
  {
38
+ private static final int TITLE_LABEL_TAG = 1;
39
+ private static final int MEDIA_VIEW_CONTAINER_TAG = 2;
40
+ private static final int ICON_VIEW_TAG = 3;
41
+ private static final int BODY_VIEW_TAG = 4;
42
+ private static final int CALL_TO_ACTION_VIEW_TAG = 5;
43
+ private static final int ADVERTISER_VIEW_TAG = 8;
44
+
37
45
  private final ReactContext reactContext;
38
46
  @Nullable
39
47
  private MaxNativeAdLoader adLoader;
@@ -147,7 +155,7 @@ public class AppLovinMAXNativeAdView
147
155
  {
148
156
  for ( Map.Entry<String, Object> entry : localExtraParameters.entrySet() )
149
157
  {
150
- adLoader.setLocalExtraParameter( entry.getKey(), (String) entry.getValue() );
158
+ adLoader.setLocalExtraParameter( entry.getKey(), entry.getValue() );
151
159
  }
152
160
  }
153
161
 
@@ -173,7 +181,7 @@ public class AppLovinMAXNativeAdView
173
181
  }
174
182
 
175
183
  view.setClickable( true );
176
-
184
+ view.setTag( TITLE_LABEL_TAG );
177
185
  clickableViews.add( view );
178
186
  }
179
187
 
@@ -189,7 +197,7 @@ public class AppLovinMAXNativeAdView
189
197
  }
190
198
 
191
199
  view.setClickable( true );
192
-
200
+ view.setTag( ADVERTISER_VIEW_TAG );
193
201
  clickableViews.add( view );
194
202
  }
195
203
 
@@ -205,7 +213,7 @@ public class AppLovinMAXNativeAdView
205
213
  }
206
214
 
207
215
  view.setClickable( true );
208
-
216
+ view.setTag( BODY_VIEW_TAG );
209
217
  clickableViews.add( view );
210
218
  }
211
219
 
@@ -222,7 +230,22 @@ public class AppLovinMAXNativeAdView
222
230
 
223
231
  view.setClickable( true );
224
232
 
225
- clickableViews.add( view );
233
+ // Some adapters, like Google, expect a Button widget for CTA to be clickable
234
+ if ( view instanceof ViewGroup )
235
+ {
236
+ Button button = new Button( reactContext );
237
+ button.setAlpha( 0 );
238
+ ( (ViewGroup) view ).addView( button );
239
+ sizeToFit( button, view );
240
+
241
+ button.setTag( CALL_TO_ACTION_VIEW_TAG );
242
+ clickableViews.add( button );
243
+ }
244
+ else
245
+ {
246
+ view.setTag( CALL_TO_ACTION_VIEW_TAG );
247
+ clickableViews.add( view );
248
+ }
226
249
  }
227
250
 
228
251
  public void setIconView(final int tag)
@@ -235,6 +258,7 @@ public class AppLovinMAXNativeAdView
235
258
  }
236
259
 
237
260
  view.setClickable( true );
261
+ view.setTag( ICON_VIEW_TAG );
238
262
  clickableViews.add( view );
239
263
 
240
264
  MaxNativeAdImage icon = nativeAd.getNativeAd().getIcon();
@@ -278,12 +302,21 @@ public class AppLovinMAXNativeAdView
278
302
  return;
279
303
  }
280
304
 
305
+ view.setTag( MEDIA_VIEW_CONTAINER_TAG );
281
306
  clickableViews.add( view );
282
307
 
283
308
  view.addOnLayoutChangeListener( this );
284
309
  view.addView( mediaView );
285
310
 
286
311
  sizeToFit( mediaView, view );
312
+
313
+ // Resize the child of `mediaView` for the networks, especially for InMobi, where the actual
314
+ // media view is added in `MaxNativeAdLoader.b()` after `mediaView` is sized so that it has
315
+ // to be resized when the network's media view is added.
316
+ if ( mediaView instanceof ViewGroup )
317
+ {
318
+ ( (ViewGroup) mediaView ).setOnHierarchyChangeListener( this );
319
+ }
287
320
  }
288
321
 
289
322
  @Override
@@ -299,7 +332,16 @@ public class AppLovinMAXNativeAdView
299
332
  }
300
333
  }
301
334
 
302
- private void sizeToFit(final @Nullable View view, final View parentView)
335
+ @Override
336
+ public void onChildViewAdded(final View parent, final View child)
337
+ {
338
+ parent.post( () -> sizeToFit( child, parent ) );
339
+ }
340
+
341
+ @Override
342
+ public void onChildViewRemoved(final View parent, final View child) { }
343
+
344
+ private static void sizeToFit(final @Nullable View view, final View parentView)
303
345
  {
304
346
  if ( view != null )
305
347
  {
@@ -361,7 +403,7 @@ public class AppLovinMAXNativeAdView
361
403
  // LINE, where the actual ad contents are loaded after `mediaView` is sized.
362
404
  if ( mediaView != null )
363
405
  {
364
- sizeToFit( mediaView, (ReactViewGroup) mediaView.getParent() );
406
+ sizeToFit( mediaView, (View) mediaView.getParent() );
365
407
  }
366
408
 
367
409
  isLoading.set( false );
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "react-native-applovin-max",
3
3
  "author": "AppLovin Corporation",
4
- "version": "5.3.0",
4
+ "version": "5.4.0",
5
5
  "description": "AppLovin MAX React Native Plugin for Android and iOS",
6
6
  "homepage": "https://github.com/AppLovin/AppLovin-MAX-React-Native",
7
7
  "license": "MIT",
@@ -11,7 +11,7 @@ Pod::Spec.new do |s|
11
11
  s.authors = package["author"]
12
12
 
13
13
  s.platforms = { :ios => "10.0" }
14
- s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_3_0" }
14
+ s.source = { :git => "https://github.com/AppLovin/AppLovin-MAX-React-Native.git", :tag => "release_5_4_0" }
15
15
 
16
16
  s.source_files = "ios/AppLovinMAX*.{h,m}"
17
17
 
@@ -80,8 +80,8 @@ export const CallToActionView = (props) => {
80
80
  if (!nativeAdView) return null;
81
81
 
82
82
  return (
83
- <TouchableOpacity {...props}>
84
- <Text {...props} ref={callToActionRef}>
83
+ <TouchableOpacity {...props} ref={callToActionRef}>
84
+ <Text {...props}>
85
85
  {nativeAd.callToAction || null}
86
86
  </Text>
87
87
  </TouchableOpacity>
package/src/index.js CHANGED
@@ -6,7 +6,7 @@ import EventListeners from "./AppLovinMAXEventListeners";
6
6
 
7
7
  const { AppLovinMAX } = NativeModules;
8
8
 
9
- const VERSION = "5.3.0";
9
+ const VERSION = "5.4.0";
10
10
 
11
11
  /*---------*/
12
12
  /* BANNERS */