Example usage for android.app Dialog requestWindowFeature

List of usage examples for android.app Dialog requestWindowFeature

Introduction

In this page you can find the example usage for android.app Dialog requestWindowFeature.

Prototype

public final boolean requestWindowFeature(int featureId) 

Source Link

Document

Enable extended window features.

Usage

From source file:Main.java

public static Dialog creativeDialog(Context context, int layout) {
    Dialog dialog = new Dialog(context, android.R.style.Theme_Holo_Light_Dialog);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.setContentView(layout);//from   w w  w  . j a  v a2  s  . c  om
    return dialog;
}

From source file:com.memetro.android.alerts.CommentDialog.java

public static void showDialog(final Context context, String comment, String creator, boolean isMine,
        final Long id) {

    final Dialog mDialog = new Dialog(context);
    mDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    mDialog.setContentView(R.layout.comment_dialog);
    mDialog.setCancelable(true);//  www .  j a  v  a2s  . co m

    TextView titleText = (TextView) mDialog.findViewById(R.id.title);
    TextView messageText = (TextView) mDialog.findViewById(R.id.message);
    Button closeButton = (Button) mDialog.findViewById(R.id.close);
    Button deleteButton = (Button) mDialog.findViewById(R.id.delete);

    titleText.setText(titleText.getText().toString() + " " + creator);
    messageText.setMovementMethod(ScrollingMovementMethod.getInstance());
    messageText.setText(comment);

    if (isMine) {
        deleteButton.setVisibility(View.VISIBLE);
        deleteButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                new DeleteInBg(context, String.valueOf(id)).execute();
                mDialog.dismiss();
                // TODO Refrescar las alertas
            }
        });
    }

    closeButton.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            mDialog.dismiss();
        }
    });

    mDialog.show();

}

From source file:de.j4velin.mapsmeasure.Dialogs.java

/**
 * @param m        the Map//from  w ww.j  a v a2  s  .c  o m
 * @param distance the current distance
 * @param area     the current area
 * @return the units dialog
 */
public static Dialog getUnits(final Map m, float distance, double area) {
    final Dialog d = new Dialog(m);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_unit);
    CheckBox metricCb = (CheckBox) d.findViewById(R.id.metric);
    metricCb.setChecked(m.metric);
    metricCb.setOnCheckedChangeListener(new OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            m.metric = !m.metric;
            m.getSharedPreferences("settings", Context.MODE_PRIVATE).edit().putBoolean("metric", isChecked)
                    .commit();
            m.updateValueText();
        }
    });
    ((TextView) d.findViewById(R.id.distance)).setText(Map.formatter_two_dec.format(Math.max(0, distance))
            + " m\n" + Map.formatter_two_dec.format(distance / 1000) + " km\n\n"
            + Map.formatter_two_dec.format(Math.max(0, distance / 0.3048f)) + " ft\n"
            + Map.formatter_two_dec.format(Math.max(0, distance / 0.9144)) + " yd\n"
            + Map.formatter_two_dec.format(distance / 1609.344f) + " mi\n"
            + Map.formatter_two_dec.format(distance / 1852f) + " nautical miles");

    ((TextView) d.findViewById(R.id.area)).setText(Map.formatter_two_dec.format(Math.max(0, area)) + " m\n"
            + Map.formatter_two_dec.format(area / 10000) + " ha\n"
            + Map.formatter_two_dec.format(area / 1000000) + " km\n\n"
            + Map.formatter_two_dec.format(Math.max(0, area / 0.09290304d)) + " ft\n"
            + Map.formatter_two_dec.format(area / 4046.8726099d) + " ac (U.S. Survey)\n"
            + Map.formatter_two_dec.format(area / 2589988.110336d) + " mi");
    d.findViewById(R.id.close).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            d.dismiss();
        }
    });
    return d;
}

From source file:fi.tuukka.weather.utils.Utils.java

