コード例 #1
0
 /** Call this when keyboard configuration has changed. */
 public void onKeyboardConfigurationChanged() {
   Log.d(TAG, "onKeyboardConfigurationChanged: mTextInputType [%d]", mTextInputType);
   if (mTextInputType != TextInputType.NONE) {
     restartInput();
     // By default, we show soft keyboard on keyboard changes. This is useful
     // when the user switches from hardware keyboard to software keyboard.
     // TODO(changwan): check if we can skip this for hardware keyboard configurations.
     showSoftKeyboard();
   }
 }
コード例 #2
0
  /**
   * Shows or hides the keyboard based on passed parameters.
   *
   * @param textInputType Text input type for the currently focused field in renderer.
   * @param textInputFlags Text input flags.
   * @param showIfNeeded Whether the keyboard should be shown if it is currently hidden.
   */
  public void updateKeyboardVisibility(
      int textInputType, int textInputFlags, boolean showIfNeeded) {
    Log.d(
        TAG,
        "updateKeyboardVisibility: type [%d->%d], flags [%d], show [%b], ",
        mTextInputType,
        textInputType,
        textInputFlags,
        showIfNeeded);
    mTextInputFlags = textInputFlags;
    if (mTextInputType != textInputType) {
      mTextInputType = textInputType;
      // No need to restart if we are going to hide anyways.
      if (textInputType != TextInputType.NONE) restartInput();
    }

    // There is no API for us to get notified of user's dismissal of keyboard.
    // Therefore, we should try to show keyboard even when text input type hasn't changed.
    if (textInputType != TextInputType.NONE) {
      if (showIfNeeded) showSoftKeyboard();
    } else {
      hideKeyboard();
    }
  }