Example usage for android.webkit WebSettings setDisplayZoomControls

List of usage examples for android.webkit WebSettings setDisplayZoomControls

Introduction

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

Prototype

public abstract void setDisplayZoomControls(boolean enabled);

Source Link

Document

Sets whether the WebView should display on-screen zoom controls when using the built-in zoom mechanisms.

Usage

From source file:Main.java

public static void hideZoomControls(android.webkit.WebSettings settings) {
    settings.setDisplayZoomControls(false);
}

From source file:io.github.hidroh.materialistic.AppUtils.java

public static void toggleWebViewZoom(WebSettings webSettings, boolean enabled) {
    webSettings.setSupportZoom(enabled);
    webSettings.setBuiltInZoomControls(enabled);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        webSettings.setDisplayZoomControls(false);
    }//from  w w w  .ja v a  2  s  . c o m
}

From source file:in.rab.bildkort.ImageFragment.java

@SuppressLint("SetJavaScriptEnabled")
@Override//from   w w w .  j ava2  s .com
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    mWebView = (WebView) getView().findViewById(R.id.webView);
    final ProgressBar progress = (ProgressBar) getView().findViewById(R.id.image_progress);
    mWebView.setWebChromeClient(new WebChromeClient());
    final WebSettings settings = mWebView.getSettings();

    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setJavaScriptEnabled(true);

    // We replace the src urls in imagepicker.js::init(), so don't load
    // images twice.
    settings.setBlockNetworkImage(true);

    mWebView.setInitialScale(100);

    mWebView.setWebViewClient(new WebViewClient() {
        @Override
        public void onPageFinished(WebView view, String url) {
            if (Objects.equals(url, GSTATIC_SERVER)) {
                settings.setBlockNetworkImage(false);

                progress.setVisibility(View.GONE);
                mWebView.setVisibility(View.VISIBLE);
            } else {
                view.loadUrl("javascript:" + getImagePickerJs() + "getPickerHtml();");
            }
        }
    });

    mWebView.addJavascriptInterface(new WcmJsObject(), "wcm");
    mWebView.loadUrl("https://www.google.se/search?tbm=isch&q=" + getWord());
}

From source file:com.rickendirk.rsgwijzigingen.WebFragment.java

@Nullable
@Override//from   w  w w  .j a  v a 2  s. c  om
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable final Bundle savedInstanceState) {

    View mainView = inflater.inflate(R.layout.fragment_web, container, false);
    if (savedInstanceState != null) {
        is1eKeerGenegeerd = true;
    }
    progressBar = (ProgressBar) getActivity().findViewById(R.id.progressBar);

    webView = (NestedWebView) mainView.findViewById(R.id.webView);
    webView.setNestedScrollingEnabled(true);
    WebSettings webSettings = webView.getSettings();
    webSettings.setBuiltInZoomControls(true);
    webSettings.setDisplayZoomControls(false);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webView.setWebViewClient(new WebViewClient() {

        @Override
        public void onPageStarted(WebView view, String url, Bitmap favicon) {
            isLoading = true;
            isFinished = false;
            progressBar.setVisibility(View.VISIBLE);
        }

        @Override
        public void onPageFinished(WebView view, String url) {
            isFinished = true;
            isLoading = false;
            //Ondestaande if voorkomt weergeven "pagina is vernieuwd" bij orintatie-verandering
            if (is1eKeerGenegeerd) {
                is1eKeerGenegeerd = false;
            } else
                Toast.makeText(getActivity(), "Pagina is vernieuwd", Toast.LENGTH_LONG).show();
            progressBar.setVisibility(View.GONE);
            swipeLayout.setRefreshing(false);
        }
    });
    webView.setWebChromeClient(new WebChromeClient() {
        @Override
        public void onProgressChanged(WebView view, int newProgress) {
            progressBar.setProgress(newProgress);
            super.onProgressChanged(view, newProgress);
        }
    });
    swipeLayout = (SwipeRefreshLayout) mainView.findViewById(R.id.swipeLayout);
    swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override
        public void onRefresh() {
            refresh();
        }
    });
    swipeLayout.setColorSchemeResources(R.color.gmailRood, R.color.orange, R.color.lighter_blue, R.color.green);

    setRetainInstance(true);
    return mainView;

}

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

private void setupWebView() {
    // Clear reddit cookie to present a fresh login form.
    CookieManager.getInstance().setCookie(".reddit.com", "reddit_session=");

    WebSettings settings = webView.getSettings();
    settings.setBuiltInZoomControls(true);
    settings.setDisplayZoomControls(false);
    settings.setLoadWithOverviewMode(true);
    settings.setSupportZoom(true);/*from   w  w w . ja  va 2 s.  co m*/
    settings.setUseWideViewPort(true);

    // Don't save usernames entered into the login forms.
    settings.setSaveFormData(false);

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

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

        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url) {
            // WebView will show an unrecognized scheme error unless we intercept
            // the OAuth callback URL and fire off an intent instead.
            return url != null && url.startsWith(Urls.OAUTH_REDIRECT_URL) && handleOAuthRedirectUrl(url);
        }
    });

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

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);//  w w w. j av  a  2s  .c o m
    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.jio.mhood.services.api.settings.LicensesFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//from w w  w .j a va  2 s  . c om
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:io.github.hidroh.materialistic.WebFragment.java

@SuppressLint("SetJavaScriptEnabled")
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setWebViewSettings(WebSettings webSettings) {
    ItemSyncAdapter.enableCache(getActivity(), webSettings);
    webSettings.setLoadWithOverviewMode(true);
    webSettings.setUseWideViewPort(true);
    webSettings.setBuiltInZoomControls(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        webSettings.setDisplayZoomControls(false);
    }/*from   ww w. j  a v a2s.  com*/
}

From source file:it.rignanese.leo.slimfacebook.PictureActivity.java

private void SetupPictureWebView() {
    webViewPicture = (MyAdvancedWebView) findViewById(R.id.webViewPicture);
    webViewPicture.setListener(this, this);

    //  webViewPicture.setDesktopMode(true);

    //webViewPicture.requestFocus(View.F);
    getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);//remove the keyboard issue

    WebSettings settings = webViewPicture.getSettings();

    settings.setBuiltInZoomControls(true);
    settings.setUseWideViewPort(true);/*from w  w w. j a va2 s.  co m*/
    settings.setJavaScriptEnabled(true);
    settings.setLoadWithOverviewMode(true);

    if (Build.VERSION.SDK_INT > Build.VERSION_CODES.HONEYCOMB) {
        // Hide the zoom controls for HONEYCOMB+
        settings.setDisplayZoomControls(false);
    }
}

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;//from   ww w  .  j a  v a  2s.co  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;
            }

        }
    });
}