Skip to content

Commit

Permalink
Release: version 3.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Joe Blubaugh committed Apr 3, 2015
1 parent 10eef43 commit ec95adb
Show file tree
Hide file tree
Showing 92 changed files with 3,861 additions and 719 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## Version 3.6.0 (April 3, 2015)

- **Facebook Update** Updated supported Facebook Audience Network version to 3.23.1
- **Bug fix** Fixed a bug where interstitials could leak memory; Fixes [issue #153](https://github.com/mopub/mopub-android-sdk/issues/153)
- **VAST Video** Updated the VAST video player to support Progress events.
- Updated **Volley** version to 1.1.0.

## Version 3.5.0 (March 10, 2015)

- Dependency changes in Maven and Gradle. No new dependencies have been added, but your build script will need to change slightly to include JCenter. See our [Getting Started Guide](https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started#adding-the-support-libraries-to-your-project) for complete instructions.
Expand Down
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,17 @@ Integration instructions are available on the [wiki](https://github.com/mopub/mo

Please view the [changelog](https://github.com/mopub/mopub-android-sdk/blob/master/CHANGELOG.md) for details.

- Dependency changes in Maven and Gradle. No new dependencies have been added, but your build script will need to change slightly to include JCenter. See our [Getting Started Guide](https://github.com/mopub/mopub-android-sdk/wiki/Getting-Started#adding-the-support-libraries-to-your-project) for complete instructions.
- Security Improvement: removed the @JavascriptInterface annotation for WebViews.
- Fixed a bug where video playback would sometimes fail to stop when an ad was dismissed.
- Fixed a bug where it was not possible to disable ad refresh; Fixes [issue #148](https://github.com/mopub/mopub-android-sdk/issues/148)
- Fixed a null pointer exception in AdViewController; Fixes [issue #150](https://github.com/mopub/mopub-android-sdk/issues/150)
- **Facebook Update** Updated supported Facebook Audience Network version to 3.23.1
- **Bug fix** Fixed a bug where interstitials could leak memory; Fixes [issue #153](https://github.com/mopub/mopub-android-sdk/issues/153)
- **VAST Video** Updated the VAST video player to support Progress events.
- Updated **Volley** version to 1.1.0.

## Requirements

- Android 2.3.1 (API Version 9) and up
- android-support-v4.jar
- android-support-annotations.jar (**New in 3.3.0**)
- MoPub Volley Library (mopub-volley-1.0.0.jar - available on JCenter) (**Updated in 3.5.0**)
- MoPub Volley Library (mopub-volley-1.1.0.jar - available on JCenter) (**Updated in 3.6.0**)
- **Recommended** Google Play Services 5.0.89 & up.

## Upgrading from 3.2.0 and Prior
Expand Down
47 changes: 43 additions & 4 deletions extras/src/com/mopub/mobileads/FacebookBanner.java
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
package com.mopub.mobileads;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.util.Log;

import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdListener;
import com.facebook.ads.AdSize;
import com.facebook.ads.AdView;
import com.mopub.common.DataKeys;
import com.mopub.common.util.Views;

import java.util.Map;

/**
* Tested with Facebook SDK 3.18.1.
* Tested with Facebook SDK 3.23.1.
*/
public class FacebookBanner extends CustomEventBanner implements AdListener {
private static final String PLACEMENT_ID_KEY = "placement_id";
Expand All @@ -33,15 +36,32 @@ protected void loadBanner(final Context context,
mBannerListener = customEventBannerListener;

final String placementId;
if (extrasAreValid(serverExtras)) {
if (serverExtrasAreValid(serverExtras)) {
placementId = serverExtras.get(PLACEMENT_ID_KEY);
} else {
mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
return;
}

mFacebookBanner = new AdView(context, placementId, AdSize.BANNER_320_50);
int width;
int height;
if (localExtrasAreValid(localExtras)) {
width = (Integer) localExtras.get(DataKeys.AD_WIDTH);
height = (Integer) localExtras.get(DataKeys.AD_HEIGHT);
} else {
mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
return;
}

AdSize adSize = calculateAdSize(width, height);
if (adSize == null) {
mBannerListener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
return;
}

mFacebookBanner = new AdView(context, placementId, adSize);
mFacebookBanner.setAdListener(this);
mFacebookBanner.disableAutoRefresh();
mFacebookBanner.loadAd();
}

Expand Down Expand Up @@ -82,11 +102,30 @@ public void onAdClicked(Ad ad) {
mBannerListener.onBannerClicked();
}

private boolean extrasAreValid(final Map<String, String> serverExtras) {
private boolean serverExtrasAreValid(final Map<String, String> serverExtras) {
final String placementId = serverExtras.get(PLACEMENT_ID_KEY);
return (placementId != null && placementId.length() > 0);
}

private boolean localExtrasAreValid(@NonNull final Map<String, Object> localExtras) {
return localExtras.get(DataKeys.AD_WIDTH) instanceof Integer
&& localExtras.get(DataKeys.AD_HEIGHT) instanceof Integer;
}

@Nullable
private AdSize calculateAdSize(int width, int height) {
// Use the smallest AdSize that will properly contain the adView
if (height <= AdSize.BANNER_320_50.getHeight()) {
return AdSize.BANNER_320_50;
} else if (height <= AdSize.BANNER_HEIGHT_90.getHeight()) {
return AdSize.BANNER_HEIGHT_90;
} else if (height <= AdSize.RECTANGLE_HEIGHT_250.getHeight()) {
return AdSize.RECTANGLE_HEIGHT_250;
} else {
return null;
}
}

@Deprecated // for testing
AdView getAdView() {
return mFacebookBanner;
Expand Down
2 changes: 1 addition & 1 deletion extras/src/com/mopub/mobileads/FacebookInterstitial.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
import java.util.Map;

/**
* Tested with Facebook SDK 3.18.1.
* Tested with Facebook SDK 3.23.1.
*/
public class FacebookInterstitial extends CustomEventInterstitial implements InterstitialAdListener {
private static final String PLACEMENT_ID_KEY = "placement_id";
Expand Down
2 changes: 1 addition & 1 deletion extras/src/com/mopub/nativeads/FacebookNative.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import java.util.Map;

/*
* Tested with Facebook SDK 3.18.1
* Tested with Facebook SDK 3.23.1
*/
public class FacebookNative extends CustomEventNative {
private static final String PLACEMENT_ID_KEY = "placement_id";
Expand Down
6 changes: 3 additions & 3 deletions mopub-sample/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mopub.simpleadsdemo"
android:versionCode="21"
android:versionName="3.5.0">
<uses-sdk android:minSdkVersion="9"
android:versionCode="22"
android:versionName="3.6.0">
<uses-sdk android:minSdkVersion="9"
android:targetSdkVersion="19"/>

<uses-permission android:name="android.permission.INTERNET" />
Expand Down
4 changes: 2 additions & 2 deletions mopub-sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ android {
buildToolsVersion '21.1.1'

defaultConfig {
versionCode 21
versionName "3.5.0"
versionCode 22
versionName "3.6.0"
minSdkVersion 9
targetSdkVersion 19
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,11 @@ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle sa
views.mLoadButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mMoPubInterstitial == null) {
mMoPubInterstitial = new MoPubInterstitial(getActivity(), adUnitId);
mMoPubInterstitial.setInterstitialAdListener(InterstitialDetailFragment.this);
}
final String keywords = views.mKeywordsField.getText().toString();
mMoPubInterstitial = new MoPubInterstitial(getActivity(), adUnitId);
mMoPubInterstitial.setInterstitialAdListener(InterstitialDetailFragment.this);
mMoPubInterstitial.setKeywords(keywords);
mMoPubInterstitial.load();
mShowButton.setEnabled(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
package com.mopub.simpleadsdemo;

import android.content.Context;
import android.support.annotation.NonNull;

import com.mopub.common.logging.MoPubLog;
import com.mopub.mobileads.MoPubErrorCode;

import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.LogManager;
import java.util.logging.LogRecord;
import java.util.logging.Logger;

/**
* Used to intercept logs so that we can view logs at a lower level
* than Verbose (ie. Level.FINEST). This will show a toast when we
* receive a matching error from the mopub sdk.
*/
public class LoggingUtils {
private LoggingUtils() {
}

/**
* The name of the custom logger we're looking for
*/
private static final String LOGGER_NAME = "com.mopub";

private static boolean sEnabled;

/**
* Makes it so that this app can intercept Level.FINEST log messages.
* This is not thread safe.
*
* @param context Needs a context to send toasts.
*/
static void enableCanaryLogging(@NonNull final Context context) {
if (sEnabled) {
return;
}

final Handler handler = new SampleAppLogHandler(context.getApplicationContext());
final Logger logger = getLogger();

logger.setLevel(Level.ALL);
logger.addHandler(handler);

sEnabled = true;
}

private static Logger getLogger() {
// This makes sure the static block in MoPubLog is executed before
// LogManager#getLogManager is called.
MoPubLog.c("Canary level logging enabled");

return LogManager.getLogManager().getLogger(LOGGER_NAME);
}

private static class SampleAppLogHandler extends Handler {

@NonNull
private final Context mContext;

protected SampleAppLogHandler(@NonNull final Context context) {
super();
mContext = context;
}

@Override
public void publish(final LogRecord logRecord) {
// Toasts the warmup message if X-Warmup flag is set to 1
if (logRecord != null && MoPubErrorCode.WARMUP.toString().equals(logRecord.getMessage())) {
Utils.logToast(mContext, MoPubErrorCode.WARMUP.toString());
}
}

@Override
public void flush() {
}

@Override
public void close() throws SecurityException {
}
}
}

Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
package com.mopub.simpleadsdemo;

import android.annotation.TargetApi;
import android.os.Build;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.webkit.WebView;

import com.mopub.common.MoPub;


public class MoPubSampleActivity extends FragmentActivity {

// Sample app web views are debuggable.
static {
setWebDebugging();
}

@TargetApi(Build.VERSION_CODES.KITKAT)
private static void setWebDebugging() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
}

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Expand All @@ -29,5 +45,9 @@ protected void onCreate(Bundle savedInstanceState) {
.add(R.id.fragment_container, listFragment)
.commit();
}

// Intercepts all logs including Level.FINEST so we can show a toast
// that is not normally user-facing. This is only used for native ads.
LoggingUtils.enableCanaryLogging(this);
}
}
6 changes: 3 additions & 3 deletions mopub-sdk/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ android {
buildToolsVersion '21.1.1'

defaultConfig {
versionCode 21
versionName "3.5.0"
versionCode 22
versionName "3.6.0"
minSdkVersion 9
targetSdkVersion 19
consumerProguardFiles 'proguard.txt'
Expand Down Expand Up @@ -50,7 +50,7 @@ android {
dependencies {
compile 'com.android.support:support-v4:19.1.+'
compile 'com.android.support:support-annotations:20.0.0'
compile 'com.mopub.volley:mopub-volley:1.0.0'
compile 'com.mopub.volley:mopub-volley:1.1.0'
}

// Don't run the Robolectric Unit Tests. They don't build properly in Gradle or Android Studio in this version.
Expand Down
2 changes: 1 addition & 1 deletion mopub-sdk/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
<dependency>
<groupId>com.mopub.volley</groupId>
<artifactId>mopub-volley</artifactId>
<version>1.0.0</version>
<version>1.1.0</version>
</dependency>

<!--test-->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
import android.net.Uri;
import android.text.TextUtils;

import com.mopub.network.Networking;
import com.mopub.network.PlayServicesUrlRewriter;

public abstract class BaseUrlGenerator {



private StringBuilder mStringBuilder;
private boolean mFirstParam;

public abstract String generateUrlString(String serverHostname);

protected void initUrlString(String serverHostname, String handlerType) {
mStringBuilder = new StringBuilder("http://" + serverHostname + handlerType);
String scheme = Networking.useHttps() ? Constants.HTTPS : Constants.HTTP;
mStringBuilder = new StringBuilder(scheme).append("://").append(serverHostname).append(handlerType);
mFirstParam = true;
}

Expand Down
Loading

0 comments on commit ec95adb

Please sign in to comment.