List of usage examples for android.app AlertDialog.Builder setIconAttribute
public void setIconAttribute(@AttrRes int attrId)
From source file:com.android.gallery3d.app.AbstractGalleryActivity.java
@TargetApi(ApiHelper.VERSION_CODES.HONEYCOMB) private static void setAlertDialogIconAttribute(AlertDialog.Builder builder) { builder.setIconAttribute(android.R.attr.alertDialogIcon); }
From source file:com.silentcircle.contacts.interactions.GroupDeletionDialogFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*from ww w . j a v a 2 s. c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { String label = getArguments().getString(ARG_LABEL); String message = getActivity().getString(R.string.delete_group_dialog_message, label); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) builder.setIconAttribute(android.R.attr.alertDialogIcon); return builder.setMessage(message) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { deleteGroup(); } }).setNegativeButton(android.R.string.cancel, null).create(); }
From source file:com.silentcircle.contacts.calllog.ClearCallLogDialog.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override/*w ww . j ava 2 s.c om*/ public Dialog onCreateDialog(Bundle savedInstanceState) { final ContentResolver resolver = getActivity().getContentResolver(); final OnClickListener okListener = new OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final ProgressDialog progressDialog = ProgressDialog.show(getActivity(), getString(R.string.clearCallLogProgress_title), "", true, false); final AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() { @Override protected Void doInBackground(Void... params) { resolver.delete(ScCalls.CONTENT_URI, null, null); return null; } @Override protected void onPostExecute(Void result) { progressDialog.dismiss(); } }; // TODO: Once we have the API, we should configure this ProgressDialog // to only show up after a certain time (e.g. 150ms) progressDialog.show(); task.execute(); } }; AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) builder.setIconAttribute(android.R.attr.alertDialogIcon); return builder.setTitle(R.string.clearCallLogConfirmation_title) .setMessage(R.string.clearCallLogConfirmation).setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, okListener).setCancelable(true).create(); }
From source file:com.android.settings.profiles.ProfilesSettings.java
private void resetAll() { AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setTitle(R.string.profile_reset_title); alert.setIconAttribute(android.R.attr.alertDialogIcon); alert.setMessage(R.string.profile_reset_message); alert.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int id) { mProfileManager.resetAll();/*from w ww.j av a2s . com*/ mAdapter.refreshProfiles(); mAdapter.refreshAppGroups(); } }); alert.setNegativeButton(R.string.cancel, null); alert.show(); }
From source file:com.silentcircle.contacts.interactions.ContactDeletionInteraction.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) private void showDialog(int messageId, final Uri contactUri) { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) builder.setIconAttribute(android.R.attr.alertDialogIcon); mDialog = builder.setMessage(messageId).setNegativeButton(android.R.string.cancel, null) .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override//from w ww .ja va 2s .c o m public void onClick(DialogInterface dialog, int whichButton) { doDeleteContact(contactUri); } }).create(); mDialog.setOnDismissListener(this); mDialog.show(); }
From source file:com.cerema.cloud2.ui.dialog.ConfirmationDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Object[] confirmationTarget = getArguments().getStringArray(ARG_CONF_ARGUMENTS); int resourceId = getArguments().getInt(ARG_CONF_RESOURCE_ID, -1); int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1); int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1); int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1); if (confirmationTarget == null || resourceId == -1) { Log_OC.wtf(getTag(), "Calling confirmation dialog without resource or arguments"); return null; }//from w ww. jav a2s . co m AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.Theme_ownCloud_Dialog) .setIcon(R.drawable.ic_warning).setMessage(String.format(getString(resourceId), confirmationTarget)) .setTitle(android.R.string.dialog_alert_title); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { builder.setIconAttribute(android.R.attr.alertDialogIcon); } if (posBtn != -1) builder.setPositiveButton(posBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (mListener != null) { mListener.onConfirmation(getTag()); } dialog.dismiss(); } }); if (neuBtn != -1) builder.setNeutralButton(neuBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (mListener != null) { mListener.onNeutral(getTag()); } dialog.dismiss(); } }); if (negBtn != -1) builder.setNegativeButton(negBtn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mListener != null) { mListener.onCancel(getTag()); } dialog.dismiss(); } }); return builder.create(); }
From source file:com.synox.android.ui.dialog.ConfirmationDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Object[] confirmationTarget = getArguments().getStringArray(ARG_CONF_ARGUMENTS); int resourceId = getArguments().getInt(ARG_CONF_RESOURCE_ID, -1); int posBtn = getArguments().getInt(ARG_POSITIVE_BTN_RES, -1); int neuBtn = getArguments().getInt(ARG_NEUTRAL_BTN_RES, -1); int negBtn = getArguments().getInt(ARG_NEGATIVE_BTN_RES, -1); if (confirmationTarget == null || resourceId == -1) { Log_OC.wtf(getTag(), "Calling confirmation dialog without resource or arguments"); return null; }/*from w ww . j a v a2s. c om*/ final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.synox_Dialog) .setIcon(R.drawable.ic_warning).setMessage(String.format(getString(resourceId), confirmationTarget)) .setTitle(android.R.string.dialog_alert_title); if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.HONEYCOMB) { builder.setIconAttribute(android.R.attr.alertDialogIcon); } if (posBtn != -1) builder.setPositiveButton(posBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (mListener != null) { mListener.onConfirmation(getTag()); } dialog.dismiss(); } }); if (neuBtn != -1) builder.setNeutralButton(neuBtn, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { if (mListener != null) { mListener.onNeutral(getTag()); } dialog.dismiss(); } }); if (negBtn != -1) builder.setNegativeButton(negBtn, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (mListener != null) { mListener.onCancel(getTag()); } dialog.dismiss(); } }); return builder.create(); }
From source file:org.totschnig.myexpenses.dialog.ExportDialogFragment.java
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @Override//from ww w. j av a2s .c o m public Dialog onCreateDialog(Bundle savedInstanceState) { Activity ctx = (Activity) getActivity(); Context wrappedCtx = DialogUtils.wrapContext1(ctx); Bundle args = getArguments(); Long accountId = args != null ? args.getLong("accountId") : null; boolean allP = false; String warningText; if (accountId == null) { allP = true; warningText = getString(R.string.warning_reset_account_all); } else if (accountId < 0L) { allP = true; AggregateAccount aa = AggregateAccount.getCachedInstance(accountId); if (aa == null) throw new DataObjectNotFoundException(accountId); warningText = getString(R.string.warning_reset_account_all, " (" + aa.currency.getCurrencyCode() + ")"); } else { warningText = getString(R.string.warning_reset_account); } LayoutInflater li = LayoutInflater.from(wrappedCtx); View view = li.inflate(R.layout.export_dialog, null); dateFormatET = (EditText) view.findViewById(R.id.date_format); String dateFormatDefault = ((SimpleDateFormat) DateFormat.getDateInstance(DateFormat.SHORT)).toPattern(); String dateFormat = MyApplication.getInstance().getSettings().getString(PREFKEY_EXPORT_DATE_FORMAT, ""); if (dateFormat.equals("")) dateFormat = dateFormatDefault; else { try { new SimpleDateFormat(dateFormat, Locale.US); } catch (IllegalArgumentException e) { dateFormat = dateFormatDefault; } } dateFormatET.setText(dateFormat); dateFormatET.addTextChangedListener(new TextWatcher() { public void afterTextChanged(Editable s) { try { new SimpleDateFormat(s.toString(), Locale.US); mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(true); } catch (IllegalArgumentException e) { dateFormatET.setError(getString(R.string.date_format_illegal)); mDialog.getButton(AlertDialog.BUTTON_POSITIVE).setEnabled(false); } } public void beforeTextChanged(CharSequence s, int start, int count, int after) { } public void onTextChanged(CharSequence s, int start, int before, int count) { } }); notYetExportedCB = (CheckBox) view.findViewById(R.id.export_not_yet_exported); deleteCB = (CheckBox) view.findViewById(R.id.export_delete); warningTV = (TextView) view.findViewById(R.id.warning_reset); formatRB = (RadioButton) view.findViewById(R.id.csv); String format = MyApplication.getInstance().getSettings().getString(MyApplication.PREFKEY_EXPORT_FORMAT, "QIF"); boolean deleteP = true; if (format.equals("CSV")) (formatRB).setChecked(true); deleteCB.setOnClickListener(this); if (Account.getHasExported(accountId)) { deleteP = false; deleteCB.setChecked(false); notYetExportedCB.setChecked(true); notYetExportedCB.setVisibility(View.VISIBLE); } warningTV.setText(warningText); if (deleteP) warningTV.setVisibility(View.VISIBLE); else warningTV.setVisibility(View.GONE); AlertDialog.Builder builder = new AlertDialog.Builder(wrappedCtx) .setTitle(allP ? R.string.menu_reset_all : R.string.menu_reset).setView(view) .setPositiveButton(android.R.string.ok, this).setNegativeButton(android.R.string.cancel, null); if (Build.VERSION.SDK_INT < 11) builder.setIcon(android.R.drawable.ic_dialog_alert); else builder.setIconAttribute(android.R.attr.alertDialogIcon); mDialog = builder.create(); return mDialog; }
From source file:org.smssecure.smssecure.ConversationListFragment.java
private void handleDeleteAllSelected() { int conversationsCount = getListAdapter().getBatchSelections().size(); AlertDialog.Builder alert = new AlertDialog.Builder(getActivity()); alert.setIconAttribute(R.attr.dialog_alert_icon); alert.setTitle(getActivity().getResources().getQuantityString( R.plurals.ConversationListFragment_delete_selected_conversations, conversationsCount, conversationsCount));//from w w w .j a v a 2s.com alert.setMessage(getActivity().getResources().getQuantityString( R.plurals.ConversationListFragment_this_will_permanently_delete_all_n_selected_conversations, conversationsCount, conversationsCount)); alert.setCancelable(true); alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { final Set<Long> selectedConversations = (getListAdapter()).getBatchSelections(); if (!selectedConversations.isEmpty()) { new AsyncTask<Void, Void, Void>() { private ProgressDialog dialog; @Override protected void onPreExecute() { dialog = ProgressDialog.show(getActivity(), getActivity().getString(R.string.ConversationListFragment_deleting), getActivity().getString( R.string.ConversationListFragment_deleting_selected_conversations), true, false); } @Override protected Void doInBackground(Void... params) { DatabaseFactory.getThreadDatabase(getActivity()) .deleteConversations(selectedConversations); MessageNotifier.updateNotification(getActivity(), masterSecret); return null; } @Override protected void onPostExecute(Void result) { dialog.dismiss(); if (actionMode != null) { actionMode.finish(); actionMode = null; } } }.execute(); } } }); alert.setNegativeButton(android.R.string.cancel, null); alert.show(); }
From source file:org.smssecure.smssecure.ConversationFragment.java
private void handleDeleteMessages(final Set<MessageRecord> messageRecords) { int messagesCount = messageRecords.size(); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setIconAttribute(R.attr.dialog_alert_icon); builder.setTitle(getActivity().getResources().getQuantityString( R.plurals.ConversationFragment_delete_selected_messages, messagesCount, messagesCount)); builder.setMessage(getActivity().getResources().getQuantityString( R.plurals.ConversationFragment_this_will_permanently_delete_all_n_selected_messages, messagesCount, messagesCount));//from w w w . java2 s .c o m builder.setCancelable(true); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { new ProgressDialogAsyncTask<MessageRecord, Void, Void>(getActivity(), R.string.ConversationFragment_deleting, R.string.ConversationFragment_deleting_messages) { @Override protected Void doInBackground(MessageRecord... messageRecords) { for (MessageRecord messageRecord : messageRecords) { boolean threadDeleted; if (messageRecord.isMms()) { threadDeleted = DatabaseFactory.getMmsDatabase(getActivity()) .delete(messageRecord.getId()); } else { threadDeleted = DatabaseFactory.getSmsDatabase(getActivity()) .deleteMessage(messageRecord.getId()); } if (threadDeleted) { threadId = -1; listener.setThreadId(threadId); } } return null; } }.execute(messageRecords.toArray(new MessageRecord[messageRecords.size()])); } }); builder.setNegativeButton(R.string.no, null); builder.show(); }