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:rs.pedjaapps.kerneltuner.ui.SDScannerActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.sd_analyzer_list);
    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    ListView sDListView = (ListView) findViewById(R.id.list);
    sDAdapter = new SDAdapter(this, R.layout.sd_list_row);
    sDListView.setAdapter(sDAdapter);/*  w  w  w. ja va  2s .c om*/
    sDListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, final int pos, long arg3) {
            final SDScannerEntry entry = sDAdapter.getItem(pos);
            AlertDialog.Builder builder = new AlertDialog.Builder(arg0.getContext());
            builder.setTitle(entry.getFileName());
            builder.setMessage(getResources().getString(R.string.sd_alert_location) + " " + entry.getPath()
                    + "\n" + getResources().getString(R.string.sd_alert_size) + " " + entry.getHRsize());

            builder.setIcon(R.drawable.ic_menu_cc);

            if (new File(entry.getPath()).isDirectory()) {
                builder.setPositiveButton(getResources().getString(R.string.sd_alert_scan),
                        new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                path = entry.getPath();
                                new ScanSDCard().execute(path);
                            }
                        });
            }
            builder.setNegativeButton(getResources().getString(R.string.delete),
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            new File(entry.getPath()).delete();
                            sDAdapter.remove(sDAdapter.getItem(pos));
                            sDAdapter.notifyDataSetChanged();
                        }
                    });

            AlertDialog alert = builder.create();
            alert.show();
        }

    });
    new ScanSDCard().execute(path);
}

From source file:net.evecom.android.log.DailyLogAddActivity.java

/**
 * //from  www  . j  av a2s.  c  o  m
 */
