Example usage for android.webkit WebSettings setSupportMultipleWindows

List of usage examples for android.webkit WebSettings setSupportMultipleWindows

Introduction

In this page you can find the example usage for android.webkit WebSettings setSupportMultipleWindows.

Prototype

public abstract void setSupportMultipleWindows(boolean support);

Source Link

Document

Sets whether the WebView whether supports multiple windows.

Usage

From source file:net.niyonkuru.koodroid.webview.BlockingWebView.java

public static BlockingWebView createInstance(Context ctx) {
    BlockingWebView view = new BlockingWebView(ctx);

    WebSettings websettings = view.getSettings();

    websettings.setJavaScriptEnabled(true);
    websettings.setDatabaseEnabled(false);
    websettings.setDomStorageEnabled(false);
    websettings.setSupportZoom(false);/*from   ww w  . j  a  v a2  s .co  m*/
    websettings.setSavePassword(false);
    websettings.setSupportMultipleWindows(false);
    websettings.setAppCacheEnabled(false);
    websettings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    websettings.setBlockNetworkImage(true);

    return view;
}

From source file:org.microg.gms.auth.login.LoginActivity.java

@SuppressLint("SetJavaScriptEnabled")
private static void prepareWebViewSettings(WebSettings settings) {
    settings.setUserAgentString(settings.getUserAgentString() + MAGIC_USER_AGENT);
    settings.setJavaScriptEnabled(true);
    settings.setSupportMultipleWindows(false);
    settings.setSaveFormData(false);/*from   ww w.ja v a2  s .  c o  m*/
    settings.setAllowFileAccess(false);
    settings.setDatabaseEnabled(false);
    settings.setNeedInitialFocus(false);
    settings.setUseWideViewPort(false);
    settings.setSupportZoom(false);
    settings.setJavaScriptCanOpenWindowsAutomatically(false);
}

From source file:com.pixate.freestyle.viewdemo.ViewDetailFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override/*from ww w. j  a va2  s  . c o m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    final View rootView = inflater.inflate(R.layout.fragment_view_detail, container, false);

    if (mItem != null) {
        // set the views
        ViewSample viewSample = mItem.getViewSample();
        final ViewGroup viewsHolder = (ViewGroup) rootView.findViewById(R.id.holder);
        viewSample.createViews(getActivity(), viewsHolder);

        // load the CSS styling for the sample
        String css = ViewsData.getCSS(getActivity(), mItem);

        // Set up syntax highlighting
        WebView cssView = (WebView) rootView.findViewById(R.id.css_style);
        WebSettings s = cssView.getSettings();
        s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
        s.setUseWideViewPort(false);
        s.setAllowFileAccess(true);
        s.setBuiltInZoomControls(true);
        s.setSupportZoom(true);
        s.setSupportMultipleWindows(false);
        s.setJavaScriptEnabled(true);

        StringBuilder contentString = new StringBuilder();
        contentString.append("<html><head>");
        contentString.append(
                "<link href='file:///android_asset/prettify/prettify.css' rel='stylesheet' type='text/css'/> ");
        contentString.append(
                "<script src='file:///android_asset/prettify/prettify.js' type='text/javascript'></script> ");
        contentString.append(
                "<script src='file:///android_asset/prettify/lang-css.js' type='text/javascript'></script> ");
        contentString.append("</head><body onload='prettyPrint()'><code class='prettyprint lang-css'>");
        contentString.append(TextUtils.htmlEncode(css).replaceAll("\n", "<br>").replaceAll(" ", "&nbsp;")
                .replaceAll("\t", "&nbsp;&nbsp;"));
        contentString.append("</code> </html> ");
        cssView.getSettings().setUseWideViewPort(true);
        cssView.loadDataWithBaseURL("file:///android_asset/prettify/", contentString.toString(), "text/html",
                StringUtil.EMPTY, StringUtil.EMPTY);

        // to aid in styling the css text shows in the textview, set its
        // ID. Eventually will not be needed.
        if (!"css-style".equals(PixateFreestyle.getStyleId(cssView))) {
            PixateFreestyle.setStyleId(cssView, "css-style", true);
        }

        // Style
        viewSample.style(css);
    }

    return rootView;
}

From source file:com.gh4a.FileViewerActivity.java

private void fillData(boolean highlight) {
    String data = new String(EncodingUtils.fromBase64(mContent.getContent()));
    WebView webView = (WebView) findViewById(R.id.web_view);

    WebSettings s = webView.getSettings();
    s.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NORMAL);
    s.setAllowFileAccess(true);/*  www. j  av a2 s .  com*/
    s.setBuiltInZoomControls(true);
    s.setLightTouchEnabled(true);
    s.setLoadsImagesAutomatically(true);
    s.setPluginsEnabled(false);
    s.setSupportZoom(true);
    s.setSupportMultipleWindows(true);
    s.setJavaScriptEnabled(true);
    s.setUseWideViewPort(true);

    webView.setWebViewClient(webViewClient);
    if (FileUtils.isImage(mName)) {
        String htmlImage = StringUtils.highlightImage(
                "https://github.com/" + mRepoOwner + "/" + mRepoName + "/raw/" + mRef + "/" + mPath);
        webView.loadDataWithBaseURL("file:///android_asset/", htmlImage, "text/html", "utf-8", "");
    } else {
        String highlighted = StringUtils.highlightSyntax(data, highlight, mName);
        webView.loadDataWithBaseURL("file:///android_asset/", highlighted, "text/html", "utf-8", "");
    }
}

