react-native-applovin-max 5.2.3 → 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.
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/applovin/reactnative/AppLovinMAXNativeAdView.java +59 -21
- package/ios/AppLovinMAXNativeAdView.m +3 -14
- package/package.json +1 -1
- package/react-native-applovin-max.podspec +1 -1
- package/src/NativeAdComponents.js +4 -4
- package/src/index.js +1 -1
package/android/build.gradle
CHANGED
|
@@ -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(),
|
|
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
|
-
|
|
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
|
-
|
|
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
|
{
|
|
@@ -357,6 +399,13 @@ public class AppLovinMAXNativeAdView
|
|
|
357
399
|
adLoader.b( ad );
|
|
358
400
|
}
|
|
359
401
|
|
|
402
|
+
// Reassure the size of `mediaView` and its children for the networks, such as
|
|
403
|
+
// LINE, where the actual ad contents are loaded after `mediaView` is sized.
|
|
404
|
+
if ( mediaView != null )
|
|
405
|
+
{
|
|
406
|
+
sizeToFit( mediaView, (View) mediaView.getParent() );
|
|
407
|
+
}
|
|
408
|
+
|
|
360
409
|
isLoading.set( false );
|
|
361
410
|
}, 500L );
|
|
362
411
|
}
|
|
@@ -396,22 +445,11 @@ public class AppLovinMAXNativeAdView
|
|
|
396
445
|
nativeAdInfo.putDouble( "starRating", ad.getStarRating().doubleValue() );
|
|
397
446
|
}
|
|
398
447
|
|
|
448
|
+
// The aspect ratio can be 0.0f when it is not provided by the network.
|
|
399
449
|
float aspectRatio = ad.getMediaContentAspectRatio();
|
|
400
|
-
if (
|
|
401
|
-
{
|
|
402
|
-
// The aspect ratio can be 0.0f when it is not provided by the network.
|
|
403
|
-
if ( Math.signum( aspectRatio ) == 0 )
|
|
404
|
-
{
|
|
405
|
-
nativeAdInfo.putDouble( "mediaContentAspectRatio", 1.0 );
|
|
406
|
-
}
|
|
407
|
-
else
|
|
408
|
-
{
|
|
409
|
-
nativeAdInfo.putDouble( "mediaContentAspectRatio", aspectRatio );
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
else
|
|
450
|
+
if ( aspectRatio > 0 )
|
|
413
451
|
{
|
|
414
|
-
nativeAdInfo.putDouble( "mediaContentAspectRatio",
|
|
452
|
+
nativeAdInfo.putDouble( "mediaContentAspectRatio", aspectRatio );
|
|
415
453
|
}
|
|
416
454
|
|
|
417
455
|
nativeAdInfo.putBoolean( "isIconImageAvailable", ( ad.getIcon() != null ) );
|
|
@@ -305,21 +305,10 @@
|
|
|
305
305
|
nativeAdInfo[@"callToAction"] = ad.callToAction;
|
|
306
306
|
nativeAdInfo[@"starRating"] = ad.starRating;
|
|
307
307
|
|
|
308
|
-
|
|
308
|
+
// The aspect ratio can be 0.0f when it is not provided by the network.
|
|
309
|
+
if ( ad.mediaContentAspectRatio > 0 )
|
|
309
310
|
{
|
|
310
|
-
|
|
311
|
-
if ( fabs(ad.mediaContentAspectRatio) < FLT_EPSILON )
|
|
312
|
-
{
|
|
313
|
-
nativeAdInfo[@"mediaContentAspectRatio"] = @(1.0);
|
|
314
|
-
}
|
|
315
|
-
else
|
|
316
|
-
{
|
|
317
|
-
nativeAdInfo[@"mediaContentAspectRatio"] = @(ad.mediaContentAspectRatio);
|
|
318
|
-
}
|
|
319
|
-
}
|
|
320
|
-
else
|
|
321
|
-
{
|
|
322
|
-
nativeAdInfo[@"mediaContentAspectRatio"] = @(1.0);
|
|
311
|
+
nativeAdInfo[@"mediaContentAspectRatio"] = @(ad.mediaContentAspectRatio);
|
|
323
312
|
}
|
|
324
313
|
|
|
325
314
|
nativeAdInfo[@"isIconImageAvailable"] = @(ad.icon != nil);
|
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.
|
|
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 => "
|
|
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}
|
|
83
|
+
<TouchableOpacity {...props} ref={callToActionRef}>
|
|
84
|
+
<Text {...props}>
|
|
85
85
|
{nativeAd.callToAction || null}
|
|
86
86
|
</Text>
|
|
87
87
|
</TouchableOpacity>
|
|
@@ -94,12 +94,12 @@ export const IconView = (props) => {
|
|
|
94
94
|
const {nativeAd, nativeAdView} = useContext(NativeAdViewContext);
|
|
95
95
|
|
|
96
96
|
useEffect(() => {
|
|
97
|
-
if (!nativeAdView || !nativeAd.image) return;
|
|
97
|
+
if (!nativeAdView || !nativeAd.image || !imageRef.current) return;
|
|
98
98
|
|
|
99
99
|
nativeAdView.setNativeProps({
|
|
100
100
|
iconView: findNodeHandle(imageRef.current),
|
|
101
101
|
});
|
|
102
|
-
}, [nativeAd, nativeAdView]);
|
|
102
|
+
}, [nativeAd, nativeAdView, imageRef.current]);
|
|
103
103
|
|
|
104
104
|
if (!nativeAdView) return null;
|
|
105
105
|
|