android.inputmethodservice.InputMethodService Java Examples

The following examples show how to use android.inputmethodservice.InputMethodService. 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: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 6 votes vote down vote up
private void refreshImeWindowVisibilityLocked() {
    final Configuration conf = mRes.getConfiguration();
    final boolean haveHardKeyboard = conf.keyboard
            != Configuration.KEYBOARD_NOKEYS;
    final boolean hardKeyShown = haveHardKeyboard
            && conf.hardKeyboardHidden
                    != Configuration.HARDKEYBOARDHIDDEN_YES;

    final boolean isScreenLocked = isKeyguardLocked();
    final boolean inputActive = !isScreenLocked && (mInputShown || hardKeyShown);
    // We assume the softkeyboard is shown when the input is active as long as the
    // hard keyboard is not shown.
    final boolean inputVisible = inputActive && !hardKeyShown;
    mImeWindowVis = (inputActive ? InputMethodService.IME_ACTIVE : 0)
            | (inputVisible ? InputMethodService.IME_VISIBLE : 0);
    updateImeWindowStatusLocked();
}
 
Example #2
Source File: ViewOutlineProviderCompatUtilsLXX.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void setInsets(final InputMethodService.Insets insets) {
    final int visibleTopInsets = insets.visibleTopInsets;
    if (mLastVisibleTopInsets != visibleTopInsets) {
        mLastVisibleTopInsets = visibleTopInsets;
        mView.invalidateOutline();
    }
}
 
Example #3
Source File: ViewOutlineProviderCompatUtilsLXX.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void setInsets(final InputMethodService.Insets insets) {
    final int visibleTopInsets = insets.visibleTopInsets;
    if (mLastVisibleTopInsets != visibleTopInsets) {
        mLastVisibleTopInsets = visibleTopInsets;
        mView.invalidateOutline();
    }
}
 
Example #4
Source File: RichInputMethodManager.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #5
Source File: RichInputMethodManager.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
public void switchToShortcutIme(final InputMethodService context) {
    if (mShortcutInputMethodInfo == null) {
        return;
    }

    final String imiId = mShortcutInputMethodInfo.getId();
    switchToTargetIME(imiId, mShortcutSubtype, context);
}
 
Example #6
Source File: LatinIME.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final SettingsValues settingsValues = mSettings.getCurrent();
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null || !hasSuggestionStripView()) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
            && mSuggestionStripView.getVisibility() == View.VISIBLE)
            ? mSuggestionStripView.getHeight() : 0;
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight;
    mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
Example #7
Source File: ChimeeInputMethodService.java    From Chimee with MIT License 5 votes vote down vote up
@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);

    // This gives an invisible padding at the top so that key popups will show in API 28+
    // Touch events on this padding are passed on to whatever views are below it.
    outInsets.visibleTopInsets = imeContainer.getVisibleTop();
    outInsets.contentTopInsets = imeContainer.getVisibleTop();
}
 
Example #8
Source File: LatinIME.java    From hackerskeyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    if (!isFullscreenMode()) {
        outInsets.contentTopInsets = outInsets.visibleTopInsets;
    }
}
 
Example #9
Source File: InputMethodManagerService.java    From TvRemoteControl with Apache License 2.0 5 votes vote down vote up
void unbindCurrentMethodLocked(boolean reportToClient, boolean savePosition) {
    if (mVisibleBound) {
        mContext.unbindService(mVisibleConnection);
        mVisibleBound = false;
    }

    if (mHaveConnection) {
        mContext.unbindService(this);
        mHaveConnection = false;
    }

    if (mCurToken != null) {
        try {
            if (DEBUG) Slog.v(TAG, "Removing window token: " + mCurToken);
            if ((mImeWindowVis & InputMethodService.IME_ACTIVE) != 0 && savePosition) {
                // The current IME is shown. Hence an IME switch (transition) is happening.
                mWindowManagerService.saveLastInputMethodWindowForTransition();
            }
            mIWindowManager.removeWindowToken(mCurToken);
        } catch (RemoteException e) {
        }
        mCurToken = null;
    }

    mCurId = null;
    clearCurMethodLocked();

    if (reportToClient && mCurClient != null) {
        executeOrSendMessage(mCurClient.client, mCaller.obtainMessageIO(
                MSG_UNBIND_METHOD, mCurSeq, mCurClient.client));
    }
}
 
