Example usage for android.app AlertDialog.Builder setIcon

List of usage examples for android.app AlertDialog.Builder setIcon

Introduction

In this page you can find the example usage for android.app AlertDialog.Builder setIcon.

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:com.frostwire.android.gui.util.DangerousPermissionsChecker.java

private boolean onExternalStoragePermissionsResult(String[] permissions, int[] grantResults) {
    if (!Ref.alive(activityRef)) {
        return false;
    }/*  ww w. j av  a  2  s.  co m*/
    final Activity activity = activityRef.get();
    for (int i = 0; i < permissions.length; i++) {
        if (grantResults[i] == PackageManager.PERMISSION_DENIED) {
            if (permissions[i].equals(Manifest.permission.WRITE_EXTERNAL_STORAGE)
                    || permissions[i].equals(Manifest.permission.READ_EXTERNAL_STORAGE)) {
                AlertDialog.Builder builder = new AlertDialog.Builder(activity);
                builder.setIcon(R.drawable.sd_card_notification);
                builder.setTitle(R.string.why_we_need_storage_permissions);
                builder.setMessage(R.string.why_we_need_storage_permissions_summary);
                builder.setNegativeButton(R.string.exit, (dialog, which) -> shutdownFrostWire());
                builder.setPositiveButton(R.string.request_again, (dialog, which) -> requestPermissions());
                AlertDialog alertDialog = builder.create();
                alertDialog.show();
                return false;
            }
        }
    }
    return true;
}

From source file:com.mycelium.wallet.activity.main.AdFragment.java

private void updateAdContent() {
    double dice = Math.random();
    if (dice < 0.3334) {
        adIcon = R.drawable.purse_small;
        adBuy = getText(R.string.ad_buy_purse);
        adUrl = getText(R.string.ad_purse_url);
        adInfo = getText(R.string.ad_purse_info);
    } else if (dice < 0.6667) {
        adIcon = R.drawable.trezor2;/*from ww  w .  j  av a2  s  .c om*/
        adBuy = getText(R.string.ad_buy_trezor);
        adUrl = getText(R.string.ad_trezor_url);
        adInfo = getText(R.string.ad_trezor_info);
    } else {
        adIcon = R.drawable.hashing24;
        adBuy = getText(R.string.ad_buy_hashing24);
        adUrl = getText(R.string.ad_hashing24_url);
        adInfo = getText(R.string.ad_hashing24_info);
    }
    btAdvice.setCompoundDrawablesWithIntrinsicBounds(adIcon, 0, 0, 0);
    btAdvice.setText(adBuy);
    btAdvice.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View view) {
            if (adInfo != null && adInfo.length() > 0) {
                AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
                builder.setMessage(adInfo);
                builder.setTitle(R.string.warning_partner);
                builder.setIcon(adIcon);
                builder.setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int id) {
                        if (adUrl != null) {
                            Intent intent = new Intent(Intent.ACTION_VIEW);
                            intent.setData(Uri.parse(adUrl.toString()));
                            startActivity(intent);
                        }
                    }
                });
                builder.setNegativeButton(R.string.cancel, null);
                AlertDialog dialog = builder.create();
                dialog.show();
            } else {
                if (adUrl != null) {
                    Intent i = new Intent(Intent.ACTION_VIEW);
                    i.setData(Uri.parse(adUrl.toString()));
                    startActivity(i);
                }
            }
        }
    });
}

From source file:com.openerp.base.account.AccountFragment.java

private void showForceConnectDialog(String message) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIcon(R.drawable.ic_action_alerts_and_states_warning);
    builder.setTitle(R.string.title_ssl_warning);
    builder.setMessage(R.string.untrusted_ssl_warning);
    builder.setNegativeButton(R.string.label_ok, null);
    builder.show();/* ww w .  j a  va 2 s  .co m*/
}

From source file:cn.count.easydrive366.signup.Step3Activity.java

