Java Code Examples for android.app.Dialog#setCanceledOnTouchOutside()
The following examples show how to use
android.app.Dialog#setCanceledOnTouchOutside() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BaseDialog.java From EosCommander with MIT License | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // the content final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
Example 2
Source File: MainActivity.java From FaceSlim with GNU General Public License v2.0 | 6 votes |
private void onCoachMark() { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); dialog.setContentView(R.layout.coach_mark); dialog.setCanceledOnTouchOutside(true); //for dismissing anywhere you touch View masterView = dialog.findViewById(R.id.coach_mark_master_view); masterView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { dialog.dismiss(); // notifications setup notice Toast.makeText(getApplicationContext(), getString(R.string.setup_notifications), Toast.LENGTH_SHORT).show(); } }); dialog.show(); }
Example 3
Source File: DialogSearching.java From BigApp_WordPress_Android with Apache License 2.0 | 6 votes |
private void init(Context context) { View view = LayoutInflater.from(context).inflate( R.layout.z_dialog_searching, null); mEt_content = (TextView) view.findViewById(R.id.tv_content); dialog = new Dialog(context, R.style.DialogStyle); dialog.setCancelable(false); dialog.setCanceledOnTouchOutside(false); dialog.setContentView(view); Window window = dialog.getWindow(); WindowManager.LayoutParams lp = window.getAttributes(); lp.width = ScreenTools.getScreenParams(context).width / 3; lp.height = lp.width; window.setBackgroundDrawableResource(R.drawable.z_shape_searching); window.setWindowAnimations(R.style.AnimEnterExit); }
Example 4
Source File: DialogCreator.java From jmessage-android-uikit with MIT License | 6 votes |
public static Dialog createDeleteMemberDialog(Context context, View.OnClickListener listener, boolean isSingle) { AlertDialog.Builder builder = new AlertDialog.Builder(context); final LayoutInflater inflater = LayoutInflater.from(context); View view = inflater.inflate(IdHelper.getLayout(context, "jmui_dialog_base_with_button"), null); builder.setView(view); TextView title = (TextView) view.findViewById(IdHelper.getViewID(context, "jmui_title")); if (isSingle) { title.setText(context.getString(IdHelper.getString(context, "jmui_delete_member_confirm_hint"))); } else { title.setText(context.getString(IdHelper.getString(context, "jmui_delete_confirm_hint"))); } final Button cancel = (Button) view.findViewById(IdHelper.getViewID(context, "jmui_cancel_btn")); final Button commit = (Button) view.findViewById(IdHelper.getViewID(context, "jmui_commit_btn")); cancel.setOnClickListener(listener); commit.setOnClickListener(listener); commit.setText(context.getString(IdHelper.getString(context, "jmui_confirm"))); final Dialog dialog = builder.create(); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); return dialog; }
Example 5
Source File: BaseDialog.java From android-mvp-architecture with Apache License 2.0 | 6 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // the content final RelativeLayout root = new RelativeLayout(getActivity()); root.setLayoutParams(new ViewGroup.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); // creating the fullscreen dialog final Dialog dialog = new Dialog(getContext()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(root); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); dialog.getWindow().setLayout( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); } dialog.setCanceledOnTouchOutside(false); return dialog; }
Example 6
Source File: LoginActivity.java From MaterialQQLite with Apache License 2.0 | 6 votes |
private void initLoginingDlg() { m_dlgLogining = new Dialog(this, R.style.dialog); m_dlgLogining.setContentView(R.layout.loginingdlg); // CircularProgress cp= (CircularProgress) findViewById(R.id.progress_circular_login); // cp.setColor(color_theme); Window win = m_dlgLogining.getWindow(); WindowManager.LayoutParams params = win.getAttributes(); int cxScreen = getScreenWidth(this); int cyScreen = getScreenHeight(this); int cy = (int) getResources().getDimension(R.dimen.cyloginingdlg); int lrMargin = (int) getResources().getDimension(R.dimen.loginingdlg_lr_margin); int tMargin = (int) getResources().getDimension(R.dimen.loginingdlg_t_margin); params.x = -(cxScreen - lrMargin * 2) / 2; params.y = (-(cyScreen - cy) / 2) + tMargin; params.width = cxScreen; params.height = cy; m_dlgLogining.setCanceledOnTouchOutside(true); //设置点击Dialog外部任意区域关闭Dialog //m_dlgLogining.setCancelable(false); // 设置为false,按返回键不能退出 }
Example 7
Source File: DialogManager.java From Gizwits-SmartSocket_Android with MIT License | 6 votes |
/** * 注销对话框. * * @param ctx the ctx * @param r 右按钮监听器 * @return the logout dialog */ public static Dialog getLogoutDialog(final Activity ctx, OnClickListener r) { final Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog) { }; LayoutInflater layoutInflater = LayoutInflater.from(ctx); View v = layoutInflater.inflate(R.layout.dialog_logout, null); Button leftBtn = (Button) v.findViewById(R.id.left_btn); Button rightBtn = (Button) v.findViewById(R.id.right_btn); leftBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { dismissDialog(ctx, dialog); } }); rightBtn.setOnClickListener(r); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); dialog.setContentView(v); return dialog; }
Example 8
Source File: VideoMerger.java From CuXtomCam with Apache License 2.0 | 6 votes |
@Override protected void onPreExecute() { super.onPreExecute(); progressDialog = new Dialog(context); progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); View view = LayoutInflater.from(context).inflate( R.layout.layout_fullscreenprogressbar, null); tv_loadingMessage = (TextView) view .findViewById(R.id.tv_loadingMessage); tv_loadingMessage.setText("Merging 0%"); progressDialog.setContentView(view); progressDialog.getWindow().setBackgroundDrawable( new ColorDrawable(android.graphics.Color.TRANSPARENT)); progressDialog.setCanceledOnTouchOutside(false); progressDialog.setCancelable(false); progressDialog.show(); }
Example 9
Source File: MainActivity.java From shinny-futures-android with GNU General Public License v3.0 | 6 votes |
/** * date: 2019/6/15 * author: chenli * description: 显示结算单 */ public void showSettlement() { String settlement = sDataManager.getBroker().getSettlement(); boolean confirmed = sDataManager.getBroker().isConfirmed(); if (settlement != null && !confirmed) { sDataManager.getBroker().setConfirmed(true); final Dialog dialog = new Dialog(this, R.style.AppTheme); View viewDialog = View.inflate(this, R.layout.view_dialog_confirm, null); dialog.setContentView(viewDialog); TextView textView = viewDialog.findViewById(R.id.settlement_info); textView.setText(settlement); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); viewDialog.findViewById(R.id.confirm).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { BaseApplication.getmTDWebSocket().sendReqConfirmSettlement(); dialog.dismiss(); } }); if (!dialog.isShowing()) dialog.show(); } }
Example 10
Source File: TrackToRoute.java From Androzic with GNU General Public License v3.0 | 6 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View rootView = inflater.inflate(R.layout.act_track_to_route, container); algA = (RadioButton) rootView.findViewById(R.id.alg_a); //algB = (RadioButton) rootView.findViewById(R.id.alg_b); algA.setChecked(true); sensitivity = (SeekBar) rootView.findViewById(R.id.sensitivity); Button generate = (Button) rootView.findViewById(R.id.generate_button); generate.setOnClickListener(saveOnClickListener); final Dialog dialog = getDialog(); dialog.setTitle(R.string.savetrack_name); dialog.setCanceledOnTouchOutside(false); return rootView; }
Example 11
Source File: PermissionHelper.java From openScale with GNU General Public License v3.0 | 6 votes |
public static boolean requestLocationServicePermission(final Fragment fragment) { LocationManager locationManager = (LocationManager) fragment.getActivity().getSystemService(LOCATION_SERVICE); if (!(locationManager.isProviderEnabled(LocationManager.GPS_PROVIDER) || locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER))) { AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext()); builder.setTitle(R.string.permission_bluetooth_info_title); builder.setIcon(R.drawable.ic_preferences_about); builder.setMessage(R.string.permission_location_service_info); builder.setPositiveButton(R.string.label_ok, 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); fragment.getActivity().startActivity(intent); } }); Dialog alertDialog = builder.create(); alertDialog.setCanceledOnTouchOutside(false); alertDialog.show(); return false; } return true; }
Example 12
Source File: MessageActivity.java From sctalk with Apache License 2.0 | 5 votes |
/** * @Description 初始化音量对话框 */ private void initSoundVolumeDlg() { soundVolumeDialog = new Dialog(this, R.style.SoundVolumeStyle); soundVolumeDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); soundVolumeDialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); soundVolumeDialog.setContentView(R.layout.tt_sound_volume_dialog); soundVolumeDialog.setCanceledOnTouchOutside(true); soundVolumeImg = (ImageView) soundVolumeDialog.findViewById(R.id.sound_volume_img); soundVolumeLayout = (LinearLayout) soundVolumeDialog.findViewById(R.id.sound_volume_bk); }
Example 13
Source File: BaseDialogFragment.java From mvvm-template with GNU General Public License v3.0 | 5 votes |
@Override public void setCancelable(boolean cancelable) { super.setCancelable(cancelable); Dialog dialog = getDialog(); if (dialog != null) { dialog.setCanceledOnTouchOutside(cancelable); } }
Example 14
Source File: WarningDialogFragment.java From DeviceConnect-Android with MIT License | 5 votes |
@SuppressLint("InflateParams") @Override public Dialog onCreateDialog(final Bundle savedInstanceState) { String packageName = getActivity().getIntent().getStringExtra(DConnectObservationService.PARAM_PACKAGE_NAME); int port = getActivity().getIntent().getIntExtra(DConnectObservationService.PARAM_PORT, -1); LayoutInflater inflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE); final View view = inflater.inflate(R.layout.activity_warning_dialog, null); final TextView appNameView = (TextView) view.findViewById(R.id.alert_message); final ImageView appIconView = (ImageView) view.findViewById(R.id.alert_icon); String appName = getAppName(packageName); Drawable icon = null; try { icon = getActivity().getPackageManager().getApplicationIcon(packageName); } catch (NameNotFoundException e) { icon = getActivity().getResources().getDrawable(R.drawable.icon); } appNameView.setText(appName); appIconView.setImageDrawable(icon); AlertDialog.Builder builder = new AlertDialog.Builder(getActivity()); Dialog dialog = builder.setTitle(getString(R.string.activity_warning)) .setMessage(getString(R.string.activity_warning_mess)).setView(view) .setPositiveButton(R.string.activity_warning_ok, (dialogs, which) -> { CheckBox box = view.findViewById(R.id.disable_observer); mDisableFlg = box.isChecked(); dismiss(); }).create(); dialog.setCanceledOnTouchOutside(false); return dialog; }
Example 15
Source File: CommentDialogFragment.java From PureComment with MIT License | 5 votes |
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog mDialog = new Dialog(getActivity(), R.style.BottomDialog); mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); mDialog.setContentView(R.layout.dialog_fragment_comment_layout); mDialog.setCanceledOnTouchOutside(true); Window window = mDialog.getWindow(); WindowManager.LayoutParams layoutParams; if (window != null) { layoutParams = window.getAttributes(); layoutParams.gravity = Gravity.BOTTOM; layoutParams.width = WindowManager.LayoutParams.MATCH_PARENT; window.setAttributes(layoutParams); } commentEditText = (EditText) mDialog.findViewById(R.id.edit_comment); photoButton = (ImageView) mDialog.findViewById(R.id.image_btn_photo); atButton = (ImageView) mDialog.findViewById(R.id.image_btn_at); sendButton = (ImageView) mDialog.findViewById(R.id.image_btn_comment_send); fillEditText(); setSoftKeyboard(); commentEditText.addTextChangedListener(mTextWatcher); photoButton.setOnClickListener(this); atButton.setOnClickListener(this); sendButton.setOnClickListener(this); return mDialog; }
Example 16
Source File: LatinIME.java From Android-Keyboard with Apache License 2.0 | 5 votes |
public void showSubtypeSwitchDialog() { // prepare dialog final Dialog dialog = new Dialog( DialogUtils.getPlatformDialogThemeContext(this), R.style.CustomDialogTheme ); SubtypeSwitchDialogView dialogView = (SubtypeSwitchDialogView) getLayoutInflater().inflate(R.layout.subtype_switch, null); dialogView.setListener(this); dialog.setContentView(dialogView); dialog.setCancelable(true); dialog.setCanceledOnTouchOutside(true); dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT)); // show dialog final IBinder windowToken = KeyboardSwitcher.getInstance().getMainKeyboardView().getWindowToken(); if (windowToken == null) { return; } final Window window = dialog.getWindow(); window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM); if (android.os.Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); window.setStatusBarColor(Color.TRANSPARENT); window.setNavigationBarColor(Color.TRANSPARENT); } WindowManager.LayoutParams lp = window.getAttributes(); lp.token = windowToken; lp.type = WindowManager.LayoutParams.TYPE_APPLICATION_ATTACHED_DIALOG; lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.MATCH_PARENT; mSubtypeSwitchDialog = dialog; dialog.show(); }
Example 17
Source File: DialogManager.java From Gizwits-SmartSocket_Android with MIT License | 5 votes |
/** * 设备故障无法使用,拨打客服热线 对话框. * * @param ctx the ctx * @param contentStr 对话框内容 * @param r 右按钮监听器 * @return the device errir dialog */ public static Dialog getDeviceErrirDialog(final Activity ctx, String contentStr, OnClickListener r) { final Dialog dialog = new Dialog(ctx, R.style.noBackgroundDialog) { }; LayoutInflater layoutInflater = LayoutInflater.from(ctx); View v = layoutInflater.inflate(R.layout.dialog_alarm_for_conditioner, null); TextView content = (TextView) v.findViewById(R.id.fault_content); Button leftBtn = (Button) v.findViewById(R.id.fault_left_btn); Button rightBtn = (Button) v.findViewById(R.id.fault_right_btn); content.setText(contentStr); leftBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { dismissDialog(ctx, dialog); } }); rightBtn.setOnClickListener(r); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCanceledOnTouchOutside(false); dialog.setCancelable(false); dialog.setContentView(v); return dialog; }
Example 18
Source File: AbsDialogFragment.java From cloudflare-scrape-Android with MIT License | 5 votes |
@NonNull @Override public Dialog onCreateDialog(@Nullable Bundle savedInstanceState) { mContext = getActivity(); Dialog dialog = new Dialog(mContext,getDialogStyle()); mRootView = LayoutInflater.from(mContext).inflate(getLayoutId(), null); dialog.setContentView(mRootView); dialog.setCancelable(canCancel()); dialog.setCanceledOnTouchOutside(canCancel()); setWindowAttributes(dialog.getWindow()); return dialog; }
Example 19
Source File: SelectDeviceDialog.java From EFRConnect-android with Apache License 2.0 | 5 votes |
@NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.setCanceledOnTouchOutside(true); if (dialog.getWindow() != null) { dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT)); } return dialog; }
Example 20
Source File: TrackExportDialog.java From Androzic with GNU General Public License v3.0 | 4 votes |
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()); View view = inflater.inflate(R.layout.dlg_exporttrack, container); nameText = (EditText) view.findViewById(R.id.name_text); nameText.setFilters(new InputFilter[] { filter }); nameText.addTextChangedListener(this); formatSpinner = (Spinner) view.findViewById(R.id.format_spinner); color = (ColorButton) view.findViewById(R.id.color_button); color.setColor(prefs.getInt(getString(R.string.pref_tracking_currentcolor), getResources().getColor(R.color.currenttrack)), Color.RED); Calendar startTime = Calendar.getInstance(); startTime.setTimeInMillis(locationService.getTrackStartTime()); Calendar endTime = Calendar.getInstance(); endTime.setTimeInMillis(locationService.getTrackEndTime()); fromSliderContainer = (SliderContainer) view.findViewById(R.id.fromSliderContainer); fromSliderContainer.setMinuteInterval(1); fromSliderContainer.setTime(endTime); fromSliderContainer.setMinTime(startTime); fromSliderContainer.setMaxTime(endTime); fromSliderContainer.setMinuteInterval(60); fromSliderContainer.setOnTimeChangeListener(onFromTimeChangeListener); tillSliderContainer = (SliderContainer) view.findViewById(R.id.tillSliderContainer); tillSliderContainer.setMinuteInterval(1); tillSliderContainer.setTime(endTime); tillSliderContainer.setMinTime(startTime); tillSliderContainer.setMaxTime(endTime); tillSliderContainer.setMinuteInterval(60); tillSliderContainer.setOnTimeChangeListener(onTillTimeChangeListener); final Dialog dialog = getDialog(); Button cancelButton = (Button) view.findViewById(R.id.cancel_button); cancelButton.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.cancel(); } }); saveButton = (Button) view.findViewById(R.id.save_button); saveButton.setOnClickListener(saveOnClickListener); validName = false; validDates = true; updateSaveButton(); dialog.setTitle(R.string.exporttrack_name); dialog.setCanceledOnTouchOutside(false); return view; }