Example #10
Source File: ViewOutlineProviderCompatUtilsLXX.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
@Override
public void setInsets(final InputMethodService.Insets insets) {
    final int visibleTopInsets = insets.visibleTopInsets;
    if (mLastVisibleTopInsets != visibleTopInsets) {
        mLastVisibleTopInsets = visibleTopInsets;
        mView.invalidateOutline();
    }
}
 
Example #11
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #12
Source File: RichInputMethodManager.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
public void switchToShortcutIme(final InputMethodService context) {
    if (mShortcutInputMethodInfo == null) {
        return;
    }

    final String imiId = mShortcutInputMethodInfo.getId();
    switchToTargetIME(imiId, mShortcutSubtype, context);
}
 
Example #13
Source File: RichInputMethodManager.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
public void switchToShortcutIme(final InputMethodService context) {
    if (mShortcutInputMethodInfo == null) {
        return;
    }

    final String imiId = mShortcutInputMethodInfo.getId();
    switchToTargetIME(imiId, mShortcutSubtype, context);
}
 
Example #14
Source File: LatinIME.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight();
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight
                // Extend touchable region below the keyboard.
                + EXTENDED_TOUCHABLE_REGION_HEIGHT;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
Example #15
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #16
Source File: RichInputMethodManager.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #17
Source File: RichInputMethodManager.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
private void switchToTargetIME(final String imiId, final InputMethodSubtype subtype,
        final InputMethodService context) {
    final IBinder token = context.getWindow().getWindow().getAttributes().token;
    if (token == null) {
        return;
    }
    final InputMethodManager imm = getInputMethodManager();
    new AsyncTask<Void, Void, Void>() {
        @Override
        protected Void doInBackground(Void... params) {
            imm.setInputMethodAndSubtype(token, imiId, subtype);
            return null;
        }
    }.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
}
 
Example #18
Source File: LatinIME.java    From openboard with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final SettingsValues settingsValues = mSettings.getCurrent();
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null || !hasSuggestionStripView()) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int suggestionsHeight = (!mKeyboardSwitcher.isShowingEmojiPalettes()
            && mSuggestionStripView.getVisibility() == View.VISIBLE)
            ? mSuggestionStripView.getHeight() : 0;
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight() - suggestionsHeight;
    mSuggestionStripView.setMoreSuggestionsHeight(visibleTopY);
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
Example #19
Source File: BaseKeyboardWidgetManager.java    From Android-Keyboard with Apache License 2.0 5 votes vote down vote up
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    List<KeyboardWidget> widgets = get();
    for (int i = 0; i < widgets.size(); i++) {
        KeyboardWidget widget = widgets.get(i);
        Rect childViewRect = widget.getViewTouchableRect();
        outInsets.touchableRegion.op(childViewRect.left, childViewRect.top, childViewRect.right, childViewRect.bottom, Region.Op.UNION);
    }
}
 
Example #20
Source File: RichInputMethodManager.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
public void switchToShortcutIme(final InputMethodService context) {
    if (mShortcutInputMethodInfo == null) {
        return;
    }

    final String imiId = mShortcutInputMethodInfo.getId();
    switchToTargetIME(imiId, mShortcutSubtype, context);
}
 
Example #21
Source File: RichInputMethodManager.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
public void switchToShortcutIme(final InputMethodService context) {
    if (mShortcutInputMethodInfo == null) {
        return;
    }

    final String imiId = mShortcutInputMethodInfo.getId();
    switchToTargetIME(imiId, mShortcutSubtype, context);
}
 
