Skip to content

Commit

Permalink
Release: version 4.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Shayefar committed Nov 12, 2015
1 parent 1415bfe commit 2a60048
Show file tree
Hide file tree
Showing 189 changed files with 2,457 additions and 999 deletions.
18 changes: 17 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,26 @@
## Version 4.1.0 (November 12, 2015)

- A number of Native Ad classes now require `Activity` instances instead of `Context`. Most users should be unaffected by this change, and it fixes a crash caused by handling themes incorrectly. The following classes are affected:

- `CustomEventNative` and its implementations including `MoPubCustomEventNative`.
- `MoPubAdAdapter` and `MoPubRecyclerAdapter`.
- `MoPubAdRenderer` and its implementations.
- `MoPubStreamAdPlacer`
- `MoPubNative`
- `NativeAd` and `NativeAdSource`
- `NativeAdViewHelper`

- Vungle's ad adapters have been updated for their 3.3.0 SDK.
- Tapjoy adapters for interstitials and rewarded video are included for their 11.2.2 SDK.
- The Play Services adapters have been tested with Play Services 7.8.0.

## Version 4.0.0 (October 6, 2015)

Version 4.0.0 includes a number of improvements to our Native Ads systems under the hood. This means a few changes for publishers integrating the ads. The [Native Ads Integration Guide](https://github.com/mopub/mopub-android-sdk/wiki/Native-Ads-Integration) describes all the steps you'll need to integrate 4.0.0.

**Native Ads Changes**
- `MoPubNativeAdRenderer` has been replaced by `MoPubStaticNativeRenderer`
- When requesting ads using `MoPubNative`, you must instantiate and register a `MoPubStaticNativeAdRenderer`. See the [Integration Document](https://github.com/mopub/mopub-android-sdk/wiki/Legacy-Native-Ads-Integration) for more details.
- When requesting ads using `MoPubNative`, you must instantiate and register a `MoPubStaticNativeAdRenderer`. See the [Integration Document](https://github.com/mopub/mopub-android-sdk/wiki/Manual-Integration-of-Native-Ads) for more details.
- `NativeResponse` has been replaced with `NativeAd`
- `NativeAd` has a new API that supports creating and rendering `View`s for Native Ads.
- `#createAdView` returns a `View` that can hold data for the `NativeAd`
Expand Down
31 changes: 13 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ The MoPub SDK is available via:
}
dependencies {
compile('com.mopub:mopub-sdk:4.0.0@aar') {
compile('com.mopub:mopub-sdk:4.1.0@aar') {
transitive = true
}
}
Expand Down Expand Up @@ -61,24 +61,19 @@ The MoPub SDK is available via:
## New in this Version
Please view the [changelog](https://github.com/mopub/mopub-android-sdk/blob/master/CHANGELOG.md) for a complete list of additions, fixes, and enhancements in the latest release.
- A number of Native Ad classes now require `Activity` instances instead of `Context`. Most users should be unaffected by this change, and it fixes a crash caused by handling themes incorrectly. The following classes are affected:
Version 4.0.0 includes a number of improvements to our Native Ads systems under the hood. This means a few changes for publishers integrating the ads. The [Native Ads Integration Guide](https://github.com/mopub/mopub-android-sdk/wiki/Native-Ads-Integration) describes all the steps you'll need to integrate 4.0.0.
- `CustomEventNative` and its implementations including `MoPubCustomEventNative`.
- `MoPubAdAdapter` and `MoPubRecyclerAdapter`.
- `MoPubAdRenderer` and its implementations.
- `MoPubStreamAdPlacer`
- `MoPubNative`
- `NativeAd` and `NativeAdSource`
- `NativeAdViewHelper`
**Native Ads Changes**
- `MoPubNativeAdRenderer` has been replaced by `MoPubStaticNativeRenderer`
- When requesting ads using `MoPubNative`, you must instantiate and register a `MoPubStaticNativeAdRenderer`. See the [Integration Document](https://github.com/mopub/mopub-android-sdk/wiki/Legacy-Native-Ads-Integration) for more details.
- `NativeResponse` has been replaced with `NativeAd`
- `NativeAd` has a new API that supports creating and rendering `View`s for Native Ads.
- `#createAdView` returns a `View` that can hold data for the `NativeAd`
- `#renderAdView` will populate the `View` with ad data.
- Other lifecycle methods from `NativeResponse` remain:
- `#prepare`, `#clear`, `#destroy`
- The process of writing new `CustomEventNative` instances has changed. These changes will support more dynamic, flexible, and attractive Native Ad formats in the future. All bundled native Custom Event files have been updated to use the new API.
**Removed Old Code**
- Removed legacy banner/interestitial listeners, deprecated in 1.11
- Removed legacy custom event implementation ("custom event methods") deprecated in 1.10
- Vungle's ad adapters have been updated for their 3.3.0 SDK.
- Tapjoy adapters for interstitials and rewarded video are included for their 11.2.2 SDK.
- The Play Services adapters have been tested with Play Services 7.8.0.
## Requirements
Expand All @@ -87,7 +82,7 @@ Version 4.0.0 includes a number of improvements to our Native Ads systems under
- android-support-annotations.jar, r22 (**Updated in 3.7.0**)
- android-support-v7-recyclerview.jar, r22 (**Updated in 3.9.0**)
- MoPub Volley Library (mopub-volley-1.1.0.jar - available on JCenter) (**Updated in 3.6.0**)
- **Recommended** Google Play Services 7.0.0
- **Recommended** Google Play Services 7.8.0
## Upgrading from 3.2.0 and Prior
In 3.3.0 a dependency on android-support-annotations.jar was added. If you are using Maven or Gradle to include the MoPub SDK, this dependency is included in the build scripts. For instructions on adding dependencies for Eclipse projects, see our [Getting Started Guide](https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started#adding-the-support-libraries-to-your-project)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import static com.google.android.gms.ads.AdSize.MEDIUM_RECTANGLE;

/*
* Compatible with version 7.0.0 of the Google Play Services SDK.
* Compatible with version 7.8.0 of the Google Play Services SDK.
*/

// Note: AdMob ads will now use this class as Google has deprecated the AdMob SDK.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
import java.util.Map;

/*
* Compatible with version 7.0.0 of the Google Play Services SDK.
* Compatible with version 7.8.0 of the Google Play Services SDK.
*/

// Note: AdMob ads will now use this class as Google has deprecated the AdMob SDK.
Expand Down
92 changes: 92 additions & 0 deletions extras/src/com/mopub/mobileads/TapjoyInterstitial.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
package com.mopub.mobileads;

import android.content.Context;
import android.text.TextUtils;

import com.mopub.common.logging.MoPubLog;
import com.tapjoy.TJActionRequest;
import com.tapjoy.TJError;
import com.tapjoy.TJPlacement;
import com.tapjoy.TJPlacementListener;

import java.util.Map;

// Tested with Tapjoy SDK 11.1.0
public class TapjoyInterstitial extends CustomEventInterstitial implements TJPlacementListener {
private TJPlacement tjPlacement;
private CustomEventInterstitialListener mInterstitialListener;

@Override
protected void loadInterstitial(Context context,
CustomEventInterstitialListener customEventInterstitialListener,
Map<String, Object> localExtras,
Map<String, String> serverExtras) {
MoPubLog.d("Requesting Tapjoy interstitial");

mInterstitialListener = customEventInterstitialListener;

String name = serverExtras.get("name");
if (TextUtils.isEmpty(name)) {
MoPubLog.d("Tapjoy interstitial loaded with empty 'name' field. Request will fail.");
}
tjPlacement = new TJPlacement(context, name, this);
tjPlacement.requestContent();
}

@Override
protected void onInvalidate() {
// No custom cleanup to do here.
}

@Override
protected void showInterstitial() {
MoPubLog.d("Tapjoy interstitial will be shown");
tjPlacement.showContent();
}

// Tapjoy

@Override
public void onRequestSuccess(TJPlacement placement) {
if (placement.isContentAvailable()) {
MoPubLog.d("Tapjoy interstitial request successful");
mInterstitialListener.onInterstitialLoaded();
} else {
MoPubLog.d("No Tapjoy interstitials available");
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.NETWORK_NO_FILL);
}
}

@Override
public void onRequestFailure(TJPlacement placement, TJError error) {
MoPubLog.d("Tapjoy interstitial request failed");
mInterstitialListener.onInterstitialFailed(MoPubErrorCode.NETWORK_NO_FILL);
}

@Override
public void onContentShow(TJPlacement placement) {
MoPubLog.d("Tapjoy interstitial shown");
mInterstitialListener.onInterstitialShown();
}

@Override
public void onContentDismiss(TJPlacement placement) {
MoPubLog.d("Tapjoy interstitial dismissed");
mInterstitialListener.onInterstitialDismissed();
}

@Override
public void onContentReady(TJPlacement placement) {
}

@Override
public void onPurchaseRequest(TJPlacement placement, TJActionRequest request,
String productId) {
}

@Override
public void onRewardRequest(TJPlacement placement, TJActionRequest request, String itemId,
int quantity) {
}

}
132 changes: 132 additions & 0 deletions extras/src/com/mopub/mobileads/TapjoyRewardedVideo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
package com.mopub.mobileads;

import android.app.Activity;
import android.support.annotation.NonNull;
import android.text.TextUtils;

import com.mopub.common.LifecycleListener;
import com.mopub.common.MediationSettings;
import com.mopub.common.logging.MoPubLog;
import com.tapjoy.TJActionRequest;
import com.tapjoy.TJError;
import com.tapjoy.TJPlacement;
import com.tapjoy.TJPlacementListener;

import java.util.Map;

// Tested with Tapjoy SDK 11.1.0
public class TapjoyRewardedVideo extends CustomEventRewardedVideo {
private static final String TAPJOY_AD_NETWORK_CONSTANT = "tapjoy_id";
private TJPlacement tjPlacement;
private static TapjoyRewardedVideoListener sTapjoyListener = new TapjoyRewardedVideoListener();

@Override
protected CustomEventRewardedVideoListener getVideoListenerForSdk() {
return sTapjoyListener;
}

@Override
protected LifecycleListener getLifecycleListener() {
return null;
}

@Override
protected String getAdNetworkId() {
return TAPJOY_AD_NETWORK_CONSTANT;
}

@Override
protected void onInvalidate() {
}

@Override
protected boolean checkAndInitializeSdk(@NonNull Activity launcherActivity,
@NonNull Map<String, Object> localExtras,
@NonNull Map<String, String> serverExtras)
throws Exception {
// Always return false, no special initialization steps to be done from here
return false;
}

@Override
protected void loadWithSdkInitialized(@NonNull Activity activity,
@NonNull Map<String, Object> localExtras,
@NonNull Map<String, String> serverExtras)
throws Exception {
MoPubLog.d("Requesting Tapjoy rewarded video");

String name = serverExtras.get("name");
if (TextUtils.isEmpty(name)) {
MoPubLog.d("Tapjoy interstitial loaded with empty 'name' field. Request will fail.");
}
tjPlacement = new TJPlacement(activity, name, sTapjoyListener);
tjPlacement.requestContent();
}

@Override
protected boolean hasVideoAvailable() {
return tjPlacement.isContentAvailable();
}

@Override
protected void showVideo() {
if (hasVideoAvailable()) {
MoPubLog.d("Tapjoy rewarded video will be shown.");
tjPlacement.showContent();
} else {
MoPubLog.d("Failed to show Tapjoy rewarded video.");
}

}

private static class TapjoyRewardedVideoListener implements TJPlacementListener, CustomEventRewardedVideoListener {
@Override
public void onRequestSuccess(TJPlacement placement) {
if (!placement.isContentAvailable()) {
MoPubLog.d("No Tapjoy rewarded videos available");
MoPubRewardedVideoManager.onRewardedVideoLoadFailure(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT, MoPubErrorCode.NETWORK_NO_FILL);
}
}

@Override
public void onContentReady(TJPlacement placement) {
MoPubLog.d("Tapjoy rewarded video content is ready");
MoPubRewardedVideoManager.onRewardedVideoLoadSuccess(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT);
}

@Override
public void onRequestFailure(TJPlacement placement, TJError error) {
MoPubLog.d("Tapjoy rewarded video request failed");
MoPubRewardedVideoManager.onRewardedVideoLoadFailure(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT, MoPubErrorCode.NETWORK_NO_FILL);
}

@Override
public void onContentShow(TJPlacement placement) {
MoPubLog.d("Tapjoy rewarded video content shown");
MoPubRewardedVideoManager.onRewardedVideoStarted(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT);
}

@Override
public void onContentDismiss(TJPlacement placement) {
MoPubLog.d("Tapjoy rewarded video content dismissed");
MoPubRewardedVideoManager.onRewardedVideoClosed(TapjoyRewardedVideo.class, TAPJOY_AD_NETWORK_CONSTANT);
}

@Override
public void onPurchaseRequest(TJPlacement placement, TJActionRequest request,
String productId) {
}

@Override
public void onRewardRequest(TJPlacement placement, TJActionRequest request, String itemId,
int quantity) {
}
}

public static final class TapjoyMediationSettings implements MediationSettings {
public TapjoyMediationSettings() {

}
}

}
Loading

0 comments on commit 2a60048

Please sign in to comment.