Java Code Examples for android.support.v7.app.AlertDialog.setCanceledOnTouchOutside()

The following are Jave code examples for showing how to use setCanceledOnTouchOutside() of the android.support.v7.app.AlertDialog class. You can vote up the examples you like. Your votes will be used in our system to get more good examples.
Example 1
Project: mobile-store   File: CrashReportActivity.java   Source Code and License Vote up 6 votes
@Override
protected void init(Bundle savedInstanceState) {
    super.init(savedInstanceState);

    final AlertDialog dialog = new AlertDialog.Builder(this)
            .setTitle(R.string.crash_dialog_title)
            .setView(R.layout.crash_report_dialog)
            .setPositiveButton(R.string.ok, this)
            .setNegativeButton(R.string.cancel, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    dialog.setOnDismissListener(this);
    dialog.show();

    comment = (EditText) dialog.findViewById(android.R.id.input);
    if (savedInstanceState != null) {
        comment.setText(savedInstanceState.getString(STATE_COMMENT));
    }
}
 
Example 2
Project: GxIconDIY   File: UserDialog.java   Source Code and License Vote up 6 votes
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) getActivity().getLayoutInflater()
            .inflate(R.layout.dialog_key, null);
    etUser = (EditText) viewGroup.findViewById(R.id.et_user);

    AlertDialog alertDialog = new AlertDialog.Builder(getContext())
            .setTitle(R.string.dlg_title_set_key)
            .setView(viewGroup)
            .setPositiveButton(R.string.dlg_bt_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (onContinueListener != null) {
                        onContinueListener.onContinue(etUser.getText().toString().trim());
                    }
                }
            })
            .create();
    alertDialog.setCanceledOnTouchOutside(false);

    return alertDialog;
}
 
Example 3
Project: papara-android   File: MainActivity.java   Source Code and License Vote up 6 votes
private void showResultDialog(final String message, int code) {

        try {
            final AlertDialog dialog = new AlertDialog.Builder(this)
                    .setTitle(getString(com.mobillium.paparasdk.R.string.title))
                    .setMessage(message + " (" + code + ")")
                    .setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();

            dialog.setCanceledOnTouchOutside(false);
            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
Example 4
Project: papara-android   File: OptionsActivity.java   Source Code and License Vote up 6 votes
private void showResultDialog(final String message, int code) {

        try {
            final AlertDialog dialog = new AlertDialog.Builder(this)
                    .setTitle(getString(com.mobillium.paparasdk.R.string.title))
                    .setMessage(message + " (" + code + ")")
                    .setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();

            dialog.setCanceledOnTouchOutside(false);
            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
Example 5
Project: papara-android   File: PaymentActivity.java   Source Code and License Vote up 6 votes
private void showResultDialog(final String message, int code) {

        try {
            final AlertDialog dialog = new AlertDialog.Builder(this)
                    .setTitle(getString(com.mobillium.paparasdk.R.string.title))
                    .setMessage(message + " (" + code + ")")
                    .setPositiveButton(getString(R.string.done), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            dialogInterface.dismiss();
                        }
                    })
                    .create();

            dialog.setCanceledOnTouchOutside(false);
            dialog.show();

        } catch (Exception ex) {
            ex.printStackTrace();
        }
    }
 
Example 6
Project: GxIconAndroid   File: UserDialog.java   Source Code and License Vote up 6 votes
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) getActivity().getLayoutInflater()
            .inflate(R.layout.dialog_key, null);
    etUser = (EditText) viewGroup.findViewById(R.id.et_user);

    AlertDialog alertDialog = new AlertDialog.Builder(getContext())
            .setTitle(R.string.dlg_title_set_key)
            .setView(viewGroup)
            .setPositiveButton(R.string.dlg_bt_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (onContinueListener != null) {
                        onContinueListener.onContinue(etUser.getText().toString().trim());
                    }
                }
            })
            .create();
    alertDialog.setCanceledOnTouchOutside(false);

    return alertDialog;
}
 
Example 7
Project: NanoIconPack   File: UserDialog.java   Source Code and License Vote up 6 votes
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    ViewGroup viewGroup = (ViewGroup) getActivity().getLayoutInflater()
            .inflate(R.layout.dialog_key, null);
    etUser = (EditText) viewGroup.findViewById(R.id.et_user);

    AlertDialog alertDialog = new AlertDialog.Builder(getContext())
            .setTitle(R.string.dlg_title_set_key)
            .setView(viewGroup)
            .setPositiveButton(R.string.dlg_bt_ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    if (onContinueListener != null) {
                        onContinueListener.onContinue(etUser.getText().toString().trim());
                    }
                }
            })
            .create();
    alertDialog.setCanceledOnTouchOutside(false);

    return alertDialog;
}
 
Example 8
Project: VBrowser-Android   File: ViewUtil.java   Source Code and License Vote up 5 votes
/**
 * 弹出一个带确认和取消的dialog
 * @param context
 * @param title
 * @param msg
 * @param okbutton
 * @param ok 点击确定事件
 * @param nobutton
 * @param no 点击取消事件
 * @return
 */
public static AlertDialog openConfirmDialog(Context context, String title,
                                            String msg, String okbutton, DialogInterface.OnClickListener ok, String nobutton,
                                            DialogInterface.OnClickListener no) {
    AlertDialog.Builder builder = new AlertDialog.Builder(context);
    builder.setTitle(title);
    builder.setMessage("\n" + msg + "\n");
    builder.setNegativeButton(okbutton, ok);
    builder.setNeutralButton(nobutton, no);
    AlertDialog loadWaitDialog = builder.create();
    loadWaitDialog.setCanceledOnTouchOutside(false);
    loadWaitDialog.show();
    return loadWaitDialog;
}
 