Example #22
Source File: LatinIME.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
@Override
public void onComputeInsets(final InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);
    // This method may be called before {@link #setInputView(View)}.
    if (mInputView == null) {
        return;
    }
    final View visibleKeyboardView = mKeyboardSwitcher.getVisibleKeyboardView();
    if (visibleKeyboardView == null) {
        return;
    }
    final int inputHeight = mInputView.getHeight();
    if (isImeSuppressedByHardwareKeyboard() && !visibleKeyboardView.isShown()) {
        // If there is a hardware keyboard and a visible software keyboard view has been hidden,
        // no visual element will be shown on the screen.
        outInsets.contentTopInsets = inputHeight;
        outInsets.visibleTopInsets = inputHeight;
        mInsetsUpdater.setInsets(outInsets);
        return;
    }
    final int visibleTopY = inputHeight - visibleKeyboardView.getHeight();
    // Need to set expanded touchable region only if a keyboard view is being shown.
    if (visibleKeyboardView.isShown()) {
        final int touchLeft = 0;
        final int touchTop = mKeyboardSwitcher.isShowingMoreKeysPanel() ? 0 : visibleTopY;
        final int touchRight = visibleKeyboardView.getWidth();
        final int touchBottom = inputHeight
                // Extend touchable region below the keyboard.
                + EXTENDED_TOUCHABLE_REGION_HEIGHT;
        outInsets.touchableInsets = InputMethodService.Insets.TOUCHABLE_INSETS_REGION;
        outInsets.touchableRegion.set(touchLeft, touchTop, touchRight, touchBottom);
    }
    outInsets.contentTopInsets = visibleTopY;
    outInsets.visibleTopInsets = visibleTopY;
    mInsetsUpdater.setInsets(outInsets);
}
 
Example #23
Source File: ImeContainerInputMethodService.java    From mongol-library with MIT License 5 votes vote down vote up
@Override
public void onComputeInsets(InputMethodService.Insets outInsets) {
    super.onComputeInsets(outInsets);

    // This gives an invisible padding at the top so that key popups will show in API 28+
    // Touch events on this padding are passed on to whatever views are below it.
    outInsets.visibleTopInsets = ime.getVisibleTop();
    outInsets.contentTopInsets = ime.getVisibleTop();
}
 
Example #24
Source File: ViewOutlineProviderCompatUtilsLXX.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
@Override
public void setInsets(final InputMethodService.Insets insets) {
    final int visibleTopInsets = insets.visibleTopInsets;
    if (mLastVisibleTopInsets != visibleTopInsets) {
        mLastVisibleTopInsets = visibleTopInsets;
        mView.invalidateOutline();
    }
}
 
Example #25
Source File: LatinIME.java    From Android-Keyboard with Apache License 2.0 4 votes vote down vote up
public HideSoftInputReceiver(InputMethodService ims) {
    mIms = ims;
}
 
Example #26
Source File: ViewOutlineProviderCompatUtils.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
@Override
public void setInsets(final InputMethodService.Insets insets) {}
 
Example #27
Source File: InputMethodServiceCompatUtils.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public static boolean enableHardwareAcceleration(final InputMethodService ims) {
    return (Boolean)CompatUtils.invoke(ims, false /* defaultValue */,
            METHOD_enableHardwareAcceleration);
}
 
Example #28
Source File: RichInputConnection.java    From Indic-Keyboard with Apache License 2.0 4 votes vote down vote up
public RichInputConnection(final InputMethodService parent) {
    mParent = parent;
    mIC = null;
    mNestLevel = 0;
}
 
Example #29
Source File: RichInputConnection.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
public RichInputConnection(final InputMethodService parent) {
    mParent = parent;
    mIC = null;
    mNestLevel = 0;
}
 
Example #30
Source File: LatinIME.java    From openboard with GNU General Public License v3.0 4 votes vote down vote up
public HideSoftInputReceiver(InputMethodService ims) {
    mIms = ims;
}