public static void showImage(Activity activity, View view, Bitmap bmp) {
    final Dialog imageDialog = new Dialog(activity);
    imageDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    imageDialog.setContentView(R.layout.showimage);
    imageDialog.setCancelable(true);/* ww w.  j av  a2s . co m*/

    ImageView imageView = (ImageView) imageDialog.findViewById(R.id.imageView);
    // Getting width & height of the given image.
    DisplayMetrics displayMetrics = activity.getResources().getDisplayMetrics();
    int wn = displayMetrics.widthPixels;
    int hn = displayMetrics.heightPixels;
    int wo = bmp.getWidth();
    int ho = bmp.getHeight();
    Matrix mtx = new Matrix();
    // Setting rotate to 90
    mtx.preRotate(90);
    // Setting resize
    mtx.postScale(((float) 1.3 * wn) / ho, ((float) 1.3 * hn) / wo);
    // Rotating Bitmap
    Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, wo, ho, mtx, true);
    BitmapDrawable bmd = new BitmapDrawable(rotatedBMP);

    imageView.setImageDrawable(bmd);

    imageView.setOnClickListener(new View.OnClickListener() {
        public void onClick(View button) {
            imageDialog.dismiss();
        }
    });

    imageDialog.show();
}

From source file:com.spoiledmilk.ibikecph.util.Util.java

public static void launchNoConnectionDialog(Context ctx) {
    final Dialog dialog = new Dialog(ctx);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_no_connection);
    TextView text = (TextView) dialog.findViewById(R.id.textNetworkError);
    text.setTypeface(IbikeApplication.getNormalFont());
    text.setText(IbikeApplication.getString("network_error_text"));
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));
    dialog.show();//from  w ww.j a  va 2  s . com
    final Handler handler = new Handler();
    handler.postDelayed(new Runnable() {
        @Override
        public void run() {
            try {
                dialog.dismiss();
            } catch (Exception e) {
                // dialog not attached to window
            }
        }
    }, 3000);
}

From source file:de.j4velin.mapsmeasure.Dialogs.java

/**
 * @param c     the Context//from   w  w w. j a  v  a 2s .c  o  m
 * @param trace the current trace of points
 * @return the "save & share" dialog
 */
