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:net.gsantner.opoc.ui.FilesystemDialog.java

@OnClick({ R.id.ui__filesystem_dialog__home, R.id.ui__filesystem_dialog__search_button,
        R.id.ui__filesystem_dialog__button_cancel, R.id.ui__filesystem_dialog__button_ok })
public void onClicked(View view) {
    switch (view.getId()) {
    case R.id.ui__filesystem_dialog__button_ok:
    case R.id.ui__filesystem_dialog__home: {
        _filesystemDialogAdapter.onClick(view);
        break;/*from w ww  .  j  av  a2s  .c o  m*/
    }
    case R.id.ui__filesystem_dialog__search_button: {
        _buttonSearch.setVisibility(View.GONE);
        _searchEdit.setVisibility(View.VISIBLE);
        _searchEdit.requestFocus();
        InputMethodManager imm = (InputMethodManager) getContext()
                .getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(_searchEdit, InputMethodManager.SHOW_IMPLICIT);
        break;
    }
    case R.id.ui__filesystem_dialog__button_cancel: {
        onFsNothingSelected(_dopt.requestId);
        break;
    }

    }
}

From source file:com.bonsai.btcreceive.ReceiveFragment.java

public void maybeShowKeyboard() {
    // Called by our parent when it would be good for us to
    // bring up the keyboard.

    mLogger.info("maybeShowKeyboard starting");

    // Does this ever happen?
    if (mFiatAmountEditText == null || mBTCAmountEditText == null)
        return;/*from   w ww .  j  a  v  a2  s. co  m*/

    // If the user has the value set already we don't want the
    // keyboard.
    if (mValueSet)
        return;

    mFiatAmountEditText.setFocusable(true);
    mFiatAmountEditText.setFocusableInTouchMode(true);
    mBTCAmountEditText.setFocusable(true);
    mBTCAmountEditText.setFocusableInTouchMode(true);

    Activity activity = getActivity();
    InputMethodManager imm = (InputMethodManager) activity.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (mUserSetAmountFiat) {
        mLogger.info("maybeShowKeyboard fiat");
        imm.showSoftInput(mFiatAmountEditText, InputMethodManager.SHOW_IMPLICIT);
        mFiatAmountEditText.requestFocus();
    } else {
        mLogger.info("maybeShowKeyboard btc");
        imm.showSoftInput(mBTCAmountEditText, InputMethodManager.SHOW_IMPLICIT);
        mBTCAmountEditText.requestFocus();
    }
}

From source file:pl.mrwojtek.sensrec.app.SamplingPeriodDialog.java

private void initializeSamplingSpinner(View view) {
    TextView samplingCaption = (TextView) view.findViewById(R.id.sampling_caption);
    MaterialUtils.transformForSpinner(samplingCaption);

    samplingSpinner = (Spinner) view.findViewById(R.id.sampling_spinner);
    samplingSpinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override/*from  ww  w . j av  a 2s  .  co  m*/
        public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
            InputMethodManager inputMethodManager = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            if (position != POSITION_CUSTOM) {
                millisecondsEdit.setText("");
                if (!initializing) {
                    millisecondsEdit.clearFocus();
                    inputMethodManager.hideSoftInputFromWindow(millisecondsEdit.getWindowToken(), 0);
                } else {
                    initializing = false;
                }
            } else {
                if (!initializing) {
                    millisecondsEdit.requestFocus();
                    inputMethodManager.showSoftInput(millisecondsEdit, InputMethodManager.SHOW_IMPLICIT);
                } else {
                    initializing = false;
                }
            }
            updateOkButton();
        }

        @Override
        public void onNothingSelected(AdapterView<?> parent) {
            // Do nothing
        }
    });
}

From source file:hobby.wei.c.framework.AbsActivity.java

protected void showInputMethod() {
    View focusView = getCurrentFocus();
    if (focusView != null) { //?
        InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(
                Context.INPUT_METHOD_SERVICE);
        inputMethodManager.showSoftInput(focusView, InputMethodManager.SHOW_IMPLICIT);
    }/*  w ww  .j  av  a  2s.  co m*/
}

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