From source file:org.openqa.selendroid.server.model.SelendroidWebDriver.java

private void configureWebView(final WebView view) {
    ServerInstrumentation.getInstance().runOnUiThread(new Runnable() {

        @Override//from w  w w.  j ava 2  s  .  c  o  m
        public void run() {
            view.clearCache(true);
            view.clearFormData();
            view.clearHistory();
            view.setFocusable(true);
            view.setFocusableInTouchMode(true);
            view.setNetworkAvailable(true);
            view.setWebChromeClient(new MyWebChromeClient());

            WebSettings settings = view.getSettings();
            settings.setJavaScriptCanOpenWindowsAutomatically(true);
            settings.setSupportMultipleWindows(true);
            settings.setBuiltInZoomControls(true);
            settings.setJavaScriptEnabled(true);
            settings.setAppCacheEnabled(true);
            settings.setAppCacheMaxSize(10 * 1024 * 1024);
            settings.setAppCachePath("");
            settings.setDatabaseEnabled(true);
            settings.setDomStorageEnabled(true);
            settings.setGeolocationEnabled(true);
            settings.setSaveFormData(false);
            settings.setSavePassword(false);
            settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
            // Flash settings
            settings.setPluginState(WebSettings.PluginState.ON);

            // Geo location settings
            settings.setGeolocationEnabled(true);
            settings.setGeolocationDatabasePath("/data/data/selendroid");
        }
    });
}

