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:de.spiritcroc.ownlog.ui.fragment.LogFilterEditFragment.java

private void initValues(Dialog dialog) {
    mEditName.setText(mInitName);//  w  w  w. j a  va 2 s.c o m
    if (mInitName.equals(getString(R.string.log_filter_default_new_name))) {
        // It's unlikely that the user wants to keep the default "new filter" name
        mEditName.selectAll();
        dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    mSortOrder = Arrays.asList(mSortOrderValues).indexOf(mInitSortOrder);
    if (mSortOrder < 0) {
        // Select default sort order
        mSortOrder = 0;
    }
    mSpinSortOrder.setSelection(mSortOrder);

    mCheckStrictFilterTags.setChecked(mInitStrictFilterTags);

    mSetTags = (ArrayList<TagItem>) mInitTags.clone();
    mExcludedTags = (ArrayList<TagItem>) mInitExcludedTags.clone();
    mEditTagsView.updateContent();
    mEditExcludedTagsView.updateContent();

    updateStrictFilterTagsInfo();
}

From source file:com.inter.trade.view.styleddialog.BaseDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = new Dialog(getActivity(), R.style.SDL_Dialog);
    // custom dialog background
    final TypedArray a = getActivity().getTheme().obtainStyledAttributes(null, R.styleable.DialogStyle,
            R.attr.sdlDialogStyle, 0);/*  w  ww  . ja  va  2 s . c o  m*/
    Drawable dialogBackground = a.getDrawable(R.styleable.DialogStyle_dialogBackground);
    a.recycle();
    dialog.getWindow().setBackgroundDrawable(dialogBackground);
    Bundle args = getArguments();
    if (args != null) {
        dialog.setCanceledOnTouchOutside(args.getBoolean(BaseDialogBuilder.ARG_CANCELABLE_ON_TOUCH_OUTSIDE));
    }
    return dialog;
}

From source file:com.jiandanbaoxian.fragment.DialogFragmentCreater.java

/**
 * Dialog/* ww  w  . ja va 2 s .  c o  m*/
 *
 * @param mContext
 * @return
 */
private Dialog showInputPasswordDialog(final Context mContext) {
    View convertView = LayoutInflater.from(mContext).inflate(R.layout.fragment_right_control, null);
    tv_forget_psw = (TextView) convertView.findViewById(R.id.tv_forget_psw);
    tv_forget_psw.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            mContext.startActivity(new Intent(mContext, MyModifyPasswordActivity.class));
        }
    });
    inputView = (GridPasswordView) convertView.findViewById(R.id.pswView);
    inputView.setOnPasswordChangedListener(new GridPasswordView.OnPasswordChangedListener() {
        @Override
        public void onChanged(String psw) {

        }

        @Override
        public void onMaxLength(String psw) {
            if (onPasswordDialogClickListener != null) {
                onPasswordDialogClickListener.getPassword(psw);
            }
        }
    });

    final Dialog dialog = new Dialog(mContext, R.style.CustomDialog);
    //        dialog.setCanceledOnTouchOutside(false);//??
    dialog.setContentView(convertView);

    dialog.getWindow().setWindowAnimations(R.style.dialog_right_control_style);
    //dialog 
    dialog.setOnShowListener(new android.content.DialogInterface.OnShowListener() {
        @Override
        public void onShow(final android.content.DialogInterface dialog) {

            new AsyncTask<Integer, Void, Void>() {
                @Override
                protected Void doInBackground(Integer... params) {
                    try {
                        Thread.sleep(params[0]);
                    } catch (InterruptedException e) {
                        e.printStackTrace();
                    }
                    return null;
                }

                @Override
                protected void onPostExecute(Void value) {
                    super.onPostExecute(value);
                    if (outerDialog.isShowing())
                        if (inputView != null) {
                            inputView.requestFocus();
                            InputMethodManager imm = (InputMethodManager) inputView.getContext()
                                    .getSystemService(Context.INPUT_METHOD_SERVICE);
                            imm.toggleSoftInput(0, InputMethodManager.SHOW_FORCED);
                        }
                }
            }.execute(600);
        }
    });

    outerDialog = dialog;
    return dialog;
}

