Example usage for android.app Dialog setCanceledOnTouchOutside

List of usage examples for android.app Dialog setCanceledOnTouchOutside

Introduction

In this page you can find the example usage for android.app Dialog setCanceledOnTouchOutside.

Prototype

public void setCanceledOnTouchOutside(boolean cancel) 

Source Link

Document

Sets whether this dialog is canceled when touched outside the window's bounds.

Usage

From source file:com.android.cabapp.fragments.MyAccountFragment.java

void showDialog() {

    final Dialog dialog = new Dialog(mContext);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.device_id_dialog);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);/*  w w w . j a  va  2  s  .c  o  m*/

    etDeviceName = (EditText) dialog.findViewById(R.id.etDeviceName);
    rlBtnSave = (RelativeLayout) dialog.findViewById(R.id.rlbtnSave);
    rlBtnCancel = (RelativeLayout) dialog.findViewById(R.id.rlbtnCancel);

    if (!Util.getPOSDeviceName(mContext).equals(""))
        etDeviceName.setText(Util.getPOSDeviceName(mContext));
    etDeviceName.setSelection(etDeviceName.getText().length());

    // dialog.setTitle("Please enter Serial number");
    rlBtnSave.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            String szDeviceName = etDeviceName.getText().toString().trim();
            if (szDeviceName.isEmpty()) {
                Util.showToastMessage(mContext, "Field cannot be left empty!", Toast.LENGTH_LONG);
            } else if (szDeviceName.length() < 11) {
                Util.showToastMessage(mContext, "Serial number cannot be less than 10!", Toast.LENGTH_LONG);
            } else {
                Util.setPOSDeviceName(mContext, szDeviceName);
                tvDeviceID.setVisibility(View.VISIBLE);
                tvDeviceID.setText(Util.getPOSDeviceName(mContext));
                Util.hideSoftKeyBoard(mContext, rlBtnSave);
                dialog.dismiss();

            }

        }
    });

    rlBtnCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            Util.hideSoftKeyBoard(mContext, v);
            dialog.dismiss();
        }
    });
    dialog.show();

}

From source file:com.kircherelectronics.accelerationfilter.activity.AccelerationPlotActivity.java

private void showHelpDialog() {
    Dialog helpDialog = new Dialog(this);
    helpDialog.setCancelable(true);//from  w w  w.j ava  2s  . c o  m
    helpDialog.setCanceledOnTouchOutside(true);

    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    helpDialog.setContentView(getLayoutInflater().inflate(R.layout.help_dialog_view, null));

    helpDialog.show();
}

From source file:com.nbplus.vbroadlauncher.HomeLauncherActivity.java

/**
 * Method to verify google play services on the device
 * *//*  w w w  .j  a  v  a2s  . c o m*/
private boolean checkPlayServices() {
    int resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(this);
    if (resultCode != ConnectionResult.SUCCESS) {
        if (GooglePlayServicesUtil.isUserRecoverableError(resultCode)) {
            Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, this,
                    PLAY_SERVICES_RESOLUTION_REQUEST);
            dialog.setCancelable(false);
            dialog.setCanceledOnTouchOutside(false);
            dialog.show();
        } else {
            Toast.makeText(getApplicationContext(), "This device is not supported Play Service.",
                    Toast.LENGTH_LONG).show();
            finish();
        }
        return false;
    }
    return true;
}

From source file:eu.power_switch.gui.dialog.ConfigurationDialog.java

@NonNull
@Override/*from   w ww . java  2s .  c o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity()) {
        @Override
        public void onBackPressed() {
            if (modified) {
                // ask to really close
                new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure)
                        .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                getDialog().cancel();
                            }
                        }).setNeutralButton(android.R.string.no, null)
                        .setMessage(R.string.all_changes_will_be_lost).show();
            } else {
                getDialog().cancel();
            }
        }
    };
    dialog.setTitle(getDialogTitle());
    dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside());
    dialog.getWindow().setSoftInputMode(getSoftInputMode());
    dialog.show();
    return dialog;
}

From source file:at.wada811.android.dialogfragments.AbstractDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    Dialog dialog = getDialog();
    if (dialog == null) {
        throw new NullPointerException("Dialog is null! #onCreateDialog must not return null.");
    }//from ww w.  ja va 2s.  co m
    super.onActivityCreated(savedInstanceState);
    if (savedInstanceState != null) {
        isCanceledOnTouchOutside = savedInstanceState.getInt(CANCELED_TOUCH_OUTSIDE, VALUE_NULL);
        useOnShowListener = savedInstanceState.getBoolean(SHOW_LISTENER);
        useOnCancelListener = savedInstanceState.getBoolean(CANCEL_LISTENER);
        useOnDismissListener = savedInstanceState.getBoolean(DISMISS_LISTENER);
        useOnKeyListener = savedInstanceState.getBoolean(KEY_LISTENER);
        extra = savedInstanceState.getBundle(EXTRA);
    }
    if (isCanceledOnTouchOutside != VALUE_NULL) {
        dialog.setCanceledOnTouchOutside(isCanceledOnTouchOutside == VALUE_TRUE);
    }
    if (useOnShowListener) {
        setOnShowListener(dialog);
    }
    if (useOnCancelListener) {
        setOnCancelListener(dialog);
    }
    if (useOnDismissListener) {
        setOnDismissListener(dialog);
    }
    if (useOnKeyListener) {
        setOnKeyListener(dialog);
    }
}

From source file:nf.frex.android.FrexActivity.java

private Dialog createColorsDialog() {
    Dialog dialog = new Dialog(this);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(0));
    dialog.setContentView(R.layout.colors_dialog);
    dialog.setTitle(getString(R.string.colors));
    dialog.setCancelable(true);/*w  w w.  ja v  a 2s  .co m*/
    dialog.setCanceledOnTouchOutside(true);
    return dialog;
}

