Example usage for android.view.inputmethod InputMethodManager SHOW_IMPLICIT

List of usage examples for android.view.inputmethod InputMethodManager SHOW_IMPLICIT

Introduction

In this page you can find the example usage for android.view.inputmethod InputMethodManager SHOW_IMPLICIT.

Prototype

int SHOW_IMPLICIT

To view the source code for android.view.inputmethod InputMethodManager SHOW_IMPLICIT.

Click Source Link

Document

Flag for #showSoftInput to indicate that this is an implicit request to show the input window, not as the result of a direct request by the user.

Usage

From source file:com.actinarium.nagbox.ui.EditTaskDialogFragment.java

@NonNull
@Override/*from  w w w  .  j  av a 2 s . co m*/
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Task taskToEdit = getArguments().getParcelable(ARG_TASK);
    final boolean isEdit = taskToEdit != null;

    // Set up our live model:
    if (savedInstanceState != null) {
        // a) restore after config change
        mTask = savedInstanceState.getParcelable(ARG_TASK);
    } else if (isEdit) {
        // b) populate from the one under editing
        mTask = new Task(taskToEdit);
    } else {
        // c) create a blank task with default interval = 5 mins
        mTask = new Task();
    }

    mBinding = EditTaskDialogBinding.inflate(LayoutInflater.from(getContext()), null, false);
    mBinding.setTask(mTask);

    final AlertDialog dialog = new AlertDialog.Builder(getContext())
            .setTitle(getString(isEdit ? R.string.dialog_edit_task : R.string.dialog_new_task))
            .setView(mBinding.getRoot()).setPositiveButton(R.string.dialog_save, null)
            .setNegativeButton(R.string.dialog_cancel, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialogInterface, int i) {
                    dialogInterface.cancel();
                }
            }).create();

    // At this moment dialog is not yet inflated, so we need to use this listener to defer some logic
    dialog.setOnShowListener(new DialogInterface.OnShowListener() {
        @Override
        public void onShow(final DialogInterface di) {
            // Set the positive button listener. This is needed to prevent dismissing the dialog when validation fails
            dialog.getButton(DialogInterface.BUTTON_POSITIVE).setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View view) {
                    boolean isValid = validateForm();
                    if (isValid) {
                        // Actually I could call the service right here instead of delegating it to the activity
                        // But for the sake of consistency let the activity serve as a controller and handle this
                        if (isEdit) {
                            mHost.saveEditedTask(mTask);
                        } else {
                            mHost.saveNewTask(mTask);
                        }
                        dismiss();
                    }
                }
            });

            // Also try requesting the input method
            if (mBinding.taskTitleInput.getEditText().requestFocus()) {
                InputMethodManager imm = (InputMethodManager) getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(mBinding.taskTitleInput.getEditText(), InputMethodManager.SHOW_IMPLICIT);
            }
        }
    });

    return dialog;
}

From source file:com.mastercard.masterpasswallet.fragments.addcard.VerifyCardFragment.java

private void prePopulateWidgets() {
    if (mListener.hasCardNumber()) {
        mEdtCardNumber.setText(mListener.getCardNumber());

        mTxtScannedCardPan.setText(getString(R.string.masked_pan,
                mListener.getCardNumber().substring(mListener.getCardNumber().length() - 4)));

        // set the focus to the next field
        if (mListener.hasCardExpiry()) {
            mEdtCvc.requestFocus();//  ww  w  .j a  va 2  s .  c  om
        } else {
            mEdtExpiry.requestFocus();
        }

        // show the keyboard
        InputMethodManager imm = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(mEdtCvc, InputMethodManager.SHOW_IMPLICIT);

        if (mListener.hasCardExpiry()) {
            // Otherwise attempt to use the expiry date
            String cardExpiryMonth = String.format("%02d", Integer.parseInt(mListener.getCardExpiryMonth()));
            String cardExpiryYear = mListener.getCardExpiryYear().substring(2);
            mEdtExpiry.setText(String.format("%s/%s", cardExpiryMonth, cardExpiryYear));
        }

        // Use the image we've decided upon, this will either be the correct one for the card
        // or default to the green one
        mImgScannedCard.setImageResource(Card.getDefaultCardImageFull());

        // Set the cardholder name
        mEdtCardholderName.setText(mListener.getCardholderName());
    } else {
        // If no card was scanned then we don't show any image
        mLayScannedCard.setVisibility(View.GONE);
    }
}

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

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

    projectRename = (TextView) dialogView.findViewById(R.id.tv_project_rename);
    projectDescriptionField = (EditText) dialogView.findViewById(R.id.project_description_upload);
    projectUploadName = (EditText) dialogView.findViewById(R.id.project_upload_name);
    sizeOfProject = (TextView) dialogView.findViewById(R.id.dialog_upload_size_of_project);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView)
            .setTitle(R.string.upload_project_dialog_title)
            .setPositiveButton(R.string.upload_button, new DialogInterface.OnClickListener() {
                @Override/*from   w  ww  .ja va  2  s  .c  o m*/
                public void onClick(DialogInterface dialog, int which) {
                    handleUploadButtonClick();
                }
            }).setNegativeButton(R.string.cancel_button, new DialogInterface.OnClickListener() {
                @Override
                public void onClick(DialogInterface dialog, int which) {
                    handleCancelButtonClick();
                }
            }).create();

    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            initListeners();

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    initControls();

    return dialog;
}

