List of usage examples for android.app Dialog getWindow
public @Nullable Window getWindow()
From source file:org.dmfs.tasks.InputTextDialogFragment.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); // hides the actual dialog title, we have one already... dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE); // we want to listen to clicks on back button dialog.setOnKeyListener(this); return dialog; }
From source file:com.kubotaku.android.code4kyoto5374.fragments.NotifySettingsDialogFragment.java
@Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); final Dialog dialog = getDialog(); dialog.setCancelable(true);/*from w w w.j ava 2s .co m*/ DisplayMetrics metrics = getResources().getDisplayMetrics(); int dialogWidth = (int) (metrics.widthPixels * 0.9f); WindowManager.LayoutParams lp = dialog.getWindow().getAttributes(); lp.width = dialogWidth; dialog.getWindow().setAttributes(lp); }
From source file:com.adithya321.sharesanalysis.fragments.FundFlowFragment.java
@Nullable @Override/*from ww w . j a va2 s. com*/ public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { ViewGroup root = (ViewGroup) inflater.inflate(R.layout.fragment_fund_flow, container, false); Window window = getActivity().getWindow(); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) window.setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark)); ((AppCompatActivity) getActivity()).getSupportActionBar() .setBackgroundDrawable(new ColorDrawable(getResources().getColor(R.color.colorPrimary))); databaseHandler = new DatabaseHandler(getContext()); fundIn = (TextView) root.findViewById(R.id.fund_in); fundOut = (TextView) root.findViewById(R.id.fund_out); fundsListView = (ListView) root.findViewById(R.id.funds_list_view); setViews(); FloatingActionButton addFundFab = (FloatingActionButton) root.findViewById(R.id.add_fund_fab); addFundFab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { final Dialog dialog = new Dialog(getContext()); dialog.setTitle("Add Fund Flow"); dialog.setContentView(R.layout.dialog_add_fund); dialog.getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.WRAP_CONTENT); dialog.show(); Calendar calendar = Calendar.getInstance(); year_start = calendar.get(Calendar.YEAR); month_start = calendar.get(Calendar.MONTH) + 1; day_start = calendar.get(Calendar.DAY_OF_MONTH); final Button selectDate = (Button) dialog.findViewById(R.id.select_date); selectDate.setText(new StringBuilder().append(day_start).append("/").append(month_start).append("/") .append(year_start)); selectDate.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Dialog dialog = new DatePickerDialog(getActivity(), onDateSetListener, year_start, month_start - 1, day_start); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { selectDate.setText(new StringBuilder().append(day_start).append("/") .append(month_start).append("/").append(year_start)); } }); dialog.show(); } }); final EditText amount = (EditText) dialog.findViewById(R.id.amount); Button addFundBtn = (Button) dialog.findViewById(R.id.add_fund_btn); addFundBtn.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Fund fund = new Fund(); fund.setId(databaseHandler.getNextKey("fund")); String stringStartDate = year_start + " " + month_start + " " + day_start; DateFormat format = new SimpleDateFormat("yyyy MM dd", Locale.ENGLISH); try { Date date = format.parse(stringStartDate); fund.setDate(date); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Date", Toast.LENGTH_SHORT).show(); return; } try { fund.setAmount(Double.parseDouble(amount.getText().toString())); } catch (Exception e) { Toast.makeText(getActivity(), "Invalid Amount", Toast.LENGTH_SHORT).show(); return; } if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_in)).isChecked()) fund.setType("in"); else if (((RadioButton) dialog.findViewById(R.id.radioBtn_fund_out)).isChecked()) fund.setType("out"); else { Toast.makeText(getActivity(), "Invalid Fund Type", Toast.LENGTH_SHORT).show(); return; } databaseHandler.addFund(fund); setViews(); dialog.dismiss(); } }); } }); return root; }
From source file:com.robopupu.api.mvp.ViewCompatDialogFragment.java
@NonNull @Override//from ww w. j a va 2 s .c o m public Dialog onCreateDialog(final Bundle inState) { final Dialog dialog = createDialog(inState); final Window window = dialog.getWindow(); window.requestFeature(Window.FEATURE_NO_TITLE); return dialog; }
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.jav a2 s . c o m*/ return dialog; }
From source file:color.kidpaint.com.kidpaintcolor.dialog.TextToolDialog.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { LayoutInflater inflater = getActivity().getLayoutInflater(); AlertDialog.Builder builder = new CustomAlertDialogBuilder(mContext); builder.setTitle(R.string.text_tool_dialog_title); final View view = inflater.inflate(R.layout.dialog_text_tool, null); mTextEditText = (EditText) view.findViewById(R.id.text_tool_dialog_input_text); mTextEditText.addTextChangedListener(new TextWatcher() { @Override// www . j av a 2 s. c o m public void beforeTextChanged(CharSequence s, int start, int count, int after) { } @Override public void onTextChanged(CharSequence s, int start, int before, int count) { } @Override public void afterTextChanged(Editable s) { String text = mTextEditText.getText().toString(); mOnTextToolDialogChangedListener.setText(text); mText = text; } }); mFontSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_font); ArrayAdapter<CharSequence> fontAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_font_array, android.R.layout.simple_spinner_item); fontAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mFontSpinner.setAdapter(fontAdapter); mFontSpinner.setBackgroundColor(Color.GRAY); mFontSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { String font = parent.getItemAtPosition(position).toString(); mOnTextToolDialogChangedListener.setFont(font); mFontIndex = position; if (mFontSpinnerInitialized) hideKeyboard(); else mFontSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); mUnderlinedToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_underlined); mUnderlinedToggleButton.setTextOn(Html .fromHtml("<u>" + getResources().getString(R.string.text_tool_dialog_underline_shortcut) + "</u>")); mUnderlinedToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean underlined = mUnderlinedToggleButton.isChecked(); mOnTextToolDialogChangedListener.setUnderlined(underlined); mUnderlined = underlined; hideKeyboard(); } }); mItalicToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_italic); mItalicToggleButton.setTextOn(Html .fromHtml("<i>" + getResources().getString(R.string.text_tool_dialog_italic_shortcut) + "</i>")); mItalicToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean italic = mItalicToggleButton.isChecked(); mOnTextToolDialogChangedListener.setItalic(italic); mItalic = italic; hideKeyboard(); } }); mBoldToggleButton = (ToggleButton) view.findViewById(R.id.text_tool_dialog_toggle_bold); mBoldToggleButton.setTextOn( Html.fromHtml("<b>" + getResources().getString(R.string.text_tool_dialog_bold_shortcut) + "</b>")); mBoldToggleButton.setOnClickListener(new ToggleButton.OnClickListener() { @Override public void onClick(View v) { boolean bold = mBoldToggleButton.isChecked(); mOnTextToolDialogChangedListener.setBold(bold); mBold = bold; hideKeyboard(); } }); mTextSizeSpinner = (Spinner) view.findViewById(R.id.text_tool_dialog_spinner_text_size); ArrayAdapter<CharSequence> textSizeAdapter = ArrayAdapter.createFromResource(mContext, R.array.text_tool_size_array, android.R.layout.simple_spinner_item); textSizeAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); mTextSizeSpinner.setAdapter(textSizeAdapter); mTextSizeSpinner.setBackgroundColor(Color.GRAY); mTextSizeSpinner.setOnItemSelectedListener(new Spinner.OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { int size = Integer.parseInt(parent.getItemAtPosition(position).toString()); mOnTextToolDialogChangedListener.setTextSize(size); mTextSizeIndex = position; if (mTextSizeSpinnerInitialized) hideKeyboard(); else mTextSizeSpinnerInitialized = true; } @Override public void onNothingSelected(AdapterView<?> parent) { } }); builder.setView(view); builder.setNeutralButton(R.string.done, this); Dialog textDialog = builder.create(); WindowManager.LayoutParams window_params = textDialog.getWindow().getAttributes(); textDialog.getWindow().setDimAmount(0.0f); textDialog.getWindow().setAttributes(window_params); return textDialog; }
From source file:nz.ac.otago.psyanlab.common.designer.program.operand.EditOperandDialogFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); Bundle args = getArguments();// w w w. j a v a2 s .co m if (args != null) { if (!args.containsKey(ARG_TITLE)) { throw new RuntimeException("Expected dialogue title."); } if (!args.containsKey(ARG_TYPE)) { throw new RuntimeException("Expected operand type request."); } if (!args.containsKey(ARG_CALLER_KIND)) { throw new RuntimeException("Expected caller kind."); } if (!args.containsKey(ARG_CALLER_ID)) { throw new RuntimeException("Expected caller id."); } if (!args.containsKey(ARG_OPERAND_ID)) { throw new RuntimeException("Expected operand id."); } mCallerId = args.getLong(ARG_CALLER_ID, INVALID_ID); mCallerKind = args.getInt(ARG_CALLER_KIND); mOperandId = args.getLong(ARG_OPERAND_ID, INVALID_ID); mOperandType = args.getInt(ARG_TYPE); mTitle = args.getString(ARG_TITLE); mHideName = args.getBoolean(ARG_HIDE_NAME, true); mEditNameEnabled = args.getBoolean(ARG_EDIT_NAME, false); mOperand = mCallbacks.getOperand(mOperandId); } if (mOperandId == INVALID_ID) { throw new RuntimeException("Invalid operand id given."); } Dialog dialog = getDialog(); dialog.setTitle(mTitle); dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); mViews = new ViewHolder(view); mViews.initViews(); Operand operand = mCallbacks.getOperand(mOperandId); if (operand instanceof CallValue) { mViews.pager.setCurrentItem(1); } else { mViews.pager.setCurrentItem(0); } }
From source file:com.linroid.pushapp.ui.home.DeviceTokenDialog.java
@NonNull @Override/*from w w w. java2 s . co m*/ public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dialog = super.onCreateDialog(savedInstanceState); // dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setTitle(R.string.title_device_qrcode); WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.MATCH_PARENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; lp.gravity = Gravity.CENTER; dialog.getWindow().setAttributes(lp); return dialog; }
From source file:com.mEmoZz.qrgen.MainActivity.java
private void keepDialog(Dialog dialog) { WindowManager.LayoutParams lp = new WindowManager.LayoutParams(); lp.copyFrom(dialog.getWindow().getAttributes()); lp.width = WindowManager.LayoutParams.WRAP_CONTENT; lp.height = WindowManager.LayoutParams.WRAP_CONTENT; dialog.getWindow().setAttributes(lp); }
From source file:org.dvbviewer.controller.ui.fragments.StreamConfig.java
@Override public Dialog onCreateDialog(Bundle savedInstanceState) { Dialog dia = super.onCreateDialog(savedInstanceState); dia.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN); dia.setTitle(R.string.streamConfig); return dia;// ww w. j ava 2 s . c om }