List of usage examples for android.webkit WebView enableSlowWholeDocumentDraw
public static void enableSlowWholeDocumentDraw()
From source file:de.baumann.browser.Browser_left.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); getWindow().setStatusBarColor(ContextCompat.getColor(Browser_left.this, R.color.colorPrimaryDark)); WebView.enableSlowWholeDocumentDraw(); setContentView(R.layout.activity_browser); helper_main.checkPin(Browser_left.this); helper_main.onStart(Browser_left.this); PreferenceManager.setDefaultValues(this, R.xml.user_settings, false); PreferenceManager.setDefaultValues(this, R.xml.user_settings_search, false); sharedPref = PreferenceManager.getDefaultSharedPreferences(this); sharedPref.edit().putBoolean("isOpened", true).apply(); boolean show = sharedPref.getBoolean("introShowDo_notShow", true); if (show) {/* w ww . j av a 2s . c om*/ helper_main.switchToActivity(Browser_left.this, Activity_intro.class, "", false); } sharedPref.edit() .putString("openURL", sharedPref.getString("startURL", "https://github.com/scoute-dich/browser/")) .apply(); sharedPref.edit().putInt("keyboard", 0).apply(); sharedPref.getInt("keyboard", 0); if (sharedPref.getString("saved_key_ok", "no").equals("no")) { char[] chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890!$%&/()=?;:_-.,+#*<>" .toCharArray(); StringBuilder sb = new StringBuilder(); Random random = new Random(); for (int i = 0; i < 25; i++) { char c = chars[random.nextInt(chars.length)]; sb.append(c); } sharedPref.edit().putString("saved_key", sb.toString()).apply(); sharedPref.edit().putString("saved_key_ok", "yes").apply(); } Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 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.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_left.this, mWebView); helper_webView.webView_WebViewClient(Browser_left.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_left.this, Browser_right.class, mWebView, toolbar); helper_editText.editText_EditorAction(editText, Browser_left.this, mWebView, urlBar); helper_editText.editText_FocusChange(editText, Browser_left.this); helper_main.grantPermissionsStorage(Browser_left.this); onNewIntent(getIntent()); }