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

The following examples show how to use android.view.inputmethod.InputMethodManager#restartInput() . 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: EmojiPopup.java    From Emoji with Apache License 2.0 6 votes vote down vote up
private void showAtBottomPending() {
  isPendingOpen = true;
  final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

  if (Utils.shouldOverrideRegularCondition(context, editText)) {
    editText.setImeOptions(editText.getImeOptions() | EditorInfo.IME_FLAG_NO_EXTRACT_UI);
    if (inputMethodManager != null) {
      inputMethodManager.restartInput(editText);
    }
  }

  if (inputMethodManager != null) {
    emojiResultReceiver.setReceiver(this);
    inputMethodManager.showSoftInput(editText, InputMethodManager.RESULT_UNCHANGED_SHOWN, emojiResultReceiver);
  }
}
 
Example 2
Source File: EmojiPopup.java    From Emoji with Apache License 2.0 6 votes vote down vote up
public void dismiss() {
  popupWindow.dismiss();
  variantPopup.dismiss();
  recentEmoji.persist();
  variantEmoji.persist();

  emojiResultReceiver.setReceiver(null);

  if (originalImeOptions != -1) {
    editText.setImeOptions(originalImeOptions);
    final InputMethodManager inputMethodManager = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);

    if (inputMethodManager != null) {
      inputMethodManager.restartInput(editText);
    }

    if (SDK_INT >= O) {
      final AutofillManager autofillManager = context.getSystemService(AutofillManager.class);
      if (autofillManager != null) {
        autofillManager.cancel();
      }
    }
  }
}
 
Example 3
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
public void stopTextComposing() {
    InputMethodManager im = (InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    // This is an overkill way to inform the InputMethod that the caret
    // might have changed position and it should re-evaluate the
    // caps mode to use.
    im.restartInput(FreeScrollingTextField.this);

    if (_inputConnection != null && _inputConnection.isComposingStarted()) {
        _inputConnection.resetComposingState();
    }
}
 
Example 4
Source File: FreeScrollingTextField.java    From CodeEditor with Apache License 2.0 5 votes vote down vote up
public void stopTextComposing() {
    InputMethodManager im = (InputMethodManager) getContext()
            .getSystemService(Context.INPUT_METHOD_SERVICE);
    // This is an overkill way to inform the InputMethod that the caret
    // might have changed position and it should re-evaluate the
    // caps mode to use.
    im.restartInput(FreeScrollingTextField.this);

    if (_inputConnection != null && _inputConnection.isComposingStarted()) {
        _inputConnection.resetComposingState();
    }
}
 
Example 5
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see View#onConfigurationChanged(Configuration)
 */
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
    TraceEvent.begin();

    if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
        mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
                ImeAdapter.getTextInputTypeNone(),
                AdapterInputConnection.INVALID_SELECTION,
                AdapterInputConnection.INVALID_SELECTION);
        InputMethodManager manager = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.restartInput(mContainerView);
    }
    mContainerViewInternals.super_onConfigurationChanged(newConfig);
    // Make sure the size is up to date in JavaScript's window.onorientationchanged.
    mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mContainerView.removeOnLayoutChangeListener(this);
            sendOrientationChangeEvent();
        }
    });
    // To request layout has side effect, but it seems OK as it only happen in
    // onConfigurationChange and layout has to be changed in most case.
    mContainerView.requestLayout();
    TraceEvent.end();
}
 
Example 6
Source File: ContentViewCore.java    From android-chromium with BSD 2-Clause "Simplified" License 5 votes vote down vote up
/**
 * @see View#onConfigurationChanged(Configuration)
 */
@SuppressWarnings("javadoc")
public void onConfigurationChanged(Configuration newConfig) {
    TraceEvent.begin();

    if (newConfig.keyboard != Configuration.KEYBOARD_NOKEYS) {
        mImeAdapter.attach(nativeGetNativeImeAdapter(mNativeContentViewCore),
                ImeAdapter.getTextInputTypeNone(),
                AdapterInputConnection.INVALID_SELECTION,
                AdapterInputConnection.INVALID_SELECTION);
        InputMethodManager manager = (InputMethodManager)
                getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        manager.restartInput(mContainerView);
    }
    mContainerViewInternals.super_onConfigurationChanged(newConfig);
    // Make sure the size is up to date in JavaScript's window.onorientationchanged.
    mContainerView.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
        @Override
        public void onLayoutChange(View v, int left, int top, int right, int bottom,
                int oldLeft, int oldTop, int oldRight, int oldBottom) {
            mContainerView.removeOnLayoutChangeListener(this);
            sendOrientationChangeEvent();
        }
    });
    // To request layout has side effect, but it seems OK as it only happen in
    // onConfigurationChange and layout has to be changed in most case.
    mContainerView.requestLayout();
    TraceEvent.end();
}
 
Example 7
Source File: MentionsEditText.java    From Spyglass with Apache License 2.0 4 votes vote down vote up
private void restartInput() {
    InputMethodManager imm = (InputMethodManager) getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    if (imm != null) {
        imm.restartInput(this);
    }
}