/** Setup webView */ @SuppressLint({"NewApi", "SetJavaScriptEnabled"}) private void setWebViewSettings() { NonLeakingWebView wv = (NonLeakingWebView) findViewById(R.id.webViewContent); wv.getSettings().setAllowFileAccess(true); wv.getSettings().setSupportZoom(UIHelper.getZoomPreferences(this)); wv.getSettings().setBuiltInZoomControls(UIHelper.getZoomPreferences(this)); wv.setDisplayZoomControl(UIHelper.getZoomControlPreferences(this)); wv.getSettings().setLoadWithOverviewMode(true); // wv.getSettings().setUseWideViewPort(true); wv.getSettings().setLoadsImagesAutomatically(getShowImagesPreferences()); if (UIHelper.getColorPreferences(this)) wv.setBackgroundColor(0); wv.getSettings().setJavaScriptEnabled(true); if (isPageLoaded) wv.loadUrl("javascript:toogleEnableBookmark(" + getBookmarkPreferences() + ")"); }
/** * Load chapter for external url (not hosted in Baka-Tsuki). Used local cache if available * (wac/mht). * * @param pageModel * @param refresh */ public void loadExternalUrl(PageModel pageModel, boolean refresh) { try { // check if .wac available String url = pageModel.getPage(); String wacName = Util.getSavedWacName(url); final NonLeakingWebView wv = (NonLeakingWebView) findViewById(R.id.webViewContent); if (!Util.isStringNullOrEmpty(wacName) && !refresh) { client.setExternalNeedSave(false); String[] urlParts = url.split("#", 2); if (urlParts.length == 2) { executeLoadWacTask(wacName, urlParts[1], url); } else executeLoadWacTask(wacName, "", url); } else { if (refresh) { Toast.makeText(this, "Refreshing WAC: " + wacName, Toast.LENGTH_SHORT).show(); Log.i(TAG, "Refreshing WAC: " + wacName); } else { Log.w(TAG, "WAC not available: " + wacName); } client.setExternalNeedSave(true); setWebViewSettings(); wv.loadUrl(url); Intent currIntent = this.getIntent(); currIntent.putExtra(Constants.EXTRA_PAGE, url); currIntent.putExtra(Constants.EXTRA_PAGE_IS_EXTERNAL, true); } setChapterTitle(pageModel); buildTOCMenu(pageModel); content = null; } catch (Exception ex) { Log.e(TAG, "Cannot load external content: " + pageModel.getPage(), ex); } }