LatinIME 修改记录

发布时间:2025-12-09 11:57:44 浏览次数:2

1.隐藏指定的按钮: KeyboardView .java# onDrawKey()

public class KeyboardView extends View { private void onDrawKey(final Key key, final Canvas canvas, final Paint paint) {//Log.e("KeyboardView", "=== onDrawKey(), key="+key.mLabel+","+key.mCode+",kname="+Constants.printableCode(key.mCode));//hide the settings key, edit by xghif(key.mCode ==Constants.CODE_SETTINGS){Log.i("KeyboardView", "----hide the settings key---");return;}    final int keyDrawX = key.getDrawX() + getPaddingLeft();    final int keyDrawY = key.mY + getPaddingTop();    canvas.translate(keyDrawX, keyDrawY);    final int keyHeight = mKeyboard.mMostCommonKeyHeight - mKeyboard.mVerticalGap;    final KeyVisualAttributes attr = key.mKeyVisualAttributes;    final KeyDrawParams params = mKeyDrawParams.mayCloneAndUpdateParams(keyHeight, attr);    params.mAnimAlpha = Constants.Color.ALPHA_OPAQUE;    if (!key.isSpacer()) {        onDrawKeyBackground(key, canvas);    }    onDrawKeyTopVisuals(key, canvas, paint, params);    canvas.translate(-keyDrawX, -keyDrawY);} }"

2.屏蔽某个按钮的功能 修改 LatinIME .java # onCodeInput()

public class LatinIME extends InputMethodService implements KeyboardActionListener,    SuggestionStripView.Listener, TargetPackageInfoGetterTask.OnTargetPackageInfoKnownListener,    Suggest.SuggestInitializationListener {...@overridepublic void onCodeInput(final int primaryCode, final int x, final int y) {    if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {        ResearchLogger.latinIME_onCodeInput(primaryCode, x, y);    }    final long when = SystemClock.uptimeMillis();    if (primaryCode != Constants.CODE_DELETE || when > mLastKeyTime + QUICK_PRESS) {        mDeleteCount = 0;    }    mLastKeyTime = when;    mConnection.beginBatchEdit();    final KeyboardSwitcher switcher = mKeyboardSwitcher;    // The space state depends only on the last character pressed and its own previous    // state. Here, we revert the space state to neutral if the key is actually modifying    // the input contents (any non-shift key), which is what we should do for    // all inputs that do not result in a special state. Each character handling is then    // free to override the state as they see fit.    final int spaceState = mSpaceState;    if (!mWordComposer.isComposingWord()) mIsAutoCorrectionIndicatorOn = false;    // TODO: Consolidate the double-space period timer, mLastKeyTime, and the space state.    if (primaryCode != Constants.CODE_SPACE) {        mHandler.cancelDoubleSpacePeriodTimer();    }    boolean didAutoCorrect = false;    switch (primaryCode) {    case Constants.CODE_DELETE:        mSpaceState = SPACE_STATE_NONE;        handleBackspace(spaceState);        mDeleteCount++;        mExpectingUpdateSelection = true;        LatinImeLogger.logOnDelete(x, y);        break;    case Constants.CODE_SHIFT:        // Note: calling back to the keyboard on Shift key is handled in onPressKey()        // and onReleaseKey().        final Keyboard currentKeyboard = switcher.getKeyboard();        if (null != currentKeyboard && currentKeyboard.mId.isAlphabetKeyboard()) {            // TODO: Instead of checking for alphabetic keyboard here, separate keycodes for            // alphabetic shift and shift while in symbol layout.            handleRecapitalize();        }        break;    case Constants.CODE_SWITCH_ALPHA_SYMBOL:        // Note: calling back to the keyboard on symbol key is handled in onPressKey()        // and onReleaseKey().        break;    case Constants.CODE_SETTINGS:        //TODO... hide settings fuction... edit by xgh        //onSettingsKeyPressed();        break;    case Constants.CODE_SHORTCUT:        mSubtypeSwitcher.switchToShortcutIME(this);        break;    case Constants.CODE_ACTION_NEXT:        performEditorAction(EditorInfo.IME_ACTION_NEXT);        break;    case Constants.CODE_ACTION_PREVIOUS:        performEditorAction(EditorInfo.IME_ACTION_PREVIOUS);        break;    case Constants.CODE_LANGUAGE_SWITCH:        handleLanguageSwitchKey();        break;    case Constants.CODE_RESEARCH:        if (ProductionFlag.USES_DEVELOPMENT_ONLY_DIAGNOSTICS) {            ResearchLogger.getInstance().onResearchKeySelected(this);        }        break;    case Constants.CODE_ENTER:        final EditorInfo editorInfo = getCurrentInputEditorInfo();        final int imeOptionsActionId =                InputTypeUtils.getImeOptionsActionIdFromEditorInfo(editorInfo);        if (InputTypeUtils.IME_ACTION_CUSTOM_LABEL == imeOptionsActionId) {            // Either we have an actionLabel and we should performEditorAction with actionId            // regardless of its value.            performEditorAction(editorInfo.actionId);        } else if (EditorInfo.IME_ACTION_NONE != imeOptionsActionId) {            // We didn't have an actionLabel, but we had another action to execute.            // EditorInfo.IME_ACTION_NONE explicitly means no action. In contrast,            // EditorInfo.IME_ACTION_UNSPECIFIED is the default value for an action, so it            // means there should be an action and the app didn't bother to set a specific            // code for it - presumably it only handles one. It does not have to be treated            // in any specific way: anything that is not IME_ACTION_NONE should be sent to            // performEditorAction.            performEditorAction(imeOptionsActionId);        } else {            // No action label, and the action from imeOptions is NONE: this is a regular            // enter key that should input a carriage return.            didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);        }        break;    case Constants.CODE_SHIFT_ENTER:        didAutoCorrect = handleNonSpecialCharacter(Constants.CODE_ENTER, x, y, spaceState);        break;    default:        didAutoCorrect = handleNonSpecialCharacter(primaryCode, x, y, spaceState);        break;    }    switcher.onCodeInput(primaryCode);    // Reset after any single keystroke, except shift and symbol-shift    if (!didAutoCorrect && primaryCode != Constants.CODE_SHIFT            && primaryCode != Constants.CODE_SWITCH_ALPHA_SYMBOL)        mLastComposedWord.deactivate();    if (Constants.CODE_DELETE != primaryCode) {        mEnteredText = null;    }    mConnection.endBatchEdit();}
latinime
需要做网站?需要网络推广?欢迎咨询客户经理 13272073477