Search in sources :

Example 46 with Builder

use of android.support.v7.app.AlertDialog.Builder in project AndroidDevelop by 7449.

the class EasyCityView method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.BottomDialog);
    initView();
    builder.setView(rootView);
    dialog = builder.create();
    Window window = dialog.getWindow();
    if (window != null) {
        WindowManager.LayoutParams wlp = window.getAttributes();
        wlp.gravity = Gravity.BOTTOM;
        window.setAttributes(wlp);
    }
    setCancelable(isCancelable);
    return dialog;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Window(android.view.Window) WindowManager(android.view.WindowManager) NonNull(android.support.annotation.NonNull)

Example 47 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Lightning-Browser by anthonycr.

the class PrivacySettingsFragment method clearHistoryDialog.

private void clearHistoryDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(mActivity);
    builder.setTitle(getResources().getString(R.string.title_clear_history));
    Dialog dialog = builder.setMessage(getResources().getString(R.string.dialog_history)).setPositiveButton(getResources().getString(R.string.action_yes), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface arg0, int arg1) {
            clearHistory().subscribeOn(Schedulers.io()).observeOn(Schedulers.main()).subscribe(new CompletableOnSubscribe() {

                @Override
                public void onComplete() {
                    Utils.showSnackbar(getActivity(), R.string.message_clear_history);
                }
            });
        }
    }).setNegativeButton(getResources().getString(R.string.action_no), null).show();
    BrowserDialog.setDialogSize(mActivity, dialog);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) BrowserDialog(acr.browser.lightning.dialog.BrowserDialog) AlertDialog(android.support.v7.app.AlertDialog) CompletableOnSubscribe(com.anthonycr.bonsai.CompletableOnSubscribe)

Example 48 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Lightning-Browser by anthonycr.

the class ProxyUtils method checkForProxy.

/*
     * If Orbot/Tor or I2P is installed, prompt the user if they want to enable
     * proxying for this session
     */
public void checkForProxy(@NonNull final Activity activity) {
    boolean useProxy = mPreferences.getUseProxy();
    final boolean orbotInstalled = OrbotHelper.isOrbotInstalled(activity);
    boolean orbotChecked = mPreferences.getCheckedForTor();
    boolean orbot = orbotInstalled && !orbotChecked;
    boolean i2pInstalled = mI2PHelper.isI2PAndroidInstalled();
    boolean i2pChecked = mPreferences.getCheckedForI2P();
    boolean i2p = i2pInstalled && !i2pChecked;
    // TODO Is the idea to show this per-session, or only once?
    if (!useProxy && (orbot || i2p)) {
        if (orbot)
            mPreferences.setCheckedForTor(true);
        if (i2p)
            mPreferences.setCheckedForI2P(true);
        AlertDialog.Builder builder = new AlertDialog.Builder(activity);
        if (orbotInstalled && i2pInstalled) {
            String[] proxyChoices = activity.getResources().getStringArray(R.array.proxy_choices_array);
            builder.setTitle(activity.getResources().getString(R.string.http_proxy)).setSingleChoiceItems(proxyChoices, mPreferences.getProxyChoice(), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    mPreferences.setProxyChoice(which);
                }
            }).setPositiveButton(activity.getResources().getString(R.string.action_ok), new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    if (mPreferences.getUseProxy())
                        initializeProxy(activity);
                }
            });
        } else {
            DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {

                @Override
                public void onClick(DialogInterface dialog, int which) {
                    switch(which) {
                        case DialogInterface.BUTTON_POSITIVE:
                            mPreferences.setProxyChoice(orbotInstalled ? Constants.PROXY_ORBOT : Constants.PROXY_I2P);
                            initializeProxy(activity);
                            break;
                        case DialogInterface.BUTTON_NEGATIVE:
                            mPreferences.setProxyChoice(Constants.NO_PROXY);
                            break;
                    }
                }
            };
            builder.setMessage(orbotInstalled ? R.string.use_tor_prompt : R.string.use_i2p_prompt).setPositiveButton(R.string.yes, dialogClickListener).setNegativeButton(R.string.no, dialogClickListener);
        }
        Dialog dialog = builder.show();
        BrowserDialog.setDialogSize(activity, dialog);
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) BrowserDialog(acr.browser.lightning.dialog.BrowserDialog) AlertDialog(android.support.v7.app.AlertDialog)