Example 9
Project: CipherSharedPrefs   File: MainActivity.java   Source Code and License Vote up 5 votes
@Override
public void onInitialized(MainPresenter presenter, MainViewState viewState) {
    if (!presenter.isInitialized()) {
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle(R.string.enter_key);
        builder.setMessage(R.string.key_requirments_message);

        EditText editText = new EditText(this);
        editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(16)});
        builder.setView(editText);

        builder.setPositiveButton(R.string.apply, null);

        AlertDialog dialog = builder.create();
        dialog.setCancelable(false);
        dialog.setCanceledOnTouchOutside(false);
        dialog.show();

        dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(v -> {
            if (editText.getText().length() == 16) {
                String key = editText.getText().toString();
                presenter.initializeWithKey(key);
                presenter.getValues();
                dialog.dismiss();
            } else {
                Toast.makeText(this, R.string.bad_key, Toast.LENGTH_LONG).show();
            }
        });

        FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) editText.getLayoutParams();
        int margin = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 16f, getResources().getDisplayMetrics());
        layoutParams.setMargins(margin, margin, margin, margin);
        editText.requestLayout();
    } else {
        if (!viewState.isPrefsLoaded() && !presenter.isTaskRunning(MainPresenter.TASK_GET_RUNNING)) {
            presenter.getValues();
        }
    }
}
 
Example 10
Project: android_nextgis_mobile   File: PermissionUtil.java   Source Code and License Vote up 5 votes
public static void requestPermissions(
        final Activity activity,
        int title,
        int message,
        final int requestCode,
        final String... permissions)
{
    boolean shouldShowDialog = false;
    for (String permission : permissions) {
        if (ActivityCompat.shouldShowRequestPermissionRationale(activity, permission)) {
            shouldShowDialog = true;
            break;
        }
    }

    if (shouldShowDialog) {
        AlertDialog builder = new AlertDialog.Builder(activity).setTitle(title)
                .setMessage(message)
                .setPositiveButton(android.R.string.ok, null)
                .create();
        builder.setCanceledOnTouchOutside(false);
        builder.show();

        builder.setOnDismissListener(new DialogInterface.OnDismissListener()
        {
            @Override
            public void onDismiss(DialogInterface dialog)
            {
                ActivityCompat.requestPermissions(activity, permissions, requestCode);
            }
        });
    } else {
        ActivityCompat.requestPermissions(activity, permissions, requestCode);
    }
}
 
Example 11
Project: chromium-for-android-56-debug-video   File: OtherFormsOfHistoryDialogFragment.java   Source Code and License Vote up 5 votes
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    super.onCreateDialog(savedInstanceState);
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View view = inflater.inflate(R.layout.other_forms_of_history_dialog, null);

    // Linkify the <link></link> span in the dialog text.
    TextView textView = (TextView) view.findViewById(R.id.text);
    final SpannableString textWithLink = SpanApplier.applySpans(
            textView.getText().toString(),
            new SpanApplier.SpanInfo("<link>", "</link>", new NoUnderlineClickableSpan() {
                @Override
                public void onClick(View widget) {
                    new TabDelegate(false /* incognito */).launchUrl(
                            WEB_HISTORY_URL, TabLaunchType.FROM_CHROME_UI);
                }
            }));

    textView.setText(textWithLink);
    textView.setMovementMethod(LinkMovementMethod.getInstance());

    // Construct the dialog.
    AlertDialog dialog = new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme)
            .setView(view)
            .setTitle(R.string.clear_browsing_data_history_dialog_title)
            .setPositiveButton(
                    R.string.ok_got_it, this)
            .create();

    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}
 
Example 12
Project: updateUtils   File: UpdateAgent.java   Source Code and License Vote up 5 votes
@Override
public void onPrompt(UpdateAgent agent) {
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new OnPromptClick(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}
 
Example 13
Project: GitHub   File: UpdateAgent.java   Source Code and License Vote up 4 votes
@Override
public void prompt(IUpdateAgent agent) {
    if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
        return;
    }
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}
 
Example 14
Project: update-master   File: UpdateAgent.java   Source Code and License Vote up 4 votes
@Override
public void prompt(IUpdateAgent agent) {
    if (mContext instanceof Activity && ((Activity) mContext).isFinishing()) {
        return;
    }
    final UpdateInfo info = agent.getInfo();
    String size = Formatter.formatShortFileSize(mContext, info.size);
    String content = String.format("最新版本:%1$s\n新版本大小:%2$s\n\n更新内容\n%3$s", info.versionName, size, info.updateContent);

    final AlertDialog dialog = new AlertDialog.Builder(mContext).create();

    dialog.setTitle("应用更新");
    dialog.setCancelable(false);
    dialog.setCanceledOnTouchOutside(false);


    float density = mContext.getResources().getDisplayMetrics().density;
    TextView tv = new TextView(mContext);
    tv.setMovementMethod(new ScrollingMovementMethod());
    tv.setVerticalScrollBarEnabled(true);
    tv.setTextSize(14);
    tv.setMaxHeight((int) (250 * density));

    dialog.setView(tv, (int) (25 * density), (int) (15 * density), (int) (25 * density), 0);


    DialogInterface.OnClickListener listener = new DefaultPromptClickListener(agent, true);

    if (info.isForce) {
        tv.setText("您需要更新应用才能继续使用\n\n" + content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "确定", listener);
    } else {
        tv.setText(content);
        dialog.setButton(DialogInterface.BUTTON_POSITIVE, "立即更新", listener);
        dialog.setButton(DialogInterface.BUTTON_NEGATIVE, "以后再说", listener);
        if (info.isIgnorable) {
            dialog.setButton(DialogInterface.BUTTON_NEUTRAL, "忽略该版", listener);
        }
    }
    dialog.show();
}