Example usage for android.app Dialog getWindow

List of usage examples for android.app Dialog getWindow

Introduction

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

Prototype

public @Nullable Window getWindow() 

Source Link

Document

Retrieve the current Window for the activity.

Usage

From source file:com.owncloud.android.ui.dialog.LoginWebViewDialog.java

@NonNull
@Override/*  w w  w.  j  a  v  a2 s  .com*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return dialog;
}

From source file:android.support.v7.app.AppCompatDialogFragment.java

/** @hide */
@Override/*from  ww w  .  jav  a 2s. c om*/
public void setupDialog(Dialog dialog, int style) {
    if (dialog instanceof AppCompatDialog) {
        // If the dialog is an AppCompatDialog, we'll handle it
        AppCompatDialog acd = (AppCompatDialog) dialog;
        switch (style) {
        case STYLE_NO_INPUT:
            dialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE
                    | WindowManager.LayoutParams.FLAG_NOT_TOUCHABLE);
            // fall through...
        case STYLE_NO_FRAME:
        case STYLE_NO_TITLE:
            acd.supportRequestWindowFeature(Window.FEATURE_NO_TITLE);
        }
    } else {
        // Else, just let super handle it
        super.setupDialog(dialog, style);
    }
}

From source file:com.zogamonline.laisiangthou.MaterialPreferenceLib.custom_preferences.DialogPreference.java

private void requestInputMethod(Dialog dialog) {
    Window window = dialog.getWindow();
    window.setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}

From source file:com.applivery.applvsdklib.ui.views.update.MustUpdateViewImpl.java

/**
 * Overrided in order to get fullScreen dialog
 * @param savedInstanceState//from w  ww.j  a  va2 s  . c o m
 * @return
 */
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {

    final RelativeLayout root = new RelativeLayout(getActivity());
    root.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    final Dialog dialog = new Dialog(getActivity());
    dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    dialog.setContentView(root);
    dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.YELLOW));
    dialog.getWindow().setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

    return dialog;
}

From source file:com.picogram.awesomeness.SettingsActivity.java

public boolean onPreferenceClick(final Preference preference) {
    if (preference.getKey().equals("statistics")) {
        //TODO/*from  w w w.  j a  v a  2s  . c  o  m*/
        Crouton.makeText(this, "This is not yet implemented", Style.INFO).show();
        final AlertDialog dialog = new AlertDialog.Builder(this).create();
        final String[] scoresTitles = new String[] { "Games Played", "Games Won", "Taps", "Taps per Puzzle",
                "Tapes per Minute", "Times Played" };
        final int gamesPlayed = 0, gamesWon = 0, taps = 0, tapsPerPuzzle = 0, tapsPerMinute = 0, timePlayed = 0;
        final int[] scores = { gamesPlayed, gamesWon, taps, tapsPerPuzzle, tapsPerMinute, timePlayed };
        // TODO: Implement the preferences and what not.
        final LinearLayout ll = new LinearLayout(this);
        ll.setOrientation(LinearLayout.VERTICAL);
        for (int i = 0; i != scores.length; ++i) {
            final LinearLayout sub = new LinearLayout(this);
            sub.setLayoutParams(new LinearLayout.LayoutParams(android.view.ViewGroup.LayoutParams.FILL_PARENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT));
            sub.setOrientation(LinearLayout.HORIZONTAL);
            TextView tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scoresTitles[i]);
            sub.addView(tv);
            tv = new TextView(this);
            tv.setLayoutParams(new TableLayout.LayoutParams(android.view.ViewGroup.LayoutParams.WRAP_CONTENT,
                    android.view.ViewGroup.LayoutParams.WRAP_CONTENT, 1f));
            tv.setText(scores[i] + "");
            sub.addView(tv);
            ll.addView(sub);
        }
        dialog.setView(ll);
        dialog.setButton("OK", new DialogInterface.OnClickListener() {
            public void onClick(final DialogInterface dialog, final int which) {
                dialog.dismiss();
            }
        });
        dialog.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        dialog.show();
        dialog.dismiss();

        return true;
    } else if (preference.getKey().equals("changelog")) {
        // Launch change log dialog
        final ChangeLogDialog _ChangelogDialog = new ChangeLogDialog(this);
        _ChangelogDialog.show();
    } else if (preference.getKey().equals("licenses")) {
        // Launch the licenses stuff.
        Dialog ld = new LicensesDialog(this, R.raw.licenses, false, false).create();
        ld.getWindow().getAttributes().windowAnimations = R.style.DialogTheme;
        ld.show();
    } else if (preference.getKey().equals("email")) {
        final String email = "warner.73+Picogram@wright.edu";
        final String subject = "Picogram - <SUBJECT>";
        final String message = "Picogram,\n\n<MESSAGE>";
        // Contact me.
        final Intent emailIntent = new Intent(Intent.ACTION_SEND);
        emailIntent.putExtra(Intent.EXTRA_EMAIL, new String[] { email });
        emailIntent.putExtra(Intent.EXTRA_SUBJECT, subject);
        emailIntent.putExtra(Intent.EXTRA_TEXT, message);
        emailIntent.setType("message/rfc822");
        this.startActivity(Intent.createChooser(emailIntent, "Send Mail Using :"));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
    } else if (preference.getKey().equals("rateapp")) {
        // TODO fix this when we publish.
        this.startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse("market://details?id=Picogram")));
        overridePendingTransition(R.anim.fadein, R.anim.exit_left);
        final Editor editor = this.prefs.edit();
        editor.putBoolean(RateMeMaybe.PREF.DONT_SHOW_AGAIN, true);
        editor.commit();
    } else if (preference.getKey().equals("logoutgoogle")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("logoutfacebook")) {
        //TODO
        Crouton.makeText(this, "This is not currently supported.", Style.INFO).show();
    } else if (preference.getKey().equals("resetusername")) {
        Util.getPreferences(this).edit().putString("username", "").commit();
        Util.getPreferences(this).edit().putBoolean("hasLoggedInUsername", false).commit();
    }
    return false;
}