From source file:org.sufficientlysecure.keychain.ui.dialog.AddKeyserverDialogFragment.java

/**
 * Creates dialog//  ww  w.  j av a2s. c  o  m
 */
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    mMessenger = getArguments().getParcelable(ARG_MESSENGER);

    CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);

    alert.setTitle(R.string.add_keyserver_dialog_title);

    LayoutInflater inflater = activity.getLayoutInflater();
    View view = inflater.inflate(R.layout.add_keyserver_dialog, null);
    alert.setView(view);

    mKeyserverEditText = (EditText) view.findViewById(R.id.keyserver_url_edit_text);
    mVerifyKeyserverCheckBox = (CheckBox) view.findViewById(R.id.verify_keyserver_checkbox);

    // we don't want dialog to be dismissed on click, thereby requiring the hack seen below
    // and in onStart
    alert.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int id) {
            // we need to have an empty listener to prevent errors on some devices as mentioned
            // at http://stackoverflow.com/q/13746412/3000919
            // actual listener set in onStart
        }
    });

    alert.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int id) {
            dismiss();
        }
    });

    // Hack to open keyboard.
    // This is the only method that I found to work across all Android versions
    // http://turbomanage.wordpress.com/2012/05/02/show-soft-keyboard-automatically-when-edittext-receives-focus/
    // Notes: * onCreateView can't be used because we want to add buttons to the dialog
    //        * opening in onActivityCreated does not work on Android 4.4
    mKeyserverEditText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            mKeyserverEditText.post(new Runnable() {
                @Override
                public void run() {
                    InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.showSoftInput(mKeyserverEditText, InputMethodManager.SHOW_IMPLICIT);
                }
            });
        }
    });
    mKeyserverEditText.requestFocus();

    mKeyserverEditText.setImeActionLabel(getString(android.R.string.ok), EditorInfo.IME_ACTION_DONE);
    mKeyserverEditText.setOnEditorActionListener(this);

    return alert.show();
}

From source file:net.olejon.mdapp.NotesActivity.java

@Override
protected void onResume() {
    super.onResume();

    // PIN code//  w ww  .jav a2s .  c  om
    if (mTools.getSharedPreferencesString("NOTES_PIN_CODE").equals("")) {
        new MaterialDialog.Builder(mContext).title(getString(R.string.notes_dialog_pin_code_title))
                .customView(R.layout.activity_notes_dialog_pin_code, true)
                .positiveText(getString(R.string.notes_dialog_pin_code_positive_button))
                .negativeText(getString(R.string.notes_dialog_pin_code_negative_button))
                .callback(new MaterialDialog.ButtonCallback() {
                    @Override
                    public void onPositive(MaterialDialog dialog) {
                        EditText pinCodeEditText = (EditText) dialog.findViewById(R.id.notes_dialog_pin_code);

                        String pinCode = pinCodeEditText.getText().toString();

                        if (pinCode.length() < 4) {
                            mTools.showToast(getString(R.string.notes_dialog_pin_code_invalid), 1);
                        } else {
                            mTools.setSharedPreferencesString("NOTES_PIN_CODE", pinCode);

                            mIsAuthenticated = true;

                            dialog.dismiss();

                            getNotes();
                        }
                    }

                    @Override
                    public void onNegative(MaterialDialog dialog) {
                        dialog.dismiss();

                        finish();
                    }
                }).showListener(new DialogInterface.OnShowListener() {
                    @Override
                    public void onShow(DialogInterface dialogInterface) {
                        mInputMethodManager.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0);
                    }
                }).cancelListener(new DialogInterface.OnCancelListener() {
                    @Override
                    public void onCancel(DialogInterface dialogInterface) {
                        dialogInterface.dismiss();

                        finish();
                    }
                }).contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue)
                .negativeColorRes(R.color.black).autoDismiss(false).show();
    } else {
        getNotes();
    }
}

