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.kircherelectronics.gyroscopeexplorer.activity.GyroscopeActivity.java

private void showHelpDialog() {
    Dialog helpDialog = new Dialog(this);

    helpDialog.setCancelable(true);/*from   w w w .j av  a 2s . c om*/
    helpDialog.setCanceledOnTouchOutside(true);
    helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

    View view = getLayoutInflater().inflate(R.layout.layout_help_home, null);

    helpDialog.setContentView(view);

    helpDialog.show();
}

From source file:com.tonyandr.caminoguideoff.map.MapActivity.java

private void infoDialog() {
    String message = "";
    if (mPrefs.contains("location-string")) {
        String[] loc_string = mPrefs.getString("location-string", "").split(",");
        if (loc_string.length > 1) {
            message = "Your current location:\n\n" + "Latitude: " + Double.parseDouble(loc_string[0]) + "\n"
                    + "Longitude: " + Double.parseDouble(loc_string[1]) + "\n\n" + "Last update: "
                    + DateFormat.getTimeInstance().format(new Date(Long.parseLong(loc_string[2])));
        }/*from   w w w. ja  v  a2  s .c om*/
    } else {
        message = "Your current location:\n\nCannot find you, sorry :(\n\nHave you enabled GPS?";
    }
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Info");
    builder.setMessage(message);
    builder.setNegativeButton("OK", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.cancel();
        }
    });
    Dialog alertDialog = builder.create();
    alertDialog.setCanceledOnTouchOutside(false);
    alertDialog.show();
}

From source file:com.tonyandr.caminoguideoff.map.MapActivity.java

private void checkGPS() {
    LocationManager lm = (LocationManager) getSystemService(LOCATION_SERVICE);
    if (!lm.isProviderEnabled(LocationManager.GPS_PROVIDER)
            && !lm.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
        // Build the alert dialog
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("Where are you?");
        builder.setMessage("Please enable Location Services and GPS");
        builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
            @Override/*from  ww w . ja v a  2s . c  o  m*/
            public void onClick(DialogInterface dialog, int which) {
                dialog.cancel();
            }
        });
        builder.setPositiveButton("Enable", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialogInterface, int i) {
                // Show location settings when the user acknowledges the alert dialog
                Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
                startActivity(intent);
            }
        });
        Dialog alertDialog = builder.create();
        alertDialog.setCanceledOnTouchOutside(false);
        alertDialog.show();
    }
}

From source file:com.gumgoose.app.quakebuddy.EarthquakeActivity.java

private void showWhatsNewDialog() {
    // Display the change log for QuakeBuddy on-screen
    Dialog dialog = new Dialog(this, android.R.style.Theme_Dialog);
    dialog.setCanceledOnTouchOutside(true);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(R.layout.dialog_change_log);
    dialog.show();//from w w w. jav  a2s  .  c o m
}

From source file:com.kubotaku.android.code4kyoto5374.fragments.OpenSourceLicenseDialog.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Dialog dialog = getDialog();
    dialog.setCancelable(true);/*from  www .j  a v  a2 s  . c o m*/

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int dialogWidth = (int) (metrics.widthPixels * 0.95f);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;
    dialog.getWindow().setAttributes(lp);

    dialog.setCanceledOnTouchOutside(true);
}

From source file:com.wrmndfzzy.atomize.intro.IntroActivity.java

protected void applicenseDialog() {
    final Dialog aLDialog = new Dialog(IntroActivity.this);
    aLDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    aLDialog.setTitle("License Agreement");
    aLDialog.setCancelable(false);/*w w  w.j  av  a  2  s.  c  om*/
    aLDialog.setCanceledOnTouchOutside(false);
    aLDialog.setContentView(R.layout.app_license_dialog);
    WebView lic = (WebView) aLDialog.findViewById(R.id.atomizeLic);
    Button disagree = (Button) aLDialog.findViewById(R.id.alDialogDisagree);
    Button agree = (Button) aLDialog.findViewById(R.id.alDialogAgree);
    lic.getSettings().setUseWideViewPort(true);
    lic.loadUrl("file:///android_asset/atomizeLicense.html");
    disagree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            aLDialog.dismiss();
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", false);
            e.apply();
            Intent homeIntent = new Intent(Intent.ACTION_MAIN);
            homeIntent.addCategory(Intent.CATEGORY_HOME);
            homeIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
            startActivity(homeIntent);
            IntroActivity.this.finish();
            MainActivity.getInstance().finish();
        }
    });
    agree.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            SharedPreferences.Editor e = getPrefs.edit();
            e.putBoolean("agreedToLicense", true);
            e.apply();
            aLDialog.dismiss();
        }
    });
    aLDialog.show();
}

From source file:co.edu.uniajc.vtf.content.ListSitesFragment.java

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case R.id.action_search:
        Dialog loDialog = this.createDialog();
        loDialog.setCanceledOnTouchOutside(false);
        loDialog.show();/*from w ww.jav a  2 s  .c  o m*/
        OptionsManager loOptions = new OptionsManager(this.getActivity());
        OptionsEntity loOptionsData = loOptions.getOptions();
        EditText loSearchControl = (EditText) loDialog.findViewById(R.id.txtSearch);
        loSearchControl.setText(loOptionsData.getSearch());
        break;
    case R.id.action_refresh:
        ListSitesFragment.this.cboForceUpdate = true;
        this.loadList(LoadActions.LOAD_DATA);
        break;
    }
    return super.onOptionsItemSelected(item);
}

From source file:org.catrobat.catroid.ui.dialogs.AcceptTermsOfUseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle bundle) {
    View view = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_terms_of_use, null);

    TextView termsOfUseUrlTextView = (TextView) view.findViewById(R.id.dialog_terms_of_use_text_view_url);
    termsOfUseUrlTextView.setMovementMethod(LinkMovementMethod.getInstance());

    String termsOfUseUrl = getString(R.string.terms_of_use_link_template, Constants.CATROBAT_TERMS_OF_USE_URL,
            getString(R.string.dialog_terms_of_use_link_text));

    termsOfUseUrlTextView.setText(Html.fromHtml(termsOfUseUrl));

    Dialog termsOfUseDialog = new AlertDialog.Builder(getActivity()).setView(view)
            .setTitle(R.string.dialog_terms_of_use_title)
            .setNeutralButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override/*  www. j  ava 2  s .  c o  m*/
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            }).create();
    termsOfUseDialog.setCanceledOnTouchOutside(true);

    return termsOfUseDialog;
}

From source file:com.inde.shiningdays.MainActivity.java

private void firstOpenAppDialog() {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    // Get the layout inflater
    LayoutInflater inflater = this.getLayoutInflater();

    final View layout = inflater.inflate(R.layout.first_open_app_dialog, null);

    builder.setView(layout).setPositiveButton(R.string.confirm_ok_label, new DialogInterface.OnClickListener() {
        @Override/* w  w w . j a va2s  .  c  o  m*/
        public void onClick(DialogInterface dialog, int which) {
        }
    });

    Dialog d = builder.create();
    d.setCanceledOnTouchOutside(false);
    d.show();
}

From source file:piuk.blockchain.android.ui.WalletActivity.java

@Override
protected Dialog onCreateDialog(final int id) {
    final WebView webView = new WebView(this);
    if (id == DIALOG_HELP)
        webView.loadUrl("file:///android_asset/help" + languagePrefix() + ".html");

    final Dialog dialog = new Dialog(WalletActivity.this);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(webView);/*from  w  w w .  j  a  v a 2  s .c  om*/
    dialog.setCanceledOnTouchOutside(true);

    return dialog;
}