List of usage examples for android.app AlertDialog setCancelable
public void setCancelable(boolean flag)
From source file:foam.littlej.android.app.ui.phone.AddReportActivity.java
/** * Create various dialog//from w ww . j av a2s .com */ @Override protected Dialog onCreateDialog(int id) { switch (id) { case DIALOG_ERROR_NETWORK: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.network_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_ERROR_SAVING: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.network_error)); dialog.setMessage(getString(R.string.file_system_error_msg)); dialog.setButton2(getString(R.string.ok), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_CHOOSE_IMAGE_METHOD: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.choose_method)); dialog.setMessage(getString(R.string.how_to_select_pic)); dialog.setButton(getString(R.string.gallery_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_PICK); intent.setData(MediaStore.Images.Media.EXTERNAL_CONTENT_URI); startActivityForResult(intent, REQUEST_CODE_IMAGE); dialog.dismiss(); } }); dialog.setButton2(getString(R.string.cancel), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton3(getString(R.string.camera_option), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE); intent.putExtra(MediaStore.EXTRA_OUTPUT, PhotoUtils.getPhotoUri(photoName, AddReportActivity.this)); startActivityForResult(intent, REQUEST_CODE_CAMERA); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } case DIALOG_MULTIPLE_CATEGORY: { if (showCategories() != null) { return new AlertDialog.Builder(this).setTitle(R.string.choose_categories) .setMultiChoiceItems(showCategories(), setCheckedCategories(), new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { // see if categories have previously if (isChecked) { mVectorCategories.add(mCategoriesId.get(whichButton)); mError = false; } else { mVectorCategories.remove(mCategoriesId.get(whichButton)); } setSelectedCategories(mVectorCategories); } }) .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { /* User clicked Yes so do some stuff */ } }).create(); } } case TIME_DIALOG_ID: return new TimePickerDialog(this, mTimeSetListener, mCalendar.get(Calendar.HOUR), mCalendar.get(Calendar.MINUTE), false); case DATE_DIALOG_ID: return new DatePickerDialog(this, mDateSetListener, mCalendar.get(Calendar.YEAR), mCalendar.get(Calendar.MONTH), mCalendar.get(Calendar.DAY_OF_MONTH)); case DIALOG_SHOW_MESSAGE: AlertDialog.Builder messageBuilder = new AlertDialog.Builder(this); messageBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showDialog = messageBuilder.create(); showDialog.show(); break; case DIALOG_SHOW_REQUIRED: AlertDialog.Builder requiredBuilder = new AlertDialog.Builder(this); requiredBuilder.setTitle(R.string.required_fields); requiredBuilder.setMessage(mErrorMessage).setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { dialog.cancel(); } }); AlertDialog showRequiredDialog = requiredBuilder.create(); showRequiredDialog.show(); break; // prompt for unsaved changes case DIALOG_SHOW_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.unsaved_changes)); dialog.setMessage(getString(R.string.want_to_cancel)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { new DiscardTask(AddReportActivity.this).execute((String) null); finish(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } // prompt for report deletion case DIALOG_SHOW_DELETE_PROMPT: { AlertDialog dialog = (new AlertDialog.Builder(this)).create(); dialog.setTitle(getString(R.string.delete_report)); dialog.setMessage(getString(R.string.want_to_delete)); dialog.setButton(getString(R.string.no), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); dialog.setButton2(getString(R.string.yes), new Dialog.OnClickListener() { public void onClick(DialogInterface dialog, int which) { // delete report deleteReport(); dialog.dismiss(); } }); dialog.setCancelable(false); return dialog; } } return null; }
From source file:de.tum.frm2.nicos_android.gui.MainActivity.java
@Override public void handleSignal(String signal, Object data, Object args) { switch (signal) { case "broken": final String error = (String) data; // Connection is broken. Try to disconnect what's left and go back to login screen. NicosClient.getClient().unregisterCallbackHandler(this); NicosClient.getClient().disconnect(); if (!_visible) return; // Activity is still visible, user probably didn't intend to shut down connection. // We display an error. runOnUiThread(new Runnable() { @Override/*w ww .ja va2 s. c o m*/ public void run() { AlertDialog alertDialog; try { alertDialog = new AlertDialog.Builder(MainActivity.this).create(); alertDialog.setTitle("Disconnected"); alertDialog.setMessage(error); alertDialog.setButton(AlertDialog.BUTTON_NEGATIVE, "Okay", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); finish(); } }); alertDialog.setCancelable(false); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } catch (Exception e) { try { finish(); } catch (Exception e2) { // User probably quit the application. } // Activity isn't running anymore // (user probably put application in background). } } }); break; case "cache": on_client_cache((Object[]) data); break; case "status": // data = tuple of (status, linenumber) _current_status = (int) ((Object[]) data)[0]; break; case "message": final ArrayList msgList = (ArrayList) data; if ((int) msgList.get(2) == NicosMessageLevel.ERROR) { runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), NicosMessageLevel.level2name(NicosMessageLevel.ERROR) + ": " + msgList.get(3), Toast.LENGTH_SHORT).show(); } }); } break; case "error": final String msg = (String) data; runOnUiThread(new Runnable() { @Override public void run() { Toast.makeText(getApplicationContext(), msg, Toast.LENGTH_SHORT).show(); } }); break; } }
From source file:com.xperia64.rompatcher.MainActivity.java
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); staticThis = MainActivity.this; setContentView(R.layout.main);/*from ww w.ja va2s .c o m*/ // Load native libraries try { System.loadLibrary("apsn64patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab apspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("ipspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ipspatcher!"); } try { System.loadLibrary("upspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab upspatcher!"); } try { System.loadLibrary("xdelta3patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xdelta3patcher!"); } try { System.loadLibrary("bpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bpspatcher!"); } try { System.loadLibrary("bzip2"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bzip2!"); } try { System.loadLibrary("bsdiffpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab bsdiffpatcher!"); } try { System.loadLibrary("ppfpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ppfpatcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("glib-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab glib-2.0!"); } try { System.loadLibrary("gmodule-2.0"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab gmodule-2.0!"); } try { System.loadLibrary("edsio"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab edsio!"); } try { System.loadLibrary("xdelta1patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ips32patcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ips32patcher!"); } try { System.loadLibrary("ecmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab ecmpatcher!"); } try { System.loadLibrary("dpspatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dpspatcher!"); } try { System.loadLibrary("dldipatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab dldipatcher!"); } try { System.loadLibrary("xpcpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab xpcpatcher!"); } try { System.loadLibrary("asarpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asarpatcher!"); } try { System.loadLibrary("asmpatcher"); } catch (UnsatisfiedLinkError e) { Log.e("Bad:", "Cannot grab asmpatcher!"); } c = (CheckBox) findViewById(R.id.backupCheckbox); d = (CheckBox) findViewById(R.id.altNameCheckbox); r = (CheckBox) findViewById(R.id.ignoreCRC); e = (CheckBox) findViewById(R.id.fileExtCheckbox); ed = (EditText) findViewById(R.id.txtOutFile); final Button romButton = (Button) findViewById(R.id.romButton); romButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = true; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final Button patchButton = (Button) findViewById(R.id.patchButton); patchButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { Globals.mode = false; Intent intent = new Intent(staticThis, FileBrowserActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP); startActivityForResult(intent, 1); } }); final ImageButton bkHelp = (ImageButton) findViewById(R.id.backupHelp); bkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.bkup_rom)); dialog.setMessage(getResources().getString(R.string.bkup_rom_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton altNameHelp = (ImageButton) findViewById(R.id.outfileHelp); altNameHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.rename1)); dialog.setMessage(getResources().getString(R.string.rename_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); final ImageButton chkHelp = (ImageButton) findViewById(R.id.ignoreHelp); chkHelp.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.ignoreChks)); dialog.setMessage(getResources().getString(R.string.ignoreChks_desc)); dialog.setCancelable(true); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.ok), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog.show(); } }); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; ed.setFilters(new InputFilter[] { filter }); c.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { d.setEnabled(true); if (d.isChecked()) { ed.setEnabled(true); e.setEnabled(true); } } else { d.setEnabled(false); ed.setEnabled(false); e.setEnabled(false); } } }); d.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { if (((CheckBox) v).isChecked()) { ed.setEnabled(true); e.setEnabled(true); } else { e.setEnabled(false); ed.setEnabled(false); } } }); final Button applyButton = (Button) findViewById(R.id.applyPatch); applyButton.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { // Warn about patching archives. if (Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".7z") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".zip") || Globals.fileToPatch.toLowerCase(Locale.US).endsWith(".rar")) { AlertDialog dialog = new AlertDialog.Builder(staticThis).create(); dialog.setTitle(getResources().getString(R.string.warning)); dialog.setMessage(getResources().getString(R.string.zip_warning_desc)); dialog.setCancelable(false); dialog.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { patchCheck(); } }); dialog.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { Toast t = Toast.makeText(staticThis, getResources().getString(R.string.nopatch), Toast.LENGTH_SHORT); t.show(); } }); dialog.show(); } else { patchCheck(); } } }); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { // Uggh. requestPermissions(); } }
From source file:org.csp.everyaware.offline.Map.java
public final void createLegalNoticesDialog(Activity activity) { AlertDialog ad = new AlertDialog.Builder(activity).create(); ad.setCancelable(false); // This blocks the 'BACK' button ad.setMessage(GooglePlayServicesUtil.getOpenSourceSoftwareLicenseInfo(activity.getApplicationContext())); ad.setButton("OK", new DialogInterface.OnClickListener() { @Override/*from w w w .j av a 2 s .c o m*/ public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); ad.show(); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void saveCfg() { localfinished = false;//from w w w . j av a 2s . co m if (Globals.isMidi(currSongName) && Globals.isPlaying == 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle("Save Cfg"); alert.setMessage("Save a MIDI configuration file"); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; // Set an EditText view to get user input final EditText input = new EditText(this); input.setFilters(new InputFilter[] { filter }); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (!value.toLowerCase(Locale.US).endsWith(Globals.compressCfg ? ".tzf" : ".tcf")) value += (Globals.compressCfg ? ".tzf" : ".tcf"); String parent = currSongName.substring(0, currSongName.lastIndexOf('/') + 1); boolean aWrite = true; boolean alreadyExists = new File(parent + value).exists(); String needRename = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { new FileOutputStream(parent + value, true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } if (!alreadyExists && aWrite) new File(parent + value).delete(); if (aWrite && new File(parent).canWrite()) { value = parent + value; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { //TODO // Write the file to getExternalFilesDir, then move it with the Uri // We need to tell JNIHandler that movement is needed. String[] tmp = Globals.getDocFilePaths(TimidityActivity.this, parent); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename = parent .substring(parent.indexOf(probablyTheRoot) + probablyTheRoot.length()) + value; value = probablyTheDirectory + '/' + value; } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; return; } } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } final String finalval = value; final boolean canWrite = aWrite; final String needToRename = needRename; final String probRoot = probablyTheRoot; if (new File(finalval).exists() || (new File(probRoot + needRename).exists() && needToRename != null)) { AlertDialog dialog2 = new AlertDialog.Builder(TimidityActivity.this).create(); dialog2.setTitle("Warning"); dialog2.setMessage("Overwrite config file?"); dialog2.setCancelable(false); dialog2.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename != null) { Globals.tryToDeleteFile(TimidityActivity.this, probRoot + needToRename); Globals.tryToDeleteFile(TimidityActivity.this, finalval); } else { Globals.tryToDeleteFile(TimidityActivity.this, finalval); } } else { new File(finalval).delete(); } saveCfgPart2(finalval, needToRename); } }); dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog2.show(); } else { saveCfgPart2(finalval, needToRename); } } }); alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alerty = alert.show(); } }
From source file:com.olacabs.customer.ui.TrackRideActivity.java
private void m13916a(LayoutInflater layoutInflater, String str) { if (this.f10194W.m13218d().getBookingCancelReasons() == null || !this.f10194W.m13218d().getBookingCancelReasons().containsKey(str)) { View inflate = layoutInflater.inflate(R.layout.view_dialog_messsage_yes_no, null, false); AlertDialog create = new Builder(this).setView(inflate).create(); ((TextView) inflate.findViewById(R.id.item_header)).setText("Cancel Ride"); ((TextView) inflate.findViewById(R.id.item_message)) .setText("Are you sure you want to cancel booking ?"); inflate.findViewById(R.id.button_yes).setOnClickListener(new AnonymousClass11(this, create, str)); inflate.findViewById(R.id.button_no).setOnClickListener(new AnonymousClass12(this, create)); create.setCancelable(false); create.show();/*from w w w .jav a2 s .c om*/ return; } inflate = layoutInflater.inflate(R.layout.view_cancel_list_dialog, null, false); this.f10198c = (ListView) inflate.findViewById(R.id.item_list); this.f10185N = inflate.findViewById(R.id.button_yes); this.f10185N.setEnabled(false); C0911a c0911a = new C0911a(this, this, (List) this.f10194W.m13218d().getBookingCancelReasons().get(str)); this.f10198c.setAdapter(c0911a); c0911a.notifyDataSetChanged(); AlertDialog create2 = new Builder(this).setView(inflate).create(); this.f10198c.setFocusable(false); this.f10198c.setOnItemClickListener(new AnonymousClass13(this, c0911a)); this.f10185N.setOnClickListener(new C09022(this, create2, str)); inflate.findViewById(R.id.button_no).setOnClickListener(new C09033(this, create2)); create2.setCancelable(false); create2.show(); }
From source file:com.xperia64.timidityae.TimidityActivity.java
public void dynExport() { localfinished = false;/*ww w.ja va 2 s . c om*/ if (Globals.isMidi(currSongName) && Globals.isPlaying == 0) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.setTitle(getResources().getString(R.string.dynex_alert1)); alert.setMessage(getResources().getString(R.string.dynex_alert1_msg)); InputFilter filter = new InputFilter() { public CharSequence filter(CharSequence source, int start, int end, Spanned dest, int dstart, int dend) { for (int i = start; i < end; i++) { String IC = "*/*\n*\r*\t*\0*\f*`*?***\\*<*>*|*\"*:*"; if (IC.contains("*" + source.charAt(i) + "*")) { return ""; } } return null; } }; final EditText input = new EditText(this); input.setFilters(new InputFilter[] { filter }); alert.setView(input); alert.setPositiveButton("Ok", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { String value = input.getText().toString(); if (!value.toLowerCase(Locale.US).endsWith(".wav")) value += ".wav"; String parent = currSongName.substring(0, currSongName.lastIndexOf('/') + 1); boolean alreadyExists = new File(parent + value).exists(); boolean aWrite = true; String needRename = null; String probablyTheRoot = ""; String probablyTheDirectory = ""; try { new FileOutputStream(parent + value, true).close(); } catch (FileNotFoundException e) { aWrite = false; } catch (IOException e) { e.printStackTrace(); } if (aWrite && !alreadyExists) new File(parent + value).delete(); if (aWrite && new File(parent).canWrite()) { value = parent + value; } else if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP && Globals.theFold != null) { String[] tmp = Globals.getDocFilePaths(TimidityActivity.this, parent); probablyTheDirectory = tmp[0]; probablyTheRoot = tmp[1]; if (probablyTheDirectory.length() > 1) { needRename = parent .substring(parent.indexOf(probablyTheRoot) + probablyTheRoot.length()) + value; value = probablyTheDirectory + '/' + value; } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } } else { value = Environment.getExternalStorageDirectory().getAbsolutePath() + '/' + value; } final String finalval = value; final boolean canWrite = aWrite; final String needToRename = needRename; final String probRoot = probablyTheRoot; if (new File(finalval).exists() || (new File(probRoot + needRename).exists() && needToRename != null)) { AlertDialog dialog2 = new AlertDialog.Builder(TimidityActivity.this).create(); dialog2.setTitle(getResources().getString(R.string.warning)); dialog2.setMessage(getResources().getString(R.string.dynex_alert2_msg)); dialog2.setCancelable(false); dialog2.setButton(DialogInterface.BUTTON_POSITIVE, getResources().getString(android.R.string.yes), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { if (!canWrite && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { if (needToRename != null) { Globals.tryToDeleteFile(TimidityActivity.this, probRoot + needToRename); Globals.tryToDeleteFile(TimidityActivity.this, finalval); } else { Globals.tryToDeleteFile(TimidityActivity.this, finalval); } } else { new File(finalval).delete(); } saveWavPart2(finalval, needToRename); } }); dialog2.setButton(DialogInterface.BUTTON_NEGATIVE, getResources().getString(android.R.string.no), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int buttonId) { } }); dialog2.show(); } else { saveWavPart2(finalval, needToRename); } } }); alert.setNegativeButton(getResources().getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { // Canceled. } }); alerty = alert.show(); } }
From source file:com.olacabs.customer.ui.TrackRideActivity.java
private void m13933c(String str, String str2) { View inflate = ((LayoutInflater) getSystemService("layout_inflater")) .inflate(R.layout.view_dialog_messsage_yes_no, null, false); AlertDialog create = new Builder(this).setView(inflate).create(); ((TextView) inflate.findViewById(R.id.button_yes)).setText(getString(R.string.sos_add_now)); ((TextView) inflate.findViewById(R.id.button_no)).setText(getString(R.string.sos_later)); ((TextView) inflate.findViewById(R.id.item_header)).setText(str); ((TextView) inflate.findViewById(R.id.item_message)).setText(str2); inflate.findViewById(R.id.button_yes).setOnClickListener(new C09044(this, create)); inflate.findViewById(R.id.button_no).setOnClickListener(new C09055(this, create)); create.setCancelable(false); create.show();/* www. ja v a 2s.c o m*/ }
From source file:cm.aptoide.pt.ApkInfo.java
public void loadMalware(final MalwareStatus malwareStatus) { runOnUiThread(new Runnable() { @Override// w w w.j a v a2s .co m public void run() { try { EnumApkMalware apkStatus = EnumApkMalware .valueOf(malwareStatus.getStatus().toUpperCase(Locale.ENGLISH)); Log.d("ApkInfoMalware-malwareStatus", malwareStatus.getStatus()); Log.d("ApkInfoMalware-malwareReason", malwareStatus.getReason()); switch (apkStatus) { case SCANNED: ((TextView) findViewById(R.id.app_badge_text)).setText(getString(R.string.trusted)); ((ImageView) findViewById(R.id.app_badge)).setImageResource(R.drawable.badge_scanned); ((LinearLayout) findViewById(R.id.badge_layout)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View trustedView = LayoutInflater.from(ApkInfo.this) .inflate(R.layout.dialog_anti_malware, null); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ApkInfo.this) .setView(trustedView); final AlertDialog trustedDialog = dialogBuilder.create(); trustedDialog.setIcon(R.drawable.badge_scanned); trustedDialog.setTitle(getString(R.string.app_trusted, viewApk.getName())); trustedDialog.setCancelable(true); TextView tvSignatureValidation = (TextView) trustedView .findViewById(R.id.tv_signature_validation); tvSignatureValidation.setText(getString(R.string.signature_verified)); ImageView check_signature = (ImageView) trustedView .findViewById(R.id.check_signature); check_signature.setImageResource(R.drawable.ic_yes); trustedDialog.setButton(Dialog.BUTTON_NEUTRAL, "Ok", new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { trustedDialog.dismiss(); } }); trustedDialog.show(); } }); break; // case UNKNOWN: // ((TextView) findViewById(R.id.app_badge_text)).setText(getString(R.string.unknown)); // ((ImageView) findViewById(R.id.app_badge)).setImageResource(R.drawable.badge_unknown); // break; case WARN: ((TextView) findViewById(R.id.app_badge_text)).setText(getString(R.string.warning)); ((ImageView) findViewById(R.id.app_badge)).setImageResource(R.drawable.badge_warn); ((LinearLayout) findViewById(R.id.badge_layout)).setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { View warnView = LayoutInflater.from(ApkInfo.this) .inflate(R.layout.dialog_anti_malware, null); AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(ApkInfo.this) .setView(warnView); final AlertDialog warnDialog = dialogBuilder.create(); warnDialog.setIcon(R.drawable.badge_warn); warnDialog.setTitle(getString(R.string.app_warning, viewApk.getName())); warnDialog.setCancelable(true); TextView tvSignatureValidation = (TextView) warnView .findViewById(R.id.tv_signature_validation); tvSignatureValidation.setText(getString(R.string.signature_not_verified)); ImageView check_signature = (ImageView) warnView.findViewById(R.id.check_signature); check_signature.setImageResource(R.drawable.ic_failed); warnDialog.setButton(Dialog.BUTTON_NEUTRAL, "Ok", new Dialog.OnClickListener() { @Override public void onClick(DialogInterface arg0, int arg1) { warnDialog.dismiss(); } }); warnDialog.show(); } }); break; // case CRITICAL: // ((TextView) findViewById(R.id.app_badge_text)).setText(getString(R.string.critical)); // ((ImageView) findViewById(R.id.app_badge)).setImageResource(R.drawable.badge_critical); // break; default: break; } } catch (Exception e) { e.printStackTrace(); } } }); }
From source file:com.mobiletin.inputmethod.indic.LatinIME.java
private void showSubtypeSelectorAndSettings() { final CharSequence title = getString(R.string.english_ime_input_options); // TODO: Should use new string "Select active input modes". final CharSequence languageSelectionTitle = getString(R.string.language_selection_title); final CharSequence[] items = new CharSequence[] { languageSelectionTitle, getString(ApplicationUtils.getActivityTitleResId(this, SettingsActivity.class)) }; final OnClickListener listener = new OnClickListener() { @Override//from www .ja va 2 s. com public void onClick(DialogInterface di, int position) { di.dismiss(); switch (position) { case 0: final Intent intent = IntentUtils.getInputLanguageSelectionIntent( mRichImm.getInputMethodIdOfThisIme(), Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED | Intent.FLAG_ACTIVITY_CLEAR_TOP); intent.putExtra(Intent.EXTRA_TITLE, languageSelectionTitle); startActivity(intent); break; case 1: launchSettings(); break; } } }; final AlertDialog.Builder builder = new AlertDialog.Builder( DialogUtils.getPlatformDialogThemeContext(this)); builder.setItems(items, listener).setTitle(title); final AlertDialog dialog = builder.create(); dialog.setCancelable(true /* cancelable */); dialog.setCanceledOnTouchOutside(true /* cancelable */); showOptionDialog(dialog); }