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:org.adaway.ui.dialog.ActivityNotFoundDialogFragment.java

/**
 * Creates dialog/* ww w .j  a  va2  s .  c o  m*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String appGooglePlayUri = getArguments().getString(ARG_APP_GOOGLE_PLAY_URI);
    final String appFDroidQuery = getArguments().getString(ARG_APP_FDROID_QUERY);
    final int title = getArguments().getInt(ARG_TITLE);
    final int message = getArguments().getInt(ARG_MESSAGE);

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    builder.setPositiveButton(R.string.button_yes, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            Intent intentGooglePlay = new Intent(Intent.ACTION_VIEW);
            intentGooglePlay.setData(Uri.parse(appGooglePlayUri));

            try {
                activity.startActivity(intentGooglePlay);
            } catch (ActivityNotFoundException e) {
                Log.e(Constants.TAG, "No Google Play Store installed!, Trying FDroid...", e);

                Intent intentFDroid = new Intent(Intent.ACTION_SEARCH);
                intentFDroid.setComponent(
                        new ComponentName("org.fdroid.fdroid", "org.fdroid.fdroid.SearchResults"));
                intentFDroid.putExtra(SearchManager.QUERY, appFDroidQuery);

                try {
                    activity.startActivity(intentFDroid);
                } catch (ActivityNotFoundException e2) {
                    Log.e(Constants.TAG, "No FDroid installed!", e2);
                }
            }
        }
    });
    builder.setNegativeButton(R.string.button_no, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dialog.dismiss();
        }
    });

    builder.setTitle(title);
    builder.setMessage(message);

    return builder.create();
}

From source file:org.jssec.android.privacypolicynopreconfirm.ConfirmFragment.java

@Override
public Dialog onCreateDialog(Bundle args) {
    // ?1 ?????????????
    final int title = getArguments().getInt("title");
    final int sentence = getArguments().getInt("sentence");
    final int type = getArguments().getInt("type");

    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View content = inflater.inflate(R.layout.fragment_comfirm, null);
    TextView linkPP = (TextView) content.findViewById(R.id.tx_link_pp);
    linkPP.setOnClickListener(new OnClickListener() {
        @Override/*from   w  w  w  . ja  va  2s.c  o  m*/
        public void onClick(View v) {
            // ?3 ?????????
            Intent intent = new Intent();
            intent.setClass(getActivity(), WebViewAssetsActivity.class);
            startActivity(intent);
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(title);
    builder.setMessage(sentence);
    builder.setView(content);

    builder.setPositiveButton(R.string.buttonOK, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (mListener != null) {
                mListener.onPositiveButtonClick(type);
            }
        }
    });
    builder.setNegativeButton(R.string.buttonNG, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (mListener != null) {
                mListener.onNegativeButtonClick(type);
            }
        }
    });

    Dialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}

From source file:org.jssec.android.privacypolicy.ConfirmFragment.java

@Override
public Dialog onCreateDialog(Bundle args) {
    // ?1 ?????????????
    // ?3 ???????????????
    final int title = getArguments().getInt("title");
    final int sentence = getArguments().getInt("sentence");
    final int type = getArguments().getInt("type");

    LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View content = inflater.inflate(R.layout.fragment_comfirm, null);
    TextView linkPP = (TextView) content.findViewById(R.id.tx_link_pp);
    linkPP.setOnClickListener(new OnClickListener() {
        @Override//from w ww .  j  av  a  2  s  . co m
        public void onClick(View v) {
            // ?5 ?????????
            Intent intent = new Intent();
            intent.setClass(getActivity(), WebViewAssetsActivity.class);
            startActivity(intent);
        }
    });

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setIcon(R.drawable.ic_launcher);
    builder.setTitle(title);
    builder.setMessage(sentence);
    builder.setView(content);

    builder.setPositiveButton(R.string.buttonOK, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (mListener != null) {
                mListener.onPositiveButtonClick(type);
            }
        }
    });
    builder.setNegativeButton(R.string.buttonNG, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
            if (mListener != null) {
                mListener.onNegativeButtonClick(type);
            }
        }
    });

    Dialog dialog = builder.create();
    dialog.setCanceledOnTouchOutside(false);

    return dialog;
}

From source file:pl.wasat.smarthma.ui.dialogs.ExceptionDialogFragment.java