From source file:com.wpi.assistments.HomeTabbedActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_webview);

    final ProgressDialog pd = ProgressDialog.show(this, "", "Loading...", true);

    isTeacher = false;/*  w w w .  j a v a  2  s.c o  m*/
    toggle = true;
    logoutFlag = false;

    homeWebView = (WebView) findViewById(R.id.homeWebView);
    homeWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView view, String url) {
            Log.i("test", view.getUrl());
            if (view.getUrl().equals("https://www.assistments.org/account/login") && !logoutFlag) {

                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
                intent.putExtra("showPopup", "true");
                startActivity(intent);
                finish();
            } else if (view.getUrl().equals("https://www.assistments.org/teacher")) {
                isTeacher = true;
            } else if (view.getUrl().equals("https://www.assistments.org/account/login") && logoutFlag) {
                Intent intent = new Intent(getApplicationContext(), LoginActivity.class);
                startActivity(intent);
            }

            if (!homeWebView.canGoBack()) {
                btnBack.setEnabled(false);
            } else {
                btnBack.setEnabled(true);
            }

            if (!homeWebView.canGoForward()) {
                btnForward.setEnabled(false);
            } else {
                btnForward.setEnabled(true);
            }

            if (pd.isShowing() && pd != null) {
                pd.dismiss();
            }
        }

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            pd.show();
            view.loadUrl(url);
            return true;
        }
    });
    homeWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
            new AlertDialog.Builder(webviewContext).setTitle("ASSISTments").setMessage(message)
                    .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            logoutFlag = true;
                            result.confirm();
                        }
                    }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int which) {
                            result.cancel();
                        }
                    }).create().show();

            return true;
        }
    });

    if (savedInstanceState != null) {
        homeWebView.restoreState(savedInstanceState);
    } else {
        /** Scaling, replaced by overview mode and wide view port
        Display display = getWindowManager().getDefaultDisplay();
        Point size = new Point();
        display.getSize(size);
        if (size.x <= 780) {
           int scaleRate = (int) ((size.x) / 7.8);
           Log.i("test", Integer.toString(size.x));
           homeWebView.setInitialScale(scaleRate);
        }
        */

        Intent intent = getIntent();

        if (intent.getStringExtra("username").equals("") && intent.getStringExtra("password").equals("")) {
            homeWebView.loadUrl("https://www.assistments.org/signup");

        } else {
            String username = intent.getStringExtra("username");
            String password = intent.getStringExtra("password");

            String postData = "login=" + username + "&password=" + password + "&commit=Log in";
            homeWebView.postUrl("https://www.assistments.org/account/login",
                    EncodingUtils.getBytes(postData, "BASE64"));
        }

    }

    WebSettings settings = homeWebView.getSettings();
    settings.setSaveFormData(false);
    settings.setSavePassword(false);
    settings.setJavaScriptEnabled(true);
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setJavaScriptCanOpenWindowsAutomatically(true);
    settings.setSupportMultipleWindows(true);
    settings.setCacheMode(WebSettings.LOAD_NO_CACHE);
    settings.setAppCacheEnabled(false);
    settings.setDomStorageEnabled(true);
    settings.setDatabaseEnabled(true);
    settings.setUseWideViewPort(false);
    settings.setLoadWithOverviewMode(true);
    homeWebView.clearCache(true);
    homeWebView.setPadding(0, 0, 0, 0);
    homeWebView.setInitialScale(getScale());

    btnBack = (Button) findViewById(R.id.btnBack);
    btnBack.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            homeWebView.goBack();
        }
    });

    btnRefresh = (Button) findViewById(R.id.btnRefresh);
    btnRefresh.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            //homeWebView.zoomOut();
            homeWebView.scrollTo(1000, 0);
            Log.i("test", "111");
            //homeWebView.reload();
        }
    });

    btnForward = (Button) findViewById(R.id.btnForward);
    btnForward.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            homeWebView.goForward();
        }
    });

    btnOffline = (Button) findViewById(R.id.btnOffline);
    btnOffline.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            if (toggle) {
                homeWebView.loadUrl(
                        "https://www.assistments.org/assistments/student/index.html#offlineUserAssignmentList/");
                btnOffline.setText("Home");
                toggle = false;
            } else {
                if (isTeacher) {
                    homeWebView.loadUrl("https://www.assistments.org/teacher");
                } else {
                    homeWebView.loadUrl("https://www.assistments.org/tutor");
                }
                btnOffline.setText("Offline");
                toggle = true;
            }

        }
    });
}

From source file:com.quarterfull.newsAndroid.NewsDetailFragment.java

