List of usage examples for android.webkit WebSettings setBuiltInZoomControls
public abstract void setBuiltInZoomControls(boolean enabled);
From source file:com.digitalarx.android.ui.dialog.SamlWebViewDialog.java
@SuppressWarnings("deprecation") @SuppressLint("SetJavaScriptEnabled") @Override/*from w ww . j a v a 2 s . com*/ public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Log_OC.d(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(getSherlockActivity().getApplicationContext()); mSsoWebView.setFocusable(true); mSsoWebView.setFocusableInTouchMode(true); mSsoWebView.setClickable(true); CookieManager cookieManager = CookieManager.getInstance(); cookieManager.setAcceptCookie(true); cookieManager.removeAllCookie(); mSsoWebView.loadUrl(mInitialUrl); WebSettings webSettings = mSsoWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(false); webSettings.setLoadWithOverviewMode(false); webSettings.setSavePassword(false); webSettings.setUserAgentString(OwnCloudClient.USER_AGENT); webSettings.setSaveFormData(false); } 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; }
From source file:de.trier.infsec.koch.droidsheep.activities.HijackActivity.java
private void setupWebView() { webview = (WebView) findViewById(R.id.webviewhijack); webview.setWebViewClient(new MyWebViewClient()); WebSettings webSettings = webview.getSettings(); webSettings.setUserAgentString("foo"); webSettings.setJavaScriptEnabled(true); webSettings.setAppCacheEnabled(false); webSettings.setBuiltInZoomControls(true); webview.setWebChromeClient(new WebChromeClient() { public void onProgressChanged(WebView view, int progress) { HijackActivity.this.setProgress(progress * 100); }/*from w ww .j a va 2 s . com*/ }); }
From source file:com.cihon.androidrestart_keven.activity.WebViewActivity.java
/** * ?webview/* w ww. ja va 2 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:com.github.snowdream.android.app.books.BookFragment.java
private void initUI(View rootview) { webView = (WebView) rootview.findViewById(R.id.webView); // progressbar = (SmoothProgressBar) rootview.findViewById(R.id.progressbar); WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setSupportZoom(true);//from w ww.j a va 2 s. co m webSettings.setBuiltInZoomControls(true); webSettings.setUseWideViewPort(true); String appCachePath = getActivity().getApplicationContext().getCacheDir().getAbsolutePath(); webSettings.setAppCachePath(appCachePath); webSettings.setAppCacheEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); // progressbar.setVisibility(View.VISIBLE); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); // progressbar.setVisibility(View.INVISIBLE); } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { super.onReceivedError(view, errorCode, description, failingUrl); // progressbar.setVisibility(View.INVISIBLE); } }); webView.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { return super.onJsAlert(view, url, message, result); } }); // The "loadAdOnCreate" and "testDevices" XML attributes no longer available. AdView adView = (AdView) rootview.findViewById(R.id.adView); AdRequest adRequest = new AdRequest.Builder().addTestDevice(AdRequest.DEVICE_ID_EMULATOR) .addTestDevice(TEST_DEVICE_ID).build(); adView.loadAd(adRequest); getView().setFocusableInTouchMode(true); getView().setOnKeyListener(new View.OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (webView.canGoBack() && keyCode == KeyEvent.KEYCODE_BACK) { webView.goBack(); return true; } return false; } }); }
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); }// w w w . java2 s. c o m }
From source file:li.klass.fhem.fragments.AbstractWebViewFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w ww . j a va2 s. com 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:com.rfo.basic.Web.java
@Override protected void onCreate(Bundle savedInstanceState) { Log.v(LOGTAG, "onCreate"); super.onCreate(savedInstanceState); ContextManager cm = Basic.getContextManager(); cm.registerContext(ContextManager.ACTIVITY_WEB, this); cm.setCurrent(ContextManager.ACTIVITY_WEB); setContentView(R.layout.web);/* w w w .j av a2 s . co m*/ View v = findViewById(R.id.web_engine); Intent intent = getIntent(); int showStatusBar = intent.getIntExtra(EXTRA_SHOW_STATUSBAR, 0); int orientation = intent.getIntExtra(EXTRA_ORIENTATION, -1); showStatusBar = (showStatusBar == 0) ? WindowManager.LayoutParams.FLAG_FULLSCREEN // do not show status bar : WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN; // show status bar getWindow().setFlags(showStatusBar, showStatusBar); setOrientation(orientation); engine = (WebView) v; WebSettings webSettings = engine.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setSupportZoom(true); webSettings.setAppCacheEnabled(true); webSettings.setDatabaseEnabled(true); webSettings.setDomStorageEnabled(true); webSettings.setAllowFileAccess(true); webSettings.setGeolocationEnabled(true); webSettings.setCacheMode(WebSettings.LOAD_NO_CACHE); engine.addJavascriptInterface(new JavaScriptInterface(), "Android"); engine.setWebViewClient(new MyWebViewClient()); aWebView = new TheWebView(this); engine.setWebChromeClient(new WebChromeClient() { @Override public boolean onJsAlert(WebView view, String url, String message, JsResult result) { //Required functionality here return super.onJsAlert(view, url, message, result); } }); }
From source file:com.vikingbrain.dmt.view.RemoteControlActivity.java
private void configureWebView(WebView webView, WebChromeClient webChromeClient, CustomWebViewClient customWebViewClient) { //Set the properties WebSettings webSettings = webView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setSupportZoom(true); //Zoom Control on web (You don't need this if ROM supports Multi-Touch webSettings.setBuiltInZoomControls(true); //Enable Multitouch if supported by ROM webSettings.setDomStorageEnabled(true); webSettings.setPluginsEnabled(true); webSettings.setUseWideViewPort(true); //normal viewport (such as a normal desktop browser) webView.setWebChromeClient(webChromeClient); webView.setWebViewClient(customWebViewClient); }
From source file:com.sonnychen.aviationhk.views.BookingFragment.java
@SuppressLint("SetJavaScriptEnabled") @Override//from w w w. j a v a 2 s . c om public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { Bundle bundle = getArguments(); if (bundle != null && !TextUtils.isEmpty(bundle.getString(BOOKING_TYPE_PARAM))) { Log.v("BOOKING-UI", "Argument: " + bundle.getString(BOOKING_TYPE_PARAM)); bookingType = BookingType.valueOf(bundle.getString(BOOKING_TYPE_PARAM)); } Log.v("BOOKING-UI", "Starting"); // Inflate the layout for this fragment View view = inflater.inflate(R.layout.fragment_booking, container, false); mProgressBar = ((ProgressBar) view.findViewById(R.id.progress)); mWebView = ((WebView) view.findViewById(R.id.booking_html)); WebSettings settings = mWebView.getSettings(); settings.setJavaScriptEnabled(true); settings.setAllowFileAccessFromFileURLs(true); settings.setAllowUniversalAccessFromFileURLs(true); settings.setBuiltInZoomControls(true); settings.setLoadWithOverviewMode(true); settings.setUseWideViewPort(true); mWebView.setWebChromeClient(new WebChromeClient()); mWebView.addJavascriptInterface(new JSInterface(getActivity(), mWebView), "Android"); mWebView.setInitialScale(1); // download PDF async new DownloadFileTask() { @Override protected void onPostExecute(Byte[] data) { // save data to file try { FileOutputStream fileOutputStream = getActivity().openFileOutput( bookingType == BookingType.HELICOPTER ? "helicopter.pdf" : "fixedwing.pdf", Context.MODE_PRIVATE); fileOutputStream.write(getbytes(data)); fileOutputStream.close(); } catch (IOException e) { e.printStackTrace(); } displayPDF(); // unfortunately HAKC does not have a valid SSL certificate } }.execute(bookingType == BookingType.HELICOPTER ? "http://aviationclub.hk/doc/helicopter_booking2.pdf" : "http://aviationclub.hk/doc/fixwing_booking2.pdf"); return view; }
From source file:org.jorge.cmp.ui.fragment.ArticleReaderFragment.java
@Override public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { setHasOptionsMenu(Boolean.TRUE); final View ret = inflater.inflate(R.layout.fragment_article_reader, container, Boolean.FALSE); View mHeaderView = ret.findViewById(R.id.image); PicassoUtils.loadInto(mContext, mArticle.getImageUrl(), mDefaultImageId, (android.widget.ImageView) mHeaderView, TAG); final String title = mArticle.getTitle(); mHeaderView.setContentDescription(title); ((TextView) ret.findViewById(R.id.title)).setText(title); WebView contentView = (WebView) ret.findViewById(android.R.id.text1); WebSettings webViewSettings = contentView.getSettings(); contentView.setOverScrollMode(View.OVER_SCROLL_NEVER); webViewSettings.setJavaScriptCanOpenWindowsAutomatically(Boolean.TRUE); webViewSettings.setBuiltInZoomControls(Boolean.FALSE); contentView.setBackgroundColor(0x00000000); //I wonder why the default background is white contentView.loadData(mArticle.getPreviewText(), "text/html; charset=UTF-8", "UTF-8"); mActionBar = mActivity.getSupportActionBar(); mActionBar.setDisplayHomeAsUpEnabled(Boolean.TRUE); mActionBarBackgroundDrawable = new ColorDrawable( mContext.getResources().getColor(R.color.toolbar_background)); if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) { mActionBarBackgroundDrawable.setCallback(mDrawableCallback); }//w w w. jav a 2 s. co m mActionBar.setBackgroundDrawable(mActionBarBackgroundDrawable); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { mOriginalElevation = mActionBar.getElevation(); mActionBar.setElevation(0); //So that the shadow of the ActionBar doesn't show over // the article title } mActionBar.setTitle(mActivity.getString(R.string.section_title_article_reader)); StickyParallaxNotifyingScrollView scrollView = (StickyParallaxNotifyingScrollView) ret .findViewById(R.id.scroll_view); scrollView.setOnScrollChangedListener(mOnScrollChangedListener); scrollView.smoothScrollTo(0, 0); if (!mArticle.isRead()) { mMarkAsReadFab = (FloatingActionButton) ret.findViewById(R.id.fab_button_mark_as_read); mMarkAsReadFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { markArticleAsRead(mArticle); if (mMarkAsReadFab.isShown()) mMarkAsReadFab.hide(); } private void markArticleAsRead(FeedArticle article) { final Realm r = Realm.getInstanceByRealmId(ArticleReaderFragment.this.mAccount.getRealmEnum()); String l = PreferenceAssistant.readSharedString(mContext, PreferenceAssistant.PREF_LANG, null); if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } final Class newsClass = NewsListFragment.class; final Class communityClass = CommunityListFragment.class; final Class schoolClass = SchoolListFragment.class; String tableName; if (mClass == newsClass) { if (l == null || !Arrays.asList(r.getLocales()).contains(l)) { l = r.getLocales()[0]; PreferenceAssistant.writeSharedString(mContext, PreferenceAssistant.PREF_LANG, l); } tableName = SQLiteDAO.getNewsTableName(r, l); } else if (mClass == communityClass) { tableName = SQLiteDAO.getCommunityTableName(); } else if (mClass == schoolClass) { tableName = SQLiteDAO.getSchoolTableName(); } else { throw new IllegalArgumentException( "Feed list fragment class " + mClass.getCanonicalName() + " not recognized."); } new AsyncTask<Object, Void, Void>() { @Override protected Void doInBackground(Object... params) { SQLiteDAO.getInstance().markArticleAsRead((FeedArticle) params[0], (String) params[1]); return null; } }.executeOnExecutor(Executors.newSingleThreadExecutor(), article, tableName); article.markAsRead(); } }); mMarkAsReadFab.hide(); mMarkAsReadFab.setVisibility(View.VISIBLE); showMarkAsReadFabIfItProceeds(); } return ret; }