@NonNull
@Override//ww w .  j  av a  2 s .  c  o  m
public Dialog onCreateDialog(Bundle savedInstanceState) {
    final Activity activity = getActivity();

    mMessenger = getArguments().getParcelable(ARG_MESSENGER);
    mDialogAction = (DialogAction) getArguments().getSerializable(ARG_ACTION);
    mPosition = getArguments().getInt(ARG_POSITION);

    CustomAlertDialogBuilder alert = new CustomAlertDialogBuilder(activity);

    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);
    mKeyserverEditTextLayout = (TextInputLayout) view.findViewById(R.id.keyserver_url_edit_text_layout);
    mKeyserverEditOnionText = (EditText) view.findViewById(R.id.keyserver_onion_edit_text);
    mKeyserverEditOnionTextLayout = (TextInputLayout) view.findViewById(R.id.keyserver_onion_edit_text_layout);
    mVerifyKeyserverCheckBox = (CheckBox) view.findViewById(R.id.verify_connection_checkbox);
    mOnlyTrustedKeyserverCheckBox = (CheckBox) view.findViewById(R.id.only_trusted_keyserver_checkbox);
    mVerifyKeyserverCheckBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            mOnlyTrustedKeyserverCheckBox.setEnabled(isChecked);
        }
    });

    switch (mDialogAction) {
    case ADD: {
        alert.setTitle(R.string.add_keyserver_dialog_title);
        break;
    }
    case EDIT: {
        alert.setTitle(R.string.edit_keyserver_dialog_title);
        ParcelableHkpKeyserver keyserver = getArguments().getParcelable(ARG_KEYSERVER);
        mKeyserverEditText.setText(keyserver.getUrl());
        mKeyserverEditOnionText.setText(keyserver.getOnion());
        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
        }
    });

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

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

    switch (mDialogAction) {
    case EDIT: {
        alert.setNeutralButton(R.string.label_keyserver_dialog_delete, new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                deleteKeyserver(mPosition);
            }
        });
        break;
    }
    case ADD: {
        // do nothing
        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
    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:com.chrynan.guitarchords.view.GuitarChordView.java

private void init(Context context, AttributeSet attrs) {
    detector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override//from   www  . j a v a2 s .  c om
        public boolean onDown(MotionEvent event) {
            boolean isMarkerInChord = false;
            int fret = NO_FRET, string = -1;
            fret = getSelectedFret(event);
            string = getSelectedString(event);
            touchEventMarker = new ChordMarker(string, fret, NO_FINGER);
            return true;
        }

        @Override
        public void onLongPress(MotionEvent event) {
            if (editable && touchEventMarker != null && chord != null && chord.contains(touchEventMarker)) {
                InputMethodManager imm = (InputMethodManager) getContext()
                        .getSystemService(Context.INPUT_METHOD_SERVICE);
                imm.showSoftInput(GuitarChordView.this, InputMethodManager.SHOW_IMPLICIT);
            }
        }
    });
    chord = new Chord();
    showFretNumbers = true;
    showFingerNumbers = true;
    editable = false;
    stringCount = 6;
    listeners = new ArrayList<>();
    fretNumberListeners = new ArrayList<>();
    stringListeners = new ArrayList<>();
    touchEventMarker = null;
    mutedText = MUTED_TEXT;
    openStringText = OPEN_STRING_TEXT;
    initPaint();
    if (attrs != null) {
        //TODO handle custom attribute values
        TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.GuitarChordView, 0, 0);
        try {
            bridgeNutColor = a.getColor(R.styleable.GuitarChordView_bridgeNutColor, DEFAULT_COLOR);
            bridgeNutPaint.setColor(bridgeNutColor);
            fretMarkerColor = a.getColor(R.styleable.GuitarChordView_fretMarkerColor, DEFAULT_COLOR);
            fretMarkerPaint.setColor(fretMarkerColor);
            stringColor = a.getColor(R.styleable.GuitarChordView_stringColor, DEFAULT_COLOR);
            stringPaint.setColor(stringColor);
            fretNumberColor = a.getColor(R.styleable.GuitarChordView_fretNumberColor, DEFAULT_COLOR);
            fretNumberPaint.setColor(fretNumberColor);
            stringMarkerColor = a.getColor(R.styleable.GuitarChordView_stringMarkerColor, DEFAULT_COLOR);
            stringMarkerPaint.setColor(stringMarkerColor);
            noteColor = a.getColor(R.styleable.GuitarChordView_noteColor, DEFAULT_COLOR);
            notePaint.setColor(noteColor);
            noteNumberColor = a.getColor(R.styleable.GuitarChordView_noteNumberColor, WHITE);
            noteNumberPaint.setColor(noteNumberColor);
            barLineColor = a.getColor(R.styleable.GuitarChordView_barLineColor, DEFAULT_COLOR);
            barLinePaint.setColor(barLineColor);
            mutedText = a.getString(R.styleable.GuitarChordView_mutedText);
            mutedText = (mutedText == null) ? MUTED_TEXT : mutedText;
            openStringText = a.getString(R.styleable.GuitarChordView_openStringText);
            openStringText = (openStringText == null) ? OPEN_STRING_TEXT : openStringText;
            stringCount = a.getInt(R.styleable.GuitarChordView_stringAmount, 6);
            editable = a.getBoolean(R.styleable.GuitarChordView_editable, false);
            showFingerNumbers = a.getBoolean(R.styleable.GuitarChordView_showFingerNumbers, true);
            showFretNumbers = a.getBoolean(R.styleable.GuitarChordView_showFretNumbers, true);
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            a.recycle();
        }
    }
}

