List of usage examples for android.webkit WebSettings setUseWideViewPort
public abstract void setUseWideViewPort(boolean use);
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 w w w . jav a 2s.co m settings.setAllowFileAccess(false); settings.setDatabaseEnabled(false); settings.setNeedInitialFocus(false); settings.setUseWideViewPort(false); settings.setSupportZoom(false); settings.setJavaScriptCanOpenWindowsAutomatically(false); }
From source file:com.prey.activities.PanelWebActivity.java
@Override public void onResume() { super.onResume(); WebSettings settings = myWebView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); myWebView.setVerticalScrollBarEnabled(false); myWebView.setHorizontalScrollBarEnabled(false); myWebView.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { activity.setTitle("Loading..."); activity.setProgress(progress * 100); if (progress == 100) activity.setTitle(R.string.app_name); }/* w ww .j av a 2s . c o m*/ }); myWebView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { PreyLogger.d("Finished:" + url); super.onPageFinished(view, url); } @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { PreyLogger.d("Started:" + url); super.onPageStarted(view, url, favicon); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { PreyLogger.d("OverrideUrl:" + url); return super.shouldOverrideUrlLoading(view, url); } }); String url = PreyConfig.getPreyConfig(getApplicationContext()).getPreyPanelJwt(); String postData = "token=" + PreyConfig.getPreyConfig(getApplicationContext()).getTokenJwt(); ; byte[] postByte = EncodingUtils.getBytes(postData, "BASE64"); myWebView.postUrl(url, postByte); }
From source file:shreckye.scu.youth.HomepageFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = inflater.inflate(R.layout.fragment_homepage, container, false); final SwipeRefreshLayout swipeRefreshLayout = (SwipeRefreshLayout) view .findViewById(R.id.swipe_refresh_layout); AppUtil.setupSwipeRefreshLayoutColors(swipeRefreshLayout); homepageWebView = (WebView) view.findViewById(R.id.homepage_web_view); WebSettings webSettings = homepageWebView.getSettings(); webSettings.setLoadWithOverviewMode(true); webSettings.setUseWideViewPort(true); webSettings.setJavaScriptEnabled(true); homepageWebView.loadUrl(HOMEPAGE_URL); homepageWebView.setWebViewClient(new WebViewClient() { @Override//from www . j av a 2 s. c o m public void onPageStarted(WebView view, String url, Bitmap favicon) { swipeRefreshLayout.setRefreshing(true); } @Override public void onPageFinished(WebView view, String url) { swipeRefreshLayout.setRefreshing(false); } }); swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { refreshAsync(); } }); FloatingActionButton fab = (FloatingActionButton) view.findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { AppUtil.openWebPageAndShowSnackbarIfFail(HomepageFragment.this, HOMEPAGE_URL, getView()); } }); return view; }
From source file:com.pixate.freestyle.viewdemo.ViewDetailFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override/*from ww 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(" ", " ") .replaceAll("\t", " ")); 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.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 w w w. ja v a2 s. c o m*/ webSettings.setBuiltInZoomControls(false); webSettings.setAllowFileAccess(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setLoadsImagesAutomatically(true); }
From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//w w w . j a v a 2s. co m public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View view = super.onCreateView(inflater, container, savedInstanceState); if (view != null) return view; view = inflater.inflate(R.layout.webview, container, false); assert view != null; final WebView webView = (WebView) view.findViewById(R.id.webView); WebSettings settings = webView.getSettings(); settings.setUseWideViewPort(true); settings.setLoadWithOverviewMode(true); settings.setJavaScriptEnabled(true); settings.setBuiltInZoomControls(true); final ProgressDialog progressDialog = new ProgressDialog(getActivity()); progressDialog.setMessage(getResources().getString(R.string.loading)); webView.setWebChromeClient(new WebChromeClient() { @Override public void onProgressChanged(WebView view, int newProgress) { super.onProgressChanged(view, newProgress); if (newProgress < 100) { progressDialog.setProgress(newProgress); progressDialog.show(); } else { progressDialog.hide(); } } }); webView.setWebViewClient(new WebViewClient() { @Override public void onReceivedSslError(WebView view, @NotNull SslErrorHandler handler, SslError error) { handler.proceed(); } @SuppressWarnings("ConstantConditions") @Override public void onReceivedHttpAuthRequest(WebView view, @NotNull HttpAuthHandler handler, String host, String realm) { FHEMServerSpec currentServer = connectionService.getCurrentServer(getActivity()); String url = currentServer.getUrl(); String alternativeUrl = trimToNull(currentServer.getAlternateUrl()); try { String fhemUrlHost = new URL(url).getHost(); String alternativeUrlHost = alternativeUrl == null ? null : new URL(alternativeUrl).getHost(); String username = currentServer.getUsername(); String password = currentServer.getPassword(); if (host.startsWith(fhemUrlHost) || (alternativeUrlHost != null && host.startsWith(alternativeUrlHost))) { handler.proceed(username, password); } else { handler.cancel(); Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_authentication); getActivity().sendBroadcast(intent); } } catch (MalformedURLException e) { Intent intent = new Intent(Actions.SHOW_TOAST); intent.putExtra(BundleExtraKeys.STRING_ID, R.string.error_host_connection); getActivity().sendBroadcast(intent); LOG.error("malformed URL: " + url, e); handler.cancel(); } } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); if ("about:blank".equalsIgnoreCase(url)) { Optional<String> alternativeUrl = getAlternateLoadUrl(); if (alternativeUrl.isPresent()) { webView.loadUrl(alternativeUrl.get()); } } else { onPageLoadFinishedCallback(view, url); } } }); return view; }
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); 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 www. ja v a2s . c o m }
From source file:com.cihon.androidrestart_keven.activity.WebViewActivity.java
/** * ?webview//from ww w.j a va2 s .c o m */ public void initWebView() { MyWebViewClient webViewClient = new MyWebViewClient(); mWebView.setWebViewClient(webViewClient); WebSettings webSettings = mWebView.getSettings(); //?? webSettings.setLoadWithOverviewMode(true); //?webview? webSettings.setUseWideViewPort(true); //?? webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setJavaScriptEnabled(true); // mWebView.loadUrl("http://webservice.cihon.cn/onStarActive1/reupload.html"); mWebView.loadUrl("http://123.57.60.91/onStar3/vehicle-License.html"); // mWebView.loadUrl("http://wxpay.wxutil.com/mch/pay/h5.v2.php"); // jsjava mWebView.addJavascriptInterface(new JsInterface(this), "demo"); }
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); }/*ww w.j a v a 2s . com*/ }
From source file:com.rickendirk.rsgwijzigingen.WebFragment.java
@Nullable @Override/*from w w w . jav a 2s . c o m*/ 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; }