From source file:com.mindorks.framework.mvp.ui.base.BaseDialog.java

@NonNull
@Override/*w  w w .j a  v  a 2  s.c o  m*/
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;
}

From source file:com.kubotaku.android.sample.sensordataviewer.fragments.ApiTokenSettingDialogFragment.java

@Override
public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    final Dialog dialog = getDialog();

    DisplayMetrics metrics = getResources().getDisplayMetrics();
    int dialogWidth = (int) (metrics.widthPixels * 0.9);

    WindowManager.LayoutParams lp = dialog.getWindow().getAttributes();
    lp.width = dialogWidth;//ww w . j av a 2s  .c o m
    dialog.getWindow().setAttributes(lp);
}

From source file:com.scoreloop.android.coreui.BaseActivity.java

private Dialog createErrorDialog(final int resId) {
    final Dialog dialog = new Dialog(this);
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    final View view = getLayoutInflater().inflate(R.layout.sl_dialog_custom, null);
    dialog.setContentView(view);//from w  w w. j  a  v  a 2  s. c  o  m
    dialog.setCanceledOnTouchOutside(true);
    ((TextView) view.findViewById(R.id.message)).setText(getString(resId));
    return dialog;
}

From source file:de.gebatzens.sia.dialog.LoginDialog.java

@Override
@NonNull//from   w w  w .j a  v a 2s.c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final String sid = getArguments().getString("sid");
    final boolean auth = getArguments().getBoolean("auth");

    AlertDialog.Builder builder = new AlertDialog.Builder(activity);
    builder.setTitle(getResources().getString(R.string.login));

    builder.setView(((LayoutInflater) activity.getSystemService(Context.LAYOUT_INFLATER_SERVICE))
            .inflate(R.layout.login_dialog, null));

    builder.setPositiveButton(getResources().getString(R.string.do_login_submit),
            new DialogInterface.OnClickListener() {

                @Override
                public void onClick(final DialogInterface dialog, int which) {
                    final String user = auth ? ((EditText) ((Dialog) dialog).findViewById(R.id.usernameInput))
                            .getText().toString() : "_anonymous";
                    final String pass = auth ? ((EditText) ((Dialog) dialog).findViewById(R.id.passwordInput))
                            .getText().toString() : "";
                    final String lsid = sid == null
                            ? ((EditText) ((Dialog) dialog).findViewById(R.id.sidInput)).getText().toString()
                            : sid;

                    new AsyncTask<String, Integer, Integer>() {

                        @Override
                        public void onPreExecute() {

                        }

                        @Override
                        public void onPostExecute(Integer v) {
                            boolean restoreDialog = false;

                            switch (v) {
                            case 0:
                                activity.startDownloadingSchool();
                                break;
                            case 1:
                                restoreDialog = true;
                                Snackbar.make(
                                        activity.getWindow().getDecorView()
                                                .findViewById(R.id.coordinator_layout),
                                        activity.getString(R.string.username_or_password_wrong),
                                        Snackbar.LENGTH_LONG).show();
                                break;
                            case 2:
                                restoreDialog = true;
                                Snackbar.make(
                                        activity.getWindow().getDecorView()
                                                .findViewById(R.id.coordinator_layout),
                                        activity.getString(R.string.could_not_connect), Snackbar.LENGTH_LONG)
                                        .show();
                                break;
                            case 3:
                                Snackbar.make(
                                        activity.getWindow().getDecorView()
                                                .findViewById(R.id.coordinator_layout),
                                        activity.getString(R.string.maintenance), Snackbar.LENGTH_LONG).show();
                                break;
                            case 4:
                                Snackbar.make(
                                        activity.getWindow().getDecorView()
                                                .findViewById(R.id.coordinator_layout),
                                        activity.getString(R.string.unknown_error_login), Snackbar.LENGTH_LONG)
                                        .show();
                                break;
                            }

                            if (restoreDialog) {
                                activity.restoreDialog = LoginDialog.this.getArguments();
                                activity.restoreDialog.putString("user", user);
                                activity.restoreDialog.putString("sid", lsid);
                            }

                        }

                        @Override
                        protected Integer doInBackground(String... params) {
                            return SIAApp.SIA_APP.api.login(params[0], params[1], params[2]);

                        }

                    }.execute(lsid, user, pass);
                    dialog.dismiss();
                }
            });

    builder.setNegativeButton(getString(R.string.abort), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    Dialog d = builder.create();
    if (auth) {
        d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }

    return d;
}

