List of usage examples for android.webkit WebSettings setSupportZoom
public abstract void setSupportZoom(boolean support);
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); websettings.setSavePassword(false);/*from w ww. j a va 2 s.co m*/ websettings.setSupportMultipleWindows(false); websettings.setAppCacheEnabled(false); websettings.setCacheMode(WebSettings.LOAD_NO_CACHE); websettings.setBlockNetworkImage(true); return view; }
From source file:com.dabay6.libraries.androidshared.ui.dialogs.changelog.util.ChangeLogDialogUtils.java
/** * @param context {@link Context} used to retrieve resources. * @param assetName Name of the asset file containing the change log json. * @param style The css style to be applied to the html. * @param callback The callback to call upon dismissal of the change log alert dialog. * * @return {@link AlertDialog} used to display the change log. *///from w w w.ja v a2s .c o m public static AlertDialog createDialog(final Context context, final String assetName, final String style, final OnChangeLogDialogListener callback) { final AlertDialog.Builder builder; final Resources res = context.getResources(); final String title = res.getString(R.string.change_log_title, AppUtils.getApplicationVersion(context)); final WebSettings settings; final WebView web = new WebView(context); String html; try { html = getHtmlChangeLog(context, assetName, style); settings = web.getSettings(); settings.setSupportZoom(false); } catch (final IOException ex) { html = StringUtils.empty(); Logger.error(TAG, ex.getMessage(), ex); } web.loadData(html, "text/html", "utf-8"); builder = new AlertDialog.Builder(context); builder.setTitle(title).setView(web).setPositiveButton(R.string.change_log_close, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, final int which) { dialog.dismiss(); if (callback != null) { callback.onChangeLogDismissed(); } } }); return builder.create(); }
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); }/*ww w .ja va2 s . co m*/ }
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);// w ww .java2 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.hyperkode.friendshare.fragment.TwitterWebViewFragment.java
public void onResume() { super.onResume(); String url = null;/*from w w w.ja v a 2s . c o m*/ FragmentManager fragmentManager = TwitterWebViewFragment.this.getActivity().getSupportFragmentManager(); Bundle args = this.getArguments(); if (args != null) { url = args.getString("URL"); loginFragment = (LoginFragment) fragmentManager.getFragment(args, "LoginFragment"); } WebView webView = (WebView) mThisActivity.findViewById(R.id.twitter_webview); WebSettings webSettings = webView.getSettings(); webSettings.setSavePassword(false); webSettings.setSaveFormData(false); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(false); webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.contains(getString(R.string.TWITTER_CALLBACK_URL))) { Uri uri = Uri.parse(url); String oauthVerifier = uri.getQueryParameter("oauth_verifier"); if (loginFragment != null) { loginFragment.setOAuthVerifierResult(oauthVerifier); } return true; } return false; } }); webView.loadUrl(url); }
From source file:org.que.activities.fragments.WebviewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_webview, container, false); if (url != null && !url.isEmpty()) { content = ((WebView) rootView.findViewById(R.id.webview)); //WebViewClient is enabled in order to force all links to load within the webview and also // in order to enable JavaScript content.setWebViewClient(new HelloWebViewClient()); WebSettings webSettings = content.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); content.loadUrl(url);/*from w w w .ja va 2 s. c om*/ } getActivity().setTitle(title); return rootView; }
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); settings.setBuiltInZoomControls(true); //load a custom user agent //see http://stackoverflow.com/questions/6856814/problems-loading-mobile-twitter-in-webview settings.setUserAgentString(//from w w w . j ava 2s . c om "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.github.snowdream.android.widget.NotFoundWebView.java
@SuppressLint({ "SetJavaScriptEnabled", "NewApi" }) private void init(Context context, AttributeSet attrs, int defStyle) { if (context == null) { return;/* ww w .j av a2s . c o m*/ } // 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); webSettings.setBuiltInZoomControls(false); webSettings.setAllowFileAccess(true); webSettings.setJavaScriptCanOpenWindowsAutomatically(true); webSettings.setLoadsImagesAutomatically(true); }
From source file:de.zell.android.util.fragments.WebviewFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.fragment_webview, container, false); if (url != null && !url.isEmpty()) { content = ((WebView) rootView.findViewById(R.id.webview)); //WebViewClient is enabled in order to force all links to load within the webview and also // in order to enable JavaScript content.setWebViewClient(new HelloWebViewClient()); WebSettings webSettings = content.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); final ProgressBar progressBar = ((MainNavigationActivity) getActivity()).getProgressBar(); content.setWebChromeClient(new WebChromeClient() { @Override/*from w w w .ja va 2 s .c om*/ public void onProgressChanged(WebView view, int newProgress) { progressBar.setProgress(newProgress); if (newProgress == 100) progressBar.setVisibility(View.GONE); } }); progressBar.setIndeterminate(true); progressBar.setVisibility(View.VISIBLE); content.loadUrl(url); } getActivity().setTitle(title); return rootView; }