From source file:com.irccloud.android.fragment.IgnoreListFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Context ctx = getActivity();/* w w  w  . j a  v  a 2s.  c o  m*/
    if (ctx == null)
        return null;

    LayoutInflater inflater = (LayoutInflater) ctx.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflater.inflate(R.layout.recyclerview, null);
    recyclerView = v.findViewById(R.id.recycler);
    recyclerView.setLayoutManager(new LinearLayoutManager(v.getContext()));
    empty = v.findViewById(android.R.id.empty);
    empty.setText(
            "You're not ignoring anyone at the moment.\n\nYou can ignore someone by tapping their nickname in the user list, long-pressing a message, or by using /ignore.");
    if (savedInstanceState != null && savedInstanceState.containsKey("cid")) {
        cid = savedInstanceState.getInt("cid");
        ignores = ServersList.getInstance().getServer(cid).raw_ignores;
        adapter = new IgnoresAdapter();
        recyclerView.setAdapter(adapter);
        if (adapter.getItemCount() > 0) {
            empty.setVisibility(View.GONE);
            recyclerView.setVisibility(View.VISIBLE);
        } else {
            empty.setVisibility(View.VISIBLE);
            recyclerView.setVisibility(View.GONE);
        }
    }
    Dialog d = new AlertDialog.Builder(ctx)
            .setTitle("Ignore list for " + ServersList.getInstance().getServer(cid).getName()).setView(v)
            .setPositiveButton("Add Ignore Mask", new AddClickListener())
            .setNegativeButton("Close", new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.dismiss();
                }
            }).create();
    d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);
    return d;
}

From source file:org.glucosio.android.fragment.OverviewFragment.java

private void showA1cDialog() {
    final Dialog a1CDialog = new Dialog(getActivity(), R.style.GlucosioTheme);

    WindowManager.LayoutParams lp = new WindowManager.LayoutParams();
    lp.copyFrom(a1CDialog.getWindow().getAttributes());
    a1CDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
    lp.width = WindowManager.LayoutParams.MATCH_PARENT;
    lp.height = WindowManager.LayoutParams.WRAP_CONTENT;
    a1CDialog.setContentView(R.layout.dialog_a1c);
    a1CDialog.getWindow().setAttributes(lp);
    a1CDialog.getWindow().addFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
    a1CDialog.getWindow().setDimAmount(0.5f);
    a1CDialog.setCanceledOnTouchOutside(true);
    a1CDialog.show();/*  w ww . j a va  2 s.  c  o m*/

    ListView a1cListView = (ListView) a1CDialog.findViewById(R.id.dialog_a1c_listview);

    A1cEstimateAdapter customAdapter = new A1cEstimateAdapter(getActivity(), R.layout.dialog_a1c_item,
            presenter.getA1cEstimateList());

    a1cListView.setAdapter(customAdapter);
}

From source file:org.mixare.MixListView.java

public void loadStopDetailsDialog(String title, StopMarker stop) {
    Dialog d = new Dialog(this) {
        public boolean onKeyDown(int keyCode, KeyEvent event) {
            if (keyCode == KeyEvent.KEYCODE_BACK)
                this.dismiss();
            return true;
        }//from  ww w  .j  av a  2  s.  c  om
    };

    d.requestWindowFeature(Window.FEATURE_NO_TITLE);
    d.getWindow().setGravity(Gravity.CENTER);
    d.setContentView(R.layout.stopdetailsdialog);

    TextView titleView = (TextView) d.findViewById(R.id.stopDetailDialogTitle);
    titleView.setText(title);

    ExpandableListView list = (ExpandableListView) d.findViewById(R.id.stopDetailDialogRouteList);

    final Button button = (Button) d.findViewById(R.id.stopWalkRouteButton);
    final double longitude = stop.getLongitude();
    final double latitude = stop.getLatitude();

    final Location start = mixContext.getCurrentLocation();

    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            Intent mapIntent = new Intent(org.mixare.maps.HelloGoogleMapsActivity.class.getName());
            mapIntent.putExtra("startLocation", start);
            mapIntent.putExtra("destLat", latitude);
            mapIntent.putExtra("destLong", longitude);

            startActivity(mapIntent);
        }
    });

    List<Map<String, ?>> groupMaps = stop.getRouteList();
    List<List<Map<String, ?>>> childMaps = stop.getRouteSubdataList();

    SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter(this, groupMaps,
            R.layout.stopdetailsdialogitemroute, new String[] { "id", "name" },
            new int[] { R.id.routeNumber, R.id.routeName }, childMaps, R.layout.stopdetailsdialogroutevariation,
            new String[] { "direction", "name", "times" },
            new int[] { R.id.routeVariationDirection, R.id.routeVariationName, R.id.routeVariationTimes });

    list.setAdapter(adapter);

    d.show();

    new StopTimesTask(adapter, stop).execute(groupMaps, childMaps);
}