From source file:com.allwinner.theatreplayer.launcher.activity.LaunchActivity.java

public void openDialog() {
    //      Dialog dialog = null;
    //      Builder builder = new Dialog.Builder(this).setTitle("?").setMessage("??");
    //      dialog = builder.create();
    //      dialog.show();

    Dialog dialog = new Dialog(this, R.style.CustomDialog);
    dialog.setContentView(R.layout.launcher_fail);
    dialog.setOnKeyListener(keylistener);
    dialog.setCanceledOnTouchOutside(false);
    dialog.setCancelable(false);//from ww w .ja  v a  2s.  c om
    dialog.show();
}

From source file:hku.fyp14017.blencode.ui.dialogs.UploadProjectDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getActivity())
            .inflate(hku.fyp14017.blencode.R.layout.dialog_upload_project, null);

    projectRename = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.tv_project_rename);
    projectDescriptionField = (EditText) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.project_description_upload);
    projectUploadName = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.project_upload_name);
    sizeOfProject = (TextView) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.dialog_upload_size_of_project);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView)
            .setTitle(hku.fyp14017.blencode.R.string.upload_project_dialog_title)
            .setPositiveButton(hku.fyp14017.blencode.R.string.upload_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleUploadButtonClick();
                        }/*  ww  w .  j a  v  a  2 s  .  c om*/
                    })
            .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleCancelButtonClick();
                        }
                    })
            .create();

    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            initListeners();

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    initControls();

    return dialog;
}

From source file:org.tigase.mobile.TigaseMobileMessengerActivity.java

@Override
protected Dialog onCreateDialog(int id, Bundle bundle) {
    switch (id) {
    case NEWS_DIALOG: {

        String str = bundle.getString("news_html");

        Builder bldr = new AlertDialog.Builder(this);
        bldr.setTitle("News");
        bldr.setCancelable(true);//from   www.  j  av a  2  s  .c  o m
        bldr.setMessage(Html.fromHtml(str));
        return bldr.create();
    }

    case CONTACT_REMOVE_DIALOG:
        return null;
    case ABOUT_DIALOG: {

        final Dialog dialog = new Dialog(this);
        dialog.setCancelable(true);
        dialog.setCanceledOnTouchOutside(true);

        dialog.setContentView(R.layout.about_dialog);
        dialog.setTitle(getString(R.string.aboutButton));

        TextView tos = (TextView) dialog.findViewById(R.id.aboutTermsOfService);
        tos.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.termsOfServiceURL) + "'>"
                + getResources().getString(R.string.termsOfService) + "</a>"));
        tos.setMovementMethod(LinkMovementMethod.getInstance());

        TextView pp = (TextView) dialog.findViewById(R.id.aboutPrivacyPolicy);
        pp.setText(Html.fromHtml("<a href='" + getResources().getString(R.string.privacyPolicyURL) + "'>"
                + getResources().getString(R.string.privacyPolicy) + "</a>"));
        pp.setMovementMethod(LinkMovementMethod.getInstance());

        Button okButton = (Button) dialog.findViewById(R.id.okButton);
        okButton.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View v) {
                dialog.cancel();
            }
        });
        return dialog;
    }
    default:
        return null;
    }
}

From source file:eu.power_switch.gui.dialog.ConfigurationDialogTabbed.java

@NonNull
@Override/*from w w  w  .jav  a 2  s.c  om*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    // ask to really close
    Dialog dialog = new Dialog(getActivity()) {
        @Override
        public void onBackPressed() {
            if (modified) {
                // ask to really close
                new AlertDialog.Builder(getActivity()).setTitle(R.string.are_you_sure)
                        .setPositiveButton(android.R.string.yes, new OnClickListener() {
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                getDialog().cancel();
                            }
                        }).setNeutralButton(android.R.string.no, null)
                        .setMessage(R.string.all_changes_will_be_lost).show();
            } else {
                getDialog().cancel();
            }
        }
    };
    dialog.setTitle(getDialogTitle());
    dialog.setCanceledOnTouchOutside(isCancelableOnTouchOutside());
    dialog.getWindow().setSoftInputMode(getSoftInputMode());

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(dialog.getWindow().getAttributes());
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    dialog.show();
    dialog.getWindow().setAttributes(lp);

    dialog.show();
    return dialog;
}