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.ada.utils.Ui.java

public static void showSoftkeyboard(View view, ResultReceiver resultReceiver) {
    Configuration config = view.getContext().getResources().getConfiguration();
    if (config.hardKeyboardHidden == Configuration.HARDKEYBOARDHIDDEN_YES) {
        InputMethodManager imm = (InputMethodManager) view.getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);

        if (resultReceiver != null) {
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT, resultReceiver);
        } else {/*from  w w w .j ava 2 s.  com*/
            imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
        }
    }
}

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

private void handleOnShow(final Dialog dialogNewVariable) {
    final Button positiveButton = ((AlertDialog) dialogNewVariable).getButton(AlertDialog.BUTTON_POSITIVE);
    positiveButton.setEnabled(false);/*  w  w  w. j a v  a2 s  .  c om*/

    EditText dialogEditText = (EditText) dialogNewVariable
            .findViewById(R.id.dialog_formula_editor_variable_name_edit_text);

    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(dialogEditText, InputMethodManager.SHOW_IMPLICIT);

    dialogEditText.addTextChangedListener(new TextWatcher() {

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {
        }

        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {
        }

        @Override
        public void afterTextChanged(Editable editable) {

            String variableName = editable.toString();
            if (ProjectManager.getInstance().getCurrentProject().getUserVariables()
                    .getUserVariable(variableName, ProjectManager.getInstance().getCurrentSprite()) != null) {

                Toast.makeText(getActivity(), R.string.formula_editor_existing_variable, Toast.LENGTH_SHORT)
                        .show();

                positiveButton.setEnabled(false);
            } else {
                positiveButton.setEnabled(true);
            }

            if (editable.length() == 0) {
                positiveButton.setEnabled(false);
            }
        }
    });
}

From source file:org.sufficientlysecure.keychain.ui.ImportKeysCloudFragment.java

private void toggleKeyboard(boolean show) {
    if (getActivity() == null) {
        return;/*  ww w . j  av a  2  s .c o  m*/
    }
    InputMethodManager inputManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);

    // check if no view has focus
    View v = getActivity().getCurrentFocus();
    if (v == null) {
        return;
    }

    if (show) {
        inputManager.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
    } else {
        inputManager.hideSoftInputFromWindow(v.getWindowToken(), 0);
    }
}

From source file:net.bytten.comicviewer.ComicViewerActivity.java

protected void resetContent() {
    comicDef = makeComicDef();/*  ww w . j a v a 2 s .  co  m*/
    provider = comicDef.getProvider();
    comicInfo = provider.createEmptyComicInfo();

    //Only hide the title bar if we're running an android less than Android 3.0
    if (VersionHacks.getSdkInt() < 11)
        requestWindowFeature(Window.FEATURE_NO_TITLE);

    setContentView(R.layout.main);
    webview = (HackedWebView) findViewById(R.id.viewer);
    title = (TextView) findViewById(R.id.title);
    comicIdSel = (EditText) findViewById(R.id.comicIdSel);

    webview.requestFocus();
    zoom = webview.getZoomControls();

    webview.setClickable(true);
    webview.setOnClickListener(new OnClickListener() {
        public void onClick(View v) {
            if (!"".equals(comicInfo.getAlt()))
                showDialog(DIALOG_SHOW_HOVER_TEXT);
        }
    });

    title.setText(comicInfo.getTitle());

    comicIdSel.setText(comicInfo.getId());
    if (comicDef.idsAreNumbers())
        comicIdSel.setInputType(InputType.TYPE_CLASS_NUMBER);
    comicIdSel.setOnEditorActionListener(new OnEditorActionListener() {
        public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
            String text = comicIdSel.getText().toString();
            if (!text.equals("") && (actionId == EditorInfo.IME_ACTION_GO
                    || (actionId == EditorInfo.IME_NULL && event.getKeyCode() == KeyEvent.KEYCODE_ENTER))) {
                loadComic(createComicUri(text));
                comicIdSel.setText("");
                return true;
            }
            return false;
        }
    });
    comicIdSel.setOnFocusChangeListener(new OnFocusChangeListener() {
        public void onFocusChange(View v, boolean hasFocus) {
            InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (hasFocus) {
                comicIdSel.setText("");
                imm.showSoftInput(comicIdSel, InputMethodManager.SHOW_IMPLICIT);
            } else {
                imm.hideSoftInputFromWindow(comicIdSel.getWindowToken(), 0);
            }
        }
    });

    ((Button) findViewById(R.id.firstBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFirst();
        }
    });

    ((Button) findViewById(R.id.prevBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToPrev();
        }
    });

    ((Button) findViewById(R.id.nextBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToNext();
        }
    });

    ((Button) findViewById(R.id.finalBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToFinal();
        }
    });

    ((ImageView) findViewById(R.id.randomBtn)).setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            goToRandom();
        }
    });

    bookmarkBtn = (ImageView) findViewById(R.id.bookmarkBtn);
    bookmarkBtn.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            toggleBookmark();
        }
    });
    refreshBookmarkBtn();
}

From source file:de.azapps.mirakel.main_activity.tasks_fragment.TasksFragment.java

