android.view.inputmethod.InputMethod Java Examples

The following examples show how to use android.view.inputmethod.InputMethod. 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: InputMethodService.java    From android_9.0.0_r45 with Apache License 2.0 6 votes vote down vote up
/**
 * The system has decided that it may be time to show your input method.
 * This is called due to a corresponding call to your
 * {@link InputMethod#showSoftInput InputMethod.showSoftInput()}
 * method.  The default implementation uses
 * {@link #onEvaluateInputViewShown()}, {@link #onEvaluateFullscreenMode()},
 * and the current configuration to decide whether the input view should
 * be shown at this point.
 * 
 * @param flags Provides additional information about the show request,
 * as per {@link InputMethod#showSoftInput InputMethod.showSoftInput()}.
 * @param configChange This is true if we are re-showing due to a
 * configuration change.
 * @return Returns true to indicate that the window should be shown.
 */
public boolean onShowInputRequested(int flags, boolean configChange) {
    if (!onEvaluateInputViewShown()) {
        return false;
    }
    if ((flags&InputMethod.SHOW_EXPLICIT) == 0) {
        if (!configChange && onEvaluateFullscreenMode()) {
            // Don't show if this is not explicitly requested by the user and
            // the input method is fullscreen.  That would be too disruptive.
            // However, we skip this change for a config change, since if
            // the IME is already shown we do want to go into fullscreen
            // mode at this point.
            return false;
        }
        if (!mSettingsObserver.shouldShowImeWithHardKeyboard() &&
                getResources().getConfiguration().keyboard != Configuration.KEYBOARD_NOKEYS) {
            // And if the device has a hard keyboard, even if it is
            // currently hidden, don't show the input method implicitly.
            // These kinds of devices don't need it that much.
            return false;
        }
    }
    return true;
}
 
Example #2
Source File: IInputMethodWrapper.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
public IInputMethodWrapper(AbstractInputMethodService context, InputMethod inputMethod) {
    mTarget = new WeakReference<>(context);
    mContext = context.getApplicationContext();
    mCaller = new HandlerCaller(mContext, null, this, true /*asyncHandler*/);
    mInputMethod = new WeakReference<>(inputMethod);
    mTargetSdkVersion = context.getApplicationInfo().targetSdkVersion;
}
 
Example #3
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 5 votes vote down vote up
private int getImeShowFlags() {
    int flags = 0;
    if (mShowForced) {
        flags |= InputMethod.SHOW_FORCED
                | InputMethod.SHOW_EXPLICIT;
    } else if (mShowExplicitlyRequested) {
        flags |= InputMethod.SHOW_EXPLICIT;
    }
    return flags;
}
 
Example #4
Source File: BaseFragment.java    From BaseUIFrame with MIT License 4 votes vote down vote up
/**
 * 显示键盘
 */
protected void showKeyBoard() {
    InputMethodManager imm = (InputMethodManager) getActivity().getApplicationContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    imm.toggleSoftInput(0, InputMethod.SHOW_FORCED);
}
 
Example #5
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 4 votes vote down vote up
InputBindResult startInputInnerLocked() {
    if (mCurMethodId == null) {
        return mNoBinding;
    }

    if (!mSystemReady) {
        // If the system is not yet ready, we shouldn't be running third
        // party code.
        return new InputBindResult(null, null, mCurMethodId, mCurSeq);
    }

    InputMethodInfo info = mMethodMap.get(mCurMethodId);
    if (info == null) {
        throw new IllegalArgumentException("Unknown id: " + mCurMethodId);
    }

    unbindCurrentMethodLocked(false, true);

    mCurIntent = new Intent(InputMethod.SERVICE_INTERFACE);
    mCurIntent.setComponent(info.getComponent());
    mCurIntent.putExtra(Intent.EXTRA_CLIENT_LABEL,
            com.android.internal.R.string.input_method_binding_label);
    mCurIntent.putExtra(Intent.EXTRA_CLIENT_INTENT, PendingIntent.getActivity(
            mContext, 0, new Intent(Settings.ACTION_INPUT_METHOD_SETTINGS), 0));
    if (bindCurrentInputMethodService(mCurIntent, this, Context.BIND_AUTO_CREATE
            | Context.BIND_NOT_VISIBLE | Context.BIND_SHOWING_UI)) {
        mLastBindTime = SystemClock.uptimeMillis();
        mHaveConnection = true;
        mCurId = info.getId();
        mCurToken = new Binder();
        try {
            if (true || DEBUG) Slog.v(TAG, "Adding window token: " + mCurToken);
            mIWindowManager.addWindowToken(mCurToken,
                    WindowManager.LayoutParams.TYPE_INPUT_METHOD);
        } catch (RemoteException e) {
        }
        return new InputBindResult(null, null, mCurId, mCurSeq);
    } else {
        mCurIntent = null;
        Slog.w(TAG, "Failure connecting to input method service: "
                + mCurIntent);
    }
    return null;
}