Example usage for android.webkit WebSettings setBuiltInZoomControls

List of usage examples for android.webkit WebSettings setBuiltInZoomControls

Introduction

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

Prototype




public abstract void setBuiltInZoomControls(boolean enabled);

Source Link

Document

Sets whether the WebView should use its built-in zoom mechanisms.

Usage

From source file:com.btmura.android.reddit.app.LinkFragment.java

@SuppressLint("SetJavaScriptEnabled")
private void setupWebView(WebView webView) {
    WebSettings settings = webView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setDomStorageEnabled(true);
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);
    settings.setSupportZoom(true);/*from w w  w  .  j av a  2 s .  com*/
    settings.setPluginState(PluginState.ON_DEMAND);
    settings.setUseWideViewPort(true);

    webView.setOnLongClickListener(this);

    webView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            if (progress != null) {
                progress.setVisibility(View.VISIBLE);
            }
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            if (progress != null) {
                progress.setVisibility(View.GONE);
            }
        }
    });

    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            if (progress != null) {
                progress.setProgress(newProgress);
            }
        }
    });
}

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);//from ww w.  ja v  a  2  s.  c om
    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:com.cnm.cnmrc.fragment.search.SearchNaverSub.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.tvch_semidetail, container, false);

    preventClickDispatching = (FrameLayout) layout.findViewById(R.id.search_tvch_prevent_click_dispatching);
    preventClickDispatching.setOnClickListener(this);

    webview = (WebView) layout.findViewById(R.id.webView);
    webview.setVisibility(View.INVISIBLE);

    // listview//from   w ww  . j  a v a 2 s  . com
    listView = (ListView) layout.findViewById(R.id.tvch_semidetail);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @SuppressLint("SetJavaScriptEnabled")
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //Intent intent = new Intent(Intent.ACTION_VIEW);
            //Uri uri = Uri.parse(mResult.get(position).getLink());
            //intent.setData(uri);
            //getActivity().startActivity(intent);

            //webview use to call own site
            webview.setWebViewClient(new WebViewClient());
            WebSettings set = webview.getSettings();
            set.setJavaScriptEnabled(true);
            set.setBuiltInZoomControls(true);
            webview.loadUrl(mResult.get(position).getLink());
            webview.setVisibility(View.VISIBLE);

            // zoom all
            webview.getSettings().setLoadWithOverviewMode(true);
            webview.getSettings().setUseWideViewPort(true);

            //webview.setVerticalScrollBarEnabled(false);
            //webview.setHorizontalScrollBarEnabled(false);
        }

    });

    return layout;
}

From source file:com.cnm.cnmrc.fragment.search.SearchNaver.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View layout = inflater.inflate(R.layout.search_naver, container, false);

    preventClickDispatching = (FrameLayout) layout.findViewById(R.id.prevent_click_dispatching);
    preventClickDispatching.setOnClickListener(this);

    webview = (WebView) layout.findViewById(R.id.webView);
    webview.setVisibility(View.INVISIBLE);

    // listview//w w w .  j a  v a2 s.com
    listView = (ListView) layout.findViewById(R.id.listview);
    listView.setDivider(null);
    listView.setDividerHeight(0);
    listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @SuppressLint("SetJavaScriptEnabled")
        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            //Intent intent = new Intent(Intent.ACTION_VIEW);
            //Uri uri = Uri.parse(mResult.get(position).getLink());
            //intent.setData(uri);
            //getActivity().startActivity(intent);

            //webview use to call own site
            webview.setWebViewClient(new WebViewClient());
            WebSettings set = webview.getSettings();
            set.setJavaScriptEnabled(true);
            set.setBuiltInZoomControls(true);
            webview.loadUrl(mResult.get(position).getLink());
            webview.setVisibility(View.VISIBLE);

            // zoom all
            webview.getSettings().setLoadWithOverviewMode(true);
            webview.getSettings().setUseWideViewPort(true);

            //webview.setVerticalScrollBarEnabled(false);
            //webview.setHorizontalScrollBarEnabled(false);
        }

    });

    return layout;
}

From source file:com.jio.mhood.services.api.settings.LicensesFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//  w  w  w . j  a  v  a2s  .  c  o m
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    ViewGroup view = (ViewGroup) inflater.inflate(R.layout.fragment_licenses, container, false);

    if (mWebView == null) {
        mWebView = new WebView(view.getContext());
        mWebView.setLayoutParams(
                new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.setBackgroundColor(0);

        WebSettings webSettings = mWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setDomStorageEnabled(true);
        webSettings.setPluginState(PluginState.ON_DEMAND);
        webSettings.setPluginState(PluginState.ON);
        webSettings.setBuiltInZoomControls(true);
        webSettings.setUseWideViewPort(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            webSettings.setDisplayZoomControls(false);
        }

        mWebView.loadUrl(URL);
    } else {
        mParent.removeView(mWebView);
    }
    mParent = view;
    mParent.addView(mWebView);

    return mParent;
}

From source file:com.analysedesgeeks.android.WebFragment.java

