List of usage examples for android.app AlertDialog.Builder setIcon
public void setIcon(Drawable icon)
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
private void showUpdateMessage() { if (mApplicationState == ApplicationState.OLD) { AlertDialog.Builder builder = new AlertDialog.Builder(MessageViewerActivity.this); builder.setTitle(R.string.new_version_title); builder.setMessage(getString(R.string.new_version_message)); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setNegativeButton(R.string.btn_exit, new DialogInterface.OnClickListener() { @Override/*from w w w.j av a 2 s . com*/ public void onClick(DialogInterface dialog, int whichButton) { Intent finishIntent = new Intent(); finishIntent.putExtra(QRCloudUtils.DATABASE_KIND_VERSIONS, true); setResult(Activity.RESULT_OK, finishIntent); finish(); } }); builder.setPositiveButton(R.string.btn_update, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Intent finishIntent = new Intent(); finishIntent.putExtra(QRCloudUtils.DATABASE_KIND_VERSIONS, true); setResult(Activity.RESULT_OK, finishIntent); finish(); // must post delayed or the camera crashes new Handler().postDelayed(new Runnable() { @Override public void run() { try { Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData( Uri.parse("market://details?id=" + getString(R.string.market_package))); startActivity(intent); } catch (ActivityNotFoundException e) { Toast.makeText(getApplicationContext(), R.string.new_version_failure, Toast.LENGTH_SHORT).show(); } } }, 250); } }); builder.show(); } }
From source file:qr.cloud.qrpedia.MessageViewerActivity.java
private void showBannedMessage() { if (mUserState == UserState.BANNED) { AlertDialog.Builder builder = new AlertDialog.Builder(MessageViewerActivity.this); builder.setTitle(R.string.banned_user_title); builder.setMessage(getString(R.string.banned_user_message)); builder.setIcon(android.R.drawable.ic_dialog_alert); builder.setNegativeButton(R.string.btn_exit, new DialogInterface.OnClickListener() { @Override//from w ww . jav a 2 s . c o m public void onClick(DialogInterface dialog, int whichButton) { Intent finishIntent = new Intent(); finishIntent.putExtra(QRCloudUtils.DATABASE_KIND_BANS, true); setResult(Activity.RESULT_OK, finishIntent); finish(); } }); builder.setPositiveButton(R.string.btn_contact, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int whichButton) { Intent finishIntent = new Intent(); finishIntent.putExtra(QRCloudUtils.DATABASE_KIND_BANS, true); setResult(Activity.RESULT_OK, finishIntent); finish(); // must post delayed or the camera crashes new Handler().postDelayed(new Runnable() { @Override public void run() { try { Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND); emailIntent.setType("plain/text"); emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[] { getString(R.string.contact_email) }); emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, getString(R.string.banned_user_email_title)); startActivity(Intent.createChooser(emailIntent, getString(R.string.btn_contact))); } catch (ActivityNotFoundException e) { Toast.makeText(getApplicationContext(), R.string.contact_email_failure, Toast.LENGTH_SHORT).show(); } } }, 250); } }); builder.show(); } }
From source file:de.ub0r.android.otpdroid.OTPdroid.java
/** * {@inheritDoc}/*w w w .j ava 2 s . c om*/ */ @Override protected final Dialog onCreateDialog(final int id) { AlertDialog.Builder builder; switch (id) { case DIALOG_ABOUT: builder = new AlertDialog.Builder(this); builder.setTitle(this.getString(R.string.about_) + " v" + this.getString(R.string.app_version)); builder.setPositiveButton(android.R.string.ok, null); builder.setView(View.inflate(this, R.layout.about, null)); return builder.create(); case DIALOG_UPDATE: builder = new AlertDialog.Builder(this); builder.setTitle(R.string.changelog_); final String[] changes = this.getResources().getStringArray(R.array.updates); final StringBuilder buf = new StringBuilder(changes[0]); for (int i = 1; i < changes.length; i++) { buf.append("\n\n"); buf.append(changes[i]); } builder.setIcon(android.R.drawable.ic_menu_info_details); builder.setMessage(buf.toString()); builder.setCancelable(true); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { public void onClick(final DialogInterface dialog, final int id) { dialog.cancel(); } }); return builder.create(); default: return null; } }
From source file:cm.aptoide.pt.ManageRepos.java
@Override public boolean onMenuItemSelected(int featureId, MenuItem item) { EnumOptionsMenu option = EnumOptionsMenu.reverseOrdinal(item.getItemId()); CharSequence[] reposArray = new CharSequence[repos.getList().size() - reposInserting.size()]; int j = 0;/* www.java2s. c o m*/ for (int i = 0; i < repos.getList().size(); i++) { if (!reposInserting.containsKey(repos.getList().get(i).get(Constants.KEY_REPO_HASHID))) { reposArray[j] = (String) repos.getList().get(i).get(Constants.KEY_REPO_URI); j++; } } switch (option) { case ADD_REPO: validateRepo(null, false); break; case REMOVE_REPO: if (reposArray.length == 0) { return true; } final Vector<Integer> remList = new Vector<Integer>(); AlertDialog.Builder builder = new AlertDialog.Builder(theme); builder.setTitle(getString(R.string.remove_repo_choose)); builder.setIcon(R.drawable.ic_menu_close_clear_cancel); builder.setMultiChoiceItems(reposArray, null, new DialogInterface.OnMultiChoiceClickListener() { public void onClick(DialogInterface dialog, int whichButton, boolean isChecked) { if (isChecked) { remList.addElement( (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID))); } else { remList.removeElement( (Integer) (repos.getList().get(whichButton).get(Constants.KEY_REPO_HASHID))); } } }); builder.setPositiveButton(getString(R.string.remove), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { for (Integer repoHashid : remList) { removeDisplayRepo(repoHashid); } alert.dismiss(); refreshReposList(); } }); builder.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert.dismiss(); return; } }); alert = builder.create(); alert.show(); break; case EDIT_REPO: if (reposArray.length == 0) { return true; } AlertDialog.Builder builder2 = new AlertDialog.Builder(theme); builder2.setTitle(getString(R.string.edit_repo_choose)); builder2.setIcon(R.drawable.ic_menu_edit); builder2.setSingleChoiceItems(reposArray, -1, new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { updt_repo = (String) (repos.getList().get(whichButton).get(Constants.KEY_REPO_URI)); } }); builder2.setPositiveButton(getString(R.string.edit), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert2.dismiss(); validateRepo(updt_repo, true); return; } }); builder2.setNegativeButton(getString(R.string.cancel), new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int whichButton) { alert2.dismiss(); return; } }); alert2 = builder2.create(); alert2.show(); break; } return super.onMenuItemSelected(featureId, item); }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
private void handleAddAttachment() { AlertDialog.Builder builder = new AlertDialog.Builder( new ContextThemeWrapper(getActivity(), R.style.GSecure_Light_Dialog)); builder.setIcon(R.drawable.ic_dialog_attach); builder.setTitle(R.string.profile_select_picture); builder.setAdapter(attachmentAdapter, new AttachmentTypeListener()); builder.show();// w w w. j a v a 2 s .c om }
From source file:github.popeen.dsub.activity.SubsonicFragmentActivity.java
private void promptRestoreFromRemoteQueue(final PlayerQueue remoteState) { AlertDialog.Builder builder = new AlertDialog.Builder(this); String message = getResources().getString(R.string.common_confirm_message, getResources().getString(R.string.download_restore_play_queue).toLowerCase(), Util.formatDate(remoteState.changed)); builder.setIcon(android.R.drawable.ic_dialog_alert).setTitle(R.string.common_confirm).setMessage(message) .setPositiveButton(R.string.common_ok, new DialogInterface.OnClickListener() { @Override//from w w w . j a v a2 s . c o m public void onClick(DialogInterface dialogInterface, int i) { new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { @Override protected Void doInBackground() throws Throwable { DownloadService downloadService = getDownloadService(); downloadService.clear(); downloadService.download(remoteState.songs, false, false, false, false, remoteState.currentPlayingIndex, remoteState.currentPlayingPosition); return null; } }.execute(); } }).setNeutralButton(R.string.common_cancel, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { @Override protected Void doInBackground() throws Throwable { DownloadService downloadService = getDownloadService(); downloadService.serializeQueue(false); return null; } }.execute(); } }).setNegativeButton(R.string.common_never, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialogInterface, int i) { new SilentBackgroundTask<Void>(SubsonicFragmentActivity.this) { @Override protected Void doInBackground() throws Throwable { DownloadService downloadService = getDownloadService(); downloadService.serializeQueue(false); SharedPreferences.Editor editor = Util.getPreferences(SubsonicFragmentActivity.this) .edit(); editor.putBoolean(Constants.PREFERENCES_KEY_RESUME_PLAY_QUEUE_NEVER, true); editor.commit(); return null; } }.execute(); } }); builder.create().show(); }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
private void handleDeleteThread() { AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(R.string.ConversationActivity_delete_thread_confirmation); builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_alert_icon)); builder.setCancelable(true);/*from w ww .j a v a2 s.c o m*/ builder.setMessage( R.string.ConversationActivity_are_you_sure_that_you_want_to_permanently_delete_this_conversation_question); builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { if (threadId > 0) { DatabaseFactory.getThreadDatabase(getActivity()).deleteConversation(threadId); getActivity().finish(); } } }); builder.setNegativeButton(R.string.no, null); builder.show(); }
From source file:org.thoughtcrime.securesms.ProfileFragment.java
private void handleLeavePushGroup() { if (recipients == null) { Toast.makeText(getActivity(), getString(R.string.ConversationActivity_invalid_recipient), Toast.LENGTH_LONG).show(); return;//from w ww . jav a 2 s . co m } AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setTitle(getString(R.string.ConversationActivity_leave_group)); builder.setIcon(Dialogs.resolveIcon(getActivity(), R.attr.dialog_info_icon)); builder.setCancelable(true); builder.setMessage(getString(R.string.ConversationActivity_are_you_sure_you_want_to_leave_this_group)); AlertDialog.Builder builder1 = builder.setPositiveButton(R.string.yes, new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { Context self = getActivity(); try { byte[] groupId = GroupUtil.getDecodedId(recipients.getPrimaryRecipient().getNumber()); DatabaseFactory.getGroupDatabase(self).setActive(groupId, false); TextSecureProtos.GroupContext context = TextSecureProtos.GroupContext.newBuilder() .setId(ByteString.copyFrom(groupId)) .setType(TextSecureProtos.GroupContext.Type.QUIT).build(); OutgoingGroupMediaMessage outgoingMessage = new OutgoingGroupMediaMessage(self, recipients, context, null); MessageSender.send(self, masterSecret, outgoingMessage, threadId, false); DatabaseFactory.getGroupDatabase(self).remove(groupId, TextSecurePreferences.getLocalNumber(self)); } catch (IOException e) { Toast.makeText(self, R.string.ConversationActivity_error_leaving_group, Toast.LENGTH_LONG).show(); } getActivity().finish(); } }); builder.setNegativeButton(R.string.no, null); builder.show(); }
From source file:com.speed.traquer.app.TraqComplaintTaxi.java
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if ((keyCode == KeyEvent.KEYCODE_BACK)) { final AlertDialog.Builder alertBox = new AlertDialog.Builder(TraqComplaintTaxi.this); alertBox.setIcon(R.drawable.info_icon); alertBox.setCancelable(false);//www . j a v a2 s . co m alertBox.setTitle("Do you want to cancel complaint?"); alertBox.setPositiveButton("Yes", new DialogInterface.OnClickListener() { public void onClick(DialogInterface arg0, int arg1) { // finish used for destroyed activity easyTracker.send(MapBuilder .createEvent("Complaint", "Cancel Complaint (Yes)", "Complaint event", null).build()); NavUtils.navigateUpFromSameTask(TraqComplaintTaxi.this); } }); alertBox.setNegativeButton("No", new DialogInterface.OnClickListener() { public void onClick(DialogInterface dialog, int arg1) { easyTracker.send(MapBuilder .createEvent("Complaint", "Cancel Complaint (No)", "Complaint event", null).build()); dialog.cancel(); } }); alertBox.show(); } return super.onKeyDown(keyCode, event); }