public static Dialog getSaveNShare(final Activity c, final Stack<LatLng> trace) {
    final Dialog d = new Dialog(c);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_save);
    d.findViewById(R.id.save).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            final File destination;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                destination = API8Wrapper.getExternalFilesDir(c);
            } else {
                destination = c.getDir("traces", Context.MODE_PRIVATE);
            }

            d.dismiss();
            AlertDialog.Builder b = new AlertDialog.Builder(c);
            b.setTitle(R.string.save);
            final View layout = c.getLayoutInflater().inflate(R.layout.dialog_enter_filename, null);
            ((TextView) layout.findViewById(R.id.location))
                    .setText(c.getString(R.string.file_path, destination.getAbsolutePath() + "/"));
            b.setView(layout);
            b.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        String fname = ((EditText) layout.findViewById(R.id.filename)).getText().toString();
                        if (fname == null || fname.length() < 1) {
                            fname = "MapsMeasure_" + System.currentTimeMillis();
                        }
                        final File f = new File(destination, fname + ".csv");
                        Util.saveToFile(f, trace);
                        d.dismiss();
                        Toast.makeText(c, c.getString(R.string.file_saved, f.getAbsolutePath()),
                                Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        Toast.makeText(c,
                                c.getString(R.string.error,
                                        e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
            b.create().show();
        }
    });
    d.findViewById(R.id.load).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {

            File[] files = c.getDir("traces", Context.MODE_PRIVATE).listFiles();

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                File ext = API8Wrapper.getExternalFilesDir(c);
                // even though we checked the external storage state, ext is still sometims null, accoring to Play Store crash reports
                if (ext != null) {
                    File[] filesExtern = ext.listFiles();
                    File[] allFiles = new File[files.length + filesExtern.length];
                    System.arraycopy(files, 0, allFiles, 0, files.length);
                    System.arraycopy(filesExtern, 0, allFiles, files.length, filesExtern.length);
                    files = allFiles;
                }
            }

            if (files.length == 0) {
                Toast.makeText(c,
                        c.getString(R.string.no_files_found,
                                c.getDir("traces", Context.MODE_PRIVATE).getAbsolutePath()),
                        Toast.LENGTH_SHORT).show();
            } else if (files.length == 1) {
                try {
                    Util.loadFromFile(Uri.fromFile(files[0]), (Map) c);
                    d.dismiss();
                } catch (IOException e) {
                    e.printStackTrace();
                    Toast.makeText(c,
                            c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                d.dismiss();
                AlertDialog.Builder b = new AlertDialog.Builder(c);
                b.setTitle(R.string.select_file);
                final DeleteAdapter da = new DeleteAdapter(files, (Map) c);
                b.setAdapter(da, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Util.loadFromFile(Uri.fromFile(da.getFile(which)), (Map) c);
                            dialog.dismiss();
                        } catch (IOException e) {
                            e.printStackTrace();
                            Toast.makeText(c,
                                    c.getString(R.string.error,
                                            e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                    Toast.LENGTH_LONG).show();
                        }
                    }
                });
                b.create().show();
            }
        }
    });
    d.findViewById(R.id.share).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {
            try {
                final File f = new File(c.getCacheDir(), "MapsMeasure.csv");
                Util.saveToFile(f, trace);
                Intent shareIntent = new Intent();
                shareIntent.setAction(Intent.ACTION_SEND);
                shareIntent.putExtra(Intent.EXTRA_STREAM,
                        FileProvider.getUriForFile(c, "de.j4velin.mapsmeasure.fileprovider", f));
                shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
                shareIntent.setType("text/comma-separated-values");
                d.dismiss();
                c.startActivity(Intent.createChooser(shareIntent, null));
            } catch (IOException e) {
                e.printStackTrace();
                Toast.makeText(c,
                        c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                        Toast.LENGTH_LONG).show();
            }
        }
    });
    return d;
}

From source file:com.normsstuff.maps4norm.Dialogs.java

/**
 * @param c     the Context//from   ww  w.j  a  v a2s  .co  m
 * @param trace the current trace of points
 * @return the "save & share" dialog
 */
