@Override public void onGeolocationPermissionsHidePrompt() { if ((adView != null) && !adView.isInterstitial() && !adView.isMRAIDExpanded()) { this.adView.getAdDispatcher().onAdCollapsed(); } }
void expand(int w, int h, boolean custom_close, final MRAIDImplementation caller, AdWebView.MRAIDFullscreenListener listener) { MRAIDChangeSize(w, h); // Add a stock close_button button to the top right corner close_button = ViewUtil.createCloseButton(this.getContext(), custom_close); FrameLayout.LayoutParams blp = (LayoutParams) close_button.getLayoutParams(); // place the close button at the top right of the adview if it isn't fullscreen if (!caller.owner.isFullScreen) { if (getChildAt(0) != null) { blp.rightMargin = (this.getMeasuredWidth() - this.getChildAt(0).getMeasuredWidth()) / 2; } } close_button.setLayoutParams(blp); close_button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { caller.close(); } }); if (caller.owner.isFullScreen) { mraidFullscreenExpand(caller, custom_close, listener); } else { // if not fullscreen, just add the close button this.addView(close_button); } isMRAIDExpanded = true; }
protected void loadAdFromHtml(String html, int width, int height) { // load an ad directly from html loadedOffscreen = true; AdWebView output = new AdWebView(this, null); RTBHTMLAdResponse response = new RTBHTMLAdResponse(width, height, getMediaType().toString(), null, getCreativeId()); response.setAdContent(html); output.loadAd(response); display(output); }
void fireAdClicked() { if (adView != null) { adView.getAdDispatcher().onAdClicked(); adView.interacted(); } }
@Override protected void onAttachedToWindow() { super.onAttachedToWindow(); isAttachedToWindow = true; // OnAttaced to Window and Impresion tracker is non null then fire impression. if (getMediaType().equals(MediaType.BANNER) && impressionTrackers != null && impressionTrackers.size() > 0) { fireImpressionTracker(); } }
@Override public void run() { setCreativeWidth(ad.getDisplayable().getCreativeWidth()); setCreativeHeight(ad.getDisplayable().getCreativeHeight()); setCreativeId(ad.getResponseData().getCreativeId()); if (ad.isMediated() && ad.getResponseData().getContentSource() == UTConstants.CSM) { try { displayMediated((MediatedDisplayable) ad.getDisplayable()); } catch (ClassCastException cce) { Clog.e(Clog.baseLogTag, "The SDK shouldn't fail downcasts to MediatedDisplayable in AdView"); display(ad.getDisplayable()); if (getMediaType().equals(MediaType.BANNER)) { if (isAdViewAttachedToWindow()) { if (impressionTrackers != null && impressionTrackers.size() > 0) { fireImpressionTracker(); setAdType(AdType.VIDEO); if (mAdFetcher.getState() == AdFetcher.STATE.AUTO_REFRESH) { mAdFetcher.stop(); setAdType(AdType.BANNER);
@Test public void testMRAIDOpenSuccessDeviceBrowser() { String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://open?uri=%s", uri); mockAdWebView.adView.setClickThroughAction(ANClickThroughAction.OPEN_DEVICE_BROWSER); implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, uri); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertEquals(ANClickThroughAction.OPEN_DEVICE_BROWSER, mockAdWebView.adView.getClickThroughAction()); assertTrue(mockAdDispatcher.adClicked); assertFalse(mockAdDispatcher.adClickedWithUrl); }
private void handleCSMResponse(Ad ownerAd, CSMSDKAdResponse csmSdkAdResponse) { Clog.i(Clog.baseLogTag, "Mediation type is CSM, passing it to MediatedAdViewController."); if (csmSdkAdResponse.getAdType().equals(UTConstants.AD_TYPE_NATIVE)) { mediatedNativeAdController = MediatedNativeAdController.create(csmSdkAdResponse, AdViewRequestManager.this); } else { AdView owner = (AdView) ownerAd; if (owner.getMediaType().equals(MediaType.BANNER)) { controller = MediatedBannerAdViewController.create( (Activity) owner.getContext(), AdViewRequestManager.this, csmSdkAdResponse, owner.getAdDispatcher()); } else if (owner.getMediaType().equals(MediaType.INTERSTITIAL)) { controller = MediatedInterstitialAdViewController.create( (Activity) owner.getContext(), AdViewRequestManager.this, csmSdkAdResponse, owner.getAdDispatcher()); } else { Clog.e(Clog.baseLogTag, "MediaType type can not be identified."); continueWaterfall(ResultCode.INVALID_REQUEST); } } }
private static void callDispatchAppEvent(AdWebView webView, Uri uri) { String event = uri.getQueryParameter("event"); String data = uri.getQueryParameter("data"); webView.adView.getAdDispatcher().onAppEvent(event, data); }
if (getMediaType().equals(MediaType.INTERSTITIAL)) { InterstitialAdView.INTERSTITIALADVIEW_TO_USE.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); InterstitialAdView.INTERSTITIALADVIEW_TO_USE.getLocationOnScreen(adviewLoc); InterstitialAdView.INTERSTITIALADVIEW_TO_USE.getMeasuredHeight()); } else { AdView.this.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); AdView.this.getLocationOnScreen(adviewLoc); container_size = new Point(AdView.this.getMeasuredWidth(), AdView.this.getMeasuredHeight());
lp.height = default_height; lp.width = default_width; if (owner.adView.getMediaType().equals(MediaType.BANNER)) { lp.gravity = default_gravity; } else { if (!owner.adView.isInterstitial() && !isMRAIDTwoPartExpanded) { owner.adView.getAdDispatcher().onAdCollapsed(); resized = false; expandedWebView = null; } else if (owner.adView.isInterstitial()) { owner.adView.getAdDispatcher().onAdCollapsed(); Activity containerActivity = ((Activity) this.owner.getContextFromMutableContext()); if (containerActivity != null && !containerActivity.isFinishing()) {
protected void close(int w, int h, MRAIDImplementation caller) { // Remove MRAID close button ViewUtil.removeChildFromParent(close_button); close_button = null; if (caller.owner.isFullScreen) { ViewUtil.removeChildFromParent(caller.owner); if (caller.getDefaultContainer() != null) { caller.getDefaultContainer().addView(caller.owner, 0); } if (caller.getFullscreenActivity() != null) { caller.getFullscreenActivity().finish(); } // Reset the context of MutableContext wrapper for banner expand and close case. if (getMediaType().equals(MediaType.BANNER) && (caller.owner.getContext() instanceof MutableContextWrapper)) { ((MutableContextWrapper) caller.owner.getContext()).setBaseContext(getContext()); } } // null these out for safety mraidFullscreenContainer = null; mraidFullscreenImplementation = null; mraidFullscreenListener = null; MRAIDChangeSize(w, h); mraid_is_closing = true; isMRAIDExpanded = false; }
void loadURLInCorrectBrowser(String url) { if (adView.getClickThroughAction() == ANClickThroughAction.OPEN_SDK_BROWSER) { if (adView.getLoadsInBackground()) { out.loadUrl(url); out.setVisibility(View.GONE); adView.addView(out); if (this.adView.getShowLoadingIndicator()) { } else if (adView.getClickThroughAction() == ANClickThroughAction.OPEN_DEVICE_BROWSER) { Clog.d(Clog.baseLogTag, Clog.getString(R.string.opening_native));
private boolean openNativeIntent(String url) { Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); try { adView.getContext().startActivity(intent); return true; } catch (ActivityNotFoundException e) { Clog.w(Clog.baseLogTag, Clog.getString(R.string.opening_url_failed, url)); if (isMRAIDEnabled) { Toast.makeText(adView.getContext(), R.string.action_cant_be_completed, Toast.LENGTH_SHORT).show(); } return false; } }
@Test public void testMRAIDOpenSuccessSDKBrowser() { String uri = "http://www.appnexus.com"; String mraidCall = String.format("mraid://open?uri=%s", uri); //Default ANClickThroughAction is ANClickThroughAction.OPEN_SDK_BROWSER implementation.dispatch_mraid_call(mraidCall, true); assertEquals(mockAdWebView.testString, uri); MockAdDispatcher mockAdDispatcher = (MockAdDispatcher) mockAdWebView.adView.getAdDispatcher(); assertEquals(ANClickThroughAction.OPEN_SDK_BROWSER, mockAdWebView.adView.getClickThroughAction()); assertTrue(mockAdDispatcher.adClicked); assertFalse(mockAdDispatcher.adClickedWithUrl); }
this.owner.adView.mraidFullscreenExpand(expandedWebView.getMRAIDImplementation(), useCustomClose, new AdWebView.MRAIDFullscreenListener() { @Override if (!this.owner.adView.isInterstitial()) { this.owner.adView.getAdDispatcher().onAdExpanded();
Clog.setErrorContext(this.getContext()); setPadding(0, 0, 0, 0); loadVariablesFromXML(context, attrs);
@Override public MediaType getMediaType() { return adView.getMediaType(); }
private void openInAppBrowser(WebView fwdWebView) { Class<?> activity_clz = AdActivity.getActivityClass(); Intent intent = new Intent(adView.getContext(), activity_clz); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_BROWSER); BrowserAdActivity.BROWSER_QUEUE.add(fwdWebView); if (adView.getBrowserStyle() != null) { String i = "" + super.hashCode(); intent.putExtra("bridgeid", i); AdView.BrowserStyle.bridge .add(new Pair<String, BrowserStyle>(i, adView.getBrowserStyle())); } try { adView.getContext().startActivity(intent); triggerBrowserLaunchEvent(); } catch (ActivityNotFoundException e) { Clog.w(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName())); BrowserAdActivity.BROWSER_QUEUE.remove(); } }
void fireImpressionTracker() { synchronized (impressionTrackers) { // Just to be fail safe since we are making it to null below to mark it as beign used. SharedNetworkManager nm = SharedNetworkManager.getInstance(getContext()); if (impressionTrackers != null && impressionTrackers.size() > 0) { for (String url : impressionTrackers) { if (nm.isConnected(getContext())) { fireImpressionTracker(url); } else { nm.addURL(url, getContext()); } } // Making it to null so that there is no duplicate firing. We fire exactly only once. impressionTrackers = null; } if(lastDisplayable !=null){ lastDisplayable.onAdImpression(); } } }