List of usage examples for android.app Dialog requestWindowFeature
public final boolean requestWindowFeature(int featureId)
From source file:com.example.android.navigationdrawer.QRCode.java
public void onQR(View v) { switch (v.getId()) { case R.id.button1: String qrInputText = MidiFile.readString; //Find screen size WindowManager manager = (WindowManager) getSystemService(WINDOW_SERVICE); Display display = manager.getDefaultDisplay(); Point point = new Point(); display.getSize(point);/*from w w w.j a va 2 s .com*/ int width = point.x; int height = point.y; int smallerDimension = width < height ? width : height; smallerDimension = smallerDimension * 3 / 4; //Encode with a QR Code image QRCodeEncoder qrCodeEncoder = new QRCodeEncoder(qrInputText, null, Contents.Type.TEXT, BarcodeFormat.QR_CODE.toString(), smallerDimension); try { Bitmap bitmap = qrCodeEncoder.encodeAsBitmap(); ImageView myImage = (ImageView) findViewById(R.id.imageView1); myImage.setImageBitmap(bitmap); // Get screen size Display display1 = this.getWindowManager().getDefaultDisplay(); Point size = new Point(); display1.getSize(size); int screenWidth = size.x; int screenHeight = size.y; // Get target image size Bitmap bitmap1 = qrCodeEncoder.encodeAsBitmap(); int bitmapHeight = bitmap1.getHeight(); int bitmapWidth = bitmap1.getWidth(); // Scale the image down to fit perfectly into the screen // The value (250 in this case) must be adjusted for phone/tables displays while (bitmapHeight > (screenHeight - 250) || bitmapWidth > (screenWidth - 250)) { bitmapHeight = bitmapHeight / 2; bitmapWidth = bitmapWidth / 2; } // Create resized bitmap image BitmapDrawable resizedBitmap = new BitmapDrawable(this.getResources(), Bitmap.createScaledBitmap(bitmap, bitmapWidth, bitmapHeight, false)); // Create dialog Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.thumbnail); ImageView image = (ImageView) dialog.findViewById(R.id.imageview); // !!! Do here setBackground() instead of setImageDrawable() !!! // image.setBackground(resizedBitmap); // Without this line there is a very small border around the image (1px) // In my opinion it looks much better without it, so the choice is up to you. dialog.getWindow().setBackgroundDrawable(null); dialog.show(); } catch (WriterException e) { e.printStackTrace(); } break; } }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Change the order of the favorite rows. * /*from w w w. jav a2 s . c o m*/ * @param context */ public static void displayChangeRowOrder(final Launcher context) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.row_list); final ListView listView = (ListView) dialog.findViewById(R.id.rowList); ArrayList<RowInfo> persistedRows = RowsTable.getRows(context); final ArrayList<RowInfo> rows = new ArrayList<RowInfo>(); // Add in reverse order to match favorite rows order for (RowInfo rowInfo : persistedRows) { rows.add(0, rowInfo); } final RowAdapter rowAdapter = new RowAdapter(context, rows); listView.setAdapter(rowAdapter); listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { RowInfo rowInfo = (RowInfo) parent.getAdapter().getItem(position); if (rowInfo.isSelected()) { rowInfo.setSelected(false); // Persist the new row order try { int counter = 0; for (int i = rowAdapter.getCount() - 1; i >= 0; i--) { RowInfo currentRowInfo = (RowInfo) parent.getAdapter().getItem(i); RowsTable.updateRow(context, currentRowInfo.getId(), currentRowInfo.getTitle(), counter, currentRowInfo.getType()); counter++; } } catch (Exception e) { Log.e(LOG_TAG, "displayChangeRowOrder", e); } Analytics.logEvent(Analytics.CHANGE_ROW_ORDER); } else { rowInfo.setSelected(true); } rowAdapter.notifyDataSetChanged(); } }); listView.setOnItemSelectedListener(new OnItemSelectedListener() { @Override public void onItemSelected(AdapterView<?> parent, View view, int position, long id) { // Swap the selected item in the list int selectedRowIndex = -1; for (int i = 0; i < rows.size(); i++) { RowInfo rowInfo = rows.get(i); if (rowInfo.isSelected()) { selectedRowIndex = i; break; } } if (selectedRowIndex != -1) { try { Collections.swap(rows, position, selectedRowIndex); rowAdapter.notifyDataSetChanged(); } catch (Exception e) { Log.e(LOG_TAG, "displayChangeRowOrder", e); } } } @Override public void onNothingSelected(AdapterView<?> arg0) { } }); listView.setDrawingCacheEnabled(true); listView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); context.reloadAllGalleries(); } }); Button okButton = (Button) dialog.findViewById(R.id.okButton); okButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { context.showCover(false); dialog.dismiss(); context.reloadAllGalleries(); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_CHANGE_ROW_ORDER); }
From source file:com.amazon.appstream.fireclient.ConnectDialogFragment.java
/** * Create callback; performs initial set-up. *//*from www . ja v a 2s . co m*/ @Override public Dialog onCreateDialog(Bundle savedInstanceState) { mEmpty.setAlpha(0); final Dialog connectDialog = new Dialog(getActivity()); connectDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); connectDialog.setCanceledOnTouchOutside(false); connectDialog.setCancelable(false); connectDialog.setContentView(R.layout.server_address); connectDialog.getWindow().setBackgroundDrawable(mEmpty); mAddressTitle = (TextView) connectDialog.findViewById(R.id.address_title); mAddressField = (TextView) connectDialog.findViewById(R.id.address); mTextEntryFields = connectDialog.findViewById(R.id.text_entry_fields); mProgressBar = (ProgressBar) connectDialog.findViewById(R.id.progress_bar); mUseHardware = (CheckBox) connectDialog.findViewById(R.id.hardware); mUseHardware.setChecked(false); final CheckBox useAppServerBox = (CheckBox) connectDialog.findViewById(R.id.appserver); useAppServerBox.setChecked(mUseAppServer); useAppServerBox.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { if (isChecked) { if (!mUseAppServer) { mDESServerAddress = mAddressField.getText().toString(); } } else { if (mUseAppServer) { mServerAddress = mAddressField.getText().toString(); } } mUseAppServer = isChecked; updateFields(); } }); mAppIdField = (TextView) connectDialog.findViewById(R.id.appid); mSpace1 = connectDialog.findViewById(R.id.space1); mSpace2 = connectDialog.findViewById(R.id.space2); mAppIdTitle = connectDialog.findViewById(R.id.appid_title); mUserIdTitle = connectDialog.findViewById(R.id.userid_title); if (mAppId != null) { mAppIdField.setText(mAppId); } mUserIdField = (TextView) connectDialog.findViewById(R.id.userid); if (mUsername != null) { mUserIdField.setText(mUsername); } mErrorMessageField = (TextView) connectDialog.findViewById(R.id.error_message); mReconnect = connectDialog.findViewById(R.id.reconnect_fields); mReconnectMessage = (TextView) connectDialog.findViewById(R.id.reconnect_message); final Button connectButton = (Button) connectDialog.findViewById(R.id.connect); connectButton.setOnClickListener(new OnClickListener() { @Override public void onClick(View v) { onConnect(); } }); TextView.OnEditorActionListener listener = new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_GO) { InputMethodManager imm = (InputMethodManager) mActivity .getSystemService(Context.INPUT_METHOD_SERVICE); imm.hideSoftInputFromWindow(mUserIdField.getWindowToken(), 0); onConnect(); } return true; } }; View.OnFocusChangeListener focusListener = new View.OnFocusChangeListener() { @Override public void onFocusChange(View v, boolean hasFocus) { connectButton.setFocusableInTouchMode(false); } }; mAppIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnFocusChangeListener(focusListener); mUserIdField.setOnEditorActionListener(listener); updateFields(); if (mAddressField.getText().length() == 0) { mAddressField.requestFocus(); connectButton.setFocusableInTouchMode(false); } else { connectButton.requestFocus(); } if (mReconnectMessageString != null) { reconnecting(mReconnectMessageString); mReconnectMessageString = null; } return connectDialog; }
From source file:com.smsc.usuario.ui.MapaActivity.java
public void getDetalle(int posicion) { final Dialog dialog = new Dialog(this); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setCancelable(false);// w w w .java 2 s. co m dialog.setContentView(R.layout.dialog_incidente); TextView lblAsunto = (TextView) dialog.findViewById(R.id.lblAsunto); lblAsunto.setText(lista.get(posicion).getStr_detalle()); TextView lblNombreInciente = (TextView) dialog.findViewById(R.id.lblNombreInciente); lblNombreInciente.setText(lista.get(posicion).getStr_tipo_incidente_nombre()); TextView lblEstado = (TextView) dialog.findViewById(R.id.lblEstado); lblEstado.setText("Enviado"); if (lista.get(posicion).getInt_estado() == 1) lblEstado.setText("En Progreso"); else if (lista.get(posicion).getInt_estado() == 2) lblEstado.setText("Valido"); else if (lista.get(posicion).getInt_estado() == 3) lblEstado.setText("Invalido"); SimpleDateFormat fecha = new SimpleDateFormat("dd/MM/yyyy"); SimpleDateFormat hora = new SimpleDateFormat("h:mm a"); TextView lblFecha = (TextView) dialog.findViewById(R.id.lblFecha); lblFecha.setText(fecha.format(lista.get(posicion).getDat_fecha_registro())); TextView lblHora = (TextView) dialog.findViewById(R.id.lblHora); lblHora.setText(hora.format(lista.get(posicion).getDat_fecha_registro())); View ViewFoto = (View) dialog.findViewById(R.id.ViewFoto); if (lista.get(posicion).getByte_foto() == null) { ViewFoto.setVisibility(View.GONE); } else { ImageView image = (ImageView) dialog.findViewById(R.id.image); image.setImageBitmap(Funciones.getBitmap(lista.get(posicion).getByte_foto())); } View ViewCalificacion = (View) dialog.findViewById(R.id.ViewCalificacion); if (lista.get(posicion).getInt_rapides() == 0 && lista.get(posicion).getInt_conformidad() == 0) { ViewCalificacion.setVisibility(View.GONE); } else { RatingBar ratingRapides = (RatingBar) dialog.findViewById(R.id.ratingRapides); ratingRapides.setRating(lista.get(posicion).getInt_rapides()); RatingBar ratingConformidad = (RatingBar) dialog.findViewById(R.id.ratingConformidad); ratingConformidad.setRating(lista.get(posicion).getInt_conformidad()); } Button btnAceptar = (Button) dialog.findViewById(R.id.btnAceptar); btnAceptar.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { dialog.dismiss(); } }); dialog.show(); }
From source file:it.andreale.mdatetimepicker.date.DatePickerDialog.java
@NonNull public Dialog onCreateDialog(Bundle savedInstanceState) { // restore old state if not null if (savedInstanceState != null) { mHeaderColor = savedInstanceState.getInt(SAVED_HEADER_COLOR, DEFAULT_ACCENT_COLOR); mSelectionColor = savedInstanceState.getInt(SAVED_SELECTION_COLOR, DEFAULT_ACCENT_COLOR); mPositiveColor = savedInstanceState.getInt(SAVED_POSITIVE_COLOR, DEFAULT_ACCENT_COLOR); mNegativeColor = savedInstanceState.getInt(SAVED_NEGATIVE_COLOR, DEFAULT_ACCENT_COLOR); mTodayColor = savedInstanceState.getInt(SAVED_TODAY_COLOR, DEFAULT_ACCENT_COLOR); mDarkTheme = savedInstanceState.getBoolean(SAVED_DARK_MODE, false); mDefaultPickerMode = savedInstanceState.getInt(SAVED_DEFAULT_MODE, DEFAULT_PICKER_MODE); mYearStart = savedInstanceState.getInt(SAVED_START_YEAR, DEFAULT_START_YEAR); mYearEnd = savedInstanceState.getInt(SAVED_END_YEAR, DEFAULT_END_YEAR); mCalendar = (Calendar) savedInstanceState.getSerializable(SAVED_CALENDAR); mHeaderDateFormat = savedInstanceState.getString(SAVED_HEADER_DATE_FORMAT, DEFAULT_HEADER_DATE_FORMAT); mPositiveText = savedInstanceState.getString(SAVED_POSITIVE_TEXT, getString(android.R.string.ok)); mNegativeText = savedInstanceState.getString(SAVED_NEGATIVE_TEXT, getString(android.R.string.cancel)); mBuilderFlag = true;//from w w w . jav a2 s . c om if (mCalendar != null) { mFirstDayOfWeek = mCalendar.getFirstDayOfWeek(); } else { mFirstDayOfWeek = DEFAULT_FIRST_DAY_OF_WEEK; } } else { mDefaultPickerMode = DEFAULT_PICKER_MODE; mCalendar.setFirstDayOfWeek(mFirstDayOfWeek); // check builder flag if (!mBuilderFlag) { throw new IllegalStateException("You must initialize DatePickerDialog throw Builder class"); } } // inflate view View view = inflatePickerView(savedInstanceState); // style views mHeaderView.setBackgroundColor(mHeaderColor); view.setBackgroundColor(mDarkTheme ? BACKGROUND_DARK : BACKGROUND_LIGHT); // create dialog Dialog dialog = new Dialog(getActivity()); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(view); return dialog; }
From source file:com.vk.sdk.dialogs.VKShareDialog.java
@NonNull @Override// w w w . j ava2 s.co m public Dialog onCreateDialog(Bundle savedInstanceState) { Context context = getActivity(); View mInternalView = LayoutInflater.from(context).inflate(R.layout.vk_share_dialog, null); assert mInternalView != null; mSendButton = (Button) mInternalView.findViewById(R.id.sendButton); mSendProgress = (ProgressBar) mInternalView.findViewById(R.id.sendProgress); mPhotoLayout = (LinearLayout) mInternalView.findViewById(R.id.imagesContainer); mShareTextField = (EditText) mInternalView.findViewById(R.id.shareText); mPhotoScroll = (HorizontalScrollView) mInternalView.findViewById(R.id.imagesScrollView); LinearLayout mAttachmentLinkLayout = (LinearLayout) mInternalView.findViewById(R.id.attachmentLinkLayout); mSendButton.setOnClickListener(sendButtonPress); //Attachment text if (savedInstanceState != null) { mShareTextField.setText(savedInstanceState.getString(SHARE_TEXT_KEY)); mAttachmentLink = savedInstanceState.getParcelable(SHARE_LINK_KEY); mAttachmentImages = (VKUploadImage[]) savedInstanceState.getParcelableArray(SHARE_IMAGES_KEY); mExistingPhotos = savedInstanceState.getParcelable(SHARE_UPLOADED_IMAGES_KEY); } else if (mAttachmentText != null) { mShareTextField.setText(mAttachmentText); } //Attachment photos mPhotoLayout.removeAllViews(); if (mAttachmentImages != null) { for (VKUploadImage mAttachmentImage : mAttachmentImages) { addBitmapToPreview(mAttachmentImage.mImageData); } mPhotoLayout.setVisibility(View.VISIBLE); } if (mExistingPhotos != null) { processExistingPhotos(); } if (mExistingPhotos == null && mAttachmentImages == null) { mPhotoLayout.setVisibility(View.GONE); } //Attachment link if (mAttachmentLink != null) { TextView linkTitle = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkTitle), linkHost = (TextView) mAttachmentLinkLayout.findViewById(R.id.linkHost); linkTitle.setText(mAttachmentLink.linkTitle); linkHost.setText(VKUtil.getHost(mAttachmentLink.linkUrl)); mAttachmentLinkLayout.setVisibility(View.VISIBLE); } else { mAttachmentLinkLayout.setVisibility(View.GONE); } Dialog result = new Dialog(context); result.requestWindowFeature(Window.FEATURE_NO_TITLE); result.setContentView(mInternalView); result.setCancelable(true); result.setOnCancelListener(new DialogInterface.OnCancelListener() { @Override public void onCancel(DialogInterface dialogInterface) { if (mListener != null) { mListener.onVkShareCancel(); } VKShareDialog.this.dismiss(); } }); return result; }
From source file:com.entertailion.android.launcher.Dialogs.java
/** * Display dialog to the user for the browser bookmarks. Allow the user to add a * browser bookmark to an existing row or a new row. * /*from www.j a v a 2s . co m*/ * @param context */ public static void displayAddBrowserBookmark(final Launcher context) { final Dialog dialog = new Dialog(context); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); dialog.setContentView(R.layout.add_browser_bookmarks_list); final EditText nameEditText = (EditText) dialog.findViewById(R.id.rowName); final RadioButton currentRadioButton = (RadioButton) dialog.findViewById(R.id.currentRadio); currentRadioButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // hide the row name edit field if the current row radio button // is selected nameEditText.setVisibility(View.GONE); } }); final RadioButton newRadioButton = (RadioButton) dialog.findViewById(R.id.newRadio); newRadioButton.setOnClickListener(new OnClickListener() { public void onClick(View v) { // show the row name edit field if the new radio button is // selected nameEditText.setVisibility(View.VISIBLE); nameEditText.requestFocus(); } }); ListView listView = (ListView) dialog.findViewById(R.id.list); final ArrayList<BookmarkInfo> bookmarks = loadBookmarks(context); Collections.sort(bookmarks, new Comparator<BookmarkInfo>() { @Override public int compare(BookmarkInfo lhs, BookmarkInfo rhs) { return lhs.getTitle().toLowerCase().compareTo(rhs.getTitle().toLowerCase()); } }); listView.setAdapter(new BookmarkAdapter(context, bookmarks)); listView.setOnItemClickListener(new android.widget.AdapterView.OnItemClickListener() { @Override public void onItemClick(final AdapterView<?> parent, final View view, final int position, final long id) { // run in thread since network logic needed to get bookmark icon new Thread(new Runnable() { public void run() { // if the new row radio button is selected, the user must enter // a name for the new row String name = nameEditText.getText().toString().trim(); if (newRadioButton.isChecked() && name.length() == 0) { nameEditText.requestFocus(); displayAlert(context, context.getString(R.string.dialog_new_row_name_alert)); return; } boolean currentRow = !newRadioButton.isChecked(); try { BookmarkInfo bookmark = (BookmarkInfo) parent.getAdapter().getItem(position); int rowId = 0; int rowPosition = 0; if (currentRow) { rowId = context.getCurrentGalleryId(); ArrayList<ItemInfo> items = ItemsTable.getItems(context, rowId); rowPosition = items.size(); // in last // position // for selected // row } else { rowId = (int) RowsTable.insertRow(context, name, 0, RowInfo.FAVORITE_TYPE); rowPosition = 0; } Intent intent = new Intent(Intent.ACTION_VIEW); intent.setData(Uri.parse(bookmark.getUrl())); Uri uri = Uri.parse(bookmark.getUrl()); Log.d(LOG_TAG, "host=" + uri.getScheme() + "://" + uri.getHost()); String icon = Utils.getWebSiteIcon(context, "http://" + uri.getHost()); Log.d(LOG_TAG, "icon1=" + icon); if (icon == null) { // try base host address int count = StringUtils.countMatches(uri.getHost(), "."); if (count > 1) { int index = uri.getHost().indexOf('.'); String baseHost = uri.getHost().substring(index + 1); icon = Utils.getWebSiteIcon(context, "http://" + baseHost); Log.d(LOG_TAG, "icon2=" + icon); } } ItemsTable.insertItem(context, rowId, rowPosition, bookmark.getTitle(), intent, icon, DatabaseHelper.SHORTCUT_TYPE); } catch (Exception e) { Log.e(LOG_TAG, "displayAddBrowserBookmark", e); } // need to do this on UI thread context.getHandler().post(new Runnable() { public void run() { context.showCover(false); dialog.dismiss(); context.reloadAllGalleries(); } }); if (currentRow) { Analytics.logEvent(Analytics.ADD_BROWSER_BOOKMARK); } else { Analytics.logEvent(Analytics.ADD_BROWSER_BOOKMARK_WITH_ROW); } } }).start(); } }); listView.setDrawingCacheEnabled(true); listView.setOnKeyListener(onKeyListener); dialog.setOnDismissListener(new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { context.showCover(false); } }); context.showCover(true); dialog.show(); Analytics.logEvent(Analytics.DIALOG_ADD_BROWSER_BOOKMARK); }
From source file:com.citrus.sdk.fragments.SavedOptions.java
private void processCardFlow(final String txnId, final String signature, final String token) { final Dialog cvvDialog = new Dialog(getActivity()); LayoutInflater inflater = (LayoutInflater) getActivity().getApplicationContext() .getSystemService(Context.LAYOUT_INFLATER_SERVICE); cvvDialog.requestWindowFeature(Window.FEATURE_NO_TITLE); View view = inflater.inflate(R.layout.cvv, null); final EditText cvvEditText = (EditText) view.findViewById(R.id.cvvText); final TextView errorText = (TextView) view.findViewById(R.id.errorText); Button payButton = (Button) view.findViewById(R.id.payButton); payButton.setOnClickListener(new OnClickListener() { @Override/*w w w. j a v a 2s .co m*/ public void onClick(View v) { if (TextUtils.isEmpty(cvvEditText.getText().toString()) || cvvEditText.getText().toString().length() < 3) { errorText.setText("Invalid cvv"); } else { fillDetails(txnId, signature, token, cvvEditText.getText().toString()); cvvDialog.dismiss(); } } }); cvvDialog.setContentView(view); cvvDialog.show(); }
From source file:com.polyvi.xface.extension.inappbrowser.XInAppBrowser.java
/** * ???// w ww . ja va2 s .co m * @param theme * @param animation * @param windowFeature ? * @return dialog */ protected Dialog createDialog(int theme, int animation, int windowFeature) { Dialog dialog = new Dialog(mContext, theme); dialog.getWindow().getAttributes().windowAnimations = animation; dialog.requestWindowFeature(windowFeature); dialog.setCancelable(true); dialog.setOnDismissListener(new DialogInterface.OnDismissListener() { public void onDismiss(DialogInterface dialog) { mBrowserListener.onDismiss(mWebContext); } }); return dialog; }
From source file:com.baruckis.nanodegree.spotifystreamer.fragments.PlayerDialogFragment.java
/** * The system calls this only when creating the layout in a dialog. *///from w w w .j ava2s. co m @NonNull @Override public Dialog onCreateDialog(Bundle savedInstanceState) { // The only reason you might override this method when using onCreateView() is // to modify any dialog characteristics. For example, the dialog includes a // title by default, but your custom layout might not need it. So here you can // remove the dialog title, but you must call the superclass to get the Dialog. Dialog dialog = super.onCreateDialog(savedInstanceState); dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); return dialog; }