List of usage examples for android.app Dialog setCanceledOnTouchOutside
public void setCanceledOnTouchOutside(boolean cancel)
From source file:de.schildbach.wallet.ui.WalletAddressDialogFragment.java
@Override public Dialog onCreateDialog(final Bundle savedInstanceState) { final Bundle args = getArguments(); final Address address = (Address) args.getSerializable(KEY_ADDRESS); final String addressStr = address.toBase58(); final String addressLabel = args.getString(KEY_ADDRESS_LABEL); final Dialog dialog = new Dialog(activity); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.wallet_address_dialog); dialog.setCanceledOnTouchOutside(true); final String uri = BitcoinURI.convertToBitcoinURI(address, null, addressLabel, null); final BitmapDrawable bitmap = new BitmapDrawable(getResources(), Qr.bitmap(uri)); bitmap.setFilterBitmap(false);//from w w w. j a va 2s.co m final ImageView imageView = (ImageView) dialog.findViewById(R.id.wallet_address_dialog_image); imageView.setImageDrawable(bitmap); final View labelButtonView = dialog.findViewById(R.id.wallet_address_dialog_label_button); final TextView labelView = (TextView) dialog.findViewById(R.id.wallet_address_dialog_label); final CharSequence label = WalletUtils.formatHash(addressStr, Constants.ADDRESS_FORMAT_GROUP_SIZE, Constants.ADDRESS_FORMAT_LINE_SIZE); labelView.setText(label); labelButtonView.setVisibility(View.VISIBLE); labelButtonView.setOnClickListener(new OnClickListener() { @Override public void onClick(final View v) { final Intent intent = new Intent(Intent.ACTION_SEND); intent.setType("text/plain"); intent.putExtra(Intent.EXTRA_TEXT, addressStr); startActivity(Intent.createChooser(intent, getString(R.string.bitmap_fragment_share))); log.info("wallet address shared via intent: {}", addressStr); } }); final View hintView = dialog.findViewById(R.id.wallet_address_dialog_hint); hintView.setVisibility( getResources().getBoolean(R.bool.show_wallet_address_dialog_hint) ? View.VISIBLE : View.GONE); final View dialogView = dialog.findViewById(R.id.wallet_address_dialog_group); dialogView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View v) { dismiss(); } }); return dialog; }
From source file:org.tigase.mobile.muc.JoinMucDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = new Dialog(getActivity()); dialog.setCancelable(true);//from w w w. j av a 2 s. com dialog.setCanceledOnTouchOutside(true); dialog.setContentView(R.layout.join_room_dialog); dialog.setTitle(getString(R.string.aboutButton)); ArrayList<String> accounts = new ArrayList<String>(); for (Account account : AccountManager.get(getActivity()).getAccountsByType(Constants.ACCOUNT_TYPE)) { accounts.add(account.name); } final Spinner accountSelector = (Spinner) dialog.findViewById(R.id.muc_accountSelector); final Button joinButton = (Button) dialog.findViewById(R.id.muc_joinButton); final Button cancelButton = (Button) dialog.findViewById(R.id.muc_cancelButton); final TextView name = (TextView) dialog.findViewById(R.id.muc_name); final TextView roomName = (TextView) dialog.findViewById(R.id.muc_roomName); final TextView mucServer = (TextView) dialog.findViewById(R.id.muc_server); final TextView nickname = (TextView) dialog.findViewById(R.id.muc_nickname); final TextView password = (TextView) dialog.findViewById(R.id.muc_password); final CheckBox autojoin = (CheckBox) dialog.findViewById(R.id.muc_autojoin); ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_spinner_item, accounts.toArray(new String[] {})); accountSelector.setAdapter(adapter); Bundle data = getArguments(); final boolean editMode = data != null && data.containsKey("editMode") && data.getBoolean("editMode"); final String id = data != null ? data.getString("id") : null; if (data != null) { accountSelector.setSelection(adapter.getPosition(data.getString("account"))); name.setText(data.getString("name")); roomName.setText(data.getString("room")); mucServer.setText(data.getString("server")); nickname.setText(data.getString("nick")); password.setText(data.getString("password")); autojoin.setChecked(data.getBoolean("autojoin")); } if (!editMode) { name.setVisibility(View.GONE); autojoin.setVisibility(View.GONE); } else { joinButton.setText("Save"); } cancelButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); joinButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { if (editMode) { BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString()); final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext()) .getMultiJaxmpp().get(account); Bundle data = new Bundle(); data.putString("id", id); data.putString("account", account.toString()); data.putString("name", name.getText().toString()); data.putString("room", roomName.getText().toString()); data.putString("server", mucServer.getText().toString()); data.putString("nick", nickname.getText().toString()); data.putString("password", password.getText().toString()); data.putBoolean("autojoin", autojoin.isChecked()); ((BookmarksActivity) getActivity()).saveItem(data); dialog.dismiss(); return; } BareJID account = BareJID.bareJIDInstance(accountSelector.getSelectedItem().toString()); final Jaxmpp jaxmpp = ((MessengerApplication) getActivity().getApplicationContext()) .getMultiJaxmpp().get(account); Runnable r = new Runnable() { @Override public void run() { try { Room room = jaxmpp.getModule(MucModule.class).join( roomName.getEditableText().toString(), mucServer.getEditableText().toString(), nickname.getEditableText().toString(), password.getEditableText().toString()); if (task != null) task.execute(room); } catch (Exception e) { Log.w("MUC", "", e); // TODO Auto-generated catch block e.printStackTrace(); } } }; (new Thread(r)).start(); dialog.dismiss(); } }); return dialog; }
From source file:eu.power_switch.gui.dialog.DonationDialog.java
@NonNull @Override//from w w w. ja va2 s. c om public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); rootView = inflater.inflate(R.layout.dialog_donation, null); View.OnClickListener onClickListener = new View.OnClickListener() { @Override public void onClick(View v) { switch (v.getId()) { case R.id.button_donate_10: initiatePurchase(SKU_DONATE_10); // initiatePurchase(SKU_TEST_PURCHASED); break; case R.id.button_donate_5: initiatePurchase(SKU_DONATE_5); // initiatePurchase(SKU_TEST_CANCELED); break; case R.id.button_donate_2: initiatePurchase(SKU_DONATE_2); // initiatePurchase(SKU_TEST_REFUNDED); break; case R.id.button_donate_1: initiatePurchase(SKU_DONATE_1); // initiatePurchase(SKU_TEST_ITEM_UNAVAILABLE); break; default: // initiatePurchase(SKU_TEST_PURCHASED); break; } } }; layoutLoading = (LinearLayout) rootView.findViewById(R.id.layoutLoading); layoutDonationButtons = (LinearLayout) rootView.findViewById(R.id.layout_donate_buttons); donate10 = (Button) rootView.findViewById(R.id.button_donate_10); donate10.setOnClickListener(onClickListener); donate5 = (Button) rootView.findViewById(R.id.button_donate_5); donate5.setOnClickListener(onClickListener); donate2 = (Button) rootView.findViewById(R.id.button_donate_2); donate2.setOnClickListener(onClickListener); donate1 = (Button) rootView.findViewById(R.id.button_donate_1); donate1.setOnClickListener(onClickListener); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); builder.setView(rootView); builder.setTitle(getString(R.string.donate)); builder.setNeutralButton(R.string.close, null); Dialog dialog = builder.create(); dialog.setCanceledOnTouchOutside(false); // prevent close dialog on touch outside window dialog.show(); return dialog; }
From source file:piuk.blockchain.android.ui.SendCoinsActivity.java
@Override protected Dialog onCreateDialog(final int id) { final WebView webView = new WebView(this); webView.loadUrl("file:///android_asset/help_send_coins" + languagePrefix() + ".html"); final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(webView);//from w ww. jav a 2s.c om dialog.setCanceledOnTouchOutside(true); return dialog; }
From source file:com.dspot.declex.example.expenses.fragment.ExpensesListFragment.java
@Click void deleteExpense() { $AlertDialog().title("Are you sure?").message("Are you sure you want to remove the selected expense?") .negativeButton("Cancel").positiveButton("Ok"); Dialog progressDialog = $ProgressDialog().message("Removing...").dialog(); progressDialog.setCanceledOnTouchOutside(false); $PutModel(expense).query("delete").orderBy("delete"); if ($PutModel.Failed) { progressDialog.dismiss();//www .j ava 2s. c om $Toast("An error occurred"); } progressDialog.dismiss(); }
From source file:com.dspot.declex.example.expenses.fragment.ExpensesListFragment.java
@Click void btnSave() {//from ww w .j a v a 2 s . co m hideModals(); String[][] parameters = { { "Creating...", "create", "" }, { "Saving...", "update", "description, comment, amount, date, time" } }; String[] params = expense.getRemoteId() == 0 ? parameters[0] : parameters[1]; Dialog progressDialog = $ProgressDialog().message(params[0]).dialog(); progressDialog.setCanceledOnTouchOutside(false); $PutModel(expense).orderBy(params[1]).fields(params[2]); if ($PutModel.Failed) { progressDialog.dismiss(); $Toast("An error occurred"); } progressDialog.dismiss(); }
From source file:com.infamous.site.activity.MainActivity.java
public Dialog getChangelog() { final Dialog CDialog = new Dialog(MainActivity.this); CDialog.setTitle(getResources().getString(R.string.changelog_title)); CDialog.setContentView(R.layout.changelog); CDialog.setCanceledOnTouchOutside(true); CDialog.setCancelable(true);/*www .j a v a 2 s . c om*/ Button Close = (Button) CDialog.findViewById(R.id.close); Close.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { CDialog.dismiss(); } }); return CDialog; }
From source file:rtandroid.benchmark.ui.dialogs.ProgressDialog.java
@NonNull @Override/*from w w w .ja va2 s. c o m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); // Extract arguments Bundle args = getArguments(); String benchmarkName = args.getString(ARG_BENCHMARK); mCasesTotal = args.getInt(ARG_CASE_COUNT); mCyclesPerRun = args.getInt(ARG_CYCLES); mCyclesTotal = mCasesTotal * mCyclesPerRun; // Prepare views View v = inflater.inflate(R.layout.dialog_progress, null); mTotalProgress = (TextView) v.findViewById(R.id.total_txt); mCurrentProgress = (TextView) v.findViewById(R.id.current_txt); mTotalProgressBar = (ProgressBar) v.findViewById(R.id.total_bar); mTotalProgressBar.setMax(mCasesTotal * mCyclesPerRun); mCurrentProgressBar = (ProgressBar) v.findViewById(R.id.current_bar); mCurrentProgressBar.setMax(mCyclesPerRun); updateProgress(); // Build dialog AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); Dialog dlg = builder.setTitle(benchmarkName).setView(v).setNegativeButton(android.R.string.cancel, this) .create(); dlg.setCanceledOnTouchOutside(false); return dlg; }
From source file:org.lunci.dumbthing.dialog.LinkShareDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { final Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setTitle(getResources().getString(R.string.link_accounts)); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { dialog.getWindow().setIcon(R.drawable.ic_link_share); }// ww w.j av a 2 s. c om return dialog; }
From source file:com.kircherelectronics.accelerationexplorer.activity.NoiseActivity.java
private void showHelpDialog() { Dialog helpDialog = new Dialog(this); helpDialog.setCancelable(true);//from w w w.java 2 s . c om helpDialog.setCanceledOnTouchOutside(true); helpDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); View view = getLayoutInflater().inflate(R.layout.layout_help_noise, null); helpDialog.setContentView(view); helpDialog.show(); }