Skip to content

Commit

Permalink
Release: version 1.17.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Nathan Shayefar committed Feb 20, 2014
1 parent 9809178 commit f0504c6
Show file tree
Hide file tree
Showing 14 changed files with 277 additions and 74 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,13 @@
- All `WebView`s are removed from their parents before `destroy()`; fixes [GitHub issue #38](https://github.com/mopub/mopub-android-sdk/issues/38)
- Removed previously-deprecated `HTML5AdView`

### Version 1.17.2 (Feb 20, 2014)

- Updated InMobi custom events to support InMobi SDK 4.0.3+ only
- MRAID viewable property now correctly updates on viewability change
- `MraidView` properly handles null schemes; fixes [GitHub issue #63](https://github.com/mopub/mopub-android-sdk/pull/63)
- Internal disk LRU cache correctly hashes keys when checking for existing files

### Version 1.17.1 (Jan 23, 2014)

- Added custom events for Google Play Services. `GooglePlayServicesBanner` and `GooglePlayServicesInterstitial` can be found in the extras directory of the SDK (`/extras/src/com/mopub/mobileads`)
Expand Down
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,11 @@ 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.

- Added custom events for Google Play Services. `GooglePlayServicesBanner` and `GooglePlayServicesInterstitial` can be found in the extras directory of the SDK (`/extras/src/com/mopub/mobileads`)
- Resolved issues with missing annotations on `addJavascriptInterface` when `targetSdkVersion` is set to API level 17 or above
- Updated MoPub sample application to allow in-app text entry of ad unit IDs
- Updated InMobi custom events
- Bug fixes

### Changes to InMobi Custom Event Integrations
**Important**: As of version 1.17.2.0, the InMobi custom events packaged with the MoPub SDK only support InMobi version 4.0.3 and up. Follow the instructions [here](https://www.inmobi.com/support/integration/23817448/22051163/android-sdk-integration-guide/) to integrate InMobi version 4.0.3 and up. If you would like to continue to use a prior version of the InMobi SDK, do not update the custom event files and follow the instructions [here](https://www.inmobi.com/support/art/23806682/22095493/mopub-adaptor-android-sdk-integration-guide/) to integrate.

## Requirements

Expand Down
21 changes: 9 additions & 12 deletions extras/src/com/mopub/mobileads/InMobiBanner.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import android.content.Context;
import com.inmobi.commons.InMobi;
import com.inmobi.commons.InMobi.LOG_LEVEL;
import com.inmobi.mediation.adapter.inmobi.InMobiExtras;
import com.inmobi.monetization.IMBanner;
import com.inmobi.monetization.IMBannerListener;
import com.inmobi.monetization.IMErrorCode;
Expand All @@ -16,7 +15,7 @@
import java.util.*;

/*
* Tested with InMobi SDK 4.0.0
* Tested with InMobi SDK 4.1.1
*/
public class InMobiBanner extends CustomEventBanner implements IMBannerListener {

Expand All @@ -38,9 +37,9 @@ protected void loadBanner(Context context,
mBannerListener.onBannerFailed(null);
return;
}
if (!isAppIntialize) {
if (!isAppInitialized) {
InMobi.initialize(activity, inMobiAppId);
isAppIntialize = true;
isAppInitialized = true;
}

/*
Expand All @@ -50,12 +49,10 @@ protected void loadBanner(Context context,
iMBanner = new IMBanner(activity, inMobiAppId,
IMBanner.INMOBI_AD_UNIT_320X50);

Map<String, String> map = new HashMap<String, String>();
InMobiExtras extras = new InMobiExtras();
map.put("tp", "c_mopub");
map.put("tp-ver", MoPub.SDK_VERSION);
extras.setRequestParams(map);
iMBanner.addNetworkExtras(extras);
Map<String, String> map = new HashMap<String, String>();
map.put("tp", "c_mopub");
map.put("tp-ver", MoPub.SDK_VERSION);
iMBanner.setRequestParams(map);
InMobi.setLogLevel(LOG_LEVEL.VERBOSE);
iMBanner.setIMBannerListener(this);
iMBanner.setRefreshInterval(-1);
Expand All @@ -65,16 +62,16 @@ protected void loadBanner(Context context,

private CustomEventBannerListener mBannerListener;
private IMBanner iMBanner;
private static boolean isAppIntialize = false;
private static boolean isAppInitialized = false;

/*
* Abstract methods from CustomEventBanner
*/

@Override
public void onInvalidate() {
iMBanner.setIMBannerListener(null);
if (iMBanner != null) {
iMBanner.setIMBannerListener(null);
Views.removeFromParent(iMBanner);
iMBanner.destroy();
}
Expand Down
21 changes: 9 additions & 12 deletions extras/src/com/mopub/mobileads/InMobiInterstitial.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import android.app.Activity;
import android.content.Context;
import com.inmobi.commons.InMobi;
import com.inmobi.mediation.adapter.inmobi.InMobiExtras;
import com.inmobi.monetization.IMErrorCode;
import com.inmobi.monetization.IMInterstitial;
import com.inmobi.monetization.IMInterstitialListener;
Expand All @@ -14,7 +13,7 @@
import java.util.*;

/*
* Tested with InMobi SDK 4.0.0
* Tested with InMobi SDK 4.1.1
*/
public class InMobiInterstitial extends CustomEventInterstitial implements IMInterstitialListener {

Expand Down Expand Up @@ -42,25 +41,23 @@ protected void loadInterstitial(Context context,
* You may also pass this String down in the serverExtras Map by
* specifying Custom Event Data in MoPub's web interface.
*/
if (!isAppIntialize) {
if (!isAppInitialized) {
InMobi.initialize(activity, inMobiAppId);
isAppIntialize = true;
isAppInitialized = true;
}
this.iMInterstitial = new IMInterstitial(activity, inMobiAppId);

Map<String, String> map = new HashMap<String, String>();
InMobiExtras extras = new InMobiExtras();
map.put("tp", "c_mopub");
map.put("tp-ver", MoPub.SDK_VERSION);
extras.setRequestParams(map);
iMInterstitial.addNetworkExtras(extras);
Map<String, String> map = new HashMap<String, String>();
map.put("tp", "c_mopub");
map.put("tp-ver", MoPub.SDK_VERSION);
iMInterstitial.setRequestParams(map);
iMInterstitial.setIMInterstitialListener(this);
iMInterstitial.loadInterstitial();
}

private CustomEventInterstitialListener mInterstitialListener;
private IMInterstitial iMInterstitial;
private static boolean isAppIntialize = false;
private static boolean isAppInitialized = false;

/*
* Abstract methods from CustomEventInterstitial
Expand All @@ -76,8 +73,8 @@ public void showInterstitial() {

@Override
public void onInvalidate() {
iMInterstitial.setIMInterstitialListener(null);
if (iMInterstitial != null) {
iMInterstitial.setIMInterstitialListener(null);
iMInterstitial.destroy();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ public void loadAd() {
mLocation = getLastKnownLocation();
}

// tested (remove me when the rest of this is tested)
String adUrl = generateAdUrl();
loadNonJavascript(adUrl);
}
Expand Down
5 changes: 2 additions & 3 deletions mopub-sdk/src/main/java/com/mopub/mobileads/DiskLruCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -59,12 +59,11 @@ synchronized boolean putStream(final String fileName, final InputStream content)
return false;
}

String hashedFileName = Utils.sha1(fileName);

if (getUri(hashedFileName) != null) {
if (getUri(fileName) != null) {
return false;
}

String hashedFileName = Utils.sha1(fileName);
File file = createFile(hashedFileName, content);

if (file == null || !file.exists()) {
Expand Down
2 changes: 1 addition & 1 deletion mopub-sdk/src/main/java/com/mopub/mobileads/MoPub.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,6 @@
package com.mopub.mobileads;

public class MoPub {
public static final String SDK_VERSION = "1.17.1.1";
public static final String SDK_VERSION = "1.17.2.0";
}

Original file line number Diff line number Diff line change
Expand Up @@ -128,22 +128,6 @@ class MraidDisplayController extends MraidAbstractController {
// A reference to the root view.
private FrameLayout mRootView;

// Tracks whether this controller's view is currently on-screen.
private boolean mIsViewable;

// Task that periodically checks whether this controller's view is on-screen.
private Runnable mCheckViewabilityTask = new Runnable() {
public void run() {
boolean currentViewable = checkViewable();
if (mIsViewable != currentViewable) {
mIsViewable = currentViewable;
getMraidView().fireChangeEventForProperty(
MraidViewableProperty.createWithViewable(mIsViewable));
}
mHandler.postDelayed(this, VIEWABILITY_TIMER_MILLIS);
}
};

// Handler for scheduling viewability checks.
private Handler mHandler = new Handler();

Expand Down Expand Up @@ -199,7 +183,6 @@ public void run() {
private void initialize() {
mViewState = ViewState.LOADING;
initializeScreenMetrics();
initializeViewabilityTimer();
mOrientationBroadcastReceiver.register(getContext());
}

Expand Down Expand Up @@ -227,11 +210,6 @@ private void initializeScreenMetrics() {
mScreenHeight = (int) (heightPixels * (160.0 / metrics.densityDpi));
}

private void initializeViewabilityTimer() {
mHandler.removeCallbacks(mCheckViewabilityTask);
mHandler.post(mCheckViewabilityTask);
}

private int getDisplayRotation() {
WindowManager wm = (WindowManager) getContext()
.getSystemService(Context.WINDOW_SERVICE);
Expand All @@ -245,7 +223,6 @@ private void onOrientationChanged(int currentRotation) {
}

public void destroy() {
mHandler.removeCallbacks(mCheckViewabilityTask);
try {
mOrientationBroadcastReceiver.unregister();
} catch (IllegalArgumentException e) {
Expand All @@ -258,7 +235,7 @@ public void destroy() {
protected void initializeJavaScriptState() {
ArrayList<MraidProperty> properties = new ArrayList<MraidProperty>();
properties.add(MraidScreenSizeProperty.createWithSize(mScreenWidth, mScreenHeight));
properties.add(MraidViewableProperty.createWithViewable(mIsViewable));
properties.add(MraidViewableProperty.createWithViewable(getMraidView().getIsVisible()));
getMraidView().fireChangeEventForProperties(properties);

mViewState = ViewState.DEFAULT;
Expand Down Expand Up @@ -770,10 +747,6 @@ protected void useCustomClose(boolean shouldUseCustomCloseButton) {
}
}

protected boolean checkViewable() {
return true;
}

FrameLayout createAdContainerLayout() {
return new FrameLayout(getContext());
}
Expand Down
38 changes: 35 additions & 3 deletions mopub-sdk/src/main/java/com/mopub/mobileads/MraidView.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ public class MraidView extends BaseWebView implements UserClickListener {
private final PlacementType mPlacementType;
private ViewGestureDetector mViewGestureDetector;
private AdConfiguration mAdConfiguration;
private boolean mIsVisible;

static class MraidListenerInfo {
private MraidListener mMraidListener;
Expand Down Expand Up @@ -118,6 +119,8 @@ public MraidView(Context context, AdConfiguration adConfiguration, ExpansionStyl
mViewGestureDetector = new ViewGestureDetector(context, this, adConfiguration);
mViewGestureDetector.setUserClickListener(this);

mIsVisible = (getVisibility() == View.VISIBLE);

initialize(expStyle, buttonStyle);
}

Expand Down Expand Up @@ -343,10 +346,15 @@ public void onReceivedError(WebView view, int errorCode, String description, Str
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
Uri uri = Uri.parse(url);

// Note that scheme will be null when we are passed a relative Uri
String scheme = uri.getScheme();

if (scheme.equals("mopub")) return true;
if (scheme.equals("mraid")) {

if ("mopub".equals(scheme)) {
return true;
}

if ("mraid".equals(scheme)) {
tryCommand(URI.create(url)); // java.net.URI, not android.net.Uri
return true;
}
Expand Down Expand Up @@ -377,6 +385,8 @@ public void onPageFinished(WebView view, String url) {
if (getMraidListener() != null) {
getMraidListener().onReady(MraidView.this);
}
mIsVisible = (getVisibility() == View.VISIBLE);
fireChangeEventForProperty(MraidViewableProperty.createWithViewable(mIsVisible));
mHasFiredReadyEvent = true;
}
}
Expand Down Expand Up @@ -409,6 +419,28 @@ public interface OnOpenListener {
public void onOpen(MraidView view);
}

public boolean getIsVisible() {
return mIsVisible;
}

@Override
protected void onVisibilityChanged (View changedView, int visibility) {
super.onVisibilityChanged(changedView, visibility);

boolean newIsVisible = (visibility == View.VISIBLE);
if (newIsVisible != mIsVisible) {
mIsVisible = newIsVisible;
if (mHasFiredReadyEvent) {
fireChangeEventForProperty(MraidViewableProperty.createWithViewable(mIsVisible));
}
}
}

@Deprecated // for testing
void setHasFiredReadyEvent(boolean hasFired) {
mHasFiredReadyEvent = hasFired;
}

@Deprecated // for testing
WebViewClient getMraidWebViewClient() {
return mWebViewClient;
Expand Down
Loading

0 comments on commit f0504c6

Please sign in to comment.