From source file:io.realm.realmtasks.list.ItemViewHolder.java

public void setEditable(boolean set) {
    if (set) {// ww w  .  j a v a2s .  c o m
        if (isEditable() == false) {
            editText.setText(text.getText().toString());
        }
        hideReadOnlyTaskText();
        editText.setVisibility(View.VISIBLE);
        editText.requestFocus();
        final Context context = editText.getContext();
        final InputMethodManager inputMethodManager = (InputMethodManager) context
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);

    } else {
        if (isEditable() == true) {
            text.setText(editText.getText().toString());
        }
        showReadOnlyTaskText();
        editText.setVisibility(View.GONE);
    }
}

From source file:com.mehmetakiftutuncu.eshotroid.activities.BusListActivity.java

private void showHideKeyboard(boolean show) {
    InputMethodManager inputManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);

    if (inputManager != null && toolbarSearchEditText != null) {
        if (show) {
            toolbarSearchEditText.requestFocus();
            inputManager.showSoftInput(toolbarSearchEditText, InputMethodManager.SHOW_IMPLICIT);
        } else {/*from  ww  w .  ja v  a  2s .co  m*/
            toolbarSearchEditText.clearFocus();
            inputManager.hideSoftInputFromWindow(toolbarSearchEditText.getWindowToken(),
                    InputMethodManager.HIDE_NOT_ALWAYS);
        }
    }
}

From source file:org.thoughtcrime.securesms.scribbles.widget.MotionView.java

public void startEditing(TextEntity entity) {
    editText.setFocusableInTouchMode(true);
    editText.setFocusable(true);/*from w  w w .j  a  v  a  2  s  .  c  o  m*/
    editText.requestFocus();
    editText.setText(entity.getLayer().getText());
    Selection.setSelection(editText.getText(), editText.length());

    InputMethodManager ims = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    ims.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
}

From source file:com.shafiq.mytwittle.view.ComposeBaseFragment.java

void showKeyboard() {
    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
}

From source file:hku.fyp14017.blencode.ui.dialogs.UploadProjectDialog.java

@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
    View dialogView = LayoutInflater.from(getActivity())
            .inflate(hku.fyp14017.blencode.R.layout.dialog_upload_project, null);

    projectRename = (TextView) dialogView.findViewById(hku.fyp14017.blencode.R.id.tv_project_rename);
    projectDescriptionField = (EditText) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.project_description_upload);
    projectUploadName = (EditText) dialogView.findViewById(hku.fyp14017.blencode.R.id.project_upload_name);
    sizeOfProject = (TextView) dialogView
            .findViewById(hku.fyp14017.blencode.R.id.dialog_upload_size_of_project);

    Dialog dialog = new AlertDialog.Builder(getActivity()).setView(dialogView)
            .setTitle(hku.fyp14017.blencode.R.string.upload_project_dialog_title)
            .setPositiveButton(hku.fyp14017.blencode.R.string.upload_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleUploadButtonClick();
                        }//  ww  w . j a  va 2 s. c o m
                    })
            .setNegativeButton(hku.fyp14017.blencode.R.string.cancel_button,
                    new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialog, int which) {
                            handleCancelButtonClick();
                        }
                    })
            .create();

    dialog.setCanceledOnTouchOutside(true);
    dialog.getWindow().setLayout(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
    dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_ADJUST_RESIZE);

    dialog.setOnShowListener(new OnShowListener() {
        @Override
        public void onShow(DialogInterface dialog) {
            initListeners();

            InputMethodManager inputManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            inputManager.showSoftInput(projectUploadName, InputMethodManager.SHOW_IMPLICIT);
        }
    });

    initControls();

    return dialog;
}