@SuppressLint("SetJavaScriptEnabled")
private void init_webView() {
    int backgroundColor = ColorHelper.getColorFromAttribute(getContext(), R.attr.news_detail_background_color);
    mWebView.setBackgroundColor(backgroundColor);

    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setAllowFileAccess(true);
    webSettings.setDomStorageEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
    webSettings.setSupportMultipleWindows(false);
    webSettings.setSupportZoom(false);/*from w ww.j a  va2 s.  c o  m*/
    webSettings.setAppCacheEnabled(true);

    registerForContextMenu(mWebView);

    mWebView.setWebChromeClient(new WebChromeClient() {
        @Override
        public boolean onConsoleMessage(ConsoleMessage cm) {
            Log.v(TAG, cm.message() + " at " + cm.sourceId() + ":" + cm.lineNumber());
            return true;
        }

        @Override
        public void onProgressChanged(WebView view, int progress) {
            if (progress < 100 && mProgressbarWebView.getVisibility() == ProgressBar.GONE) {
                mProgressbarWebView.setVisibility(ProgressBar.VISIBLE);
            }
            mProgressbarWebView.setProgress(progress);
            if (progress == 100) {
                mProgressbarWebView.setVisibility(ProgressBar.GONE);

                //The following three lines are a workaround for websites which don't use a background color
                int bgColor = ContextCompat.getColor(getContext(),
                        R.color.slider_listview_text_color_dark_theme);
                NewsDetailActivity ndActivity = ((NewsDetailActivity) getActivity());
                mWebView.setBackgroundColor(bgColor);
                ndActivity.mViewPager.setBackgroundColor(bgColor);

                if (ThemeChooser.isDarkTheme(getActivity())) {
                    mWebView.setBackgroundColor(
                            ContextCompat.getColor(getContext(), android.R.color.transparent));
                }
            }
        }
    });

    mWebView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (changedUrl) {
                changedUrl = false;

                if (!url.equals("file:///android_asset/") && (urls.isEmpty() || !urls.get(0).equals(url))) {
                    urls.add(0, url);

                    Log.v(TAG, "Page finished (added): " + url);
                }
            }

            super.onPageStarted(view, url, favicon);
        }
    });

    mWebView.setOnTouchListener(new View.OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            if (v.getId() == R.id.webview && event.getAction() == MotionEvent.ACTION_DOWN) {
                changedUrl = true;
            }

            return false;
        }
    });
}

From source file:io.selendroid.server.model.SelendroidWebDriver.java

private void configureWebView(final WebView view) {
    ServerInstrumentation.getInstance().getCurrentActivity().runOnUiThread(new Runnable() {

        @Override//  w  w w  .j  ava2s .co m
        public void run() {
            try {
                view.clearCache(true);
                view.clearFormData();
                view.clearHistory();
                view.setFocusable(true);
                view.setFocusableInTouchMode(true);
                view.setNetworkAvailable(true);
                // need to check the class name rather than checking instanceof
                // since when it is not an instanceof, it likely means the app under test
                // does not contain the Cordova project and this will cause a RuntimeException
                if (view.getClass().getSimpleName().equalsIgnoreCase("CordovaWebView")) {
                    CordovaWebView webview = (CordovaWebView) view;
                    CordovaInterface ci = null;
                    chromeClient = new ExtendedCordovaChromeClient(null, webview);
                } else {
                    chromeClient = new SelendroidWebChromeClient();
                }
                view.setWebChromeClient(chromeClient);

                WebSettings settings = view.getSettings();
                settings.setJavaScriptCanOpenWindowsAutomatically(true);
                settings.setSupportMultipleWindows(true);
                settings.setBuiltInZoomControls(true);
                settings.setJavaScriptEnabled(true);
                settings.setAppCacheEnabled(true);
                settings.setAppCacheMaxSize(10 * 1024 * 1024);
                settings.setAppCachePath("");
                settings.setDatabaseEnabled(true);
                settings.setDomStorageEnabled(true);
                settings.setGeolocationEnabled(true);
                settings.setSaveFormData(false);
                settings.setSavePassword(false);
                settings.setRenderPriority(WebSettings.RenderPriority.HIGH);
                // Flash settings
                settings.setPluginState(WebSettings.PluginState.ON);

                // Geo location settings
                settings.setGeolocationEnabled(true);
                settings.setGeolocationDatabasePath("/data/data/selendroid");
            } catch (Exception e) {
                SelendroidLogger.error("Error configuring web view", e);
            }
        }
    });
}

