List of usage examples for android.webkit WebView enableSlowWholeDocumentDraw
public static void enableSlowWholeDocumentDraw()
From source file:com.huangyu.mdeditor.ui.widget.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }//from w w w. j a v a 2 s. co m this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:org.lib.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; if (Build.VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }//from w ww . j a v a 2 s .com this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.twtstudio.bbs.bdpqchen.bbs.mdeditor.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }//from ww w .j a va 2s . com this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); // this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.gc.markdown.widget.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }//from w ww . j a v a2 s.c o m this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); loadUrl(); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:com.tsy.leanote.widget.MarkdownPreviewView.java
@SuppressLint({ "AddJavascriptInterface", "SetJavaScriptEnabled" }) private void init(Context context) { if (!isInEditMode()) { this.mContext = context; // setOrientation(VERTICAL); if (VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); }//from w ww . ja v a 2 s . c o m this.mWebView = new WebView(this.mContext); this.mWebView.getSettings().setJavaScriptEnabled(true); this.mWebView.setVerticalScrollBarEnabled(false); this.mWebView.setHorizontalScrollBarEnabled(false); this.mWebView.addJavascriptInterface(new JavaScriptInterface(this), "handler"); this.mWebView.setWebViewClient(new MdWebViewClient(this)); this.mWebView.loadUrl("file:///android_asset/markdown.html"); addView(this.mWebView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT)); } }
From source file:net.sarangnamu.scroll_capture.MainActivity.java
@SuppressLint("SetJavaScriptEnabled") @Override// www . j a va2s . c o m protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WebView.enableSlowWholeDocumentDraw(); } setContentView(R.layout.activity_main); ButterKnife.bind(this); mWeb.loadUrl("http://aucd29.tistory.com/m"); BkCfg.hideKeyboard(mWeb); mWeb.getSettings().setJavaScriptEnabled(true); mWeb.getSettings().setDomStorageEnabled(true); mWeb.getSettings().setLoadWithOverviewMode(true); mWeb.getSettings().setUseWideViewPort(true); mWeb.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if (mLog.isDebugEnabled()) { String log = ""; log += "===================================================================\n"; log += "WEBPAGE LOADED\n"; log += "===================================================================\n"; mLog.debug(log); } if (url.equals("http://aucd29.tistory.com/")) { mProgress.setVisibility(View.GONE); // mFab.animate().alpha(1); } } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (url.equals("http://aucd29.tistory.com/")) { mProgress.setVisibility(View.VISIBLE); // mFab.animate().alpha(0); } } @Override public void onReceivedError(WebView view, WebResourceRequest request, WebResourceError error) { if (mLog.isErrorEnabled()) { String log = ""; log += "===================================================================\n"; log += "ERROR: \n"; log += "===================================================================\n"; mLog.error(log); } super.onReceivedError(view, request, error); } }); }
From source file:com.github.dfa.diaspora_android.web.BrowserFragment.java
private void applyWebViewSettings() { this.webSettings = webView.getSettings(); webSettings.setAllowFileAccess(false); webSettings.setUseWideViewPort(true); webSettings.setLoadWithOverviewMode(true); webSettings.setUserAgentString(//w w w.ja v a 2 s . c om "Mozilla/5.0 (Linux; U; Android 4.4.4; Nexus 5 Build/KTU84P) AppleWebkit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30"); webSettings.setDomStorageEnabled(true); webSettings.setMinimumFontSize(appSettings.getMinimumFontSize()); webSettings.setLoadsImagesAutomatically(appSettings.isLoadImages()); webSettings.setAppCacheEnabled(true); if (android.os.Build.VERSION.SDK_INT >= 21) { WebView.enableSlowWholeDocumentDraw(); webSettings.setMixedContentMode(WebSettings.MIXED_CONTENT_ALWAYS_ALLOW); } this.registerForContextMenu(webView); //webView.setParentActivity(this); webView.setOverScrollMode(WebView.OVER_SCROLL_ALWAYS); this.webViewClient = new CustomWebViewClient((App) getActivity().getApplication(), webView); webView.setWebViewClient(webViewClient); webView.setWebChromeClient(new ProgressBarWebChromeClient(webView, progressBar)); }
From source file:de.baumann.hhsmoodle.fragmentsMain.FragmentBrowser.java
@SuppressWarnings("ResultOfMethodCallIgnored") @SuppressLint("SetJavaScriptEnabled") @Override//from w w w . j a v a 2s. c o m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_screen_browser, container, false); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { WebView.enableSlowWholeDocumentDraw(); } PreferenceManager.setDefaultValues(getActivity(), R.xml.user_settings, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(getActivity()); sharedPref.edit().putString("browserStarted", "true").apply(); customViewContainer = (FrameLayout) rootView.findViewById(R.id.customViewContainer); progressBar = (ProgressBar) rootView.findViewById(R.id.progressBar); viewPager = (ViewPager) getActivity().findViewById(R.id.viewpager); SwipeRefreshLayout swipeView = (SwipeRefreshLayout) rootView.findViewById(R.id.swipe); assert swipeView != null; swipeView.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent); swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mWebView.reload(); } }); mWebView = (WebView) rootView.findViewById(R.id.webView); mWebChromeClient = new myWebChromeClient(); mWebView.setWebChromeClient(mWebChromeClient); imageButton_left = (ImageButton) rootView.findViewById(R.id.imageButton_left); imageButton_right = (ImageButton) rootView.findViewById(R.id.imageButton_right); if (sharedPref.getBoolean("arrow", false)) { imageButton_left.setVisibility(View.VISIBLE); imageButton_right.setVisibility(View.VISIBLE); } else { imageButton_left.setVisibility(View.INVISIBLE); imageButton_right.setVisibility(View.INVISIBLE); } helper_webView.webView_Settings(getActivity(), mWebView); helper_webView.webView_WebViewClient(getActivity(), swipeView, mWebView); mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimetype, long contentLength) { final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); Snackbar snackbar = Snackbar .make(mWebView, getString(R.string.toast_download_1) + " " + filename, Snackbar.LENGTH_INDEFINITE) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url)); request.allowScanningByMediaScanner(); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! request.setDestinationInExternalPublicDir(newFileDest(), filename); DownloadManager dm = (DownloadManager) getActivity() .getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Snackbar.make(mWebView, getString(R.string.toast_download) + " " + filename, Snackbar.LENGTH_LONG).show(); getActivity().registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); } }); snackbar.show(); } }); String URLtoOpen = sharedPref.getString("loadURL", ""); if (URLtoOpen.isEmpty()) { mWebView.loadUrl( sharedPref.getString("favoriteURL", "https://moodle.huebsch.ka.schule-bw.de/moodle/my/")); } else { mWebView.loadUrl(URLtoOpen); } setHasOptionsMenu(true); return rootView; }
From source file:de.baumann.browser.Browser_right.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(ContextCompat.getColor(Browser_right.this, R.color.colorTwoDark)); WebView.enableSlowWholeDocumentDraw(); setContentView(R.layout.activity_browser); helper_main.onStart(Browser_right.this); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.edit()//w w w .j a va 2 s . c o m .putString("openURL", sharedPref.getString("startURL", "https://github.com/scoute-dich/browser/")) .apply(); sharedPref.edit().putInt("keyboard", 0).apply(); sharedPref.getInt("keyboard", 0); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); toolbar.setBackgroundColor(ContextCompat.getColor(Browser_right.this, R.color.colorTwo)); setSupportActionBar(toolbar); actionBar = getSupportActionBar(); customViewContainer = (FrameLayout) findViewById(R.id.customViewContainer); progressBar = (ProgressBar) findViewById(R.id.progressBar); editText = (EditText) findViewById(R.id.editText); editText.setVisibility(View.GONE); editText.setHint(R.string.app_search_hint); editText.clearFocus(); urlBar = (TextView) findViewById(R.id.urlBar); imageButton = (ImageButton) findViewById(R.id.imageButton); imageButton.setVisibility(View.INVISIBLE); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mWebView.scrollTo(0, 0); imageButton.setVisibility(View.INVISIBLE); if (!actionBar.isShowing()) { urlBar.setText(mWebView.getTitle()); actionBar.show(); } helper_browser.setNavArrows(mWebView, imageButton_left, imageButton_right); } }); SwipeRefreshLayout swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe); assert swipeView != null; swipeView.setColorSchemeResources(R.color.colorTwo, R.color.colorAccent); swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mWebView.reload(); } }); mWebView = (ObservableWebView) findViewById(R.id.webView); if (sharedPref.getString("fullscreen", "2").equals("2") || sharedPref.getString("fullscreen", "2").equals("3")) { mWebView.setScrollViewCallbacks(this); } mWebChromeClient = new myWebChromeClient(); mWebView.setWebChromeClient(mWebChromeClient); imageButton_left = (ImageButton) findViewById(R.id.imageButton_left); imageButton_right = (ImageButton) findViewById(R.id.imageButton_right); if (sharedPref.getBoolean("arrow", false)) { imageButton_left.setVisibility(View.VISIBLE); imageButton_right.setVisibility(View.VISIBLE); } else { imageButton_left.setVisibility(View.INVISIBLE); imageButton_right.setVisibility(View.INVISIBLE); } helper_webView.webView_Settings(Browser_right.this, mWebView); helper_webView.webView_WebViewClient(Browser_right.this, swipeView, mWebView, urlBar); mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); if (isNetworkUnAvailable()) { if (sharedPref.getBoolean("offline", false)) { if (isNetworkUnAvailable()) { // loading offline mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); Snackbar.make(mWebView, R.string.toast_cache, Snackbar.LENGTH_SHORT).show(); } } else { Snackbar.make(mWebView, R.string.toast_noInternet, Snackbar.LENGTH_SHORT).show(); } } mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimetype, long contentLength) { registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); Snackbar snackbar = Snackbar .make(mWebView, getString(R.string.toast_download_1) + " " + filename, Snackbar.LENGTH_LONG) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url)); request.allowScanningByMediaScanner(); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Snackbar.make(mWebView, getString(R.string.toast_download) + " " + filename, Snackbar.LENGTH_SHORT).show(); } }); snackbar.show(); } }); helper_browser.toolbar(Browser_right.this, Browser_left.class, mWebView, toolbar); helper_editText.editText_EditorAction(editText, Browser_right.this, mWebView, urlBar); helper_editText.editText_FocusChange(editText, Browser_right.this); helper_main.grantPermissionsStorage(Browser_right.this); onNewIntent(getIntent()); }
From source file:de.baumann.browser.Browser.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); WebView.enableSlowWholeDocumentDraw(); setContentView(R.layout.activity_browser); helper_main.onStart(Browser.this); Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); setSupportActionBar(toolbar);//from ww w . ja v a 2 s.com PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.edit().putInt("keyboard", 0).apply(); sharedPref.getInt("keyboard", 0); customViewContainer = (FrameLayout) findViewById(R.id.customViewContainer); progressBar = (ProgressBar) findViewById(R.id.progressBar); editText = (EditText) findViewById(R.id.editText); editText.setHint(R.string.app_search_hint); editText.clearFocus(); imageButton = (ImageButton) findViewById(R.id.imageButton); imageButton.setVisibility(View.INVISIBLE); imageButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { mWebView.scrollTo(0, 0); imageButton.setVisibility(View.INVISIBLE); actionBar = getSupportActionBar(); assert actionBar != null; if (!actionBar.isShowing()) { editText.setText(mWebView.getTitle()); actionBar.show(); } setNavArrows(); } }); SwipeRefreshLayout swipeView = (SwipeRefreshLayout) findViewById(R.id.swipe); assert swipeView != null; swipeView.setColorSchemeResources(R.color.colorPrimary, R.color.colorAccent); swipeView.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mWebView.reload(); } }); mWebView = (ObservableWebView) findViewById(R.id.webView); if (sharedPref.getString("fullscreen", "2").equals("2") || sharedPref.getString("fullscreen", "2").equals("3")) { mWebView.setScrollViewCallbacks(this); } mWebChromeClient = new myWebChromeClient(); mWebView.setWebChromeClient(mWebChromeClient); imageButton_left = (ImageButton) findViewById(R.id.imageButton_left); imageButton_right = (ImageButton) findViewById(R.id.imageButton_right); if (sharedPref.getBoolean("arrow", false)) { imageButton_left.setVisibility(View.VISIBLE); imageButton_right.setVisibility(View.VISIBLE); } else { imageButton_left.setVisibility(View.INVISIBLE); imageButton_right.setVisibility(View.INVISIBLE); } helper_webView.webView_Settings(Browser.this, mWebView); helper_webView.webView_WebViewClient(Browser.this, swipeView, mWebView, editText); mWebView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); if (isNetworkUnAvailable()) { if (sharedPref.getBoolean("offline", false)) { if (isNetworkUnAvailable()) { // loading offline mWebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK); Snackbar.make(mWebView, R.string.toast_cache, Snackbar.LENGTH_SHORT).show(); } } else { Snackbar.make(mWebView, R.string.toast_noInternet, Snackbar.LENGTH_SHORT).show(); } } mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(final String url, String userAgent, final String contentDisposition, final String mimetype, long contentLength) { registerReceiver(onComplete, new IntentFilter(DownloadManager.ACTION_DOWNLOAD_COMPLETE)); final String filename = URLUtil.guessFileName(url, contentDisposition, mimetype); Snackbar snackbar = Snackbar .make(mWebView, getString(R.string.toast_download_1) + " " + filename, Snackbar.LENGTH_LONG) .setAction(getString(R.string.toast_yes), new View.OnClickListener() { @Override public void onClick(View view) { DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); request.addRequestHeader("Cookie", CookieManager.getInstance().getCookie(url)); request.allowScanningByMediaScanner(); request.setNotificationVisibility( DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); //Notify client once download is completed! request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename); DownloadManager dm = (DownloadManager) getSystemService(DOWNLOAD_SERVICE); dm.enqueue(request); Snackbar.make(mWebView, getString(R.string.toast_download) + " " + filename, Snackbar.LENGTH_SHORT).show(); } }); snackbar.show(); } }); helper_editText.editText_Touch(editText, Browser.this, mWebView); helper_editText.editText_EditorAction(editText, Browser.this, mWebView); helper_editText.editText_FocusChange(editText, Browser.this); onNewIntent(getIntent()); helper_main.grantPermissionsStorage(Browser.this); }