@NonNull
@Override/*from  w w w  .jav  a2 s .  c om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    int title = getArguments().getInt("title");
    String exMess = getArguments().getString(MESSAGE);
    final String exRawMess = getArguments().getString(RAW_MESSAGE);
    final String exRawCause = getArguments().getString(RAW_CAUSE);

    GlobalPreferences globalPreferences = new GlobalPreferences(getActivity());

    AlertDialog.Builder exceptionAlertDialog = new AlertDialog.Builder(getActivity());
    exceptionAlertDialog.setIcon(R.drawable.ic_action_name).setTitle(title)
            .setMessage(exMess + getString(R.string.please_correct_your_query_))
            .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    ((BaseSmartHMActivity) getActivity()).doPositiveClick();
                }
            }).setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int whichButton) {
                    ((BaseSmartHMActivity) getActivity()).doNegativeClick();
                }
            });
    if (globalPreferences.getIsDebugMode()) {
        exceptionAlertDialog.setNeutralButton(R.string.alert_dialog_details,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int whichButton) {
                        String detailMessage = formatDetailMessage(exRawMess, exRawCause);
                        showDialog(detailMessage, exRawMess, exRawCause);
                    }
                });
    }
    return exceptionAlertDialog.create();
}

From source file:com.dimasdanz.kendalipintu.usermodel.UserDialogManager.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = getActivity().getLayoutInflater();
    final ArrayList<String> userData = new ArrayList<String>();
    final View view = inflater.inflate(R.layout.dialog_user_form, null);
    final TextView txtUserID = (TextView) view.findViewById(R.id.txtUserID);
    final EditText txtUsername = (EditText) view.findViewById(R.id.txtUserName);
    final EditText txtUserPass = (EditText) view.findViewById(R.id.txtUserPass);
    int btnText = R.string.action_add_account;
    if (!getArguments().isEmpty()) {
        btnText = R.string.change;//from  www  .j a  v  a  2s.  co m
        txtUserID.setText(getArguments().getStringArrayList("data").get(0));
        txtUsername.setText(getArguments().getStringArrayList("data").get(1));
        txtUserPass.setText(getArguments().getStringArrayList("data").get(2));
    }

    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), 4);
    builder.setIcon(R.drawable.ic_action_group);
    builder.setTitle(R.string.dialog_title_userform);
    builder.setView(view);
    builder.setPositiveButton(btnText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (txtUsername.getText().toString().length() > 0 || txtUserPass.getText().length() > 0) {
                userData.add(txtUserID.getText().toString());
                userData.add(txtUsername.getText().toString());
                userData.add(txtUserPass.getText().toString());
                mListener.onDialogPositiveClick(UserDialogManager.this, userData);
            } else {
                //TODO Change string, use a better listener
                Toast.makeText(getActivity(), "Please fill all field", Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNegativeButton(R.string.delete, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            if (txtUserID.getText().toString().length() > 0) {
                userData.add(txtUserID.getText().toString());
                mListener.onDialogNegativeClick(UserDialogManager.this, userData);
            } else {
                //TODO Change string, use a better listener
                Toast.makeText(getActivity(), "Please fill all field", Toast.LENGTH_SHORT).show();
            }
        }
    });
    builder.setNeutralButton(R.string.close, null);
    return builder.create();
}

From source file:mobile.client.iot.pzalejko.iothome.MainActivity.java

private void showAbout() {
    View messageView = getLayoutInflater().inflate(R.layout.about, null, false);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setIcon(R.drawable.iot_app_icon);
    builder.setTitle(getString(R.string.app_name) + " " + getString(R.string.app_version));
    builder.setView(messageView);//from   w w w  .j av  a2 s .c  o m
    builder.create();
    builder.show();
}

From source file:org.sufficientlysecure.keychain.ui.dialog.LookupUnknownKeyDialogFragment.java

/**
 * Creates dialog//from   w  ww.  ja  v  a  2 s  . c o m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    final long unknownKeyId = getArguments().getLong(ARG_UNKNOWN_KEY_ID);
    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.title_unknownSignatureKey);
    alert.setMessage(getString(R.string.lookupUnknownKey, PgpHelper.getSmallFingerPrint(unknownKeyId)));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            sendMessageToHandler(MESSAGE_OKAY);

            Intent intent = new Intent(activity, KeyServerQueryActivity.class);
            intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
            intent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, unknownKeyId);
            startActivityForResult(intent, Id.request.look_up_key_id);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            sendMessageToHandler(MESSAGE_CANCEL);
        }
    });
    alert.setCancelable(true);
    alert.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            sendMessageToHandler(MESSAGE_CANCEL);
        }
    });

    return alert.create();
}

From source file:com.jsw.MngProductDatabase.Fragments.AddCategory_Fragment.java

public Dialog create() {
    final AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle("Add New Category");
    builder.setIcon(R.drawable.ic_add_white_24dp);
    builder.setMessage("Type the category you wanna add.");

    //mName = (EditText)getActivity().getLayoutInflater().inflate(R.layout.layout_add_category, ).findViewById(R.id.et_addCategory);
    LayoutInflater infl = LayoutInflater.from(getContext());
    mName = (EditText) infl.inflate(R.layout.layout_add_category, null).findViewById(R.id.et_addCategory);

    builder.setView(mName);//  w w  w  .  j a  v a 2s  . c om

    builder.setPositiveButton(getContext().getText(android.R.string.ok), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialogInterface, int i) {

            Category cat = new Category(1, mName.getText().toString());

            if (DatabaseManager.getInstance().checkCategory(cat)) {
                Toast.makeText(getContext(), "Category already exists", Toast.LENGTH_LONG).show();
                dismiss();
            } else {
                new CategoryPresenter(view).addCategory(cat);
            }
        }
    });

    builder.setNegativeButton(getContext().getText(android.R.string.cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dismiss();
                }
            });

    return builder.create();
}

From source file:id.nci.stm_9.DeleteFileDialogFragment.java

/**
 * Creates dialog/*from   w w w. j  a v a  2 s  .c  o m*/
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();

    final String deleteFile = getArguments().getString(ARG_DELETE_FILE);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.warning);
    alert.setMessage(this.getString(R.string.file_delete_confirmation, deleteFile));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            // Send all information needed to service to edit key in other thread
            Intent intent = new Intent(activity, KeychainIntentService.class);

            // fill values for this action
            Bundle data = new Bundle();

            intent.setAction(KeychainIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(KeychainIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment
                    .newInstance(R.string.progress_deleting_securely, ProgressDialog.STYLE_HORIZONTAL);

            // Message is received after deleting is done in ApgService
            KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(activity,
                    deletingDialog) {
                public void handleMessage(Message message) {
                    // handle messages by standard ApgHandler first
                    super.handleMessage(message);

                    if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                        Toast.makeText(activity, R.string.file_delete_successful, Toast.LENGTH_SHORT).show();
                    }
                };
            };

            // Create a new Messenger for the communication back
            Messenger messenger = new Messenger(saveHandler);
            intent.putExtra(KeychainIntentService.EXTRA_MESSENGER, messenger);

            // show progress dialog
            deletingDialog.show(activity.getSupportFragmentManager(), "deletingDialog");

            // start service with intent
            activity.startService(intent);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });
    alert.setCancelable(true);

    return alert.create();
}

