Java Code Examples for android.view.inputmethod.InputMethodManager#isAcceptingText()

The following examples show how to use android.view.inputmethod.InputMethodManager#isAcceptingText() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: LockableActivity.java    From smartcoins-wallet with MIT License 6 votes vote down vote up
public void showKeyboard(View view) {
    InputMethodManager imm = (InputMethodManager)
            getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(view, InputMethodManager.SHOW_IMPLICIT);

    if (imm.isAcceptingText()) {
        Log.d(TAG, "Software Keyboard was shown");
    } else {
        Log.d(TAG, "Software Keyboard was not shown.");
        //Sometimes the android doesn't show the keyboard at start up. Scheduling a new open solved for all tested cases
        if (view.getVisibility() == View.VISIBLE) {
            Log.d(TAG, "View is still visible. Scheduling a new input opening attempt...");
            final View runnableView = view;
            view.postDelayed(new Runnable() {
                public void run() {
                    // do work
                    showKeyboard(runnableView);
                }
            }, 100);
        }
    }
}
 
Example 2
Source File: HiddenEditText.java    From mollyim-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
  boolean focus = super.requestFocus(direction, previouslyFocusedRect);

  if (currentTextEntity != null && focus) {
    currentTextEntity.setFocused(true);
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
    if (!imm.isAcceptingText()) {
      imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }
  }

  return focus;
}
 
Example 3
Source File: GameActivity.java    From Game with GNU General Public License v3.0 5 votes vote down vote up
public void drawKeyboard() {
      InputMethodManager imm = (InputMethodManager) this
              .getSystemService(Context.INPUT_METHOD_SERVICE);
      Objects.requireNonNull(imm).toggleSoftInput(InputMethodManager.SHOW_FORCED, InputMethodManager.HIDE_IMPLICIT_ONLY);
      if (imm.isAcceptingText()) osConfig.F_SHOWING_KEYBOARD = true;
      if (Config.S_SIDE_MENU_TOGGLE) {
      	hadSideMenu = mudclient.getOptionSideMenu();
	mudclient.setOptionSideMenu(false);
}
  }
 
Example 4
Source File: SDLActivity.java    From simpleSDL with MIT License 5 votes vote down vote up
/**
 * This method is called by SDL using JNI.
 */
public static boolean isScreenKeyboardShown() 
{
    if (mTextEdit == null) {
        return false;
    }

    if (!mScreenKeyboardShown) {
        return false;
    }

    InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.isAcceptingText();

}
 
Example 5
Source File: MainActivity.java    From Primary with GNU General Public License v3.0 5 votes vote down vote up
private void goAwayKeys(EditText input) {
    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

    if(imm!=null && imm.isAcceptingText()) { // verify if the soft keyboard is open
        if (input!=null) {
            imm.hideSoftInputFromWindow(input.getWindowToken(), 0);
        } else if (getCurrentFocus()!=null){
            imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
        }
    }
}
 
Example 6
Source File: MainActivity.java    From journaldev with MIT License 5 votes vote down vote up
private void hideSoftKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(INPUT_METHOD_SERVICE);

    if (imm.isAcceptingText()) {
        // verify if the soft keyboard is open
        imm.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
    }
}
 
Example 7
Source File: HiddenEditText.java    From deltachat-android with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean requestFocus(int direction, Rect previouslyFocusedRect) {
  boolean focus = super.requestFocus(direction, previouslyFocusedRect);

  if (currentTextEntity != null && focus) {
    currentTextEntity.setFocused(true);
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.showSoftInput(this, InputMethodManager.SHOW_IMPLICIT);
    if (!imm.isAcceptingText()) {
      imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, InputMethodManager.HIDE_IMPLICIT_ONLY);
    }
  }

  return focus;
}
 