private void chooseDriverType() {
    final JSONArray list = AppSettings.driver_type_list;
    if (list == null) {
        return;//from   w ww.ja  va2s .co  m
    }
    String types = edtCar_type.getText().toString();

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    MultiChoiceID.clear();
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(this.getResources().getString(R.string.app_name));

    final String[] items = new String[list.length()];
    boolean[] checkedItems = new boolean[list.length()];
    try {
        for (int i = 0; i < list.length(); i++) {
            JSONObject item = list.getJSONObject(i);
            String code = item.getString("code");
            String name = item.getString("name");
            String years = item.getString("years");
            items[i] = String.format("%s--%s(%s)", code, name, years);
            if (types.contains(code)) {
                checkedItems[i] = true;
                MultiChoiceID.add(i);
            } else {
                checkedItems[i] = false;
            }
        }
    } catch (Exception e) {
        log(e);
    }

    builder.setMultiChoiceItems(items, checkedItems, new DialogInterface.OnMultiChoiceClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which, boolean isChecked) {
            if (isChecked) {
                if (!MultiChoiceID.contains(which))
                    MultiChoiceID.add(which);
            } else {
                if (MultiChoiceID.contains(which)) {
                    int i_index = MultiChoiceID.indexOf(which);
                    MultiChoiceID.remove(i_index);
                }
            }

        }
    });
    builder.setPositiveButton(this.getResources().getString(R.string.ok),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {

                    changeDriverType();
                }
            });
    builder.setNegativeButton(this.getResources().getString(R.string.cancel),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {

                }
            });
    builder.show();
}

From source file:gxu.software_engineering.market.android.ui.RegisterBoxFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), android.R.style.Theme_Holo_Dialog);
    final View v = getActivity().getLayoutInflater().inflate(R.layout.register, null);
    builder.setIcon(R.drawable.social_add_person).setTitle(R.string.register);
    return builder.setView(v).setNegativeButton(R.string.no, null)
            .setPositiveButton(R.string.ok, new OnClickListener() {
                @Override// w w w  . j a va  2s.  c om
                public void onClick(DialogInterface dialog, int which) {
                    String[] data = data(v);
                    ContentValues user = null;
                    try {
                        user = new Post2Server().execute(data).get();
                    } catch (Exception e) {
                        Log.wtf("register error!", e);
                        Toast.makeText(getActivity(), R.string.register_fail, Toast.LENGTH_SHORT).show();
                    }
                    Toast.makeText(getActivity(), R.string.register_ok, Toast.LENGTH_SHORT).show();
                    if (user != null) {
                        getActivity().getContentResolver().insert(Uri.parse(C.BASE_URI + C.USERS), user);
                    } else {
                        Toast.makeText(getActivity(), R.string.register_fail, Toast.LENGTH_SHORT).show();
                    }
                }
            }).create();
}

From source file:it.simoneloru.ctmdroid.activities.TimetableActivity.java

@Override
protected Dialog onCreateDialog(int id) {
    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
    alertBuilder.setMessage(R.string.unknowHost);
    alertBuilder.setTitle(android.R.string.dialog_alert_title);
    alertBuilder.setIcon(android.R.drawable.ic_dialog_alert);
    alertBuilder.setPositiveButton(android.R.string.ok, null);
    AlertDialog eulaMsg = alertBuilder.create();
    return eulaMsg;
}

From source file:com.jaspersoft.android.jaspermobile.dialog.SimpleDialogFragment.java

@NonNull
@Override//from   w w  w .  j  a  va2  s.c o m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity()).setTitle(title)
            .setMessage(message);

    if (iconRes != 0) {
        dialogBuilder.setIcon(iconRes);
    }

    if (positiveButtonText != null) {
        dialogBuilder.setPositiveButton(positiveButtonText, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (mDialogListener != null) {
                    onPositiveClick();
                }
            }
        });
    }
    if (negativeButtonText != null) {
        dialogBuilder.setNegativeButton(negativeButtonText, new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
                if (mDialogListener != null) {
                    onNegativeClick();
                }
            }
        });
    }

    Dialog dialog = dialogBuilder.create();
    dialog.setCanceledOnTouchOutside(canceledOnTouchOutside);
    return dialog;
}