From source file:id.nci.stm_9.LookupUnknownKeyDialogFragment.java

/**
 * Creates dialog//from   www.  j a v  a 2s .  c  o  m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    final long unknownKeyId = getArguments().getLong(ARG_UNKNOWN_KEY_ID);
    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    AlertDialog.Builder alert = new AlertDialog.Builder(activity);

    alert.setIcon(android.R.drawable.ic_dialog_alert);
    alert.setTitle(R.string.title_unknown_signature_key);
    alert.setMessage(getString(R.string.lookup_unknown_key, PgpKeyHelper.convertKeyIdToHex(unknownKeyId)));

    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            sendMessageToHandler(MESSAGE_OKAY);

            Intent intent = new Intent(activity, KeyServerQueryActivity.class);
            intent.setAction(KeyServerQueryActivity.ACTION_LOOK_UP_KEY_ID);
            intent.putExtra(KeyServerQueryActivity.EXTRA_KEY_ID, unknownKeyId);
            //                startActivityForResult(intent, Id.request.look_up_key_id);
            startActivityForResult(intent, 0x00007006);
        }
    });
    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();

            sendMessageToHandler(MESSAGE_CANCEL);
        }
    });
    alert.setCancelable(true);
    alert.setOnCancelListener(new OnCancelListener() {

        @Override
        public void onCancel(DialogInterface dialog) {
            sendMessageToHandler(MESSAGE_CANCEL);
        }
    });

    return alert.create();
}