List of usage examples for android.app AlertDialog.Builder setTitle
@Override public void setTitle(CharSequence title)
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a continue / cancel dialog./*from ww w . j a va 2s .c o m*/ * @param context The current context. * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onContinue The dialog listener for the continue button. * @param onCancel The dialog listener for the cancel button. */ public static void showContinueCancelDialog(Context context, int icon, String title, String message, DialogInterface.OnClickListener onContinue, DialogInterface.OnClickListener onCancel) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(title); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Continue), onContinue); builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), onCancel); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard Ok dialog.//from w w w.j a v a2s . co m * @param context The current context. * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. */ public static void showOkDialog(Context context, int icon, String title, String message) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(false); builder.setIcon(icon); builder.setTitle(title); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Ok), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard yes / no dialog.//from w w w.jav a2 s . c o m * @param context The current context. * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onYes The dialog listener for the yes button. */ public static void showYesNoDialog(Context context, int icon, int title, int message, DialogInterface.OnClickListener onYes) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(context.getResources().getString(title)); builder.setMessage(context.getResources().getString(message)); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Yes), onYes); builder.setNegativeButton(context.getResources().getString(R.string.Commons_No), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:org.geek.utils.ApplicationUtils.java
/** * Display a standard Ok / Cancel dialog. * @param context The current context./* w ww . ja va 2 s .c om*/ * @param icon The dialog icon. * @param title The dialog title. * @param message The dialog message. * @param onYes The dialog listener for the yes button. */ public static void showOkCancelDialog(Context context, int icon, String title, String message, DialogInterface.OnClickListener onYes) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setCancelable(true); builder.setIcon(icon); builder.setTitle(title); builder.setMessage(message); builder.setInverseBackgroundForced(true); builder.setPositiveButton(context.getResources().getString(R.string.Commons_Ok), onYes); builder.setNegativeButton(context.getResources().getString(R.string.Commons_Cancel), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { dialog.dismiss(); } }); AlertDialog alert = builder.create(); alert.show(); }
From source file:net.naonedbus.utils.InfoDialogUtils.java
/** * Afficher une dialog avec un contenu au format HTML * /* w ww .j av a2 s. c o m*/ * @param context * @param html */ public static void showHtml(final Context context, final String html) { AlertDialog.Builder moreDetailsDialog = null; final WebView webView = new WebView(context); final ScrollView scrollView = new ScrollView(context); webView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY); webView.setBackgroundColor(Color.WHITE); webView.loadDataWithBaseURL("fake://not/needed", html, "text/html", "UTF-8", null); // Encoding // fix // for // Android // 3.x // / // 4.x scrollView.addView(webView); moreDetailsDialog = new AlertDialog.Builder(context); moreDetailsDialog.setIcon(android.R.drawable.ic_dialog_info); moreDetailsDialog.setTitle("Informations"); moreDetailsDialog.setView(scrollView); moreDetailsDialog.setPositiveButton(android.R.string.ok, null); moreDetailsDialog.show(); }
From source file:com.onesignal.GenerateNotification.java
private static int showNotificationAsAlert(final JSONObject gcmJson, final Activity activity) { final int aNotificationId = new Random().nextInt(); activity.runOnUiThread(new Runnable() { @Override/* w w w.j a v a 2s . c o m*/ public void run() { AlertDialog.Builder builder = new AlertDialog.Builder(activity); builder.setTitle(getTitle(gcmJson)); try { builder.setMessage(gcmJson.getString("alert")); } catch (Throwable t) { } List<String> buttonsLabels = new ArrayList<String>(); List<String> buttonIds = new ArrayList<String>(); addAlertButtons(gcmJson, buttonsLabels, buttonIds); final List<String> finalButtonIds = buttonIds; Intent buttonIntent = getNewBaseIntent(aNotificationId); buttonIntent.putExtra("action_button", true); buttonIntent.putExtra("from_alert", true); buttonIntent.putExtra("onesignal_data", gcmJson.toString()); try { if (gcmJson.has("grp")) buttonIntent.putExtra("grp", gcmJson.getString("grp")); } catch (JSONException e) { } final Intent finalButtonIntent = buttonIntent; DialogInterface.OnClickListener buttonListener = new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int which) { int index = which + 3; if (finalButtonIds.size() > 1) { try { JSONObject customJson = new JSONObject(gcmJson.getString("custom")); JSONObject additionalDataJSON = customJson.getJSONObject("a"); additionalDataJSON.put("actionSelected", finalButtonIds.get(index)); JSONObject newJsonData = new JSONObject(gcmJson.toString()); newJsonData.put("custom", customJson.toString()); finalButtonIntent.putExtra("onesignal_data", newJsonData.toString()); NotificationOpenedProcessor.processIntent(activity, finalButtonIntent); } catch (Throwable t) { } } else // No action buttons, close button simply pressed. NotificationOpenedProcessor.processIntent(activity, finalButtonIntent); } }; // Back button pressed builder.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { NotificationOpenedProcessor.processIntent(activity, finalButtonIntent); } }); for (int i = 0; i < buttonsLabels.size(); i++) { if (i == 0) builder.setNeutralButton(buttonsLabels.get(i), buttonListener); else if (i == 1) builder.setNegativeButton(buttonsLabels.get(i), buttonListener); else if (i == 2) builder.setPositiveButton(buttonsLabels.get(i), buttonListener); } AlertDialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); } }); return aNotificationId; }
From source file:com.android.mms.ui.ConversationList.java
/** * Build and show the proper delete thread dialog. The UI is slightly different * depending on whether there are locked messages in the thread(s) and whether we're * deleting a single thread or all threads. * @param listener gets called when the delete button is pressed * @param deleteAll whether to show a single thread or all threads UI * @param hasLockedMessages whether the thread(s) contain locked messages * @param context used to load the various UI elements *//* w ww .j a v a2 s.c om*/ public static void confirmDeleteThreadDialog(final DeleteThreadListener listener, boolean deleteAll, boolean hasLockedMessages, Context context) { View contents = View.inflate(context, R.layout.delete_thread_dialog_view, null); TextView msg = (TextView) contents.findViewById(R.id.message); msg.setText(deleteAll ? R.string.confirm_delete_all_conversations : R.string.confirm_delete_conversation); final CheckBox checkbox = (CheckBox) contents.findViewById(R.id.delete_locked); if (!hasLockedMessages) { checkbox.setVisibility(View.GONE); } else { listener.setDeleteLockedMessage(checkbox.isChecked()); checkbox.setOnClickListener(new View.OnClickListener() { public void onClick(View v) { listener.setDeleteLockedMessage(checkbox.isChecked()); } }); } AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(R.string.confirm_dialog_title).setIcon(android.R.drawable.ic_dialog_alert) .setCancelable(true).setPositiveButton(R.string.delete, listener) .setNegativeButton(R.string.no, null).setView(contents).show(); }
From source file:com.pdftron.pdf.utils.Utils.java
public static AlertDialog.Builder getAlertDialogBuilder(Context context, String message, String title) { AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setMessage(message).setCancelable(true); if (!isNullOrEmpty(title)) { builder.setTitle(title); }//from www . j ava 2s . co m return builder; }
From source file:im.vector.util.BugReporter.java
/** * Send a bug report either with email or with Vector. *///from w w w.j av a2 s .c om public static void sendBugReport() { final Activity currentActivity = VectorApp.getCurrentActivity(); // no current activity so cannot display an alert if (null == currentActivity) { sendBugReport(VectorApp.getInstance().getApplicationContext(), true, true, "", null); return; } final Context appContext = currentActivity.getApplicationContext(); LayoutInflater inflater = currentActivity.getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.dialog_bug_report, null); final AlertDialog.Builder dialog = new AlertDialog.Builder(currentActivity); dialog.setTitle(R.string.send_bug_report); dialog.setView(dialogLayout); final EditText bugReportText = (EditText) dialogLayout.findViewById(R.id.bug_report_edit_text); final CheckBox includeLogsButton = (CheckBox) dialogLayout .findViewById(R.id.bug_report_button_include_logs); final CheckBox includeCrashLogsButton = (CheckBox) dialogLayout .findViewById(R.id.bug_report_button_include_crash_logs); final ProgressBar progressBar = (ProgressBar) dialogLayout.findViewById(R.id.bug_report_progress_view); final TextView progressTextView = (TextView) dialogLayout.findViewById(R.id.bug_report_progress_text_view); dialog.setPositiveButton(R.string.send, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // will be overridden to avoid dismissing the dialog while displaying the progress } }); dialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // will be overridden to avoid dismissing the dialog while displaying the progress } }); // final AlertDialog bugReportDialog = dialog.show(); final Button cancelButton = bugReportDialog.getButton(AlertDialog.BUTTON_NEGATIVE); final Button sendButton = bugReportDialog.getButton(AlertDialog.BUTTON_POSITIVE); if (null != cancelButton) { cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // check if there is no upload in progress if (includeLogsButton.isEnabled()) { bugReportDialog.dismiss(); } else { mIsCancelled = true; cancelButton.setEnabled(false); } } }); } if (null != sendButton) { sendButton.setEnabled(false); sendButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { // disable the active area while uploading the bug report bugReportText.setEnabled(false); sendButton.setEnabled(false); includeLogsButton.setEnabled(false); includeCrashLogsButton.setEnabled(false); progressTextView.setVisibility(View.VISIBLE); progressTextView.setText(appContext.getString(R.string.send_bug_report_progress, 0 + "")); progressBar.setVisibility(View.VISIBLE); progressBar.setProgress(0); sendBugReport(VectorApp.getInstance(), includeLogsButton.isChecked(), includeCrashLogsButton.isChecked(), bugReportText.getText().toString(), new IMXBugReportListener() { @Override public void onUploadFailed(String reason) { try { if (null != VectorApp.getInstance() && !TextUtils.isEmpty(reason)) { Toast.makeText(VectorApp.getInstance(), VectorApp.getInstance() .getString(R.string.send_bug_report_failed, reason), Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e(LOG_TAG, "## onUploadFailed() : failed to display the toast " + e.getMessage()); } try { // restore the dialog if the upload failed bugReportText.setEnabled(true); sendButton.setEnabled(true); includeLogsButton.setEnabled(true); includeCrashLogsButton.setEnabled(true); cancelButton.setEnabled(true); progressTextView.setVisibility(View.GONE); progressBar.setVisibility(View.GONE); } catch (Exception e) { Log.e(LOG_TAG, "## onUploadFailed() : failed to restore the dialog button " + e.getMessage()); try { bugReportDialog.dismiss(); } catch (Exception e2) { Log.e(LOG_TAG, "## onUploadFailed() : failed to dismiss the dialog " + e2.getMessage()); } } mIsCancelled = false; } @Override public void onUploadCancelled() { onUploadFailed(null); } @Override public void onProgress(int progress) { if (progress > 100) { Log.e(LOG_TAG, "## onProgress() : progress > 100"); progress = 100; } else if (progress < 0) { Log.e(LOG_TAG, "## onProgress() : progress < 0"); progress = 0; } progressBar.setProgress(progress); progressTextView.setText( appContext.getString(R.string.send_bug_report_progress, progress + "")); } @Override public void onUploadSucceed() { try { if (null != VectorApp.getInstance()) { Toast.makeText(VectorApp.getInstance(), VectorApp.getInstance().getString( R.string.send_bug_report_sent), Toast.LENGTH_LONG).show(); } } catch (Exception e) { Log.e(LOG_TAG, "## onUploadSucceed() : failed to dismiss the toast " + e.getMessage()); } try { bugReportDialog.dismiss(); } catch (Exception e) { Log.e(LOG_TAG, "## onUploadSucceed() : failed to dismiss the dialog " + e.getMessage()); } } }); } }); } bugReportText.addTextChangedListener(new TextWatcher() { @Override public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { if (null != sendButton) { sendButton.setEnabled(bugReportText.getText().toString().length() > 10); } } @Override public void afterTextChanged(Editable s) { } }); }
From source file:org.csware.ee.utils.Tools.java
public static void show(final Activity activity, final int id) { final Context context = activity; AlertDialog.Builder builder = new AlertDialog.Builder(context); builder.setTitle(""); builder.setMessage(""); builder.setPositiveButton("", new DialogInterface.OnClickListener() { @Override//from ww w .java 2 s . c o m public void onClick(DialogInterface dialog, int which) { int version = android.os.Build.VERSION.SDK_INT; Intent intent; if (version < 11) { intent = new Intent(); intent.setClassName("com.android.settings", "com.android.settings.WirelessSettings"); } else { //3.0? //intent = new Intent( android.provider.Settings.ACTION_WIRELESS_SETTINGS); intent = new Intent(android.provider.Settings.ACTION_SETTINGS); } if (id == 1) { activity.finish(); } context.startActivity(intent); } }); builder.setNegativeButton("?", new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (id == 1) { activity.finish(); } } }); builder.create().show(); }