List of usage examples for android.app AlertDialog setButton
@Deprecated public void setButton(CharSequence text, final OnClickListener listener)
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptMultiAIO(final Activity activity) { // if (!ICS) { // Toast.makeText(getApplicationContext(), // "Multithread AIO supported only for ICS and above!", // Toast.LENGTH_SHORT).show(); // this.mMultiAIO.setChecked(false); // return;/*w ww . ja va2 s . c o m*/ // } final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Warning!"); TextView info = new TextView(activity); info.setText("Enabling Multithreaded AIO might speed up I/O in the VM " + "but it might not work for all devices. " + "Multithreaded AIO is experimental and might damage any disk image you open with Limbo so keep a " + "backup of your images if you're not certain. " + "If you see errors uncheck this option and try again."); alertDialog.setView(info); final Handler handler = this.handler; alertDialog.setButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { LimboSettingsManager.setMultiAIO(activity, true); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { mMultiAIO.setChecked(false); LimboSettingsManager.setMultiAIO(activity, false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mMultiAIO.setChecked(false); LimboSettingsManager.setMultiAIO(activity, false); } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
private void promptImportMachines() { // TODO Auto-generated method stub final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Import Machines"); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222);/* ww w. ja va2 s. co m*/ TextView imageNameView = new TextView(activity); imageNameView.setVisibility(View.VISIBLE); imageNameView.setId(201012010); imageNameView.setText( "Step 1: Place the machine.CSV file you export previously under \"limbo\" directory in your SD card.\n" + "Step 2: WARNING: Any machine with the same name will be replaced!\n" + "Step 3: Press \"OK\".\n"); RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); mLayout.addView(imageNameView, searchViewParams); alertDialog.setView(mLayout); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("OK", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // For each line create a Machine progDialog = ProgressDialog.show(activity, "Please Wait", "Importing Machines...", true); ImportMachines importer = new ImportMachines(); importer.execute(); } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { return; } }); alertDialog.show(); }
From source file:pt.aptoide.backupapps.Aptoide.java
@Override public boolean onOptionsItemSelected(MenuItem item) { EnumOptionsMenu menuEntry = EnumOptionsMenu.reverseOrdinal(item.getItemId()); Log.d("Aptoide-OptionsMenu", "menuOption: " + menuEntry + " itemid: " + item.getItemId()); switch (menuEntry) { // case MANAGE_REPO: // availableAdapter.sleep(); // Intent manageRepo = new Intent(this, ManageRepos.class); // startActivity(manageRepo); // return true; case UNINSTALL: try {/*from w ww .j av a 2s . c o m*/ serviceDataCaller.callUninstallApps(installedAdapter.getSelectedIds()); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } return true; case DELETE: //TODO improve listIds as an extended parcelable array ;) then use it as a carrier for checked hashids list return true; case DISPLAY_OPTIONS: if (!loadingRepos.get()) { //TODO refactor extract dialog management class LayoutInflater displayOptionsInflater = LayoutInflater.from(this); View displayOptions = displayOptionsInflater.inflate(R.layout.dialog_display_options, null); Builder dialogBuilder = new AlertDialog.Builder(theme).setView(displayOptions); final AlertDialog sortDialog = dialogBuilder.create(); sortDialog.setIcon(android.R.drawable.ic_menu_sort_by_size); sortDialog.setTitle(getString(R.string.display_options)); // *********************************************************** // Categories // final RadioButton byCategory = (RadioButton) displayOptions.findViewById(R.id.by_category); // final RadioButton byAll = (RadioButton) displayOptions.findViewById(R.id.by_all); // if(availableByCategory){ // byCategory.setChecked(true); // }else{ // byAll.setChecked(true); // } // // final View spacer = displayOptions.findViewById(R.id.spacer); // // if(currentAppsList != EnumAppsLists.Available){ // spacer.setVisibility(View.GONE); // ((RadioGroup) displayOptions.findViewById(R.id.group_show)).setVisibility(View.GONE); // } // *********************************************************** // Sorting final View group_sort = displayOptions.findViewById(R.id.group_sort); final RadioButton byAlphabetic = (RadioButton) displayOptions.findViewById(R.id.by_alphabetic); final RadioButton byFreshness = (RadioButton) displayOptions.findViewById(R.id.by_freshness); final RadioButton bySize = (RadioButton) displayOptions.findViewById(R.id.by_size); // spacer.setVisibility(View.VISIBLE); group_sort.setVisibility(View.VISIBLE); switch (appsSortingPolicy) { case ALPHABETIC: byAlphabetic.setChecked(true); break; case FRESHNESS: byFreshness.setChecked(true); break; case SIZE: bySize.setChecked(true); break; default: break; } // *********************************************************** final CheckBox showSystemApps = (CheckBox) displayOptions.findViewById(R.id.show_system_apps); boolean showSystemAppsState = false; try { showSystemAppsState = serviceDataCaller.callGetShowSystemApps(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } showSystemApps.setChecked(showSystemAppsState); final boolean storedShowSystemAppsState = showSystemAppsState; sortDialog.setButton(getString(R.string.done), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // boolean byCategoryChanged = false; EnumAppsSorting newSortingPolicy = null; // if(byCategory.isChecked() != availableByCategory){ // byCategoryChanged = true; // availableByCategory = byCategory.isChecked(); // setAvailableListBy(availableByCategory); // } if (showSystemApps.isChecked() != storedShowSystemAppsState) { setShowSystemApps(showSystemApps.isChecked()); } if (byAlphabetic.isChecked()) { newSortingPolicy = EnumAppsSorting.ALPHABETIC; } else if (byFreshness.isChecked()) { newSortingPolicy = EnumAppsSorting.FRESHNESS; } else if (bySize.isChecked()) { newSortingPolicy = EnumAppsSorting.SIZE; } if (newSortingPolicy != null && newSortingPolicy != appsSortingPolicy) { // availableAdapter.sleep(); appsSortingPolicy = newSortingPolicy; setAppsSortingPolicy(appsSortingPolicy); } // if(byCategoryChanged){ // if(availableByCategory){ // availableAdapter.sleep(); // categoriesAdapter.resetDisplayCategories(); // }else{ // availableAdapter.resetDisplay(null); // } // } sortDialog.dismiss(); } }); sortDialog.show(); } else { Toast.makeText(Aptoide.this, getString(R.string.option_not_available_while_updating_repos), Toast.LENGTH_SHORT).show(); } return true; // case SEARCH_MENU: // onSearchRequested(); // return true; case UN_SELECT_ALL: switch (currentAppsList) { case RESTORE: if (availableAdapter.isDynamic()) { Toast.makeText(Aptoide.this, getString(R.string.too_many_apps_to_select_at_once), Toast.LENGTH_SHORT).show(); return true; } availableAdapter.toggleSelectAll(); break; case BACKUP: installedAdapter.toggleSelectAll(); break; default: break; } return true; case ABOUT: LayoutInflater aboutInflater = LayoutInflater.from(this); View about = aboutInflater.inflate(R.layout.about, null); TextView info = (TextView) about.findViewById(R.id.credits); info.setText(getString(R.string.credits, versionName)); Builder aboutCreator = new AlertDialog.Builder(theme).setView(about); final AlertDialog aboutDialog = aboutCreator.create(); aboutDialog.setIcon(R.drawable.icon); aboutDialog.setTitle(R.string.self_name); // aboutDialog.setButton(getText(R.string.changelog), new DialogInterface.OnClickListener() { // public void onClick(DialogInterface dialog, int whichButton) { // Uri uri = Uri.parse(getString(R.string.changelog_url)); // startActivity(new Intent( Intent.ACTION_VIEW, uri)); // } // }); aboutDialog.show(); return true; case SETTINGS: // availableAdapter.sleep(); Intent settings = new Intent(this, Settings.class); startActivity(settings); return true; case LOGIN: // boolean insertingRepo = false; // try { // insertingRepo = serviceDataCaller.callIsInsertingRepo(); // } catch (RemoteException e1) { // // TODO Auto-generated catch block // e1.printStackTrace(); // } // if(insertingRepo){ // AptoideLog.d(Aptoide.this, getString(R.string.updating_repo_please_wait)); // Toast.makeText(getApplicationContext(), getResources().getString(R.string.updating_repo_please_wait), Toast.LENGTH_SHORT).show(); // } // else{ Log.d("Aptoide-Settings", "clicked set server login"); String token = null; try { token = serviceDataCaller.callGetServerToken(); } catch (RemoteException e) { // TODO Auto-generated catch block e.printStackTrace(); } if (token == null) { Log.d("Aptoide-Settings", "No login set"); Intent login = new Intent(Aptoide.this, BazaarLogin.class); login.putExtra("InvoqueType", BazaarLogin.InvoqueType.NO_CREDENTIALS_SET.ordinal()); startActivity(login); // DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.NO_CREDENTIALS_SET); // loginComments.setOnDismissListener(new OnDismissListener() { // @Override // public void onDismiss(DialogInterface dialog) { // addAppVersionComment(); // } // }); // dialogLogin.show(); } else { Log.d("Aptoide-Settings", "Login edit"); Intent login = new Intent(Aptoide.this, BazaarLogin.class); login.putExtra("InvoqueType", BazaarLogin.InvoqueType.OVERRIDE_CREDENTIALS.ordinal()); startActivity(login); // DialogLogin dialogLogin = new DialogLogin(Settings.this, serviceDataCaller, DialogLogin.InvoqueType.OVERRIDE_CREDENTIALS); // Toast.makeText(Settings.this, "Login already set", Toast.LENGTH_SHORT).show(); // dialogLogin.show(); } // } return true; case FOLLOW: new DialogFollowOnSocialNets(this, serviceDataCaller).show(); return true; // case SCHEDULED_DOWNLOADS: // availableAdapter.sleep(); // Intent manageScheduled = new Intent(this, ManageScheduled.class); // startActivity(manageScheduled); // return true; // case UPDATE_ALL: // if(!loadingRepos.get()){ // AptoideLog.d(this, "Update all"); // try { // serviceDataCaller.callUpdateAll(); // } catch (RemoteException e) { // // TODO Auto-generated catch block // e.printStackTrace(); // } // }else{ // Toast.makeText(Aptoide.this, "Option not available while updating stores!", Toast.LENGTH_SHORT).show(); // } // return true; default: return super.onOptionsItemSelected(item); } }
From source file:self.philbrown.droidQuery.$.java
/** * Uses the current context to show an alert dialog. * @param title the alert title//from w w w.j a v a2 s.co m * @param text the alert message. * @see #alert(String) */ public void alert(String title, String text) { AlertDialog alert = new AlertDialog.Builder(context).create(); alert.setTitle(title); alert.setMessage(text); alert.setButton("OK", new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); alert.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptVNCAllowExternal(final Activity activity) { final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Enable VNC server"); TextView textView = new TextView(activity); textView.setVisibility(View.VISIBLE); textView.setId(201012010);//from w ww . ja va 2s . c o m textView.setText("VNC Server: " + this.getLocalIpAddress() + ":" + "5901\n" + "Warning: VNC is not secure make sure you're on a private network!\n"); EditText passwdView = new EditText(activity); passwdView.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD); passwdView.setHint("Password"); passwdView.setEnabled(true); passwdView.setVisibility(View.VISIBLE); passwdView.setId(11111); passwdView.setSingleLine(); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222); RelativeLayout.LayoutParams textViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); textViewParams.addRule(RelativeLayout.ALIGN_PARENT_TOP, mLayout.getId()); mLayout.addView(textView, textViewParams); RelativeLayout.LayoutParams passwordViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); passwordViewParams.addRule(RelativeLayout.BELOW, textView.getId()); // passwordViewParams.addRule(RelativeLayout.ALIGN_PARENT_BOTTOM, // mLayout.getId()); mLayout.addView(passwdView, passwordViewParams); alertDialog.setView(mLayout); final Handler handler = this.handler; alertDialog.setButton("Set", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(11111); if (a.getText().toString().trim().equals("")) { Toast.makeText(getApplicationContext(), "Password cannot be empty!", Toast.LENGTH_SHORT).show(); vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } else { sendHandlerMessage(handler, Const.VNC_PASSWORD, "vnc_passwd", "passwd"); vnc_passwd = a.getText().toString(); vnc_allow_external = 1; // LimboSettingsManager.setVNCAllowExternal(activity, true); } } }); alertDialog.setButton2("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { vnc_passwd = null; vnc_allow_external = 0; mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); return; } }); alertDialog.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialog) { mVNCAllowExternal.setChecked(false); // LimboSettingsManager.setVNCAllowExternal(activity, false); vnc_passwd = null; vnc_allow_external = 0; } }); alertDialog.show(); }
From source file:com.max2idea.android.limbo.main.LimboActivity.java
public void promptImageName(final Activity activity, String hd) { final String hd_string = hd; final AlertDialog alertDialog; alertDialog = new AlertDialog.Builder(activity).create(); alertDialog.setTitle("Image Name"); RelativeLayout mLayout = new RelativeLayout(this); mLayout.setId(12222);/*from ww w .j a v a 2 s . c o m*/ EditText imageNameView = new EditText(activity); imageNameView.setEnabled(true); imageNameView.setVisibility(View.VISIBLE); imageNameView.setId(201012010); imageNameView.setSingleLine(); RelativeLayout.LayoutParams searchViewParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); mLayout.addView(imageNameView, searchViewParams); final Spinner size = new Spinner(this); RelativeLayout.LayoutParams setPlusParams = new RelativeLayout.LayoutParams( RelativeLayout.LayoutParams.FILL_PARENT, RelativeLayout.LayoutParams.WRAP_CONTENT); size.setId(201012044); String[] arraySpinner = new String[7]; for (int i = 0; i < arraySpinner.length; i++) { if (i < 5) { arraySpinner[i] = (i + 1) + " GB"; } } arraySpinner[5] = "10 GB"; arraySpinner[6] = "20 GB"; ArrayAdapter sizeAdapter = new ArrayAdapter(this, android.R.layout.simple_spinner_item, arraySpinner); sizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); size.setAdapter(sizeAdapter); setPlusParams.addRule(RelativeLayout.BELOW, imageNameView.getId()); mLayout.addView(size, setPlusParams); // TODO: Not working for now // final TextView preallocText = new TextView(this); // preallocText.setText("Preallocate? "); // preallocText.setTextSize(15); // RelativeLayout.LayoutParams preallocTParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocTParams.addRule(RelativeLayout.BELOW, size.getId()); // mLayout.addView(preallocText, preallocTParams); // preallocText.setId(64512044); // // final CheckBox prealloc = new CheckBox(this); // RelativeLayout.LayoutParams preallocParams = new // RelativeLayout.LayoutParams( // RelativeLayout.LayoutParams.WRAP_CONTENT, // RelativeLayout.LayoutParams.WRAP_CONTENT); // preallocParams.addRule(RelativeLayout.BELOW, size.getId()); // preallocParams.addRule(RelativeLayout.RIGHT_OF, // preallocText.getId()); // preallocParams.addRule(RelativeLayout.ALIGN_PARENT_RIGHT, // preallocText.getId()); // mLayout.addView(prealloc, preallocParams); // prealloc.setId(64512344); alertDialog.setView(mLayout); final Handler handler = this.handler; // alertDialog.setMessage(body); alertDialog.setButton("Create", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int sizeSel = size.getSelectedItemPosition(); String templateImage = "hd1g.qcow2"; if (sizeSel < 5) { templateImage = "hd" + (sizeSel + 1) + "g.qcow2"; } else if (sizeSel == 5) { templateImage = "hd10g.qcow2"; } else if (sizeSel == 6) { templateImage = "hd20g.qcow2"; } // UIUtils.log("Searching..."); EditText a = (EditText) alertDialog.findViewById(201012010); progDialog = ProgressDialog.show(activity, "Please Wait", "Creating HD Image...", true); // CreateImage createImg = new // CreateImage(a.getText().toString(), // hd_string, sizeInt, prealloc.isChecked()); // CreateImage createImg = new CreateImage(a.getText().toString(), // hd_string, sizeInt, false); // createImg.execute(); String image = a.getText().toString(); if (!image.endsWith(".qcow2")) { image += ".qcow2"; } createImg(templateImage, image, hd_string); } }); alertDialog.show(); }