From source file:org.catrobat.catroid.ui.dialogs.OverwriteRenameDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(context).inflate(R.layout.dialog_overwrite_project, null);

    replaceButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_replace);
    replaceButton.setOnClickListener(this);
    renameButton = (RadioButton) dialogView.findViewById(R.id.dialog_overwrite_project_radio_rename);
    renameButton.setOnClickListener(this);
    projectText = (EditText) dialogView.findViewById(R.id.dialog_overwrite_project_edit);
    projectText.setText(programName);/*from w ww  .ja v  a2  s . c o m*/
    projectTextView = (TextView) dialogView.findViewById(R.id.dialog_overwrite_project_edit_text);
    projectTextLine = dialogView.findViewById(R.id.dialog_overwrite_project_edit_line);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView).setTitle(R.string.overwrite_text)
            .setPositiveButton(R.string.ok, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                }
            }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    ToastUtil.showError(context, R.string.notification_download_project_cancel);
                }
            }).create();

    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            Button positiveButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_POSITIVE);
            positiveButton.setOnClickListener(new OnClickListener() {
                @Override
                public void onClick(View view) {
                    handleOkButton();
                }
            });
        }
    });

    dialog.setOnKeyListener(new OnKeyListener() {
        @Override
        public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
            if (event.getAction() == KeyEvent.ACTION_DOWN && keyCode == KeyEvent.KEYCODE_ENTER) {
                boolean okButtonResult = handleOkButton();
                if (okButtonResult) {
                    dismiss();
                }
                return okButtonResult;
            } else if (keyCode == KeyEvent.KEYCODE_BACK) {
                ToastUtil.showError(context, R.string.notification_download_project_cancel);
                return true;
            }

            return false;
        }
    });

    return dialog;
}

From source file:com.app.blockydemo.ui.dialogs.ScriptNameDialog.java

@Override
public Dialog onCreateDialog(Bundle bundle) {
    final View dialogView = LayoutInflater.from(getActivity()).inflate(R.layout.dialog_script_editor_name,
            null);/*  www  .  ja v  a2s  . c om*/

    final Dialog dialogNewVariable = new AlertDialog.Builder(getActivity()).setView(dialogView)
            .setTitle(R.string.formula_editor_script_name)
            .setNegativeButton(R.string.cancel_button, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    dialog.cancel();
                }
            }).setPositiveButton(R.string.ok, new OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    handleOkButton(dialogView);
                }
            }).create();

    dialogNewVariable.setCanceledOnTouchOutside(true);
    dialogNewVariable.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialogNewVariable.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            handleOnShow(dialogNewVariable);
        }
    });

    return dialogNewVariable;
}

From source file:org.rm3l.maoni.ui.MaoniActivity.java