private String submit() {
    /**  */
    if (btEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (sswgButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rzlxButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (gzsjButton.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (rznrEditText.getText().toString().trim().length() < 1) {
        DialogToast("");
        return "";
    } else if (years > calendar.get(Calendar.YEAR)) {
        DialogToast("");
        return "";
    } else if (years == calendar.get(Calendar.YEAR)) {
        if (month > calendar.get(Calendar.MONTH) + 1) {
            DialogToast("");
            return "";
        } else if (month == calendar.get(Calendar.MONTH) + 1) {
            if (day > calendar.get(Calendar.DAY_OF_MONTH)) {
                DialogToast("");
                return "";
            }
        }
    }

    final AlertDialog.Builder builder = new AlertDialog.Builder(DailyLogAddActivity.this);
    builder.setTitle("");
    builder.setIcon(R.drawable.qq_dialog_default_icon);// 
    builder.setMessage("");
    builder.setPositiveButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            progressDialog = ProgressDialog.show(DailyLogAddActivity.this, "", "...");

            formSubmit();

        }
    });
    builder.setNegativeButton("", new DialogInterface.OnClickListener() {
        // @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    builder.show();
    return "1";
}

From source file:seantool.SeanNotify.java

public void showAlert(Drawable iconDrawable, String title, String message, String positiveStr,
        DialogInterface.OnClickListener positiveListener, String negativeStr,
        DialogInterface.OnClickListener negativeListener) {
    if (isNonNullAndEmptyCheck(title) && isNonNullAndEmptyCheck(message)) {
        if (!isNonNullAndEmptyCheck(positiveStr))
            positiveStr = "Ok";
        if (!isNonNullAndEmptyCheck(negativeStr))
            negativeStr = "Cancel";

        AlertDialog.Builder builder = new AlertDialog.Builder(context).setTitle(title).setMessage(message);

        if (positiveListener != null) {
            builder.setPositiveButton(positiveStr, positiveListener);
        }// ww w. j  a  v  a2s .co m

        if (negativeListener != null) {
            builder.setNegativeButton(negativeStr, negativeListener);
        }

        if (iconDrawable != null) {
            builder.setIcon(iconDrawable);
        }

        builder.show();

    }

}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysActivity.java

/**
 * Import keys with mImportData/*  ww w  .  j  ava  2s .  co m*/
 */
public void importKeys() {
    if (mImportData != null || mImportFilename != null) {
        Log.d(Constants.TAG, "importKeys started");

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

        intent.putExtra(KeychainIntentService.EXTRA_ACTION, KeychainIntentService.ACTION_IMPORT_KEYRING);

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

        // TODO: check for key type?
        // data.putInt(ApgIntentService.IMPORT_KEY_TYPE, Id.type.secret_key);

        if (mImportData != null) {
            data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_BYTES);
            data.putByteArray(KeychainIntentService.IMPORT_BYTES, mImportData);
        } else {
            data.putInt(KeychainIntentService.TARGET, KeychainIntentService.TARGET_FILE);
            data.putString(KeychainIntentService.IMPORT_FILENAME, mImportFilename);
        }

        intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

        // Message is received after importing is done in ApgService
        KeychainIntentServiceHandler saveHandler = new KeychainIntentServiceHandler(this,
                R.string.progress_importing, ProgressDialog.STYLE_HORIZONTAL) {
            public void handleMessage(Message message) {
                // handle messages by standard ApgHandler first
                super.handleMessage(message);

                if (message.arg1 == KeychainIntentServiceHandler.MESSAGE_OKAY) {
                    // get returned data bundle
                    Bundle returnData = message.getData();

                    int added = returnData.getInt(KeychainIntentService.RESULT_IMPORT_ADDED);
                    int updated = returnData.getInt(KeychainIntentService.RESULT_IMPORT_UPDATED);
                    int bad = returnData.getInt(KeychainIntentService.RESULT_IMPORT_BAD);
                    String toastMessage;
                    if (added > 0 && updated > 0) {
                        toastMessage = getString(R.string.keysAddedAndUpdated, added, updated);
                    } else if (added > 0) {
                        toastMessage = getString(R.string.keysAdded, added);
                    } else if (updated > 0) {
                        toastMessage = getString(R.string.keysUpdated, updated);
                    } else {
                        toastMessage = getString(R.string.noKeysAddedOrUpdated);
                    }
                    Toast.makeText(ImportKeysActivity.this, toastMessage, Toast.LENGTH_SHORT).show();
                    if (bad > 0) {
                        AlertDialog.Builder alert = new AlertDialog.Builder(ImportKeysActivity.this);

                        alert.setIcon(android.R.drawable.ic_dialog_alert);
                        alert.setTitle(R.string.warning);
                        alert.setMessage(ImportKeysActivity.this.getString(R.string.badKeysEncountered, bad));

                        alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
                            public void onClick(DialogInterface dialog, int id) {
                                dialog.cancel();
                            }
                        });
                        alert.setCancelable(true);
                        alert.create().show();
                    } else if (mDeleteAfterImport) {
                        // everything went well, so now delete, if that was turned on
                        DeleteFileDialogFragment deleteFileDialog = DeleteFileDialogFragment
                                .newInstance(mImportFilename);
                        deleteFileDialog.show(getSupportFragmentManager(), "deleteDialog");
                    }
                }
            };
        };

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

        // show progress dialog
        saveHandler.showProgressDialog(this);

        // start service with intent
        startService(intent);
    } else {
        Toast.makeText(this, R.string.error_nothingImport, Toast.LENGTH_LONG).show();
    }
}

From source file:org.adblockplus.android.Preferences.java

@Override
protected Dialog onCreateDialog(final int id) {
    Dialog dialog = null;/*from w ww .  ja  v  a 2 s .  co m*/
    switch (id) {
    case ABOUT_DIALOG:
        dialog = new AboutDialog(this);
        break;
    case HIDEICONWARNING_DIALOG:
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.warning);
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setCancelable(false);
        final StringBuffer message = new StringBuffer();
        message.append(getString(R.string.msg_hideicon_warning));
        builder.setPositiveButton(R.string.gotit, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(final DialogInterface dialog, final int id) {
                dialog.cancel();
            }
        });
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
            message.append("<br/><br/>");
            message.append(getString(R.string.msg_hideicon_native));
            builder.setNeutralButton(R.string.showme, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(final DialogInterface dialog, final int id) {
                    AdblockPlus.showAppDetails(getApplicationContext());
                    dialog.cancel();
                }
            });
        }
        builder.setMessage(Html.fromHtml(message.toString()));
        dialog = builder.create();
        break;
    }
    return dialog;
}

From source file:de.eidottermihi.rpicheck.fragment.QueryErrorMessagesDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    List<String> messages = this.getArguments().getStringArrayList(KEY_ERROR_MESSAGES);
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.errormessages_dialog_title);
    WebView wv = new WebView(getActivity());
    wv.loadDataWithBaseURL(null, this.createErrorMessages(messages), "text/html", "UTF-8", null);
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        Compability.setViewLayerTypeSoftware(wv);
    }/*  w  ww . j a v  a  2s  . c o m*/
    wv.setBackgroundColor(0);
    builder.setView(wv);
    builder.setCancelable(false);
    builder.setPositiveButton("Ok", null);
    builder.setIcon(android.R.drawable.ic_dialog_info);
    return builder.create();
}

