Skip to content

Commit

Permalink
Merge branch 'rc1.6' into github-master
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark Ha committed Dec 20, 2013
2 parents 581af94 + da14ad5 commit 684d11a
Show file tree
Hide file tree
Showing 42 changed files with 734 additions and 719 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ mediation/mediatedviews/.DS_Store
mediation/mediatedviews/doc/
mediation/mediatedviews/gen/
mediation/mediating/.DS_Store
mediation/mediating/*/gen/
sdk/.DS_Store
sdk/doc/
sdk/gen/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
public class Constants {
public final static String BASE_LOG_TAG = "OPENSDK-APP";
public final static String PREFS_TAG = "OPENSDK-APP-PREFS";
public final static String DEBUG_AUCTION_URL = "http://mediation.adnxs.com/mob?";
public final static String PREFERENCES = "AppNexus SDK App";

public final static String LOG_FILENAME = "AN_LOG_FILE";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import android.app.AlertDialog;
import android.content.ActivityNotFoundException;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
Expand All @@ -40,6 +41,8 @@
import org.json.JSONException;
import org.json.JSONObject;

import java.net.URI;

public class DebugFragment extends Fragment {

TextView txtRequest, txtResponse;
Expand Down Expand Up @@ -192,7 +195,7 @@ public void onClick(View view) {
};

private class DebugAuctionWebViewClient extends WebViewClient {
WebView webView;
private WebView webView;

private DebugAuctionWebViewClient(WebView view) {
this.webView = view;
Expand Down Expand Up @@ -230,18 +233,15 @@ public boolean shouldOverrideUrlLoading(WebView view, String url) {
String result;

public String getUrl() {
StringBuilder params = new StringBuilder();
params.append("&id=").append(Prefs.getPlacementId(getActivity()));
params.append("&debug_member=").append(Prefs.getMemberId(getActivity()));
params.append("&dongle=").append(Prefs.getDongle(getActivity()));
params.append("&size=").append(Prefs.getSize(getActivity()));
return Constants.DEBUG_AUCTION_URL + params.toString();
StringBuilder auctionURL = new StringBuilder(Clog.getLastRequest());
auctionURL.append("&debug_member=").append(Prefs.getMemberId(getActivity()));
auctionURL.append("&dongle=").append(Prefs.getDongle(getActivity()));
return auctionURL.toString();
}

public void runAuction() {
final String debugAuctionUrl = getUrl();
Clog.d(Constants.BASE_LOG_TAG, "Running a Debug Auction: " + debugAuctionUrl);
// loadUrl(debugAuctionUrl);

final HTTPGet<Void, Void, HTTPResponse> auctionGet = new HTTPGet<Void, Void, HTTPResponse>() {
@Override
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.appnexus.opensdk;

import android.content.Context;
import com.appnexus.opensdk.utils.Clog;
import com.mopub.mobileads.CustomEventBanner;
import com.mopub.mobileads.MoPubErrorCode;

Expand All @@ -31,28 +32,32 @@ public class MoPubMediationBanner extends CustomEventBanner implements AdListene

@Override
protected void loadBanner(Context context, CustomEventBannerListener customEventBannerListener, Map<String, Object> localExtras, Map<String, String> serverExtras) {
Clog.d(Clog.mediationLogTag, "Initializing ANBanner via MoPub SDK");
this.listener = customEventBannerListener;

String apid;
String placementID;
int width;
int height;

if (extrasAreValid(serverExtras)) {
apid = serverExtras.get(PLACEMENTID_KEY);
placementID = serverExtras.get(PLACEMENTID_KEY);
width = Integer.parseInt(serverExtras.get(AD_WIDTH_KEY));
height = Integer.parseInt(serverExtras.get(AD_HEIGHT_KEY));
Clog.d(Clog.mediationLogTag, String.format("Server extras were valid: placementID: %s, width: %s, height: %s", placementID, width, height));
} else {
listener.onBannerFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
Clog.e(Clog.mediationLogTag, "Failed to parse server extras. Check setup of placement in MoPub.");
return;
}

bav = new BannerAdView(context);
bav.setPlacementID(apid);
bav.setAdHeight(height);
bav.setAdWidth(width);
bav.setPlacementID(placementID);
bav.setAdSize(width, height);
bav.setShouldServePSAs(false);
bav.setAdListener(this);

bav.loadAd();

Clog.d(Clog.mediationLogTag, "Load ANBanner");
bav.loadAdOffscreen();
}

private boolean extrasAreValid(Map<String, String> serverExtras) {
Expand All @@ -75,26 +80,31 @@ protected void onInvalidate() {

@Override
public void onAdLoaded(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANBanner loaded successfully");
if (listener != null) listener.onBannerLoaded(bav);
}

@Override
public void onAdRequestFailed(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANBanner failed to load");
if (listener != null) listener.onBannerFailed(MoPubErrorCode.UNSPECIFIED);
}

@Override
public void onAdExpanded(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANBanner expanded");
if (listener != null) listener.onBannerExpanded();
}

@Override
public void onAdCollapsed(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANBanner collapsed");
if (listener != null) listener.onBannerCollapsed();
}

@Override
public void onAdClicked(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANBanner was clicked");
if (listener != null) listener.onBannerClicked();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package com.appnexus.opensdk;

import android.content.Context;
import com.appnexus.opensdk.utils.Clog;
import com.mopub.mobileads.CustomEventInterstitial;
import com.mopub.mobileads.MoPubErrorCode;

Expand All @@ -29,18 +30,24 @@ public class MoPubMediationInterstitial extends CustomEventInterstitial implemen

@Override
protected void loadInterstitial(Context context, CustomEventInterstitialListener customEventInterstitialListener, Map<String, Object> localExtras, Map<String, String> serverExtras) {
Clog.d(Clog.mediationLogTag, "Initializing ANInterstitial via MoPub SDK");
listener = customEventInterstitialListener;
String apid;
String placementID;
if (extrasAreValid(serverExtras)) {
apid = serverExtras.get(PLACEMENTID_KEY);
placementID = serverExtras.get(PLACEMENTID_KEY);
Clog.d(Clog.mediationLogTag, String.format("Server extras were valid: placementID: %s", placementID));
} else {
listener.onInterstitialFailed(MoPubErrorCode.ADAPTER_CONFIGURATION_ERROR);
Clog.e(Clog.mediationLogTag, "Failed to parse server extras. Check setup of placement in MoPub.");
return;
}

iad = new InterstitialAdView(context);
iad.setPlacementID(apid);
iad.setPlacementID(placementID);
iad.setShouldServePSAs(false);
iad.setAdListener(this);

Clog.d(Clog.mediationLogTag, "Fetch ANInterstitial");
iad.loadAd();
}

Expand All @@ -50,8 +57,16 @@ private boolean extrasAreValid(Map<String, String> serverExtras) {

@Override
protected void showInterstitial() {
if (iad != null)
if (iad != null && iad.isReady()) {
Clog.d(Clog.mediationLogTag, "Show ANInterstitial");
iad.show();
} else {
if (iad == null) {
Clog.e(Clog.mediationLogTag, "Failed to show ANInterstitial; null object");
} else if (!iad.isReady()) {
Clog.e(Clog.mediationLogTag, "Failed to show ANInterstitial; ad unavailable");
}
}
}

@Override
Expand All @@ -63,26 +78,31 @@ protected void onInvalidate() {

@Override
public void onAdLoaded(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANInterstitial loaded successfully");
if (listener != null) listener.onInterstitialLoaded();
}

@Override
public void onAdRequestFailed(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANInterstitial failed to load");
if (listener != null) listener.onInterstitialFailed(MoPubErrorCode.UNSPECIFIED);
}

@Override
public void onAdExpanded(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANInterstitial expanded");
if (listener != null) listener.onInterstitialShown();
}

@Override
public void onAdCollapsed(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANInterstitial collapsed");
if (listener != null) listener.onInterstitialDismissed();
}

@Override
public void onAdClicked(AdView adView) {
Clog.d(Clog.mediationLogTag, "ANInterstitial was clicked");
if (listener != null) listener.onInterstitialClicked();
}
}
3 changes: 1 addition & 2 deletions sdk/res/values/errors.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
<string formatted="false" name="no_response">Request received no response from the server.</string>
<string formatted="false" name="response_body">Response body: %s</string>
<string formatted="false" name="response_header">Header: %s Value: %s</string>
<string formatted="false" name="response_blank">The server returned a blank 200 OK HTTP response. Unless the maximum retries have been reached, this request will be retried shortly.</string>
<string formatted="false" name="response_blank">The server returned a blank 200 OK HTTP response.</string>
<string formatted="false" name="response_error">E301: The server replied with an error: %s</string>
<string formatted="false" name="response_no_ads">The server responded, but didn\'t return any ads.</string>
<string formatted="false" name="response_json_error">E300: There was an error parsing the JSON response: %s</string>
Expand Down Expand Up @@ -111,7 +111,6 @@
<string formatted="false" name="result_cb_bad_response">result cb returned a bad response</string>
<string formatted="false" name="fire_cb_result_null">firing result cb with null resultCB</string>
<string formatted="false" name="cancel_request">Cancelling scheduled request</string>
<string formatted="false" name="retry_already_cancelled">Tried to execute a retry request that was cancelled</string>
<string formatted="false" name="resize">MRAID resize() called with w:%d, h:%d, offset_x:%d, offset_y:%d, cust_close_position:%s, allow_offscreen:%b</string>
<string formatted="false" name="set_orientation_properties">MRAID setOrientationProperties called with allow_orientation_change=%b, orientation=%d</string>
<string formatted="false" name="create_calendar_event">MRAID createCalendarEvent() called</string>
Expand Down
6 changes: 3 additions & 3 deletions sdk/src/com/appnexus/opensdk/AdActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@
import java.util.Locale;

/**
* This is the main ad activity. You must add a reference to in your app's AndroidManifest.xml
* file. {@link BrowserActivity} Also needs to be added allow the in-app browser functionality,
* This is the main ad activity. You must add a reference to this to
* your app's AndroidManifest.xml file. {@link BrowserActivity} also
* needs to be added allow the in-app browser functionality:
* <pre>
* {@code
* <application>
* ....
* <activity android:name="com.appnexus.opensdk.AdActivity" />
* <activity android:name="com.appnexus.opensdk.BrowserActivity" />
* </application>
Expand Down
9 changes: 1 addition & 8 deletions sdk/src/com/appnexus/opensdk/AdFetcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -245,13 +245,11 @@ public void run() {
owner.popMediatedAd(),
owner.getAdDispatcher());
} else if (owner.isInterstitial()) {
MediatedInterstitialAdViewController output = MediatedInterstitialAdViewController.create(
MediatedInterstitialAdViewController.create(
(Activity) owner.getContext(),
owner.mAdFetcher,
owner.popMediatedAd(),
owner.getAdDispatcher());
if (output != null)
output.getView();
}
} else if ((response != null)
&& response.isMraid()) {
Expand Down Expand Up @@ -280,11 +278,6 @@ public AdView getOwner() {
return owner;
}

@Override
public void setAdRequest(AdRequest adRequest) {
this.adRequest = adRequest;
}

public void clearDurations() {
lastFetchTime = -1;
timePausedAt = -1;
Expand Down
34 changes: 19 additions & 15 deletions sdk/src/com/appnexus/opensdk/AdListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@
package com.appnexus.opensdk;

/**
* Implement this interface and pass it to your {@link BannerAdView} and {@link InterstitialAdView}
* objects to receive events on the status of the ad.
* Implement this interface and pass it to your {@link BannerAdView}
* and {@link InterstitialAdView} objects to receive events on the
* status of the ad.
*/
public interface AdListener {
/**
Expand All @@ -29,37 +30,40 @@ public interface AdListener {
public void onAdLoaded(AdView adView);

/**
* Called when an ad request has failed.
* Ad request failures may include no ad available, or networking errors
* Called when an ad request has failed. Ad requests can fail
* because no ad is available, or because of networking errors.
*
* @param adView The {@link AdView} that loaded the ad.
*/
public void onAdRequestFailed(AdView adView);

/**
* Called when an ad expands due to user interaction. MRAID ads that expand
* the screen generate these events. This event may fire from both Banner and Interstitial ads.
* This would be a good time to stop or pause your application due
* to the user interacting with the ad.
* Called when an ad expands due to user interaction. MRAID ads
* that expand the screen generate these events, for example.
* This event may fire from both banner and interstitial ads.
* This would be a good time to stop or pause your application due
* to the user interacting with the ad. This is the inverse of
* onAdCollapsed.
*
* @param adView The {@link AdView} that loaded the ad.
*/
public void onAdExpanded(AdView adView);

/**
* Called when an ad is closed/unexpanded. The user has stopped interacting
* with the ad. This is the corollary of onAdExpanded.
* Called when an ad is closed/unexpanded, for example if the user
* has stopped interacting with the ad. This is the inverse of
* onAdExpanded.
*
* @param adView The {@link AdView} that loaded the ad.
*/
public void onAdCollapsed(AdView adView);

/**
* Called when an ad is clicked. The current activity will be paused
* as the user switches activities to the activity launched from
* the ad interaction. For example the user clicked a link that
* opened a web browser, or the user touched a click to call link
* which launched the phone dialer.
* Called when an ad is clicked. The current activity will be
* paused as the user switches to the activity launched from the
* ad interaction. For example, the user may click a link that
* opens a web browser, or touch a click-to-call link which
* launches the phone dialer.
*
* @param adView The {@link AdView} that loaded the ad.
*/
Expand Down
Loading

0 comments on commit 684d11a

Please sign in to comment.