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;
}
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)));
}
Aggregations