Example 49 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Lightning-Browser by anthonycr.

the class BookmarkSettingsFragment method showChooserDialog.

private void showChooserDialog(final Activity activity, List<String> list) {
    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(activity, android.R.layout.simple_list_item_1);
    for (String title : list) {
        adapter.add(title);
    }
    builder.setTitle(R.string.supported_browsers_title);
    builder.setAdapter(adapter, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String title = adapter.getItem(which);
            Preconditions.checkNonNull(title);
            Source source = null;
            if (title.equals(getString(R.string.stock_browser))) {
                source = Source.STOCK;
            } else if (title.equals(getTitle(activity, "com.android.chrome"))) {
                source = Source.CHROME_STABLE;
            } else if (title.equals(getTitle(activity, "com.android.beta"))) {
                source = Source.CHROME_BETA;
            } else if (title.equals(getTitle(activity, "com.android.dev"))) {
                source = Source.CHROME_DEV;
            }
            if (source != null) {
                new ImportBookmarksTask(activity, source).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
            }
        }
    });
    Dialog dialog = builder.show();
    BrowserDialog.setDialogSize(activity, dialog);
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Source(acr.browser.lightning.database.bookmark.BookmarkLocalSync.Source) Dialog(android.app.Dialog) BrowserDialog(acr.browser.lightning.dialog.BrowserDialog) AlertDialog(android.support.v7.app.AlertDialog) ArrayAdapter(android.widget.ArrayAdapter)

Example 50 with Builder

use of android.support.v7.app.AlertDialog.Builder in project Android-DialogFragments by wada811.

the class AlertDialogFragment method onCreateDialog.

@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    if (!isFromBuilder) {
        throw new RuntimeException("Use MaterialAlertDialogFragment$Builder");
    }
    final Bundle args = getArguments();
    final int theme = args.getInt(THEME);
    AlertDialog.Builder builder;
    if (theme == VALUE_NULL || Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        builder = new AlertDialog.Builder(getActivity());
    } else {
        builder = newDialogBuilder(theme);
    }
    iconId = args.getInt(ICON_ID, VALUE_NULL);
    if (iconId != VALUE_NULL) {
        builder.setIcon(iconId);
    }
    final CharSequence title = args.getCharSequence(TITLE);
    boolean useCustomTitle = args.getBoolean(CUSTOM_TITLE);
    if (title != null) {
        builder.setTitle(title);
    } else if (useCustomTitle) {
        setCustomTitle(builder);
    }
    final CharSequence message = args.getCharSequence(MESSAGE);
    if (message != null) {
        builder.setMessage(message);
    }
    final int useInverseBackground = args.getInt(INVERSE_BACKGROUND);
    if (useInverseBackground != VALUE_NULL) {
        builder.setInverseBackgroundForced(useInverseBackground == VALUE_TRUE);
    }
    // View
    setView(builder);
    // List
    setItems(builder);
    setAdapter(builder);
    setSingleChoiceItems(builder);
    setMultiChoiceItems(builder);
    // Buttons
    setPositiveButton(builder);
    setNeutralButton(builder);
    setNegativeButton(builder);
    // Build
    return builder.create();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Bundle(android.os.Bundle) SuppressLint(android.annotation.SuppressLint) NonNull(android.support.annotation.NonNull)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)114 DialogInterface (android.content.DialogInterface)76 View (android.view.View)67 TextView (android.widget.TextView)48 Intent (android.content.Intent)36 RecyclerView (android.support.v7.widget.RecyclerView)27 ListView (android.widget.ListView)23 Dialog (android.app.Dialog)22 LayoutInflater (android.view.LayoutInflater)20 ImageView (android.widget.ImageView)20 EditText (android.widget.EditText)18 SuppressLint (android.annotation.SuppressLint)17 Context (android.content.Context)17 Bundle (android.os.Bundle)15 NonNull (android.support.annotation.NonNull)14 Button (android.widget.Button)13 ArrayList (java.util.ArrayList)12 BrowserDialog (acr.browser.lightning.dialog.BrowserDialog)10 OnClickListener (android.content.DialogInterface.OnClickListener)10 ScrollView (android.widget.ScrollView)10