From source file:de.baumann.hhsmoodle.helper.helper_main.java

public static void showKeyboard(final Activity activity, final EditText editText) {
    new Handler().postDelayed(new Runnable() {
        public void run() {
            InputMethodManager imm = (InputMethodManager) activity
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText, InputMethodManager.SHOW_IMPLICIT);
            editText.setSelection(editText.length());
        }// w  w w .  jav  a 2s.co m
    }, 200);
}

From source file:com.farmerbb.taskbar.fragment.AdvancedFragment.java

@SuppressLint("SetTextI18n")
@Override//from   www . j  a  v a2s . c o  m
public boolean onPreferenceClick(final Preference p) {
    final SharedPreferences pref = U.getSharedPreferences(getActivity());

    switch (p.getKey()) {
    case "clear_pinned_apps":
        Intent clearIntent = null;

        switch (pref.getString("theme", "light")) {
        case "light":
            clearIntent = new Intent(getActivity(), ClearDataActivity.class);
            break;
        case "dark":
            clearIntent = new Intent(getActivity(), ClearDataActivityDark.class);
            break;
        }

        startActivity(clearIntent);
        break;
    case "launcher":
        if (U.canDrawOverlays(getActivity())) {
            ComponentName component = new ComponentName(getActivity(), HomeActivity.class);
            getActivity().getPackageManager().setComponentEnabledSetting(component,
                    ((CheckBoxPreference) p).isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                            : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                    PackageManager.DONT_KILL_APP);
        } else {
            U.showPermissionDialog(getActivity());
            ((CheckBoxPreference) p).setChecked(false);
        }

        if (!((CheckBoxPreference) p).isChecked())
            LocalBroadcastManager.getInstance(getActivity())
                    .sendBroadcast(new Intent("com.farmerbb.taskbar.KILL_HOME_ACTIVITY"));
        break;
    case "keyboard_shortcut":
        ComponentName component = new ComponentName(getActivity(), KeyboardShortcutActivity.class);
        getActivity().getPackageManager()
                .setComponentEnabledSetting(component,
                        ((CheckBoxPreference) p).isChecked() ? PackageManager.COMPONENT_ENABLED_STATE_ENABLED
                                : PackageManager.COMPONENT_ENABLED_STATE_DISABLED,
                        PackageManager.DONT_KILL_APP);
        break;
    case "dashboard_grid_size":
        AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
        LinearLayout dialogLayout = (LinearLayout) View.inflate(getActivity(), R.layout.dashboard_size_dialog,
                null);

        boolean isPortrait = getActivity().getApplicationContext().getResources()
                .getConfiguration().orientation == Configuration.ORIENTATION_PORTRAIT;
        boolean isLandscape = getActivity().getApplicationContext().getResources()
                .getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE;

        int editTextId = -1;
        int editText2Id = -1;

        if (isPortrait) {
            editTextId = R.id.fragmentEditText2;
            editText2Id = R.id.fragmentEditText1;
        }

        if (isLandscape) {
            editTextId = R.id.fragmentEditText1;
            editText2Id = R.id.fragmentEditText2;
        }

        final EditText editText = (EditText) dialogLayout.findViewById(editTextId);
        final EditText editText2 = (EditText) dialogLayout.findViewById(editText2Id);

        builder.setView(dialogLayout).setTitle(R.string.dashboard_grid_size)
                .setPositiveButton(R.string.action_ok, (dialog, id) -> {
                    boolean successfullyUpdated = false;

                    String widthString = editText.getText().toString();
                    String heightString = editText2.getText().toString();

                    if (widthString.length() > 0 && heightString.length() > 0) {
                        int width = Integer.parseInt(widthString);
                        int height = Integer.parseInt(heightString);

                        if (width > 0 && height > 0) {
                            SharedPreferences.Editor editor = pref.edit();
                            editor.putInt("dashboard_width", width);
                            editor.putInt("dashboard_height", height);
                            editor.apply();

                            updateDashboardGridSize(true);
                            successfullyUpdated = true;
                        }
                    }

                    if (!successfullyUpdated)
                        U.showToast(getActivity(), R.string.invalid_grid_size);
                }).setNegativeButton(R.string.action_cancel, null);

        editText.setText(Integer.toString(pref.getInt("dashboard_width",
                getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_width))));
        editText2.setText(Integer.toString(pref.getInt("dashboard_height",
                getActivity().getApplicationContext().getResources().getInteger(R.integer.dashboard_height))));

        AlertDialog dialog = builder.create();
        dialog.show();

        new Handler().post(() -> {
            InputMethodManager imm = (InputMethodManager) getActivity()
                    .getSystemService(Context.INPUT_METHOD_SERVICE);
            imm.showSoftInput(editText2, InputMethodManager.SHOW_IMPLICIT);
        });

        break;
    case "navigation_bar_buttons":
        Intent intent = null;

        switch (pref.getString("theme", "light")) {
        case "light":
            intent = new Intent(getActivity(), NavigationBarButtonsActivity.class);
            break;
        case "dark":
            intent = new Intent(getActivity(), NavigationBarButtonsActivityDark.class);
            break;
        }

        startActivity(intent);
        break;
    }

    return true;
}

From source file:com.pixplicity.castdemo.MainActivity.java

private void setConnected(boolean connected) {
    mBtSend.setEnabled(connected);/*from  w  ww  .ja  va  2 s  .c  om*/
    mBtSpeak.setEnabled(connected);
    mEtMessage.setEnabled(connected);
    if (connected) {
        mEtMessage.requestFocus();
        // Implicity request a soft input mode
        InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.showSoftInput(mEtMessage, InputMethodManager.SHOW_IMPLICIT);
    }

}

From source file:com.gm.goldencity.util.Utils.java

/**
 * Show keyboard of a View/*w w  w.  ja  v  a2  s. co  m*/
 *
 * @param context Application context
 * @param view    Edit text or another view that you want hide the keyboard
 */
public static void showKeyboard(Context context, @NonNull View view) {
    InputMethodManager inputMethodManager = (InputMethodManager) context
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    inputMethodManager.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);
}