Java源码示例:android.view.inputmethod.CursorAnchorInfo

示例1
/**
 * Call {@link InputMethodService#onUpdateCursorAnchorInfo
 * InputMethodService.onUpdateCursorAnchorInfo()}.
 */
public void updateCursorAnchorInfo(CursorAnchorInfo info) {
    if (!isEnabled()) {
        return;
    }
    InputMethodService.this.onUpdateCursorAnchorInfo(info);
}
 
示例2
@Override
public void updateCursorAnchorInfo(@NonNull GeckoSession aSession, @NonNull CursorAnchorInfo info) {
    if (mState.mSession == aSession) {
        for (GeckoSession.TextInputDelegate listener : mTextInputListeners) {
            listener.updateCursorAnchorInfo(aSession, info);
        }
    }
}
 
示例3
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Nullable
public static CursorAnchorInfoCompatWrapper wrap(@Nullable final CursorAnchorInfo instance) {
    if (BuildCompatUtils.EFFECTIVE_SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return null;
    }
    if (instance == null) {
        return null;
    }
    return new RealWrapper(instance);
}
 
示例4
/**
 * @see android.view.inputmethod.InputMethodManager#updateCursorAnchorInfo(View,
 * CursorAnchorInfo)
 */
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void updateCursorAnchorInfo(View view, CursorAnchorInfo cursorAnchorInfo) {
    if (DEBUG_LOGS) Log.i(TAG, "updateCursorAnchorInfo");
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        getInputMethodManager().updateCursorAnchorInfo(view, cursorAnchorInfo);
    }
}
 
示例5
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Nullable
public static CursorAnchorInfoCompatWrapper wrap(@Nullable final CursorAnchorInfo instance) {
    if (BuildCompatUtils.EFFECTIVE_SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
        return null;
    }
    if (instance == null) {
        return null;
    }
    return new RealWrapper(instance);
}
 
示例6
@Override
public void updateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
    mCaller.executeOrSendMessage(
            mCaller.obtainMessageO(DO_UPDATE_CURSOR_ANCHOR_INFO, cursorAnchorInfo));
}
 
示例7
public RealWrapper(@Nonnull final CursorAnchorInfo info) {
    mInstance = info;
}
 
示例8
/**
 * Computes the CursorAnchorInfo instance and notify to InputMethodManager if needed.
 */
private void updateCursorAnchorInfo(View view) {
    if (!mHasCoordinateInfo) return;

    if (mLastCursorAnchorInfo == null) {
        // Reuse the builder object.
        mCursorAnchorInfoBuilder.reset();

        CharSequence text = mComposingTextDelegate.getText();
        int selectionStart = mComposingTextDelegate.getSelectionStart();
        int selectionEnd = mComposingTextDelegate.getSelectionEnd();
        int composingTextStart = mComposingTextDelegate.getComposingTextStart();
        int composingTextEnd = mComposingTextDelegate.getComposingTextEnd();
        if (text != null && 0 <= composingTextStart && composingTextEnd <= text.length()) {
            mCursorAnchorInfoBuilder.setComposingText(composingTextStart,
                    text.subSequence(composingTextStart, composingTextEnd));
            float[] compositionCharacterBounds = mCompositionCharacterBounds;
            if (compositionCharacterBounds != null) {
                int numCharacter = compositionCharacterBounds.length / 4;
                for (int i = 0; i < numCharacter; ++i) {
                    float left = compositionCharacterBounds[i * 4];
                    float top = compositionCharacterBounds[i * 4 + 1];
                    float right = compositionCharacterBounds[i * 4 + 2];
                    float bottom = compositionCharacterBounds[i * 4 + 3];
                    int charIndex = composingTextStart + i;
                    mCursorAnchorInfoBuilder.addCharacterBounds(charIndex, left, top, right,
                            bottom, CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION);
                }
            }
        }
        mCursorAnchorInfoBuilder.setSelectionRange(selectionStart, selectionEnd);
        mMatrix.setScale(mScale, mScale);
        mMatrix.postTranslate(mTranslationX, mTranslationY);
        mCursorAnchorInfoBuilder.setMatrix(mMatrix);
        if (mHasInsertionMarker) {
            mCursorAnchorInfoBuilder.setInsertionMarkerLocation(
                    mInsertionMarkerHorizontal,
                    mInsertionMarkerTop,
                    mInsertionMarkerBottom,
                    mInsertionMarkerBottom,
                    mIsInsertionMarkerVisible ? CursorAnchorInfo.FLAG_HAS_VISIBLE_REGION :
                            CursorAnchorInfo.FLAG_HAS_INVISIBLE_REGION);
        }
        mLastCursorAnchorInfo = mCursorAnchorInfoBuilder.build();
    }

    if (mInputMethodManagerWrapper != null) {
        mInputMethodManagerWrapper.updateCursorAnchorInfo(view, mLastCursorAnchorInfo);
    }
    mHasPendingImmediateRequest = false;
}
 
示例9
public RealWrapper(@Nonnull final CursorAnchorInfo info) {
    mInstance = info;
}
 
示例10
/**
 * Called when the application has reported a new location of its text insertion point and
 * characters in the composition string.  This is only called if explicitly requested by the
 * input method. The default implementation does nothing.
 * @param cursorAnchorInfo The positional information of the text insertion point and the
 * composition string.
 */
public void onUpdateCursorAnchorInfo(CursorAnchorInfo cursorAnchorInfo) {
    // Intentionally empty
}