Example usage for android.app AlertDialog setIcon

List of usage examples for android.app AlertDialog setIcon

Introduction

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

Prototype

public void setIcon(Drawable icon) 

Source Link

Usage

From source file:org.adawaycn.ui.BlacklistFragment.java

/**
 * Add new entry based on input//w  w  w  .jav a 2s .  com
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (org.adawaycn.util.RegexUtils.isValidHostname(input)) {
            org.adawaycn.provider.ProviderHelper.insertBlacklistItem(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_hostname_title);
            alertDialog.setMessage(getString(R.string.no_hostname));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:com.veniosg.dir.android.dialog.CreateDirectoryDialog.java

@NonNull
@Override/* w  w  w  . jav a2s  .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    LayoutInflater inflater = LayoutInflater.from(getActivity());
    LinearLayout view = (LinearLayout) inflater.inflate(R.layout.dialog_text_input, null);
    final EditText v = view.findViewById(R.id.textinput);
    v.setHint(R.string.folder_name);

    v.setOnEditorActionListener((text, actionId, event) -> {
        if (actionId == IME_ACTION_GO)
            createFolder(text.getText(), getActivity());
        return true;
    });

    AlertDialog dialog = new AlertDialog.Builder(getActivity()).setTitle(R.string.create_new_folder)
            .setView(view)
            .setPositiveButton(android.R.string.ok,
                    (dialog1, which) -> createFolder(v.getText(), getActivity()))
            .setNegativeButton(android.R.string.cancel, null).create();
    dialog.setIcon(R.drawable.ic_dialog_folder);
    return dialog;
}

From source file:com.yeldi.yeldibazaar.FDroid.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case UPDATE_REPO:
        updateRepos();//from  www .  j a v a 2 s .  c  om
        return true;

    case MANAGE_REPO:
        Intent i = new Intent(this, ManageRepo.class);
        startActivityForResult(i, REQUEST_MANAGEREPOS);
        return true;

    case PREFERENCES:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

    case SEARCH:
        onSearchRequested();
        return true;

    case ABOUT:
        LayoutInflater li = LayoutInflater.from(this);
        View view = li.inflate(R.layout.about, null);

        // Fill in the version...
        TextView tv = (TextView) view.findViewById(R.id.version);
        PackageManager pm = getPackageManager();
        try {
            PackageInfo pi = pm.getPackageInfo(getApplicationContext().getPackageName(), 0);
            tv.setText(pi.versionName);
        } catch (Exception e) {
        }

        Builder p = new AlertDialog.Builder(this).setView(view);
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.icon);
        alrt.setTitle(getString(R.string.about_title));
        alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Uri uri = Uri.parse("https://f-droid.org");
                        startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    }
                });
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:sssemil.com.hostsaway.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input//  ww  w . j av a 2 s . c om
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adaway.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input// ww w  .  j  a va2  s . co  m
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(org.adaway.R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.adawaycn.ui.HostsSourcesFragment.java

/**
 * Add new entry based on input/*ww  w  . j a  v a  2  s .  c o  m*/
 *
 * @param input
 */
private void addEntry(String input) {
    if (input != null) {
        if (RegexUtils.isValidUrl(input)) {

            // insert hosts source into database
            ProviderHelper.insertHostsSource(mActivity, input);
        } else {
            AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
            alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
            alertDialog.setTitle(R.string.no_url_title);
            alertDialog.setMessage(getString(R.string.no_url));
            alertDialog.setButton(getString(R.string.button_close), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dlg, int sum) {
                    dlg.dismiss();
                }
            });
            alertDialog.show();
        }
    }
}