public static Dialog getSaveNShare(final Activity c, final Stack<LatLng> trace) {
    final Dialog d = new Dialog(c);
    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.setContentView(R.layout.dialog_save);
    d.findViewById(R.id.saveMarks).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View vX) {
            final File destination;
            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                destination = API8Wrapper.getExternalFilesDir(c);
            } else {
                destination = c.getDir("traces", Context.MODE_PRIVATE);
            }

            d.dismiss();
            AlertDialog.Builder b = new AlertDialog.Builder(c);
            b.setTitle(R.string.save);
            final View layout = c.getLayoutInflater().inflate(R.layout.dialog_enter_filename, null);
            ((TextView) layout.findViewById(R.id.location))
                    .setText(c.getString(R.string.file_path, destination.getAbsolutePath() + "/"));
            b.setView(layout);
            b.setPositiveButton(R.string.save, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    try {
                        String fname = ((EditText) layout.findViewById(R.id.filename)).getText().toString();
                        if (fname == null || fname.length() < 1) {
                            fname = "MapsMeasure_" + System.currentTimeMillis();
                        }
                        final File f = new File(destination, fname + ".csv");
                        Util.saveToFile(f, trace);
                        d.dismiss();
                        Toast.makeText(c, c.getString(R.string.file_saved, f.getAbsolutePath()),
                                Toast.LENGTH_SHORT).show();
                    } catch (Exception e) {
                        Toast.makeText(c,
                                c.getString(R.string.error,
                                        e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                Toast.LENGTH_LONG).show();
                    }
                }
            });
            b.create().show();
        }
    });
    d.findViewById(R.id.loadMarks).setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(final View v) {

            File[] files = c.getDir("traces", Context.MODE_PRIVATE).listFiles();

            if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.FROYO
                    && Environment.MEDIA_MOUNTED.equals(Environment.getExternalStorageState())) {
                File ext = API8Wrapper.getExternalFilesDir(c);
                // even though we checked the external storage state, ext is still sometimes null, accoring to Play Store crash reports
                if (ext != null) {
                    File[] filesExtern = ext.listFiles();
                    File[] allFiles = new File[files.length + filesExtern.length];
                    System.arraycopy(files, 0, allFiles, 0, files.length);
                    System.arraycopy(filesExtern, 0, allFiles, files.length, filesExtern.length);
                    files = allFiles;
                }
            }

            if (files.length == 0) {
                Toast.makeText(c,
                        c.getString(R.string.no_files_found,
                                c.getDir("traces", Context.MODE_PRIVATE).getAbsolutePath()),
                        Toast.LENGTH_SHORT).show();
            } else if (files.length == 1) {
                try {
                    Util.loadFromFile(Uri.fromFile(files[0]), (MyMapActivity) c);
                    d.dismiss();
                } catch (IOException e) {
                    e.printStackTrace();
                    Toast.makeText(c,
                            c.getString(R.string.error, e.getClass().getSimpleName() + "\n" + e.getMessage()),
                            Toast.LENGTH_LONG).show();
                }
            } else {
                d.dismiss();
                AlertDialog.Builder b = new AlertDialog.Builder(c);
                b.setTitle(R.string.select_file);
                final DeleteAdapter da = new DeleteAdapter(files, (MyMapActivity) c);
                b.setAdapter(da, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        try {
                            Util.loadFromFile(Uri.fromFile(da.getFile(which)), (MyMapActivity) c);
                            dialog.dismiss();
                        } catch (IOException e) {
                            e.printStackTrace();
                            Toast.makeText(c,
                                    c.getString(R.string.error,
                                            e.getClass().getSimpleName() + "\n" + e.getMessage()),
                                    Toast.LENGTH_LONG).show();
                        }
                    }
                });
                b.create().show();
            }
        }
    });
    /*        
            d.findViewById(R.id.share).setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(final View v) {
        try {
            final File f = new File(c.getCacheDir(), "MapsMeasure.csv");
            Util.saveToFile(f, trace);
            Intent shareIntent = new Intent();
            shareIntent.setAction(Intent.ACTION_SEND);
            shareIntent.putExtra(Intent.EXTRA_STREAM, FileProvider
                    .getUriForFile(c, "de.j4velin.mapsmeasure.fileprovider", f));
            shareIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
            shareIntent.setType("text/comma-separated-values");
            d.dismiss();
            c.startActivity(Intent.createChooser(shareIntent, null));
        } catch (IOException e) {
            e.printStackTrace();
            Toast.makeText(c, c.getString(R.string.error,
                            e.getClass().getSimpleName() + "\n" + e.getMessage()),
                    Toast.LENGTH_LONG).show();
        }
    }
            });
    */
    return d;
}

From source file:click.kobaken.rxirohaandroid_sample.view.fragment.SplashFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);
    Dialog dialog = getDialog();
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.fragment_splash);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
}

From source file:by.android.dailystatus.dialog.LicenseDialog.java

public Dialog onCreateDialog(Bundle savedInstanceState) {
    final FragmentActivity activity = getActivity();
    final Dialog dialog = new Dialog(activity);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(R.layout.dialog_license);
    TextView description = (TextView) dialog.findViewById(R.id.txt_dialog_version_description);
    if (text != null && !TextUtils.isEmpty(text)) {
        description.setText(text);/*from  w  w  w .  j a  va2 s. co  m*/
    }

    dialog.findViewById(R.id.but_dialog_version_ok).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            dismiss();

        }
    });

    return dialog;
}

From source file:com.androzic.plugin.tracker.PreferencesHelpDialog.java

@NonNull
@Override//from w w  w .  ja v a 2 s.  com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    return dialog;
}