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.synox.android.ui.dialog.CreateFolderDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mParentFolder = getArguments().getParcelable(ARG_PARENT_FOLDER);

    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.edit_box_dialog, null);

    // Setup layout 
    EditText inputText = ((EditText) v.findViewById(R.id.user_input));
    inputText.setText("");
    inputText.requestFocus();/*from   w w  w  .  java2 s .c om*/

    /*LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
        LinearLayout.LayoutParams.MATCH_PARENT,
        LinearLayout.LayoutParams.MATCH_PARENT);
    inputText.setLayoutParams(lp);*/

    // Build the dialog  
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.synox_AlertDialog);
    builder.setView(v).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this).setTitle(R.string.uploader_info_dirname);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:it.polimi.spf.app.permissiondisclaimer.PermissionDisclaimerDialogFragment.java

@NonNull
@Override//from  w ww . j  a va2  s  .com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Dialog dialog = super.onCreateDialog(savedInstanceState);
    dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
    dialog.setCanceledOnTouchOutside(false);
    return dialog;
}

From source file:com.cerema.cloud2.ui.dialog.RenameFileDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE);

    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.edit_box_dialog, null);

    // Setup layout 
    String currentName = mTargetFile.getFileName();
    EditText inputText = ((EditText) v.findViewById(R.id.user_input));
    inputText.setText(currentName);/*w  w w. j  ava  2 s. c  om*/
    int selectionStart = 0;
    int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf(".");
    int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
    if (selectionStart >= 0 && selectionEnd >= 0) {
        inputText.setSelection(Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd));
    }
    inputText.requestFocus();

    // Build the dialog  
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setView(v).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this).setTitle(R.string.rename_dialog_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:com.synox.android.ui.dialog.RenameFileDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    mTargetFile = getArguments().getParcelable(ARG_TARGET_FILE);

    // Inflate the layout for the dialog
    LayoutInflater inflater = getActivity().getLayoutInflater();
    View v = inflater.inflate(R.layout.edit_box_dialog, null);

    // Setup layout 
    String currentName = mTargetFile.getFileName();
    EditText inputText = ((EditText) v.findViewById(R.id.user_input));
    inputText.setText(currentName);/*w  w  w  .  ja v  a 2  s  . com*/
    int selectionStart = 0;
    int extensionStart = mTargetFile.isFolder() ? -1 : currentName.lastIndexOf(".");
    int selectionEnd = (extensionStart >= 0) ? extensionStart : currentName.length();
    if (selectionStart >= 0 && selectionEnd >= 0) {
        inputText.setSelection(Math.min(selectionStart, selectionEnd), Math.max(selectionStart, selectionEnd));
    }
    inputText.requestFocus();

    // Build the dialog  
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity(), R.style.synox_AlertDialog);
    builder.setView(v).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this).setTitle(R.string.rename_dialog_title);
    Dialog d = builder.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:bf.io.openshop.ux.dialogs.LicensesDialogFragment.java

@Override
public void onStart() {
    super.onStart();
    Dialog d = getDialog();
    if (d != null) {
        Window window = d.getWindow();
        if (window != null)
            window.setWindowAnimations(R.style.dialogFragmentAnimation);
        else/*from ww w .jav  a2  s  . c  o  m*/
            Timber.e("Cannot set dialog animation");
    }
}

From source file:nz.ac.otago.psyanlab.common.designer.program.operand.ClearOperandDialogueFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();// w w  w .j  a  va2  s  . co m
    if (args != null) {
        mTitleResId = args.getInt(ARG_TITLE, R.string.title_pick_number);
        mOperandId = args.getLong(ARG_OPERAND_ID, -1);
    }

    if (mOperandId == -1) {
        throw new RuntimeException("Invalid operand id.");
    }

    mOperand = mCallbacks.getOperand(mOperandId);

    // Build dialogue.
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    builder.setMessage(getString(R.string.message_clear_operand, mOperand.getName()))
            .setPositiveButton(R.string.action_clear, mPositiveListener)
            .setNegativeButton(R.string.action_cancel, mNegativeListener);

    // Create the AlertDialog object and return it
    Dialog dialog = builder.create();
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_HIDDEN);
    return dialog;
}

From source file:com.cerema.cloud2.ui.dialog.CredentialsDialogFragment.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {

    // Create field for username
    mUsernameET = new EditText(getActivity());
    mUsernameET.setHint(getActivity().getText(R.string.auth_username));

    // Create field for password
    mPasswordET = new EditText(getActivity());
    mPasswordET.setHint(getActivity().getText(R.string.auth_password));
    mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);

    // Prepare LinearLayout for dialog
    LinearLayout ll = new LinearLayout(getActivity());
    ll.setOrientation(LinearLayout.VERTICAL);
    ll.addView(mUsernameET);//  w ww  .j  a v  a 2  s.c o m
    ll.addView(mPasswordET);

    ll.requestFocus();

    setRetainInstance(true);

    Builder authDialog = new AlertDialog.Builder(getActivity())
            .setTitle(getActivity().getText(R.string.saml_authentication_required_text)).setView(ll)
            .setCancelable(false).setPositiveButton(R.string.common_ok, this)
            .setNegativeButton(R.string.common_cancel, this);

    Dialog d = authDialog.create();
    d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return d;
}

From source file:com.akhbulatov.wordkeeper.ui.dialog.CategoryEditorDialog.java

@NonNull
@Override//from   ww w.j  a  va2  s  .  c om
public Dialog onCreateDialog(Bundle savedInstanceState) {
    AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
    LayoutInflater inflater = getActivity().getLayoutInflater();

    builder.setView(inflater.inflate(R.layout.dialog_category_editor, null)).setTitle(mTitleId)
            .setPositiveButton(mPositiveTextId,
                    (dialog, which) -> mListener.onFinishCategoryEditorDialog(CategoryEditorDialog.this,
                            mPositiveTextId))
            .setNegativeButton(mNegativeTextId, (dialog, which) -> dialog.dismiss());

    Dialog dialog = builder.create();
    // Shows the soft keyboard automatically
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
    return dialog;
}

From source file:it.gulch.linuxday.android.fragments.RoomImageDialogFragment.java

@NonNull
@Override/*from w w  w . j  a va2s.  c  o  m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    Bundle args = getArguments();

    ImageView imageView = new ImageView(getActivity());
    imageView.setImageResource(args.getInt("imageResId"));

    Dialog dialog = new AlertDialog.Builder(getActivity()).setTitle(args.getString("roomName"))
            .setView(imageView).create();
    dialog.getWindow().getAttributes().windowAnimations = R.style.RoomImageDialogAnimations;
    return dialog;
}

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);
}