From source file:com.lemon.lime.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getBatteryPercentage();//from  www.j a  v a  2  s .co  m
    setContentView(R.layout.activity_main);
    getSupportActionBar().setDisplayShowCustomEnabled(true);
    getSupportActionBar().setDisplayShowTitleEnabled(false);
    mWebView = (ObservableWebView) findViewById(R.id.activity_main_webview);
    mWebView.setScrollViewCallbacks(this);
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    View v = inflator.inflate(R.layout.bar, null);
    getSupportActionBar().setCustomView(v);

    WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath());

    swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            mWebView.reload();
        }
    });
    swipeLayout.setColorSchemeResources(R.color.lili, R.color.colorPrimary, R.color.red);

    window = getWindow();
    favicon = (ImageView) findViewById(R.id.favicon);
    editurl = (EditText) findViewById(R.id.editurl);
    mWebView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype,
                long contentLength) {

            Uri uri = Uri.parse(url);
            Intent intent = new Intent(Intent.ACTION_VIEW, uri);
            startActivity(intent);
        }

    });

    favicon.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (lili == 5) {
                lilimode();
                lili = 0;
                lilimode = true;
            } else {
                lili = lili + 1;
            }
        }
    });

    editurl.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_ENTER) {
                if (event.getAction() == KeyEvent.ACTION_UP) {
                    if (editurl.getText().toString().contains("file:///")) {
                        filemgr();
                    } else if (editurl.getText().toString().contains("gaymode")) {
                        gaymode();
                    } else if (editurl.getText().toString().contains("exitapp")) {
                        finish();
                    } else if (editurl.getText().toString().contains("light")) {
                        flash();
                    }

                    if (isconnected()) {
                        if (editurl.getText().toString().contains("http://")
                                || editurl.getText().toString().contains("https://")) {
                            mWebView.loadUrl(editurl.getText().toString());

                        } else if (editurl.getText().toString().contains(".com")
                                || editurl.getText().toString().contains(".net")
                                || editurl.getText().toString().contains(".org")
                                || editurl.getText().toString().contains(".gov")
                                || editurl.getText().toString().contains(".hu")
                                || editurl.getText().toString().contains(".sk")
                                || editurl.getText().toString().contains(".co.uk")
                                || editurl.getText().toString().contains(".co.in")
                                || editurl.getText().toString().contains(".cn")
                                || editurl.getText().toString().contains(".it")
                                || editurl.getText().toString().contains(".de")
                                || editurl.getText().toString().contains(".aus")
                                || editurl.getText().toString().contains(".hr")
                                || editurl.getText().toString().contains(".cz")
                                || editurl.getText().toString().contains(".xyz")
                                || editurl.getText().toString().contains(".pl")
                                || editurl.getText().toString().contains(".io")) {
                            mWebView.loadUrl("http://" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);

                        } else {
                            mWebView.loadUrl("https://www.google.com/search?q=" + editurl.getText().toString());

                            InputMethodManager imm = (InputMethodManager) getSystemService(
                                    Context.INPUT_METHOD_SERVICE);
                            imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0);
                        }
                    }
                    return true;
                }
                return false;
            }

            return true;
        }
    });
    // Enable Javascript
    WebSettings webSettings = mWebView.getSettings();
    webSettings.setJavaScriptEnabled(true);
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setSupportMultipleWindows(true);

    if (isconnected()) {
        mWebView.loadUrl("http://google.com");
    } else {

        final View coordinatorLayoutView = findViewById(R.id.snackbarPosition);
        mWebView.loadUrl("file:///android_asset/nonet.html");
        Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.offline, Snackbar.LENGTH_LONG);
        snackbar.show();

    }

    mWebView.setWebChromeClient(new WebChromeClient() {

        @Override
        public void onReceivedIcon(WebView mWebView, Bitmap icon) {
            super.onReceivedIcon(mWebView, icon);
            favicon.setImageBitmap(icon);
        }

        public void onProgressChanged(WebView view, int progress) {
            activity.setProgress(progress * 100);
            int a = progress;
            if (lilimode) {
                editurl.setText("Liling: " + Integer.toString(a) + "?");
            } else
                editurl.setText("Liming: " + Integer.toString(a) + "%");
            if (progress == 100) {

                editurl.setHint(view.getTitle());
                activity.setTitle(view.getTitle());
                editurl.setText(view.getUrl());

                fav();

                //battery
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    if (level <= 20) {
                        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
                        window.setNavigationBarColor(Color.RED);
                        window.setStatusBarColor(Color.RED);
                        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED));
                    }
                }
            }
        }
    });

    mWebView.setWebViewClient(new WebViewClient() {
        public void onPageFinished(WebView mWebView, String url) {
            swipeLayout.setRefreshing(false);
        }
    });

}

