List of usage examples for android.webkit WebView setWebViewClient
public void setWebViewClient(WebViewClient client)
From source file:terse.a1.TerseActivity.java
private void viewPath9display(String path, LayoutParams widgetParams) { String explain;/*from ww w .j av a 2s . co m*/ if (terp_error != null) { explain = "terp_error = " + terp_error; } else { try { terp.say("Sending to terp: %s", path); final Dict d = terp.handleUrl(path, taQuery); explain = "DEFAULT EXPLANATION:\n\n" + d.toString(); Str TYPE = d.cls.terp.newStr("type"); Str VALUE = d.cls.terp.newStr("value"); Str TITLE = d.cls.terp.newStr("title"); Str type = (Str) d.dict.get(TYPE); Ur value = d.dict.get(VALUE); Ur title = d.dict.get(TITLE); // { // double ticks = Static.floatAt(d, "ticks", -1); // double nanos = Static.floatAt(d, "nanos", -1); // Toast.makeText( // getApplicationContext(), // Static.fmt("%d ticks, %.3f secs", (long) ticks, // (double) nanos / 1e9), Toast.LENGTH_SHORT) // .show(); // } if (type.str.equals("list") && value instanceof Vec) { final ArrayList<Ur> v = ((Vec) value).vec; final ArrayList<String> labels = new ArrayList<String>(); final ArrayList<String> links = new ArrayList<String>(); for (int i = 0; i < v.size(); i++) { Ur item = v.get(i); String label = item instanceof Str ? ((Str) item).str : item.toString(); if (item instanceof Vec && ((Vec) item).vec.size() == 2) { // OLD STYLE label = ((Vec) item).vec.get(0).toString(); Matcher m = LINK_P.matcher(label); if (m.lookingAt()) { label = m.group(2) + " " + m.group(3); } label += " [" + ((Vec) item).vec.get(1).toString().length() + "]"; links.add(null); // Use old style, not links. } else { // NEW STYLE label = item.toString(); if (label.charAt(0) == '/') { String link = Terp.WHITE_PLUS.split(label, 2)[0]; links.add(link); } else { links.add(""); } } labels.add(label); } if (labels.size() != links.size()) terp.toss("lables#%d links#%d", labels.size(), links.size()); ListView listv = new ListView(this); listv.setAdapter(new ArrayAdapter<String>(this, R.layout.list_item, labels)); listv.setLayoutParams(widgetParams); listv.setTextFilterEnabled(true); listv.setOnItemClickListener(new OnItemClickListener() { public void onItemClick(AdapterView<?> parent, View view, int position, long id) { // When clicked, show a toast with the TextView text // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); String toast_text = ((TextView) view).getText().toString(); // if (v.get(position) instanceof Vec) { if (links.get(position) == null) { // OLD STYLE Vec pair = (Vec) v.get(position); if (pair.vec.size() == 2) { if (pair.vec.get(0) instanceof Str) { String[] words = ((Str) pair.vec.get(0)).str.split("\\|"); Log.i("TT-WORDS", terp.arrayToString(words)); toast_text += "\n\n" + Static.arrayToString(words); if (words[1].equals("link")) { Uri uri = new Uri.Builder().scheme("terse").path(words[2]).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } } } else { // NEW STYLE terp.say("NEW STYLE LIST SELECT #%d link=<%s> label=<%s>", position, links.get(position), labels.get(position)); if (links.get(position).length() > 0) { Uri uri = new Uri.Builder().scheme("terse").path(links.get(position)).build(); Intent intent = new Intent("android.intent.action.MAIN", uri); intent.setClass(getApplicationContext(), TerseActivity.class); startActivity(intent); } } // } // Toast.makeText(getApplicationContext(), // ((TextView) view).getText(), // Toast.LENGTH_SHORT).show(); } }); setContentView(listv); return; } else if (type.str.equals("edit") && value instanceof Str) { final EditText ed = new EditText(this); ed.setText(taSaveMe == null ? value.toString() : taSaveMe); ed.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_FLAG_MULTI_LINE | InputType.TYPE_TEXT_VARIATION_LONG_MESSAGE | InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS); ed.setLayoutParams(widgetParams); // ed.setTextSize(TypedValue.COMPLEX_UNIT_SP, 22); ed.setTextAppearance(this, R.style.teletype); ed.setBackgroundColor(Color.BLACK); ed.setGravity(Gravity.TOP); ed.setScrollBarStyle(View.SCROLLBARS_OUTSIDE_INSET); ed.setVerticalFadingEdgeEnabled(true); ed.setVerticalScrollBarEnabled(true); ed.setOnKeyListener(new OnKeyListener() { public boolean onKey(View v, int keyCode, KeyEvent event) { // If the event is a key-down event on the "enter" // button // if ((event.getAction() == KeyEvent.ACTION_DOWN) // && // (keyCode == KeyEvent.KEYCODE_ENTER)) { // // Perform action on key press // Toast.makeText(TerseActivity.this, ed.getText(), // Toast.LENGTH_SHORT).show(); // return true; // } return false; } }); Button btn = new Button(this); btn.setText("Save"); btn.setOnClickListener(new OnClickListener() { public void onClick(View v) { // Perform action on clicks String text = ed.getText().toString(); text = Parser.charSubsts(text); Toast.makeText(TerseActivity.this, text, Toast.LENGTH_SHORT).show(); String action = stringAt(d, "action"); String query = ""; String f1 = stringAt(d, "field1"); String v1 = stringAt(d, "value1"); String f2 = stringAt(d, "field2"); String v2 = stringAt(d, "value2"); f1 = (f1 == null) ? "f1null" : f1; v1 = (v1 == null) ? "v1null" : v1; f2 = (f2 == null) ? "f2null" : f2; v2 = (v2 == null) ? "v2null" : v2; startTerseActivity(action, query, stringAt(d, "field1"), stringAt(d, "value1"), stringAt(d, "field2"), stringAt(d, "value2"), "text", text); } }); LinearLayout linear = new LinearLayout(this); linear.setOrientation(LinearLayout.VERTICAL); linear.addView(btn); linear.addView(ed); setContentView(linear); return; } else if (type.str.equals("draw") && value instanceof Vec) { Vec v = ((Vec) value); DrawView dv = new DrawView(this, v.vec, d); dv.setLayoutParams(widgetParams); setContentView(dv); return; } else if (type.str.equals("live")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); TerseSurfView tsv = new TerseSurfView(this, blk, event); setContentView(tsv); return; } else if (type.str.equals("fnord")) { Blk blk = value.mustBlk(); Blk event = Static.urAt(d, "event").asBlk(); FnordView fnord = new FnordView(this, blk, event); setContentView(fnord); return; } else if (type.str.equals("world") && value instanceof Str) { String newWorld = value.toString(); if (Terp.WORLD_P.matcher(newWorld).matches()) { world = newWorld; resetTerp(); explain = Static.fmt("Switching to world <%s>\nUse menu to go Home.", world); Toast.makeText(getApplicationContext(), explain, Toast.LENGTH_LONG).show(); } else { terp.toss("Bad world syntax (must be 3 letters then 0 to 3 digits: <%s>", newWorld); } // Fall thru for explainv.setText(explain). } else if (type.str.equals("text")) { explain = "<<< " + title + " >>>\n\n" + value.toString(); // Fall thru for explainv.setText(explain). } else if (type.str.equals("html")) { final WebView webview = new WebView(this); // webview.loadData(value.toString(), "text/html", null); webview.loadDataWithBaseURL("terse://terse", value.toString(), "text/html", "UTF-8", null); webview.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { // terp.say("WebView UrlLoading: url=%s", url); URI uri = URI.create("" + url); // terp.say("WebView UrlLoading: URI=%s", uri); terp.say("WebView UrlLoading: getPath=%s", uri.getPath()); terp.say("WebView UrlLoading: getQuery=%s", uri.getQuery()); // Toast.makeText(getApplicationContext(), // uri.toASCIIString(), Toast.LENGTH_SHORT) // .show(); // webview.invalidate(); // // TextView quick = new // TextView(TerseActivity.this); // quick.setText(uri.toASCIIString()); // quick.setBackgroundColor(Color.BLACK); // quick.setTextColor(Color.WHITE); // setContentView(quick); startTerseActivity(uri.getPath(), uri.getQuery()); return true; } }); // webview.setWebChromeClient(new WebChromeClient()); webview.getSettings().setBuiltInZoomControls(true); // webview.getSettings().setJavaScriptEnabled(true); webview.getSettings().setDefaultFontSize(18); webview.getSettings().setNeedInitialFocus(true); webview.getSettings().setSupportZoom(true); webview.getSettings().setSaveFormData(true); setContentView(webview); // ScrollView scrollv = new ScrollView(this); // scrollv.addView(webview); // setContentView(scrollv); return; } else { explain = "Unknown page type: " + type.str + " with vaule type: " + value.cls + "\n\n##############\n\n"; explain += value.toString(); // Fall thru for explainv.setText(explain). } } catch (Exception ex) { ex.printStackTrace(); explain = Static.describe(ex); } } TextView explainv = new TextView(this); explainv.setText(explain); explainv.setBackgroundColor(Color.BLACK); explainv.setTextSize(TypedValue.COMPLEX_UNIT_SP, 24); explainv.setTextColor(Color.YELLOW); SetContentViewWithHomeButtonAndScroll(explainv); }
From source file:com.nextgis.mobile.fragment.AttributesFragment.java
private void setAttributes() { if (mAttributes == null) return;/*from w w w.j a v a 2s . c o m*/ mAttributes.removeAllViews(); int[] attrs = new int[] { android.R.attr.textColorPrimary }; TypedArray ta = getContext().obtainStyledAttributes(attrs); String textColor = Integer.toHexString(ta.getColor(0, Color.BLACK)).substring(2); ta.recycle(); final WebView webView = new WebView(getContext()); webView.setVerticalScrollBarEnabled(false); String data = "<!DOCTYPE html><html><head><meta charset='utf-8'><style>body{word-wrap:break-word;color:#" + textColor + ";font-family:Roboto Light,sans-serif;font-weight:300;line-height:1.15em}.flat-table{table-layout:fixed;margin-bottom:20px;width:100%;border-collapse:collapse;border:none;box-shadow:inset 1px -1px #ccc,inset -1px 1px #ccc}.flat-table td{box-shadow:inset -1px -1px #ccc,inset -1px -1px #ccc;padding:.5em}.flat-table tr{-webkit-transition:background .3s,box-shadow .3s;-moz-transition:background .3s,box-shadow .3s;transition:background .3s,box-shadow .3s}</style></head><body><table class='flat-table'><tbody>"; FragmentActivity activity = getActivity(); if (null == activity) return; ((MainActivity) activity).setSubtitle(String.format(getString(R.string.features_count_attributes), mItemPosition + 1, mFeatureIDs.size())); checkNearbyItems(); try { data = parseAttributes(data); } catch (RuntimeException e) { e.printStackTrace(); } data += "</tbody></table></body></html>"; webView.loadDataWithBaseURL(null, data, "text/html", "UTF-8", null); mAttributes.addView(webView); webView.setWebViewClient(new WebViewClient() { @Override public void onPageFinished(WebView view, String url) { webView.setBackgroundColor(Color.TRANSPARENT); } public boolean shouldOverrideUrlLoading(WebView view, String url) { view.getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } }); IGISApplication app = (GISApplication) getActivity().getApplication(); final Map<String, Integer> mAttaches = new HashMap<>(); PhotoGallery.getAttaches(app, mLayer, mItemId, mAttaches, false); if (mAttaches.size() > 0) { final PhotoPicker gallery = new PhotoPicker(getActivity(), true); int px = ControlHelper.dpToPx(16, getResources()); gallery.setDefaultPreview(true); gallery.setPadding(px, 0, px, 0); gallery.post(new Runnable() { @Override public void run() { gallery.restoreImages(new ArrayList<>(mAttaches.keySet())); } }); mAttributes.addView(gallery); } }
From source file:nya.miku.wishmaster.http.cloudflare.CloudflareChecker.java
private Cookie checkAntiDDOS(final CloudflareException exception, final HttpHost proxy, CancellableTask task, final Activity activity) { synchronized (lock) { if (processing) return null; processing = true;/*from w ww . j a v a 2s . com*/ } processing2 = true; currentCookie = null; if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) { CookieSyncManager.createInstance(activity); CookieManager.getInstance().removeAllCookie(); } else { CompatibilityImpl.clearCookies(CookieManager.getInstance()); } final ViewGroup layout = (ViewGroup) activity.getWindow().getDecorView().getRootView(); final WebViewClient client = new WebViewClient() { @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { handler.proceed(); } @Override public void onPageFinished(WebView webView, String url) { super.onPageFinished(webView, url); Logger.d(TAG, "Got Page: " + url); String value = null; try { String[] cookies = CookieManager.getInstance().getCookie(url).split("[;]"); for (String cookie : cookies) { if ((cookie != null) && (!cookie.trim().equals("")) && (cookie.startsWith(" " + exception.getRequiredCookieName() + "="))) { value = cookie.substring(exception.getRequiredCookieName().length() + 2); } } } catch (NullPointerException e) { Logger.e(TAG, e); } if (value != null) { BasicClientCookieHC4 cf_cookie = new BasicClientCookieHC4(exception.getRequiredCookieName(), value); cf_cookie.setDomain("." + Uri.parse(url).getHost()); cf_cookie.setPath("/"); currentCookie = cf_cookie; Logger.d(TAG, "Cookie found: " + value); processing2 = false; } else { Logger.d(TAG, "Cookie is not found"); } } }; activity.runOnUiThread(new Runnable() { @SuppressLint("SetJavaScriptEnabled") @Override public void run() { webView = new WebView(activity); webView.setVisibility(View.GONE); layout.addView(webView); webView.setWebViewClient(client); webView.getSettings().setUserAgentString(HttpConstants.USER_AGENT_STRING); webView.getSettings().setJavaScriptEnabled(true); webViewContext = webView.getContext(); if (proxy != null) WebViewProxy.setProxy(webViewContext, proxy.getHostName(), proxy.getPort()); webView.loadUrl(exception.getCheckUrl()); } }); long startTime = System.currentTimeMillis(); while (processing2) { long time = System.currentTimeMillis() - startTime; if ((task != null && task.isCancelled()) || time > TIMEOUT) { processing2 = false; } } activity.runOnUiThread(new Runnable() { @Override public void run() { try { layout.removeView(webView); webView.stopLoading(); webView.clearCache(true); webView.destroy(); webView = null; } finally { if (proxy != null) WebViewProxy.setProxy(webViewContext, null, 0); processing = false; } } }); return currentCookie; }
From source file:com.lemon.lime.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getBatteryPercentage();/*from w w w .j a v a2s . c o m*/ setContentView(R.layout.activity_main); getSupportActionBar().setDisplayShowCustomEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); mWebView = (ObservableWebView) findViewById(R.id.activity_main_webview); mWebView.setScrollViewCallbacks(this); LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); View v = inflator.inflate(R.layout.bar, null); getSupportActionBar().setCustomView(v); WebIconDatabase.getInstance().open(getDir("icons", MODE_PRIVATE).getPath()); swipeLayout = (SwipeRefreshLayout) findViewById(R.id.swipeToRefresh); swipeLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { mWebView.reload(); } }); swipeLayout.setColorSchemeResources(R.color.lili, R.color.colorPrimary, R.color.red); window = getWindow(); favicon = (ImageView) findViewById(R.id.favicon); editurl = (EditText) findViewById(R.id.editurl); mWebView.setDownloadListener(new DownloadListener() { public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Uri uri = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, uri); startActivity(intent); } }); favicon.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (lili == 5) { lilimode(); lili = 0; lilimode = true; } else { lili = lili + 1; } } }); editurl.setOnKeyListener(new OnKeyListener() { @Override public boolean onKey(View v, int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_ENTER) { if (event.getAction() == KeyEvent.ACTION_UP) { if (editurl.getText().toString().contains("file:///")) { filemgr(); } else if (editurl.getText().toString().contains("gaymode")) { gaymode(); } else if (editurl.getText().toString().contains("exitapp")) { finish(); } else if (editurl.getText().toString().contains("light")) { flash(); } if (isconnected()) { if (editurl.getText().toString().contains("http://") || editurl.getText().toString().contains("https://")) { mWebView.loadUrl(editurl.getText().toString()); } else if (editurl.getText().toString().contains(".com") || editurl.getText().toString().contains(".net") || editurl.getText().toString().contains(".org") || editurl.getText().toString().contains(".gov") || editurl.getText().toString().contains(".hu") || editurl.getText().toString().contains(".sk") || editurl.getText().toString().contains(".co.uk") || editurl.getText().toString().contains(".co.in") || editurl.getText().toString().contains(".cn") || editurl.getText().toString().contains(".it") || editurl.getText().toString().contains(".de") || editurl.getText().toString().contains(".aus") || editurl.getText().toString().contains(".hr") || editurl.getText().toString().contains(".cz") || editurl.getText().toString().contains(".xyz") || editurl.getText().toString().contains(".pl") || editurl.getText().toString().contains(".io")) { mWebView.loadUrl("http://" + editurl.getText().toString()); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0); } else { mWebView.loadUrl("https://www.google.com/search?q=" + editurl.getText().toString()); InputMethodManager imm = (InputMethodManager) getSystemService( Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(editurl.getWindowToken(), 0); } } return true; } return false; } return true; } }); // Enable Javascript WebSettings webSettings = mWebView.getSettings(); webSettings.setJavaScriptEnabled(true); webSettings.setBuiltInZoomControls(true); webSettings.setDisplayZoomControls(false); webSettings.setSupportMultipleWindows(true); if (isconnected()) { mWebView.loadUrl("http://google.com"); } else { final View coordinatorLayoutView = findViewById(R.id.snackbarPosition); mWebView.loadUrl("file:///android_asset/nonet.html"); Snackbar snackbar = Snackbar.make(coordinatorLayoutView, R.string.offline, Snackbar.LENGTH_LONG); snackbar.show(); } mWebView.setWebChromeClient(new WebChromeClient() { @Override public void onReceivedIcon(WebView mWebView, Bitmap icon) { super.onReceivedIcon(mWebView, icon); favicon.setImageBitmap(icon); } public void onProgressChanged(WebView view, int progress) { activity.setProgress(progress * 100); int a = progress; if (lilimode) { editurl.setText("Liling: " + Integer.toString(a) + "?"); } else editurl.setText("Liming: " + Integer.toString(a) + "%"); if (progress == 100) { editurl.setHint(view.getTitle()); activity.setTitle(view.getTitle()); editurl.setText(view.getUrl()); fav(); //battery if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (level <= 20) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setNavigationBarColor(Color.RED); window.setStatusBarColor(Color.RED); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.RED)); } } } } }); mWebView.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView mWebView, String url) { swipeLayout.setRefreshing(false); } }); }
From source file:org.liberty.android.fantastischmemo.downloader.google.GoogleOAuth2AccessCodeRetrievalFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { super.onCreate(savedInstanceState); final View v = inflater.inflate(R.layout.oauth_login_layout, container, false); final WebView webview = (WebView) v.findViewById(R.id.login_page); final View loadingText = v.findViewById(R.id.auth_page_load_text); final View progressDialog = v.findViewById(R.id.auth_page_load_progress); final LinearLayout ll = (LinearLayout) v.findViewById(R.id.ll); // We have to set up the dialog's webview size manually or the webview will be zero size. // This should be a bug of Android. Rect displayRectangle = new Rect(); Window window = mActivity.getWindow(); window.getDecorView().getWindowVisibleDisplayFrame(displayRectangle); ll.setMinimumWidth((int) (displayRectangle.width() * 0.9f)); ll.setMinimumHeight((int) (displayRectangle.height() * 0.8f)); webview.getSettings().setJavaScriptEnabled(true); try {/*from w ww . j ava2s . c o m*/ String uri = String.format( "https://accounts.google.com/o/oauth2/auth?client_id=%s&response_type=%s&redirect_uri=%s&scope=%s", URLEncoder.encode(AMEnv.GOOGLE_CLIENT_ID, "UTF-8"), URLEncoder.encode("code", "UTF-8"), URLEncoder.encode(AMEnv.GOOGLE_REDIRECT_URI, "UTF-8"), URLEncoder.encode(AMEnv.GDRIVE_SCOPE, "UTF-8")); webview.loadUrl(uri); } catch (Exception e) { throw new RuntimeException(e); } // This is workaround to show input on some android version. webview.requestFocus(View.FOCUS_DOWN); webview.setOnTouchListener(new View.OnTouchListener() { public boolean onTouch(View v, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: case MotionEvent.ACTION_UP: if (!v.hasFocus()) { v.requestFocus(); } break; } return false; } }); webview.setWebViewClient(new WebViewClient() { private boolean authenticated = false; @Override public void onPageFinished(WebView view, String url) { loadingText.setVisibility(View.GONE); progressDialog.setVisibility(View.GONE); webview.setVisibility(View.VISIBLE); if (authenticated == true) { return; } String code = getAuthCodeFromUrl(url); String error = getErrorFromUrl(url); if (error != null) { authCodeReceiveListener.onAuthCodeError(error); authenticated = true; dismiss(); } if (code != null) { authenticated = true; authCodeReceiveListener.onAuthCodeReceived(code); dismiss(); } } }); return v; }
From source file:com.openatk.planting.MainActivity.java
@Override public boolean onOptionsItemSelected(MenuItem item) { if (item.getItemId() == R.id.main_menu_add) { // Check if have an operation if (operationsList.isEmpty()) { // Show dialog to create operation createOperation(new Callable<Void>() { public Void call() { return addFieldMapView(); }//from ww w . ja v a 2 s . com }); } else { addFieldMapView(); } } else if (item.getItemId() == R.id.main_menu_current_location) { Location myLoc = map.getMyLocation(); if (myLoc == null) { Toast.makeText(this, "Still searching for your location", Toast.LENGTH_SHORT).show(); } else { CameraPosition oldPos = map.getCameraPosition(); CameraPosition newPos = new CameraPosition(new LatLng(myLoc.getLatitude(), myLoc.getLongitude()), map.getMaxZoomLevel(), oldPos.tilt, oldPos.bearing); map.animateCamera(CameraUpdateFactory.newCameraPosition(newPos)); } } else if (item.getItemId() == R.id.main_menu_layers) { MenuItem layers = menu.findItem(R.id.main_menu_layers); if (showingHazards == false) { showingHazards = true; layers.setTitle("Hide Hazards"); } else { showingHazards = false; layers.setTitle("Show Hazards"); } SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getApplicationContext()); SharedPreferences.Editor editor = prefs.edit(); editor.putBoolean("showingHazards", showingHazards); editor.commit(); drawHazards(); } else if (item.getItemId() == R.id.main_menu_list_view) { if (mCurrentState == STATE_LIST_VIEW) { // Show map view Log.d("MainActivity", "Showing map view"); setState(STATE_DEFAULT); //item.setIcon(R.drawable.list_view); this.invalidateOptionsMenu(); } else { // Show list view Log.d("MainActivity", "Showing list view"); setState(STATE_LIST_VIEW); //item.setIcon(R.drawable.map_view); this.invalidateOptionsMenu(); } } else if (item.getItemId() == R.id.main_menu_help) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Help"); WebView wv = new WebView(this); wv.loadUrl("file:///android_asset/Help.html"); wv.getSettings().setSupportZoom(true); wv.getSettings().setBuiltInZoomControls(true); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); alert.setView(wv); alert.setNegativeButton("Close", null); alert.show(); } else if (item.getItemId() == R.id.main_menu_legal) { CharSequence licence = "The MIT License (MIT)\n" + "\n" + "Copyright (c) 2013 Purdue University\n" + "\n" + "Permission is hereby granted, free of charge, to any person obtaining a copy " + "of this software and associated documentation files (the \"Software\"), to deal " + "in the Software without restriction, including without limitation the rights " + "to use, copy, modify, merge, publish, distribute, sublicense, and/or sell " + "copies of the Software, and to permit persons to whom the Software is " + "furnished to do so, subject to the following conditions:" + "\n" + "The above copyright notice and this permission notice shall be included in " + "all copies or substantial portions of the Software.\n" + "\n" + "THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR " + "IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, " + "FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE " + "AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER " + "LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, " + "OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN " + "THE SOFTWARE.\n"; new AlertDialog.Builder(this).setTitle("Legal").setMessage(licence) .setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton("Close", null).show(); } return true; }
From source file:com.ibuildapp.romanblack.WebPlugin.WebPlugin.java
@Override public void create() { try {/* www . j av a2s. co m*/ setContentView(R.layout.romanblack_html_main); root = (FrameLayout) findViewById(R.id.romanblack_root_layout); webView = new ObservableWebView(this); webView.setLayoutParams(new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.MATCH_PARENT, RelativeLayout.LayoutParams.MATCH_PARENT)); root.addView(webView); webView.setHorizontalScrollBarEnabled(false); setTitle("HTML"); Intent currentIntent = getIntent(); Bundle store = currentIntent.getExtras(); widget = (Widget) store.getSerializable("Widget"); if (widget == null) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } appName = widget.getAppName(); if (widget.getPluginXmlData().length() == 0) { if (currentIntent.getStringExtra("WidgetFile").length() == 0) { handler.sendEmptyMessageDelayed(INITIALIZATION_FAILED, 100); return; } } if (widget.getTitle() != null && widget.getTitle().length() > 0) { setTopBarTitle(widget.getTitle()); } else { setTopBarTitle(getResources().getString(R.string.romanblack_html_web)); } currentUrl = (String) getSession(); if (currentUrl == null) { currentUrl = ""; } ConnectivityManager cm = (ConnectivityManager) this.getSystemService(Context.CONNECTIVITY_SERVICE); NetworkInfo ni = cm.getActiveNetworkInfo(); if (ni != null && ni.isConnectedOrConnecting()) { isOnline = true; } // topbar initialization setTopBarLeftButtonText(getString(R.string.common_home_upper), true, new View.OnClickListener() { @Override public void onClick(View view) { onBackPressed(); } }); if (isOnline) { webView.getSettings().setJavaScriptEnabled(true); } webView.setScrollBarStyle(WebView.SCROLLBARS_OUTSIDE_OVERLAY); webView.getSettings().setGeolocationEnabled(true); webView.getSettings().setAllowFileAccess(true); webView.getSettings().setAppCacheEnabled(true); webView.getSettings().setCacheMode(WebSettings.LOAD_DEFAULT); webView.getSettings().setBuiltInZoomControls(true); webView.getSettings().setDomStorageEnabled(true); webView.getSettings().setUseWideViewPort(false); webView.getSettings().setSavePassword(false); webView.clearHistory(); webView.invalidate(); if (Build.VERSION.SDK_INT >= 19) { } webView.getSettings().setUserAgentString( "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; Nexus One Build/FRG83) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1"); webView.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { v.invalidate(); switch (event.getAction()) { case MotionEvent.ACTION_DOWN: { } break; case MotionEvent.ACTION_UP: { if (!v.hasFocus()) { v.requestFocus(); } } break; case MotionEvent.ACTION_MOVE: { } break; } return false; } }); webView.setBackgroundColor(Color.WHITE); try { if (widget.getBackgroundColor() != Color.TRANSPARENT) { webView.setBackgroundColor(widget.getBackgroundColor()); } } catch (IllegalArgumentException e) { } webView.setDownloadListener(new DownloadListener() { @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength) { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); } }); webView.setWebChromeClient(new WebChromeClient() { FrameLayout.LayoutParams LayoutParameters = new FrameLayout.LayoutParams( FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.MATCH_PARENT); @Override public void onGeolocationPermissionsShowPrompt(final String origin, final GeolocationPermissions.Callback callback) { AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setTitle(R.string.location_dialog_title); builder.setMessage(R.string.location_dialog_description); builder.setCancelable(true); builder.setPositiveButton(R.string.location_dialog_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, true, false); } }); builder.setNegativeButton(R.string.location_dialog_not_allow, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { callback.invoke(origin, false, false); } }); AlertDialog alert = builder.create(); alert.show(); } @Override public void onShowCustomView(View view, WebChromeClient.CustomViewCallback callback) { if (customView != null) { customViewCallback.onCustomViewHidden(); return; } view.setBackgroundColor(Color.BLACK); view.setLayoutParams(LayoutParameters); root.addView(view); customView = view; customViewCallback = callback; webView.setVisibility(View.GONE); } @Override public void onHideCustomView() { if (customView == null) { return; } else { closeFullScreenVideo(); } } public void openFileChooser(ValueCallback<Uri> uploadMsg) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT);//Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); isMedia = true; startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } // For Android 3.0+ public void openFileChooser(ValueCallback uploadMsg, String acceptType) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("*/*"); startActivityForResult(Intent.createChooser(i, "File Browser"), FILECHOOSER_RESULTCODE); } //For Android 4.1 public void openFileChooser(ValueCallback<Uri> uploadMsg, String acceptType, String capture) { mUploadMessage = uploadMsg; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); isMedia = true; i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); } @Override public boolean onShowFileChooser(WebView webView, ValueCallback<Uri[]> filePathCallback, FileChooserParams fileChooserParams) { isV21 = true; mUploadMessageV21 = filePathCallback; Intent i = new Intent(Intent.ACTION_GET_CONTENT); i.addCategory(Intent.CATEGORY_OPENABLE); i.setType("image/*"); startActivityForResult(Intent.createChooser(i, "File Chooser"), FILECHOOSER_RESULTCODE); return true; } @Override public void onReceivedTouchIconUrl(WebView view, String url, boolean precomposed) { super.onReceivedTouchIconUrl(view, url, precomposed); } }); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); if (state == states.EMPTY) { currentUrl = url; setSession(currentUrl); state = states.LOAD_START; handler.sendEmptyMessage(SHOW_PROGRESS); } } @Override public void onLoadResource(WebView view, String url) { if (!alreadyLoaded && (url.startsWith("http://www.youtube.com/get_video_info?") || url.startsWith("https://www.youtube.com/get_video_info?")) && Build.VERSION.SDK_INT < 11) { try { String path = url.contains("https://www.youtube.com/get_video_info?") ? url.replace("https://www.youtube.com/get_video_info?", "") : url.replace("http://www.youtube.com/get_video_info?", ""); String[] parqamValuePairs = path.split("&"); String videoId = null; for (String pair : parqamValuePairs) { if (pair.startsWith("video_id")) { videoId = pair.split("=")[1]; break; } } if (videoId != null) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse("http://www.youtube.com/watch?v=" + videoId))); needRefresh = true; alreadyLoaded = !alreadyLoaded; return; } } catch (Exception ex) { } } else { super.onLoadResource(view, url); } } @Override public void onPageFinished(WebView view, String url) { if (hideProgress) { if (TextUtils.isEmpty(WebPlugin.this.url)) { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } else { view.loadUrl("javascript:(function(){" + "l=document.getElementById('link');" + "e=document.createEvent('HTMLEvents');" + "e.initEvent('click',true,true);" + "l.dispatchEvent(e);" + "})()"); hideProgress = false; } } else { state = states.LOAD_COMPLETE; handler.sendEmptyMessage(HIDE_PROGRESS); super.onPageFinished(view, url); } } @Override public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) { if (errorCode == WebViewClient.ERROR_BAD_URL) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); } } @Override public void onReceivedSslError(WebView view, final SslErrorHandler handler, SslError error) { final AlertDialog.Builder builder = new AlertDialog.Builder(WebPlugin.this); builder.setMessage(R.string.notification_error_ssl_cert_invalid); builder.setPositiveButton(WebPlugin.this.getResources().getString(R.string.wp_continue), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.proceed(); } }); builder.setNegativeButton(WebPlugin.this.getResources().getString(R.string.wp_cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { handler.cancel(); } }); final AlertDialog dialog = builder.create(); dialog.show(); } @Override public void onFormResubmission(WebView view, Message dontResend, Message resend) { super.onFormResubmission(view, dontResend, resend); } @Override public WebResourceResponse shouldInterceptRequest(WebView view, WebResourceRequest request) { return super.shouldInterceptRequest(view, request); } @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { try { if (url.contains("youtube.com/watch")) { if (Build.VERSION.SDK_INT < 11) { try { startActivity( new Intent(Intent.ACTION_VIEW, Uri.parse("http://www.youtube.com")) .setData(Uri.parse(url))); return true; } catch (Exception ex) { return false; } } else { return false; } } else if (url.contains("paypal.com")) { if (url.contains("&bn=ibuildapp_SP")) { return false; } else { url = url + "&bn=ibuildapp_SP"; webView.loadUrl(url); return true; } } else if (url.contains("sms:")) { try { Intent smsIntent = new Intent(Intent.ACTION_VIEW); smsIntent.setData(Uri.parse(url)); startActivity(smsIntent); return true; } catch (Exception ex) { Log.e("", ex.getMessage()); return false; } } else if (url.contains("tel:")) { Intent callIntent = new Intent(Intent.ACTION_CALL); callIntent.setData(Uri.parse(url)); startActivity(callIntent); return true; } else if (url.contains("mailto:")) { MailTo mailTo = MailTo.parse(url); Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { mailTo.getTo() }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, mailTo.getSubject()); emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, mailTo.getBody()); WebPlugin.this.startActivity(Intent.createChooser(emailIntent, getString(R.string.romanblack_html_send_email))); return true; } else if (url.contains("rtsp:")) { Uri address = Uri.parse(url); Intent intent = new Intent(Intent.ACTION_VIEW, address); final PackageManager pm = getPackageManager(); final List<ResolveInfo> matches = pm.queryIntentActivities(intent, 0); if (matches.size() > 0) { startActivity(intent); } else { Toast.makeText(WebPlugin.this, getString(R.string.romanblack_html_no_video_player), Toast.LENGTH_SHORT).show(); } return true; } else if (url.startsWith("intent:") || url.startsWith("market:") || url.startsWith("col-g2m-2:")) { Intent it = new Intent(); it.setData(Uri.parse(url)); startActivity(it); return true; } else if (url.contains("//play.google.com/")) { startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url))); return true; } else { if (url.contains("ibuildapp.com-1915109")) { String param = Uri.parse(url).getQueryParameter("widget"); finish(); if (param != null && param.equals("1001")) com.appbuilder.sdk.android.Statics.launchMain(); else if (param != null && !"".equals(param)) { View.OnClickListener widget = Statics.linkWidgets.get(Integer.valueOf(param)); if (widget != null) widget.onClick(view); } return false; } currentUrl = url; setSession(currentUrl); if (!isOnline) { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(STOP_LOADING); } else { String pageType = "application/html"; if (!url.contains("vk.com")) { getPageType(url); } if (pageType.contains("application") && !pageType.contains("html") && !pageType.contains("xml")) { startActivityForResult(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), DOWNLOAD_REQUEST_CODE); return super.shouldOverrideUrlLoading(view, url); } else { view.getSettings().setLoadWithOverviewMode(true); view.getSettings().setUseWideViewPort(true); view.setBackgroundColor(Color.WHITE); } } return false; } } catch (Exception ex) { // Error Logging return false; } } }); handler.sendEmptyMessage(SHOW_PROGRESS); new Thread() { @Override public void run() { EntityParser parser; if (widget.getPluginXmlData() != null) { if (widget.getPluginXmlData().length() > 0) { parser = new EntityParser(widget.getPluginXmlData()); } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } } else { String xmlData = readXmlFromFile(getIntent().getStringExtra("WidgetFile")); parser = new EntityParser(xmlData); } parser.parse(); url = parser.getUrl(); html = parser.getHtml(); if (url.length() > 0 && !isOnline) { handler.sendEmptyMessage(NEED_INTERNET_CONNECTION); } else { if (isOnline) { } else { if (html.length() == 0) { } } if (html.length() > 0 || url.length() > 0) { handler.sendEmptyMessageDelayed(SHOW_HTML, 700); } else { handler.sendEmptyMessage(HIDE_PROGRESS); handler.sendEmptyMessage(INITIALIZATION_FAILED); } } } }.start(); } catch (Exception ex) { } }
From source file:biz.bokhorst.xprivacy.ActivityMain.java
private void optionChangelog() { WebView webview = new WebView(this); webview.setWebViewClient(new WebViewClient() { public void onPageFinished(WebView view, String url) { int userId = Util.getUserId(Process.myUid()); Version currentVersion = new Version(Util.getSelfVersionName(ActivityMain.this)); PrivacyManager.setSetting(userId, PrivacyManager.cSettingChangelog, currentVersion.toString()); }/*from w w w . ja v a2s .c o m*/ }); webview.loadUrl("https://github.com/M66B/XPrivacy/blob/master/CHANGELOG.md"); AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this); alertDialogBuilder.setTitle(R.string.menu_changelog); alertDialogBuilder.setIcon(getThemed(R.attr.icon_launcher)); alertDialogBuilder.setView(webview); AlertDialog alertDialog = alertDialogBuilder.create(); alertDialog.show(); }
From source file:com.microsoft.windowsazure.mobileservices.LoginManager.java
/** * Creates the UI for the interactive authentication process * //from w ww. j a v a 2 s . co m * @param provider * The provider used for the authentication process * @param startUrl * The initial URL for the authentication process * @param endUrl * The final URL for the authentication process * @param context * The context used to create the authentication dialog * @param callback * Callback to invoke when the authentication process finishes */ private void showLoginUI(final String startUrl, final String endUrl, final Context context, LoginUIOperationCallback callback) { if (startUrl == null || startUrl == "") { throw new IllegalArgumentException("startUrl can not be null or empty"); } if (endUrl == null || endUrl == "") { throw new IllegalArgumentException("endUrl can not be null or empty"); } if (context == null) { throw new IllegalArgumentException("context can not be null"); } final LoginUIOperationCallback externalCallback = callback; final AlertDialog.Builder builder = new AlertDialog.Builder(context); // Create the Web View to show the login page final WebView wv = new WebView(context); builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException("User Canceled")); } } }); wv.getSettings().setJavaScriptEnabled(true); DisplayMetrics displaymetrics = new DisplayMetrics(); ((Activity) context).getWindowManager().getDefaultDisplay().getMetrics(displaymetrics); int webViewHeight = displaymetrics.heightPixels; wv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, webViewHeight)); wv.requestFocus(View.FOCUS_DOWN); wv.setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View view, MotionEvent event) { int action = event.getAction(); if (action == MotionEvent.ACTION_DOWN || action == MotionEvent.ACTION_UP) { if (!view.hasFocus()) { view.requestFocus(); } } return false; } }); // Create a LinearLayout and add the WebView to the Layout LinearLayout layout = new LinearLayout(context); layout.setOrientation(LinearLayout.VERTICAL); layout.addView(wv); // Add a dummy EditText to the layout as a workaround for a bug // that prevents showing the keyboard for the WebView on some devices EditText dummyEditText = new EditText(context); dummyEditText.setVisibility(View.GONE); layout.addView(dummyEditText); // Add the layout to the dialog builder.setView(layout); final AlertDialog dialog = builder.create(); wv.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { // If the URL of the started page matches with the final URL // format, the login process finished if (isFinalUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(url, null); } dialog.dismiss(); } super.onPageStarted(view, url, favicon); } // Checks if the given URL matches with the final URL's format private boolean isFinalUrl(String url) { if (url == null) { return false; } return url.startsWith(endUrl); } // Checks if the given URL matches with the start URL's format private boolean isStartUrl(String url) { if (url == null) { return false; } return url.startsWith(startUrl); } @Override public void onPageFinished(WebView view, String url) { if (isStartUrl(url)) { if (externalCallback != null) { externalCallback.onCompleted(null, new MobileServiceException( "Logging in with the selected authentication provider is not enabled")); } dialog.dismiss(); } } }); wv.loadUrl(startUrl); dialog.show(); }
From source file:app.clirnet.com.clirnetapp.activity.LoginActivity.java
private void showDialog12() { final View checkBoxView = View.inflate(this, R.layout.alert_checkbox, null); final CheckBox checkBox = (CheckBox) checkBoxView.findViewById(R.id.checkBox); final WebView wv = (WebView) checkBoxView.findViewById(R.id.webview); // checkBox.setText("Yes, I accept the terms and condition"); final AlertDialog.Builder ad = new AlertDialog.Builder(this) // .setMessage(termsnconditiomessage) .setView(checkBoxView).setIcon(R.drawable.info).setTitle("Terms of Service"); checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override//from w w w . ja va 2 s. c om public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { //Method will send radio button checked status to yes button for further process of redirection checkedStatus(true); } else { checkedStatus(false); Toast.makeText(getApplicationContext(), "Please accept the terms and condition to proceed ", Toast.LENGTH_LONG).show(); } } }); wv.setVisibility(View.VISIBLE); wv.loadUrl("http://doctor.clirnet.com/doctor/patientcentral/termsandcondition"); wv.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { view.loadUrl(url); return true; } }); ad.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { //Toast.makeText(mContext.getApplicationContext(), "You have accepted the TOS. Welcom to the site", Toast.LENGTH_SHORT).show(); if (responceCheck) { rememberTermsCondition("Yes"); Intent intent = new Intent(getApplicationContext(), SplashActivity.class); startActivity(intent); new AppController().showToastMsg(getApplicationContext(), "Login Successful"); startService(); } else { new AppController().showToastMsg(getApplicationContext(), "Please accept the terms and condition to proceed"); // Toast.makeText(mContext.getApplicationContext(), "Please accept the terms and condition to proceed", Toast.LENGTH_SHORT).show(); } } }); ad.setNegativeButton("No", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), "You have denied the TOS. You may not access the site", Toast.LENGTH_SHORT).show(); rememberTermsCondition("No"); } }); ad.setNeutralButton("Cancel", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Toast.makeText(getApplicationContext(), "Please select yes or no", Toast.LENGTH_SHORT).show(); rememberTermsCondition("No"); } }); ad.setCancelable(false); ad.setView(checkBoxView); ad.show(); }