Example 8
Source File: MainActivity.java    From AutoAP with Apache License 2.0 5 votes vote down vote up
@Override
public void onClick(View v) {
    switch (v.getId()) {
        case R.id.save_button:
            ssid = ssidEditText.getText().toString();
            password = passwordEditText.getText().toString();

            if (TextUtils.isEmpty(ssid)) {
                ssidEditText.setError("Network SSID is empty");
                return;
            }
            if (TextUtils.isEmpty(password) || password.length() < WifiAPUtils.PASS_MIN_LENGTH) {
                passwordEditText.setError("You must have 8 characters in password");
                return;
            }

            SharedPreferences.Editor editor = mSharedPrefs.edit();
            editor.putString(Constants.PREFS_SSID, ssid);
            editor.putString(Constants.PREFS_SECURITY, securityType);
            editor.putString(Constants.PREFS_PASSWORD, password);
            editor.commit();

            InputMethodManager inputMethodManager = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
            if (inputMethodManager.isAcceptingText()) {
                inputMethodManager.hideSoftInputFromWindow(getCurrentFocus().getWindowToken(), 0);
            }

            Toast.makeText(MainActivity.this, "Network Info saved", Toast.LENGTH_SHORT).show();
            break;
        case R.id.tethering_image:
            if (mSwitch.isChecked()) {
                mSwitch.setChecked(false);
            } else {
                mSwitch.setChecked(true);
            }
            break;
    }
}
 
Example 9
Source File: LyricsViewFragment.java    From QuickLyric with GNU General Public License v3.0 5 votes vote down vote up
private void exitEditTagsMode() {
    ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).setImageResource(R.drawable.ic_done_anim);
    Drawable editIcon = ((ImageButton) getActivity().findViewById(R.id.edit_tags_btn)).getDrawable();
    ((Animatable) editIcon).start();

    if (getActivity().getCurrentFocus() != null) {
        InputMethodManager imm = (InputMethodManager) getActivity().getSystemService(Context.INPUT_METHOD_SERVICE);
        if (imm.isAcceptingText())
            imm.hideSoftInputFromWindow(getActivity().getCurrentFocus().getWindowToken(), 0);
    }

    EditText songTV = getActivity().findViewById(R.id.song);
    EditText artistTV = getActivity().findViewById(R.id.artist);
    EditText newLyrics = getActivity().findViewById(R.id.edit_lyrics);

    songTV.setInputType(InputType.TYPE_NULL);
    artistTV.setInputType(InputType.TYPE_NULL);
    songTV.setBackgroundColor(Color.TRANSPARENT);
    artistTV.setBackgroundColor(Color.TRANSPARENT);

    String txt = mLrcThread == null ? null : mLyrics.getText();
    if (txt == null)
        txt = "";

    File musicFile = Id3Reader.getFile(getActivity(), mLyrics.getOriginalArtist(), mLyrics.getOriginalTitle(), true);

    if (!mLyrics.getArtist().equals(artistTV.getText().toString())
            || !mLyrics.getTitle().equals(songTV.getText().toString())
            || !Html.fromHtml(txt).toString().equals(newLyrics.getText().toString())) {
        mLyrics.setArtist(artistTV.getText().toString());
        mLyrics.setTitle(songTV.getText().toString());
        mLyrics.setText(newLyrics.getText().toString().replaceAll("\n", "<br/>"));
        if (PermissionsChecker.requestPermission(getActivity(),
                "android.permission.WRITE_EXTERNAL_STORAGE", 0, Id3Writer.REQUEST_CODE))
            new Id3Writer(this).execute(mLyrics, musicFile);
    } else
        new Id3Writer(this).onPreExecute();
    update(mLyrics, getView(), false);
}
 
Example 10
Source File: SDLActivity.java    From android-port with GNU General Public License v3.0 5 votes vote down vote up
/**
 * This method is called by SDL using JNI.
 */
public static boolean isScreenKeyboardShown() 
{
    if (mTextEdit == null) {
        return false;
    }

    if (!mScreenKeyboardShown) {
        return false;
    }

    InputMethodManager imm = (InputMethodManager) SDL.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    return imm.isAcceptingText();

}
 
Example 11
Source File: ViewTaskActivity.java    From ResearchStack with Apache License 2.0 4 votes vote down vote up
private void hideKeyboard() {
    InputMethodManager imm = (InputMethodManager) getSystemService(Activity.INPUT_METHOD_SERVICE);
    if (imm.isActive() && imm.isAcceptingText()) {
        imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0);
    }
}