From source file:com.acrutiapps.browser.ui.components.CustomWebView.java

@SuppressLint("SetJavaScriptEnabled")
public void loadSettings() {
    WebSettings settings = getSettings();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());

    settings.setJavaScriptEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_JAVASCRIPT, true));
    settings.setLoadsImagesAutomatically(prefs.getBoolean(Constants.PREFERENCE_ENABLE_IMAGES, true));
    settings.setUseWideViewPort(prefs.getBoolean(Constants.PREFERENCE_USE_WIDE_VIEWPORT, true));
    settings.setLoadWithOverviewMode(prefs.getBoolean(Constants.PREFERENCE_LOAD_WITH_OVERVIEW, false));

    settings.setGeolocationEnabled(prefs.getBoolean(Constants.PREFERENCE_ENABLE_GEOLOCATION, true));
    settings.setSaveFormData(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_FORM_DATA, true));
    settings.setSavePassword(prefs.getBoolean(Constants.PREFERENCE_REMEMBER_PASSWORDS, true));

    settings.setTextZoom(prefs.getInt(Constants.PREFERENCE_TEXT_SCALING, 100));

    int minimumFontSize = prefs.getInt(Constants.PREFERENCE_MINIMUM_FONT_SIZE, 1);
    settings.setMinimumFontSize(minimumFontSize);
    settings.setMinimumLogicalFontSize(minimumFontSize);

    boolean useInvertedDisplay = prefs.getBoolean(Constants.PREFERENCE_INVERTED_DISPLAY, false);
    setWebSettingsProperty(settings, "inverted", useInvertedDisplay ? "true" : "false");

    if (useInvertedDisplay) {
        setWebSettingsProperty(settings, "inverted_contrast",
                Float.toString(prefs.getInt(Constants.PREFERENCE_INVERTED_DISPLAY_CONTRAST, 100) / 100f));
    }/*  w  w  w.  j a va  2  s  . co m*/

    settings.setUserAgentString(prefs.getString(Constants.PREFERENCE_USER_AGENT, Constants.USER_AGENT_ANDROID));
    settings.setPluginState(PluginState
            .valueOf(prefs.getString(Constants.PREFERENCE_PLUGINS, PluginState.ON_DEMAND.toString())));

    CookieManager.getInstance().setAcceptCookie(prefs.getBoolean(Constants.PREFERENCE_ACCEPT_COOKIES, true));

    settings.setSupportZoom(true);
    settings.setDisplayZoomControls(false);
    settings.setBuiltInZoomControls(true);
    settings.setSupportMultipleWindows(true);
    settings.setEnableSmoothTransition(true);

    if (mPrivateBrowsing) {
        settings.setGeolocationEnabled(false);
        settings.setSaveFormData(false);
        settings.setSavePassword(false);

        settings.setAppCacheEnabled(false);
        settings.setDatabaseEnabled(false);
        settings.setDomStorageEnabled(false);
    } else {
        // HTML5 API flags
        settings.setAppCacheEnabled(true);
        settings.setDatabaseEnabled(true);
        settings.setDomStorageEnabled(true);

        // HTML5 configuration settings.
        settings.setAppCacheMaxSize(3 * 1024 * 1024);
        settings.setAppCachePath(mContext.getDir("appcache", 0).getPath());
        settings.setDatabasePath(mContext.getDir("databases", 0).getPath());
        settings.setGeolocationDatabasePath(mContext.getDir("geolocation", 0).getPath());
    }

    setLongClickable(true);
    setDownloadListener(this);
}