Esempio n. 1
0
  public AdWebView(
      AdViewContainer parent,
      MASTAdLog log,
      DisplayMetrics metrics,
      boolean mraid,
      boolean handleClicks) {
    super(parent.getContext());
    this.setId(getIdForView());

    adViewContainer = parent;
    adLog = log;
    // this.metrics = metrics;
    supportMraid = mraid;
    // launchBrowserOnClicks = handleClicks;

    // dataToInject = null;
    defferedJavascript = new StringBuffer();

    // Clients for javascript and other integration
    setWebChromeClient(new AdWebChromeClient());
    setWebViewClient(new AdWebViewClient(parent.getContext()));

    // Customize settings for web view
    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setSavePassword(false);
    webSettings.setSaveFormData(false);
    webSettings.setSupportZoom(false);
    webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE);

    // apply standard properties
    setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);

    if (supportMraid) {
      javascriptInterface = new JavascriptInterface(parent, this);
      mraidInterface = new MraidInterface(parent, this);

      /*mraidScript = FileUtils.readTextFromJar(parent.getContext(),
      "/js/mraid.js");*/
    }

    // System.out.println("mraid script read: " + mraidScript);

    if (handleClicks) {
      adClickHandler = new AdClickHandler(adViewContainer);
    }
  }
Esempio n. 2
0
  public int getStatusBarHeight() {
    try {
      Rect rect = new Rect();
      Window window = ((Activity) (adViewContainer.getContext())).getWindow();
      window.getDecorView().getWindowVisibleDisplayFrame(rect);
      int statusBarHeight = rect.top;
      return statusBarHeight;
    } catch (Exception ex) {
      // NA
    }

    return 0;
  }