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.thialfihar.android.apg.ui.dialog.DeleteFileDialogFragment.java

/**
 * Creates dialog/*ww w .j a  v  a2s  .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(R.drawable.ic_dialog_alert_holo_light);
    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, ApgIntentService.class);

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

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

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

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

                    if (message.arg1 == ApgIntentServiceHandler.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(ApgIntentService.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:org.sufficientlysecure.keychain.ui.dialog.DeleteFileDialogFragment.java

/**
 * Creates dialog/*from   w w w  .  j  a  v a  2s. c om*/
 */
@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.fileDeleteConfirmation, 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.putExtra(KeychainIntentService.EXTRA_ACTION,
                    KeychainIntentService.ACTION_DELETE_FILE_SECURELY);
            data.putString(KeychainIntentService.DELETE_FILE, deleteFile);
            intent.putExtra(KeychainIntentService.EXTRA_DATA, data);

            ProgressDialogFragment deletingDialog = ProgressDialogFragment
                    .newInstance(R.string.progress_deletingSecurely, 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.fileDeleteSuccessful, 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:org.hedgewars.hedgeroid.TeamAddDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.dialog_addteam_title);
    builder.setIcon(R.drawable.human);
    String[] teamNames = new String[availableTeams.size()];
    for (int i = 0; i < availableTeams.size(); i++) {
        teamNames[i] = availableTeams.get(i).name;
    }//  w w w. j a  v  a  2s .  c o  m
    builder.setItems(teamNames, new OnClickListener() {
        public void onClick(DialogInterface dialog, int which) {
            listener.onTeamAddDialogSubmitted(availableTeams.get(which));
        }
    });
    return builder.create();
}

From source file:org.sufficientlysecure.ical.ui.UrlDialog.java

@Override
@NonNull/*from w w w. ja v a  2s.c om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {

    mActivity = (MainActivity) getActivity();

    ViewGroup nullViewGroup = null; // Avoid bad lint warning in inflate()
    View view = mActivity.getLayoutInflater().inflate(R.layout.urldialog, nullViewGroup);

    mCheckboxLoginRequired = (CheckBox) view.findViewById(R.id.CheckboxLoginRequired);
    CompoundButton.OnCheckedChangeListener loginRequiredTask;
    loginRequiredTask = new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton button, boolean isChecked) {
            mTextUsername.setEnabled(isChecked);
            mTextPassword.setEnabled(isChecked);
        }
    };
    mCheckboxLoginRequired.setOnCheckedChangeListener(loginRequiredTask);

    mTextCalendarUrl = (EditText) view.findViewById(R.id.TextCalendarUrl);
    mTextUsername = (EditText) view.findViewById(R.id.TextUsername);
    mTextPassword = (EditText) view.findViewById(R.id.TextPassword);

    Settings settings = mActivity.getSettings();
    mTextCalendarUrl.setText(settings.getString(Settings.PREF_LASTURL));
    mTextUsername.setText(settings.getString(Settings.PREF_LASTURLUSERNAME));
    mTextPassword.setText(settings.getString(Settings.PREF_LASTURLPASSWORD));

    mCheckboxLoginRequired.setChecked(mTextUsername.getText().length() != 0);
    mTextCalendarUrl.selectAll();

    DialogInterface.OnClickListener okTask;
    okTask = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface iface, int id) {
            // We override this in onStart()
        }
    };

    DialogInterface.OnClickListener cancelTask;
    cancelTask = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface iface, int id) {
            iface.cancel();
        }
    };

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    AlertDialog dlg = builder.setIcon(R.mipmap.ic_launcher).setTitle(R.string.enter_source_url).setView(view)
            .setPositiveButton(android.R.string.ok, okTask)
            .setNegativeButton(android.R.string.cancel, cancelTask).create();
    dlg.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
    return dlg;
}

From source file:com.hartcode.hartweather.list.WeatherItemViewHolder.java

@Override
public boolean onLongClick(View v) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this.view.getContext());
    builder.setTitle(resources.getString(R.string.dialog_delete_title));
    builder.setIcon(android.R.drawable.ic_menu_delete);
    builder.setMessage(resources.getString(R.string.dialog_delete_question))
            .setPositiveButton(resources.getString(R.string.dialog_delete_positive), this)
            .setNegativeButton(resources.getString(R.string.dialog_delete_negative), this).show();
    return false;
}

From source file:org.fdroid.fdroid.privileged.views.UninstallDialogActivity.java

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

    final Intent intent = getIntent();
    final String packageName = intent.getStringExtra(Installer.EXTRA_PACKAGE_NAME);

    PackageManager pm = getPackageManager();

    ApplicationInfo appInfo;/*ww w  .  j a v  a 2s .co m*/
    try {
        //noinspection WrongConstant (lint is actually wrong here!)
        appInfo = pm.getApplicationInfo(packageName, PackageManager.GET_UNINSTALLED_PACKAGES);
    } catch (PackageManager.NameNotFoundException e) {
        throw new RuntimeException("Failed to get ApplicationInfo for uninstalling");
    }

    final boolean isSystem = (appInfo.flags & ApplicationInfo.FLAG_SYSTEM) != 0;
    final boolean isUpdate = (appInfo.flags & ApplicationInfo.FLAG_UPDATED_SYSTEM_APP) != 0;

    if (isSystem && !isUpdate) {
        // Cannot remove system apps unless we're uninstalling updates
        throw new RuntimeException("Cannot remove system apps unless we're uninstalling updates");
    }

    int messageId;
    if (isUpdate) {
        messageId = R.string.uninstall_update_confirm;
    } else {
        messageId = R.string.uninstall_confirm;
    }

    // hack to get theme applied (which is not automatically applied due to activity's Theme.NoDisplay
    ContextThemeWrapper theme = new ContextThemeWrapper(this, FDroidApp.getCurThemeResId());

    final AlertDialog.Builder builder = new AlertDialog.Builder(theme);
    builder.setTitle(appInfo.loadLabel(pm));
    builder.setIcon(appInfo.loadIcon(pm));
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            Intent data = new Intent();
            data.putExtra(Installer.EXTRA_PACKAGE_NAME, packageName);
            setResult(Activity.RESULT_OK, intent);
            finish();
        }
    });
    builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    builder.setOnCancelListener(new DialogInterface.OnCancelListener() {
        @Override
        public void onCancel(DialogInterface dialog) {
            setResult(Activity.RESULT_CANCELED);
            finish();
        }
    });
    builder.setMessage(messageId);
    builder.create().show();
}

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

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(R.string.exception_dialog_title);
    builder.setMessage(getArguments().getString(MESSAGE_KEY));
    builder.setPositiveButton("Ok", null);
    builder.setIcon(android.R.drawable.ic_dialog_alert);
    return builder.create();
}