From source file:com.stoutner.privacybrowser.CreateHomeScreenShortcut.java

@Override
@NonNull/*from w ww.  ja  va2  s . c  om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // Create a drawable version of the favorite icon.
    Drawable favoriteIconDrawable = new BitmapDrawable(getResources(), MainWebViewActivity.favoriteIcon);

    // Use AlertDialog.Builder to create the AlertDialog
    AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(getActivity());
    LayoutInflater customDialogInflater = getActivity().getLayoutInflater();
    alertDialogBuilder.setTitle(R.string.shortcut_name);
    alertDialogBuilder.setIcon(favoriteIconDrawable);
    alertDialogBuilder.setView(customDialogInflater.inflate(R.layout.create_home_screen_shortcut_dialog, null));
    alertDialogBuilder.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            buttonListener.onCreateHomeScreenShortcutCancel(CreateHomeScreenShortcut.this);
        }
    });
    alertDialogBuilder.setPositiveButton(R.string.create, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            buttonListener.onCreateHomeScreenShortcutCreate(CreateHomeScreenShortcut.this);
        }
    });

    // Assign the alertDialogBuilder to an AlertDialog.
    final AlertDialog alertDialog = alertDialogBuilder.create();

    // Show the keyboard when the dialog is displayed on the screen.
    alertDialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);

    // We need to show alertDialog before we can setOnKeyListener below.
    alertDialog.show();

    EditText shortcutNameEditText = (EditText) alertDialog.findViewById(R.id.shortcutNameEditText);

    // Allow the "enter" key on the keyboard to create the shortcut.
    shortcutNameEditText.setOnKeyListener(new View.OnKeyListener() {
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button, select the PositiveButton "Create".
            if ((event.getAction() == KeyEvent.ACTION_DOWN) && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Trigger the create listener.
                buttonListener.onCreateHomeScreenShortcutCreate(CreateHomeScreenShortcut.this);

                // Manually dismiss alertDialog.
                alertDialog.dismiss();

                // Consume the event.
                return true;
            } else {
                // If any other key was pressed, do not consume the event.
                return false;
            }
        }
    });

    // onCreateDialog requires the return of an AlertDialog.
    return alertDialog;
}

From source file:org.fdroid.enigtext.ConversationListFragment.java

private void handleDeleteAllSelected() {
    AlertDialog.Builder alert = new AlertDialog.Builder(getActivity());
    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.ConversationListFragment_delete_threads_question);
    alert.setMessage(//from   w  w  w  . ja  v a  2  s  .c  o m
            R.string.ConversationListFragment_are_you_sure_you_wish_to_delete_all_selected_conversation_threads);
    alert.setCancelable(true);

    alert.setPositiveButton(R.string.delete, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final Set<Long> selectedConversations = ((ConversationListAdapter) getListAdapter())
                    .getBatchSelections();

            if (!selectedConversations.isEmpty()) {
                new AsyncTask<Void, Void, Void>() {
                    private ProgressDialog dialog;

                    @Override
                    protected void onPreExecute() {
                        dialog = ProgressDialog.show(getActivity(),
                                getSherlockActivity().getString(R.string.ConversationListFragment_deleting),
                                getSherlockActivity()
                                        .getString(R.string.ConversationListFragment_deleting_selected_threads),
                                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;
                            batchMode = false;
                        }
                    }
                }.execute();
            }
        }
    });

    alert.setNegativeButton(android.R.string.cancel, null);
    alert.show();
}

From source file:color.kidpaint.com.kidpaintcolor.dialog.InfoDialog.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override//from www. java  2s.  c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new CustomAlertDialogBuilder(getActivity());

    if (mTitleResource != NULL_RESOURCE) {
        builder.setTitle(mTitleResource);
    }

    int imageResource = mDialogType.getImageResource();
    if (imageResource != NULL_RESOURCE) {
        builder.setIcon(imageResource);
    }

    if (mMessageResource != NULL_RESOURCE) {
        builder.setMessage(mMessageResource);
    }

    builder.setNeutralButton(android.R.string.ok, this);
    return builder.create();
}