From source file:de.gebatzens.sia.dialog.FilterDialog.java

@Override
@NonNull//from w w w.ja v  a  2s  . c o m
public Dialog onCreateDialog(Bundle bundle) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setTitle(getString(
            isMainFilterDialog() ? (getUpdatePosition() == -1 ? R.string.add_main_filter : R.string.edit_filter)
                    : (getUpdatePosition() == -1 ? R.string.hide_subject : R.string.edit_filter)));
    builder.setView(View.inflate(getActivity(), R.layout.filter_dialog, null));

    builder.setPositiveButton(getString(R.string.ok), new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            activity.changed = true;
            EditText ed = (EditText) ((Dialog) dialog).findViewById(R.id.filter_text);
            CheckBox cb = (CheckBox) ((Dialog) dialog).findViewById(R.id.checkbox_contains);
            AppCompatSpinner spinner = (AppCompatSpinner) ((Dialog) dialog).findViewById(R.id.filter_spinner);

            String filtertext = ed.getText().toString().trim();
            if (filtertext.isEmpty() || ed.getError() != null) {
                Snackbar.make(getActivity().getWindow().getDecorView().findViewById(R.id.coordinator_layout),
                        getString(R.string.invalid_filter), Snackbar.LENGTH_LONG).show();
            } else {
                if (isMainFilterDialog()) {
                    Filter.IncludingFilter mainFilter;
                    if (getMainFilterPosition() == -1) {
                        mainFilter = new Filter.IncludingFilter(
                                spinner.getSelectedItemPosition() == 0 ? Filter.FilterType.CLASS
                                        : Filter.FilterType.TEACHER,
                                filtertext);
                        SIAApp.SIA_APP.filters.including.add(mainFilter);
                    } else {
                        mainFilter = SIAApp.SIA_APP.filters.including.get(getMainFilterPosition());
                        mainFilter.setFilter(filtertext);
                        mainFilter.setType(spinner.getSelectedItemPosition() == 0 ? Filter.FilterType.CLASS
                                : Filter.FilterType.TEACHER);
                    }
                } else {
                    Filter.ExcludingFilter f;
                    Filter.IncludingFilter inc = SIAApp.SIA_APP.filters.including
                            .get(spinner.getSelectedItemPosition());
                    if (getUpdatePosition() == -1) {
                        f = new Filter.ExcludingFilter(Filter.FilterType.SUBJECT, filtertext, inc);
                        inc.excluding.add(f);
                    } else {
                        f = inc.excluding.get(getUpdatePosition());
                        f.setFilter(filtertext);
                    }

                    f.contains = cb.isChecked();
                }

                activity.updateData();
                FilterActivity.saveFilter(SIAApp.SIA_APP.filters);
            }
            dialog.dismiss();
        }

    });

    builder.setNegativeButton(getString(R.string.abort), new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dialog.dismiss();
        }
    });
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}