From source file:com.docd.purefm.ui.dialogs.PartitionInfoDialog.java

public Dialog onCreateDialog(final Bundle savedInstanceState) {
    final Activity activity = this.getActivity();
    if (activity == null || activity.isFinishing()) {
        return null;
    }/*w  ww .j  av  a  2 s. co  m*/
    //noinspection InflateParams
    mView = activity.getLayoutInflater().inflate(R.layout.dialog_partition_info, null);
    final AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setIcon(ThemeUtils.getDrawableNonNull(activity, R.attr.ic_menu_info));
    builder.setTitle(R.string.menu_partition);
    builder.setView(mView);
    builder.setNeutralButton(R.string.close, null);
    return builder.create();

}

From source file:ua.naiksoftware.chars.Sender.java

@Override
protected void onPreExecute() {
    Log.d(tag, "onPreExecute begin");

    ProgressBar progressBar = new ProgressBar(EngineActivity.CONTEXT);
    progressBar.setIndeterminate(true);//from   ww  w.j a  v a  2s .  c o  m

    AlertDialog.Builder builder = new AlertDialog.Builder(EngineActivity.CONTEXT);
    builder.setCustomTitle(progressBar);
    builder.setIcon(android.R.drawable.ic_menu_upload);
    builder.setMessage(R.string.send_record);
    builder.setCancelable(false);
    dialog = builder.create();
    dialog.show();
    Log.d(tag, "onPreExecute end");
}

From source file:ivl.android.moneybalance.CalculationListActivity.java

private void confirmAndDelete(final Calculation calculation) {
    AlertDialog.Builder dialog = new AlertDialog.Builder(this);
    dialog.setIcon(android.R.drawable.ic_delete);
    dialog.setTitle(calculation.getTitle());
    dialog.setMessage(R.string.confirm_delete_calculation);
    dialog.setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
        @Override//w  w  w  .  jav a  2 s  .c  o  m
        public void onClick(DialogInterface dialog, int which) {
            dataSource.delete(calculation.getId());
            refresh();
        }
    });
    dialog.setNegativeButton(android.R.string.no, null);
    dialog.show();
}