public void focusNew(final boolean request_focus) {
    if (this.newTask == null) {
        return;/*  w ww  .j  a  v  a  2 s .c o  m*/
    }
    this.newTask.setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(final View v, final boolean hasFocus) {
            if (TasksFragment.this.main.getCurrentPosition() != MainActivity.getTasksFragmentPosition()) {
                return;
            }
            TasksFragment.this.newTask.post(new Runnable() {
                @Override
                public void run() {
                    if (getActivity() == null) {
                        // What the fuck?? This should not happen but it happens for some users
                        return;
                    }
                    final InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    if (imm == null) {
                        Log.w(TasksFragment.TAG, "Inputmanager==null");
                        return;
                    }
                    imm.restartInput(TasksFragment.this.newTask);
                    if (request_focus && hasFocus) {
                        getActivity().getWindow()
                                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_VISIBLE);
                        imm.showSoftInput(TasksFragment.this.newTask, InputMethodManager.SHOW_IMPLICIT);
                        getActivity().getWindow()
                                .setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
                    } else if (!hasFocus) {
                        TasksFragment.this.newTask.requestFocus();
                        imm.showSoftInput(TasksFragment.this.newTask, InputMethodManager.SHOW_IMPLICIT);
                    } else {
                        clearFocus();
                    }
                }
            });
        }
    });
    this.newTask.requestFocus();
    if (!this.newTask.hasFocus()) {
        this.newTask.postDelayed(new Runnable() {
            @Override
            public void run() {
                TasksFragment.this.newTask.requestFocus();
                Log.wtf(TAG, "second try");
            }
        }, 10);
    }
}

From source file:com.tweetlanes.android.view.ComposeBaseFragment.java

void showKeyboard() {
    InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(mEditText, InputMethodManager.SHOW_IMPLICIT);
    //getActivity().getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
}

From source file:com.duy.pascal.ui.debug.activities.DebugActivity.java

@Override
public void showKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    mConsoleView.requestFocus();/*  w  ww .ja v a 2 s  . c o m*/
    if (imm != null) {
        imm.showSoftInput(mConsoleView, InputMethodManager.SHOW_IMPLICIT);
    }
}

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

@NonNull
@Override//from  w  w w .  j  a  va2 s .  com
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    mMessenger = getArguments().getParcelable(IN_MESSENGER);
    mAction = (Action) getArguments().getSerializable(IN_ACTION);
    mPosition = getArguments().getInt(IN_POSITION);
    if (getArguments().getString(IN_URI) == null)
        mURI = null;
    else
        mURI = Uri.parse(getArguments().getString(IN_URI));

    CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);

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

    mAuthorityAliasText = (EditText) view.findViewById(R.id.smartpgp_authority_alias_edit_text);
    mAuthorityAliasTextLayout = (TextInputLayout) view
            .findViewById(R.id.smartpgp_authority_alias_edit_text_layout);
    mAuthorityAdd = (Button) view.findViewById(R.id.smartpgp_authority_filename);

    mAuthorityAdd.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            FileHelper.openDocument(AddEditSmartPGPAuthorityDialogFragment.this, null, "*/*", false,
                    EncryptFilesFragment.REQUEST_CODE_INPUT);
        }
    });

    mAuthorityAliasText.setText(getArguments().getString(IN_ALIAS));

    switch (mAction) {
    case ADD:
        alert.setTitle(R.string.add_smartpgp_authority_dialog_title);
        break;
    case EDIT:
    case DELETE:
        alert.setTitle(R.string.show_smartpgp_authority_dialog_title);
        break;
    }

    // we don't want dialog to be dismissed on click for keyserver addition or edit,
    // 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 for adding keyservers or editing them
            dismiss();
        }
    });

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

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

    switch (mAction) {
    case EDIT:
    case DELETE:
        alert.setNeutralButton(R.string.label_smartpgp_authority_dialog_delete,
                new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialog, int which) {
                        deleteAuthority();
                    }
                });
        break;
    }

    // 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
    mAuthorityAliasText.setOnFocusChangeListener(new View.OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            mAuthorityAliasText.post(new Runnable() {
                @Override
                public void run() {
                    InputMethodManager imm = (InputMethodManager) getActivity()
                            .getSystemService(Context.INPUT_METHOD_SERVICE);
                    imm.showSoftInput(mAuthorityAliasText, InputMethodManager.SHOW_IMPLICIT);
                }
            });
        }
    });
    mAuthorityAliasText.requestFocus();

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

    return alert.show();
}

From source file:com.cerema.cloud2.ui.fragment.SearchShareesFragment.java

@Override
public void onStart() {
    super.onStart();
    // focus the search view and request the software keyboard be shown
    View searchView = getView().findViewById(R.id.searchView);
    if (searchView.requestFocus()) {
        InputMethodManager imm = (InputMethodManager) getActivity()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm != null) {
            imm.showSoftInput(searchView.findFocus(), InputMethodManager.SHOW_IMPLICIT);
        }/*from  w  w w.j a va2  s.  co  m*/
    }
}

From source file:com.king.base.BaseDialogFragment.java

/**
 * /*from  w w  w.j a  va2 s  .  c  om*/
 *
 * @param v
 */
public void showInputMethod(final EditText v) {

    v.requestFocus();
    InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(v, InputMethodManager.SHOW_IMPLICIT);
}