@Override
public View onCreateView(final LayoutInflater inflater, final ViewGroup container,
        final Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    final View v = inflater.inflate(R.layout.fragment_webview, container, false);

    webview = (WebView) v.findViewById(R.id.webview);

    final WebSettings settings = webview.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    settings.setDefaultZoom(WebSettings.ZoomDensity.FAR);
    settings.setSupportZoom(true);//www.j a v  a  2 s.  c  o  m
    settings.setBuiltInZoomControls(true);

    //load a custom user agent 
    //see http://stackoverflow.com/questions/6856814/problems-loading-mobile-twitter-in-webview
    settings.setUserAgentString(
            "Mozilla/5.0 (Linux; U; Android 2.0; en-us; Droid Build/ESD20) AppleWebKit/530.17 (KHTML, like Gecko) Version/4.0 Mobile Safari/530.17");

    final View loading = v.findViewById(R.id.loading);

    webview.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageFinished(final WebView view, final String url) {
            loading.setVisibility(View.GONE);
        }
    });

    webview.loadUrl(url);

    return v;
}

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

@SuppressLint("SetJavaScriptEnabled")
@Override//  w  w  w  .ja  va2s. 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.github.snowdream.android.widget.NotFoundWebView.java

@SuppressLint({ "SetJavaScriptEnabled", "NewApi" })
private void init(Context context, AttributeSet attrs, int defStyle) {
    if (context == null) {
        return;/* www.j  av a 2  s .c  om*/
    }

    // enable JavaScript
    WebSettings settings = this.getSettings();
    settings.setJavaScriptEnabled(true);

    settings.setSupportZoom(true);
    settings.setBuiltInZoomControls(true);
    settings.setLoadWithOverviewMode(true);
    settings.setDefaultZoom(ZoomDensity.FAR);

    //settings.setUseWideViewPort(true);
    //webView.setInitialScale(1);

    // init attrs
    TypedArray a = getContext().obtainStyledAttributes(attrs, R.styleable.CustomWebView);

    try {
        int type = a.getInteger(R.styleable.CustomWebView_type, 0);
        switch (type) {
        case 0:
            script = context.getString(R.string.html_notfound);
            break;
        case 1:
            script = context.getString(R.string.html_qq_narrow);
            break;
        case 2:
            script = context.getString(R.string.html_qq_narrow);
            break;
        case 3:
            script = context.getString(R.string.html_qq_wide);
            break;
        case 4:
            script = context.getString(R.string.html_yibo);
            break;
        default:
            script = a.getString(R.styleable.CustomWebView_script);
            break;
        }
    } finally {
        a.recycle();
    }
}

From source file:com.ap.github.ui.activitys.LoginActivity.java

@SuppressLint("SetJavaScriptEnabled")
private void initLoginWebView() {
    mLoginWebView.setVerticalScrollBarEnabled(false);
    mLoginWebView.setHorizontalScrollBarEnabled(false);
    mLoginWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
    mLoginWebView.getSettings().setJavaScriptEnabled(true);
    mLoginWebView.setWebViewClient(new LoginWebViewClient(this));

    WebSettings webSettings = mLoginWebView.getSettings();
    webSettings.setUseWideViewPort(true);
    webSettings.setSupportZoom(false);//from ww w.  j av a2s  .c  om
    webSettings.setBuiltInZoomControls(false);
    webSettings.setAllowFileAccess(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(true);
    webSettings.setLoadsImagesAutomatically(true);
}

From source file:com.cerema.cloud2.ui.dialog.SamlWebViewDialog.java

@SuppressWarnings("deprecation")
@SuppressLint("SetJavaScriptEnabled")
@Override/* w  ww .j av a 2 s  .c o  m*/
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    Log_OC.v(TAG, "onCreateView, savedInsanceState is " + savedInstanceState);

    // Inflate layout of the dialog  
    RelativeLayout ssoRootView = (RelativeLayout) inflater.inflate(R.layout.sso_dialog, container, false); // null parent view because it will go in the dialog layout

    if (mSsoWebView == null) {
        // initialize the WebView
        mSsoWebView = new SsoWebView(getActivity().getApplicationContext());
        mSsoWebView.setFocusable(true);
        mSsoWebView.setFocusableInTouchMode(true);
        mSsoWebView.setClickable(true);

        WebSettings webSettings = mSsoWebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        webSettings.setBuiltInZoomControls(false);
        webSettings.setLoadWithOverviewMode(false);
        webSettings.setSavePassword(false);
        webSettings.setUserAgentString(MainApp.getUserAgent());
        webSettings.setSaveFormData(false);

        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.setAcceptCookie(true);
        cookieManager.removeAllCookie();

        mSsoWebView.loadUrl(mInitialUrl);
    }

    mWebViewClient.setTargetUrl(mTargetUrl);
    mSsoWebView.setWebViewClient(mWebViewClient);

    // add the webview into the layout
    RelativeLayout.LayoutParams layoutParams = new RelativeLayout.LayoutParams(
            RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
    ssoRootView.addView(mSsoWebView, layoutParams);
    ssoRootView.requestLayout();

    return ssoRootView;
}