From source file:uk.co.senab.photup.PhotoViewerActivity.java

private void showCaptionDialog() {
    final PhotoUpload currentUpload = getCurrentUpload();
    if (null != currentUpload) {

        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.photo_caption);
        builder.setIcon(R.drawable.ic_action_caption);

        // Set an EditText view to get user input
        final FrameLayout layout = new FrameLayout(this);
        final int margin = getResources().getDimensionPixelSize(R.dimen.spacing);
        layout.setPadding(margin, margin, margin, margin);

        final EditText input = new EditText(this);
        input.setMinLines(2);/* w  w w  . j  av  a 2 s  .  c  o  m*/
        input.setText(currentUpload.getCaption());
        layout.addView(input);

        builder.setView(layout);

        final DialogInterface.OnClickListener listener = new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {

                switch (whichButton) {
                case AlertDialog.BUTTON_POSITIVE:
                    currentUpload.setCaption(input.getText().toString());
                    getSupportActionBar().setTitle(currentUpload.toString());
                    break;

                case AlertDialog.BUTTON_NEGATIVE:
                default:
                    dialog.dismiss();
                    break;
                }
            }
        };

        builder.setPositiveButton(android.R.string.ok, listener);
        builder.setNegativeButton(android.R.string.cancel, listener);
        builder.show();
    }
}

From source file:de.da_sense.moses.client.service.MosesService.java

/**
 * This function will be executed on first run and shows some welcome
 * dialog./*  www  .  java 2 s .  co  m*/
 * 
 * @param context
 *            The context under which the dialog is shown.
 */
private void showWelcomeDialog(final Context context) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);

    builder.setIcon(R.drawable.ic_launcher);
    builder.setCancelable(false); // This blocks the 'BACK' button
    builder.setMessage(getString(R.string.welcome_to_moses_string));
    builder.setTitle(getString(R.string.welcome_to_moses_title_string));
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    AlertDialog alert = builder.create();
    alert.show();
    Log.d("MoSeS.SERVICE", "First login.");
    PreferenceManager.getDefaultSharedPreferences(this).edit().putBoolean("first_start", false).commit();
}

From source file:monakhv.android.samlib.AuthorTagsActivity.java

private Dialog tagRemoveAlert() {
    AlertDialog.Builder adb = new AlertDialog.Builder(this);
    adb.setTitle(R.string.Attention);//from ww  w.  j  av  a  2 s .  co  m

    String tagName = cursor.getString(cursor.getColumnIndex(SQLController.COL_TAG_NAME));
    String msg = getString(R.string.alert_tag_delete);
    msg = msg.replaceAll("__", tagName);

    adb.setMessage(msg);
    adb.setIcon(android.R.drawable.ic_dialog_alert);
    adb.setPositiveButton(R.string.Yes, deleteTagListener);
    adb.setNegativeButton(R.string.No, deleteTagListener);
    return adb.create();

}

From source file:com.jaanussiim.slimtimer.android.activities.LoginActivity.java

@Override
protected Dialog onCreateDialog(final int id) {
    switch (id) {
    case DIALOG_LOGGING_IN: {
        ProgressDialog dialog = new ProgressDialog(this);
        dialog.setMessage(getText(R.string.logging_in_message));
        dialog.setIndeterminate(true);//  w ww .jav a2s . c  om
        dialog.setCancelable(true);
        dialog.setOnCancelListener(this);
        return dialog;
    }
    case DIALOG_AUTHENTICATION_ERROR:
    case DIALOG_NETWORK_ERROR:
    case DIALOG_UNKNOWN_ERROR:
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.login_error_dialog_title);
        if (id == DIALOG_AUTHENTICATION_ERROR) {
            builder.setMessage(R.string.login_error_authentication_error);
        } else if (id == DIALOG_NETWORK_ERROR) {
            builder.setMessage(R.string.login_error_network_error);
        } else {
            builder.setMessage(R.string.login_error_network_error);
        }
        builder.setIcon(android.R.drawable.ic_dialog_alert);
        builder.setPositiveButton(R.string.button_title_ok, null);
        return builder.create();
    default:
        return super.onCreateDialog(id);
    }
}