From source file:org.fdroid.fdroid.MainActivity.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_login:
        if (mService != null) {
            com.skubit.Utils.startAuthorization(this, mService);
        } else {//from w  ww  . j a  v  a2s  .co  m
            if (!com.skubit.Utils.isIabInstalled(getPackageManager())) {
                startActivityForResult(com.skubit.Utils.getIabIntent(), com.skubit.Utils.PLAY_CODE);
            }
        }
        return true;
    case R.id.action_update_repo:
        updateRepos();
        return true;

    case R.id.action_manage_repos:
        Intent i = new Intent(this, ManageReposActivity.class);
        startActivityForResult(i, REQUEST_MANAGEREPOS);
        return true;

    case R.id.action_settings:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

    case R.id.action_swap:
        startActivity(new Intent(this, SwapActivity.class));
        return true;

    case R.id.action_search:
        onSearchRequested();
        return true;

    case R.id.action_bluetooth_apk:
        /*
         * If Bluetooth has not been enabled/turned on, then enabling
         * device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    case R.id.action_about:
        View view = null;
        if (Build.VERSION.SDK_INT >= 11) {
            LayoutInflater li = LayoutInflater.from(this);
            view = li.inflate(R.layout.about, null);
        } else {
            view = View.inflate(new ContextThemeWrapper(this, R.style.AboutDialogLight), R.layout.about, null);
        }

        // Fill in the version...
        try {
            PackageInfo pi = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0);
            ((TextView) view.findViewById(R.id.version)).setText(pi.versionName);
        } catch (Exception e) {
        }

        AlertDialog.Builder p = null;
        if (Build.VERSION.SDK_INT >= 11) {
            p = new AlertDialog.Builder(this).setView(view);
        } else {
            p = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AboutDialogLight)).setView(view);
        }
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.ic_launcher_market);
        alrt.setTitle(getString(R.string.about_title));
        alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Uri uri = Uri.parse("https://f-droid.org");
                        startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    }
                });
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.wahtod.wififixer.ui.MainActivity.java

public void showServiceAlert() {
    final Context c;
    c = this;//w  w  w.ja v a 2 s.co  m
    AlertDialog alert = new AlertDialog.Builder(c).create();
    alert.setTitle(getString(R.string.note));
    alert.setIcon(R.drawable.icon);
    alert.setMessage(getString(R.string.servicealert_message));
    alert.setButton(AlertDialog.BUTTON_POSITIVE, getString(R.string.ok_button),
            new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int which) {
                    PrefUtil.writeBoolean(c, PrefConstants.SERVICEWARNED, true);
                }
            });
    alert.show();
}

From source file:id.ridon.keude.Keude.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    switch (item.getItemId()) {

    case R.id.action_update_repo:
        updateRepos();//from ww w. j  a v a 2s . com
        return true;

    case R.id.action_manage_repos:
        Intent i = new Intent(this, ManageReposActivity.class);
        startActivityForResult(i, REQUEST_MANAGEREPOS);
        return true;

    case R.id.action_settings:
        Intent prefs = new Intent(getBaseContext(), PreferencesActivity.class);
        startActivityForResult(prefs, REQUEST_PREFS);
        return true;

    case R.id.action_swap:
        startActivity(new Intent(this, SwapActivity.class));
        return true;

    case R.id.action_search:
        onSearchRequested();
        return true;

    case R.id.action_bluetooth_apk:
        /*
         * If Bluetooth has not been enabled/turned on, then enabling
         * device discoverability will automatically enable Bluetooth
         */
        Intent discoverBt = new Intent(BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE);
        discoverBt.putExtra(BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION, 121);
        startActivityForResult(discoverBt, REQUEST_ENABLE_BLUETOOTH);
        // if this is successful, the Bluetooth transfer is started
        return true;

    case R.id.action_about:
        View view = null;
        if (Build.VERSION.SDK_INT >= 11) {
            LayoutInflater li = LayoutInflater.from(this);
            view = li.inflate(R.layout.about, null);
        } else {
            view = View.inflate(new ContextThemeWrapper(this, R.style.AboutDialogLight), R.layout.about, null);
        }

        // Fill in the version...
        try {
            PackageInfo pi = getPackageManager().getPackageInfo(getApplicationContext().getPackageName(), 0);
            ((TextView) view.findViewById(R.id.version)).setText(pi.versionName);
        } catch (Exception e) {
        }

        Builder p = null;
        if (Build.VERSION.SDK_INT >= 11) {
            p = new AlertDialog.Builder(this).setView(view);
        } else {
            p = new AlertDialog.Builder(new ContextThemeWrapper(this, R.style.AboutDialogLight)).setView(view);
        }
        final AlertDialog alrt = p.create();
        alrt.setIcon(R.drawable.ic_launcher);
        alrt.setTitle(getString(R.string.about_title));
        alrt.setButton(AlertDialog.BUTTON_NEUTRAL, getString(R.string.about_website),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                        Uri uri = Uri.parse("https://f-droid.org");
                        startActivity(new Intent(Intent.ACTION_VIEW, uri));
                    }
                });
        alrt.setButton(AlertDialog.BUTTON_NEGATIVE, getString(R.string.ok),
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int whichButton) {
                    }
                });
        alrt.show();
        return true;
    }
    return super.onOptionsItemSelected(item);
}

From source file:sssemil.com.hostsaway.ui.BlacklistFragment.java

/**
 * Edit entry based on selection in context menu
 *
 * @param info// w  ww.ja va 2s.  c  o m
 */
private void menuEditEntry(AdapterContextMenuInfo info) {
    mCurrentRowId = info.id; // set global RowId to row id from cursor to use inside save button
    int position = info.position;
    View v = info.targetView;

    CheckBox cBox = (CheckBox) v.findViewWithTag(position);

    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setCancelable(true);
    builder.setTitle(getString(R.string.checkbox_list_edit_dialog_title));

    // build view from layout
    LayoutInflater factory = LayoutInflater.from(mActivity);
    final View dialogView = factory.inflate(R.layout.lists_hostname_dialog, null);
    final EditText inputEditText = (EditText) dialogView.findViewById(R.id.list_dialog_hostname);
    inputEditText.setText(cBox.getText());

    // move cursor to end of EditText
    Editable inputEditContent = inputEditText.getText();
    inputEditText.setSelection(inputEditContent.length());

    builder.setView(dialogView);

    builder.setPositiveButton(getResources().getString(R.string.button_save),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();

                    String input = inputEditText.getText().toString();

                    if (RegexUtils.isValidHostname(input)) {
                        ProviderHelper.updateBlacklistItemHostname(mActivity, mCurrentRowId, input);
                    } else {
                        AlertDialog alertDialog = new AlertDialog.Builder(mActivity).create();
                        alertDialog.setIcon(android.R.drawable.ic_dialog_alert);
                        alertDialog.setTitle(R.string.no_hostname_title);
                        alertDialog.setMessage(getString(sssemil.com.hostsaway.R.string.no_hostname));
                        alertDialog.setButton(getString(R.string.button_close),
                                new DialogInterface.OnClickListener() {
                                    public void onClick(DialogInterface dlg, int sum) {
                                        dlg.dismiss();
                                    }
                                });
                        alertDialog.show();
                    }
                }
            });
    builder.setNegativeButton(getResources().getString(R.string.button_cancel),
            new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            });
    AlertDialog alert = builder.create();
    alert.show();
}