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; } }
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(); } } }
FrameLayout fslayout = new FrameLayout(this.getContext()); close_button = ViewUtil.createCloseButton(this.getContext(), use_custom_close); close_button.setOnClickListener(new View.OnClickListener() { @Override Intent i = new Intent(getContext(), activity_clz); i.putExtra(AdActivity.INTENT_KEY_ACTIVITY_TYPE, AdActivity.ACTIVITY_TYPE_MRAID); getContext().startActivity(i); } catch (ActivityNotFoundException e) { Clog.e(Clog.baseLogTag, Clog.getString(R.string.adactivity_missing, activity_clz.getName()));
public AdWebView(AdView adView, UTAdRequester requester) { super(new MutableContextWrapper(adView.getContext())); this.adView = adView; this.caller_requester = requester; this.initialMraidStateString = MRAIDImplementation.MRAID_INIT_STATE_STRINGS[ MRAIDImplementation.MRAID_INIT_STATE.STARTING_DEFAULT.ordinal()]; setupSettings(); setup(); }
public MockAdWebView(AdView owner) { super(new MockBannerAdView(owner.getContext()), null); this.setLayoutParams(new ViewGroup.LayoutParams(0, 0)); }
close_button = new ImageButton(this.getContext()) {
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; }
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); } } }
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; }
Clog.setErrorContext(this.getContext());
final float scale = adView.getContext().getResources() .getDisplayMetrics().density;