GoogleAdManager/22.1.0.1
This commit is contained in:
Родитель
f8596beb2e
Коммит
1b595f8e08
|
@ -1,5 +1,8 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## 22.1.0.1
|
||||||
|
* Support for native ads in external plugins (e.g. React Native).
|
||||||
|
|
||||||
## 22.1.0.0
|
## 22.1.0.0
|
||||||
* Certified with GoogleAdManager SDK 22.1.0.
|
* Certified with GoogleAdManager SDK 22.1.0.
|
||||||
* Remove the `getPrivacySetting()` function and call privacy methods directly.
|
* Remove the `getPrivacySetting()` function and call privacy methods directly.
|
||||||
|
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
private val versionMajor = 22
|
private val versionMajor = 22
|
||||||
private val versionMinor = 1
|
private val versionMinor = 1
|
||||||
private val versionPatch = 0
|
private val versionPatch = 0
|
||||||
private val versionAdapterPatch = 0
|
private val versionAdapterPatch = 1
|
||||||
|
|
||||||
val libraryVersionName by extra("${versionMajor}.${versionMinor}.${versionPatch}.${versionAdapterPatch}")
|
val libraryVersionName by extra("${versionMajor}.${versionMinor}.${versionPatch}.${versionAdapterPatch}")
|
||||||
val libraryVersionCode by extra((versionMajor * 1000000) + (versionMinor * 10000) + (versionPatch * 100) + versionAdapterPatch)
|
val libraryVersionCode by extra((versionMajor * 1000000) + (versionMinor * 10000) + (versionPatch * 100) + versionAdapterPatch)
|
||||||
|
|
|
@ -10,6 +10,7 @@ import android.text.TextUtils;
|
||||||
import android.util.DisplayMetrics;
|
import android.util.DisplayMetrics;
|
||||||
import android.view.Display;
|
import android.view.Display;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
import android.view.WindowManager;
|
import android.view.WindowManager;
|
||||||
import android.widget.ImageView;
|
import android.widget.ImageView;
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAd;
|
||||||
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;
|
import com.google.android.gms.ads.rewardedinterstitial.RewardedInterstitialAdLoadCallback;
|
||||||
|
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
|
@ -83,6 +85,13 @@ public class GoogleAdManagerMediationAdapter
|
||||||
extends MediationAdapterBase
|
extends MediationAdapterBase
|
||||||
implements MaxInterstitialAdapter, /* MaxAppOpenAdapter */ MaxRewardedInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter /* MaxNativeAdAdapter */
|
implements MaxInterstitialAdapter, /* MaxAppOpenAdapter */ MaxRewardedInterstitialAdapter, MaxRewardedAdapter, MaxAdViewAdapter /* MaxNativeAdAdapter */
|
||||||
{
|
{
|
||||||
|
private static final int TITLE_LABEL_TAG = 1;
|
||||||
|
private static final int MEDIA_VIEW_CONTAINER_TAG = 2;
|
||||||
|
private static final int ICON_VIEW_TAG = 3;
|
||||||
|
private static final int BODY_VIEW_TAG = 4;
|
||||||
|
private static final int CALL_TO_ACTION_VIEW_TAG = 5;
|
||||||
|
private static final int ADVERTISER_VIEW_TAG = 8;
|
||||||
|
|
||||||
private static final AtomicBoolean initialized = new AtomicBoolean();
|
private static final AtomicBoolean initialized = new AtomicBoolean();
|
||||||
|
|
||||||
private AdManagerInterstitialAd interstitialAd;
|
private AdManagerInterstitialAd interstitialAd;
|
||||||
|
@ -1406,46 +1415,115 @@ public class GoogleAdManagerMediationAdapter
|
||||||
private class MaxGoogleAdManagerNativeAd
|
private class MaxGoogleAdManagerNativeAd
|
||||||
extends MaxNativeAd
|
extends MaxNativeAd
|
||||||
{
|
{
|
||||||
public MaxGoogleAdManagerNativeAd(final Builder builder)
|
public MaxGoogleAdManagerNativeAd(final Builder builder) { super( builder ); }
|
||||||
{
|
|
||||||
super( builder );
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void prepareViewForInteraction(final MaxNativeAdView maxNativeAdView)
|
public void prepareViewForInteraction(final MaxNativeAdView maxNativeAdView)
|
||||||
|
{
|
||||||
|
prepareForInteraction( Collections.<View>emptyList(), maxNativeAdView );
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean prepareForInteraction(final List<View> clickableViews, final ViewGroup container)
|
||||||
{
|
{
|
||||||
final NativeAd nativeAd = GoogleAdManagerMediationAdapter.this.nativeAd;
|
final NativeAd nativeAd = GoogleAdManagerMediationAdapter.this.nativeAd;
|
||||||
if ( nativeAd == null )
|
if ( nativeAd == null )
|
||||||
{
|
{
|
||||||
e( "Failed to register native ad views: native ad is null." );
|
e( "Failed to register native ad views: native ad is null." );
|
||||||
return;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeAdView = new NativeAdView( maxNativeAdView.getContext() );
|
nativeAdView = new NativeAdView( container.getContext() );
|
||||||
|
|
||||||
// The Google Native Ad View needs to be wrapped around the main native ad view.
|
// Native integrations
|
||||||
View mainView = maxNativeAdView.getMainView();
|
if ( container instanceof MaxNativeAdView )
|
||||||
maxNativeAdView.removeView( mainView );
|
|
||||||
nativeAdView.addView( mainView );
|
|
||||||
maxNativeAdView.addView( nativeAdView );
|
|
||||||
|
|
||||||
nativeAdView.setIconView( maxNativeAdView.getIconImageView() );
|
|
||||||
nativeAdView.setHeadlineView( maxNativeAdView.getTitleTextView() );
|
|
||||||
nativeAdView.setAdvertiserView( maxNativeAdView.getAdvertiserTextView() );
|
|
||||||
nativeAdView.setBodyView( maxNativeAdView.getBodyTextView() );
|
|
||||||
nativeAdView.setCallToActionView( maxNativeAdView.getCallToActionButton() );
|
|
||||||
|
|
||||||
View mediaView = getMediaView();
|
|
||||||
if ( mediaView instanceof MediaView )
|
|
||||||
{
|
{
|
||||||
nativeAdView.setMediaView( (MediaView) mediaView );
|
MaxNativeAdView maxNativeAdView = (MaxNativeAdView) container;
|
||||||
|
|
||||||
|
// The Google Native Ad View needs to be wrapped around the main native ad view.
|
||||||
|
View mainView = maxNativeAdView.getMainView();
|
||||||
|
maxNativeAdView.removeView( mainView );
|
||||||
|
nativeAdView.addView( mainView );
|
||||||
|
maxNativeAdView.addView( nativeAdView );
|
||||||
|
|
||||||
|
nativeAdView.setIconView( maxNativeAdView.getIconImageView() );
|
||||||
|
nativeAdView.setHeadlineView( maxNativeAdView.getTitleTextView() );
|
||||||
|
nativeAdView.setAdvertiserView( maxNativeAdView.getAdvertiserTextView() );
|
||||||
|
nativeAdView.setBodyView( maxNativeAdView.getBodyTextView() );
|
||||||
|
nativeAdView.setCallToActionView( maxNativeAdView.getCallToActionButton() );
|
||||||
|
|
||||||
|
View mediaView = getMediaView();
|
||||||
|
if ( mediaView instanceof MediaView )
|
||||||
|
{
|
||||||
|
nativeAdView.setMediaView( (MediaView) mediaView );
|
||||||
|
}
|
||||||
|
else if ( mediaView instanceof ImageView )
|
||||||
|
{
|
||||||
|
nativeAdView.setImageView( mediaView );
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeAdView.setNativeAd( nativeAd );
|
||||||
}
|
}
|
||||||
else if ( mediaView instanceof ImageView )
|
// Plugins
|
||||||
{
|
{
|
||||||
nativeAdView.setImageView( mediaView );
|
for ( View view : clickableViews )
|
||||||
|
{
|
||||||
|
int tag = (int) view.getTag();
|
||||||
|
|
||||||
|
if ( tag == TITLE_LABEL_TAG )
|
||||||
|
{
|
||||||
|
nativeAdView.setHeadlineView( view );
|
||||||
|
}
|
||||||
|
else if ( tag == ICON_VIEW_TAG )
|
||||||
|
{
|
||||||
|
nativeAdView.setIconView( view );
|
||||||
|
}
|
||||||
|
else if ( tag == BODY_VIEW_TAG )
|
||||||
|
{
|
||||||
|
nativeAdView.setBodyView( view );
|
||||||
|
}
|
||||||
|
else if ( tag == CALL_TO_ACTION_VIEW_TAG )
|
||||||
|
{
|
||||||
|
nativeAdView.setCallToActionView( view );
|
||||||
|
}
|
||||||
|
else if ( tag == ADVERTISER_VIEW_TAG )
|
||||||
|
{
|
||||||
|
nativeAdView.setAdvertiserView( view );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
View mediaView = getMediaView();
|
||||||
|
ViewGroup midContainer = ( mediaView != null ) ? (ViewGroup) mediaView.getParent() : null;
|
||||||
|
|
||||||
|
// mediaView must be already added to the container unless the user skipped it, but the
|
||||||
|
// parent may not be the container, although it should be within the hierarchy
|
||||||
|
if ( midContainer != null && container.findViewById( midContainer.getId() ) != null )
|
||||||
|
{
|
||||||
|
// The Google Native Ad View needs to be inserted between mediaView and midContainer
|
||||||
|
// for mediaView to be visible
|
||||||
|
midContainer.removeView( mediaView );
|
||||||
|
nativeAdView.addView( mediaView );
|
||||||
|
midContainer.addView( nativeAdView );
|
||||||
|
|
||||||
|
if ( mediaView instanceof MediaView )
|
||||||
|
{
|
||||||
|
nativeAdView.setMediaView( (MediaView) mediaView );
|
||||||
|
}
|
||||||
|
else if ( mediaView instanceof ImageView )
|
||||||
|
{
|
||||||
|
nativeAdView.setImageView( mediaView );
|
||||||
|
}
|
||||||
|
|
||||||
|
nativeAdView.setNativeAd( nativeAd );
|
||||||
|
|
||||||
|
// stretch nativeAdView out to midContainer
|
||||||
|
nativeAdView.measure( View.MeasureSpec.makeMeasureSpec( midContainer.getWidth(), View.MeasureSpec.EXACTLY ),
|
||||||
|
View.MeasureSpec.makeMeasureSpec( midContainer.getHeight(), View.MeasureSpec.EXACTLY ) );
|
||||||
|
nativeAdView.layout( 0, 0, midContainer.getWidth(), midContainer.getHeight() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeAdView.setNativeAd( nativeAd );
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Загрузка…
Ссылка в новой задаче