private void initScreenCaptureView(@NonNull final Intent intent) {
    final ImageButton screenshotThumb = (ImageButton) findViewById(R.id.maoni_screenshot);

    final TextView touchToPreviewTextView = (TextView) findViewById(R.id.maoni_screenshot_touch_to_preview);
    if (touchToPreviewTextView != null && intent.hasExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT)) {
        touchToPreviewTextView.setText(intent.getCharSequenceExtra(SCREENSHOT_TOUCH_TO_PREVIEW_HINT));
    }//from w ww . j a v a2  s. c o m

    final View screenshotContentView = findViewById(R.id.maoni_include_screenshot_content);
    if (!TextUtils.isEmpty(mScreenshotFilePath)) {
        final File file = new File(mScreenshotFilePath.toString());
        if (file.exists()) {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.VISIBLE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.VISIBLE);
            }
            if (screenshotThumb != null) {
                //Thumbnail - load with smaller resolution so as to reduce memory footprint
                screenshotThumb.setImageBitmap(
                        ViewUtils.decodeSampledBitmapFromFilePath(file.getAbsolutePath(), 100, 100));
            }

            // Hook up clicks on the thumbnail views.
            if (screenshotThumb != null) {
                screenshotThumb.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {

                        final Dialog imagePreviewDialog = new Dialog(MaoniActivity.this);

                        imagePreviewDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                        imagePreviewDialog.getWindow()
                                .setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));

                        imagePreviewDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
                            @Override
                            public void onDismiss(DialogInterface dialogInterface) {
                                //nothing;
                            }
                        });

                        imagePreviewDialog.setContentView(R.layout.maoni_screenshot_preview);

                        final View.OnClickListener clickListener = new View.OnClickListener() {
                            @Override
                            public void onClick(View v) {
                                imagePreviewDialog.dismiss();
                            }
                        };

                        final ImageView imageView = (ImageView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image);
                        imageView.setImageURI(Uri.fromFile(file));

                        final DrawableView drawableView = (DrawableView) imagePreviewDialog
                                .findViewById(R.id.maoni_screenshot_preview_image_drawable_view);
                        final DrawableViewConfig config = new DrawableViewConfig();
                        // If the view is bigger than canvas, with this the user will see the bounds
                        config.setShowCanvasBounds(true);
                        config.setStrokeWidth(57.0f);
                        config.setMinZoom(1.0f);
                        config.setMaxZoom(1.0f);
                        config.setStrokeColor(mHighlightColor);
                        final View decorView = getWindow().getDecorView();
                        config.setCanvasWidth(decorView.getWidth());
                        config.setCanvasHeight(decorView.getHeight());
                        drawableView.setConfig(config);
                        drawableView.bringToFront();

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_highlight_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mHighlightColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_pick_blackout_color)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        config.setStrokeColor(mBlackoutColor);
                                    }
                                });
                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_close)
                                .setOnClickListener(clickListener);

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_undo)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        drawableView.undo();
                                    }
                                });

                        imagePreviewDialog.findViewById(R.id.maoni_screenshot_preview_save)
                                .setOnClickListener(new View.OnClickListener() {
                                    @Override
                                    public void onClick(View view) {
                                        ViewUtils.exportViewToFile(MaoniActivity.this,
                                                imagePreviewDialog.findViewById(
                                                        R.id.maoni_screenshot_preview_image_view_updated),
                                                new File(mScreenshotFilePath.toString()));
                                        initScreenCaptureView(intent);
                                        imagePreviewDialog.dismiss();
                                    }
                                });

                        imagePreviewDialog.setCancelable(true);
                        imagePreviewDialog.setCanceledOnTouchOutside(false);

                        imagePreviewDialog.show();
                    }
                });
            }
        } else {
            if (mIncludeScreenshot != null) {
                mIncludeScreenshot.setVisibility(View.GONE);
            }
            if (screenshotContentView != null) {
                screenshotContentView.setVisibility(View.GONE);
            }
        }
    } else {
        if (mIncludeScreenshot != null) {
            mIncludeScreenshot.setVisibility(View.GONE);
        }
        if (screenshotContentView != null) {
            screenshotContentView.setVisibility(View.GONE);
        }
    }
}

From source file:com.lloydtorres.stately.explore.ExploreActivity.java

/**
 * Handles which dialog to show for confirmation/password when moving regions.
 *///from www .  ja va2 s.  co m
public void handleRegionMove() {
    if (isInProgress) {
        SparkleHelper.makeSnackbar(view, getString(R.string.multiple_request_error));
        return;
    }

    AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this, RaraHelper.getThemeMaterialDialog(this));
    LayoutInflater inflater = getLayoutInflater();
    final View dialogView = inflater.inflate(R.layout.fragment_dialog_move_password, null);
    AppCompatEditText passView = (AppCompatEditText) dialogView.findViewById(R.id.move_password);
    final AppCompatEditText fPassView = passView;
    DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String password = null;
            if (fPassView.getText().length() >= 0) {
                password = fPassView.getText().toString();
            }
            getLocalId(String.format(Locale.US, Region.QUERY_HTML, SparkleHelper.getIdFromName(id)), password);
            dialog.dismiss();
        }
    };

    if (isPassword) {
        dialogBuilder.setTitle(getString(R.string.explore_region_password)).setView(dialogView)
                .setPositiveButton(getString(R.string.explore_move_confirm), dialogClickListener)
                .setNegativeButton(getString(R.string.explore_negative), null);
    } else {
        dialogBuilder.setTitle(String.format(Locale.US, getString(R.string.explore_region_move), name))
                .setPositiveButton(getString(R.string.explore_move_confirm), dialogClickListener)
                .setNegativeButton(getString(R.string.explore_negative), null);
    }

    Dialog d = dialogBuilder.create();
    if (isPassword) {
        d.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    }
    d.show();
}