Search in sources :

Example 1 with WPWebViewClient

use of org.wordpress.android.util.WPWebViewClient in project WordPress-Android by wordpress-mobile.

the class PostPreviewFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.post_preview_fragment, container, false);
    mWebView = (WebView) view.findViewById(R.id.webView);
    WPWebViewClient client = new WPWebViewClient(mSite, mAccountStore.getAccessToken());
    mWebView.setWebViewClient(client);
    return view;
}
Also used : WPWebViewClient(org.wordpress.android.util.WPWebViewClient) View(android.view.View) WebView(android.webkit.WebView)

Example 2 with WPWebViewClient

use of org.wordpress.android.util.WPWebViewClient in project WordPress-Android by wordpress-mobile.

the class WPWebViewActivity method configureWebView.

@SuppressLint("SetJavaScriptEnabled")
@Override
protected void configureWebView() {
    mWebView.getSettings().setJavaScriptEnabled(true);
    mWebView.getSettings().setDomStorageEnabled(true);
    WebViewClient webViewClient;
    Bundle extras = getIntent().getExtras();
    // Configure the allowed URLs if available
    ArrayList<String> allowedURL = null;
    if (extras.getBoolean(DISABLE_LINKS_ON_PAGE, false)) {
        String addressToLoad = extras.getString(URL_TO_LOAD);
        String authURL = extras.getString(AUTHENTICATION_URL);
        allowedURL = new ArrayList<>();
        if (!TextUtils.isEmpty(addressToLoad)) {
            allowedURL.add(addressToLoad);
        }
        if (!TextUtils.isEmpty(authURL)) {
            allowedURL.add(authURL);
        }
        if (extras.getStringArray(ALLOWED_URLS) != null) {
            String[] urls = extras.getStringArray(ALLOWED_URLS);
            for (String currentURL : urls) {
                allowedURL.add(currentURL);
            }
        }
    }
    if (getIntent().hasExtra(LOCAL_BLOG_ID)) {
        SiteModel site = mSiteStore.getSiteByLocalId(getIntent().getIntExtra(LOCAL_BLOG_ID, -1));
        if (site == null) {
            AppLog.e(AppLog.T.UTILS, "No valid blog passed to WPWebViewActivity");
            finish();
        }
        webViewClient = new WPWebViewClient(site, mAccountStore.getAccessToken(), allowedURL);
    } else {
        webViewClient = new URLFilteredWebViewClient(allowedURL);
    }
    mWebView.setWebViewClient(webViewClient);
    mWebView.setWebChromeClient(new WPWebChromeClient(this, (ProgressBar) findViewById(R.id.progress_bar)));
}
Also used : WPWebViewClient(org.wordpress.android.util.WPWebViewClient) Bundle(android.os.Bundle) SiteModel(org.wordpress.android.fluxc.model.SiteModel) URLFilteredWebViewClient(org.wordpress.android.util.URLFilteredWebViewClient) ProgressBar(android.widget.ProgressBar) WPWebChromeClient(org.wordpress.android.util.helpers.WPWebChromeClient) WebViewClient(android.webkit.WebViewClient) WPWebViewClient(org.wordpress.android.util.WPWebViewClient) URLFilteredWebViewClient(org.wordpress.android.util.URLFilteredWebViewClient) SuppressLint(android.annotation.SuppressLint)

Aggregations

WPWebViewClient (org.wordpress.android.util.WPWebViewClient)2 SuppressLint (android.annotation.SuppressLint)1 Bundle (android.os.Bundle)1 View (android.view.View)1 WebView (android.webkit.WebView)1 WebViewClient (android.webkit.WebViewClient)1 ProgressBar (android.widget.ProgressBar)1 SiteModel (org.wordpress.android.fluxc.model.SiteModel)1 URLFilteredWebViewClient (org.wordpress.android.util.URLFilteredWebViewClient)1 WPWebChromeClient (org.wordpress.android.util.helpers.WPWebChromeClient)1