當前位置: 首頁>>代碼示例>>Java>>正文


Java InputConnection.beginBatchEdit方法代碼示例

本文整理匯總了Java中android.view.inputmethod.InputConnection.beginBatchEdit方法的典型用法代碼示例。如果您正苦於以下問題:Java InputConnection.beginBatchEdit方法的具體用法?Java InputConnection.beginBatchEdit怎麽用?Java InputConnection.beginBatchEdit使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.view.inputmethod.InputConnection的用法示例。


在下文中一共展示了InputConnection.beginBatchEdit方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: doubleSpace

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void doubleSpace() {
    //if (!mAutoPunctuate) return;
    if (mCorrectionMode == Suggest.CORRECTION_NONE) return;
    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    CharSequence lastThree = ic.getTextBeforeCursor(3, 0);
    if (lastThree != null && lastThree.length() == 3
            && Character.isLetterOrDigit(lastThree.charAt(0))
            && lastThree.charAt(1) == KEYCODE_SPACE && lastThree.charAt(2) == KEYCODE_SPACE) {
        ic.beginBatchEdit();
        ic.deleteSurroundingText(2, 0);
        ic.commitText(". ", 1);
        ic.endBatchEdit();
        updateShiftKeyState(getCurrentInputEditorInfo());
        mJustAddedAutoSpace = true;
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:18,代碼來源:KP2AKeyboard.java

示例2: onText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public void onText(CharSequence text) {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    if (text == null)
	{
    	Log.e("KP2AK", "text = null!");
    	return;
	}
    abortCorrection(false);
    ic.beginBatchEdit();
    if (mPredicting) {
        commitTyped(ic);
    }
    maybeRemovePreviousPeriod(text);
    ic.commitText(text, 1);
    ic.endBatchEdit();
    updateShiftKeyState(getCurrentInputEditorInfo());
    mKeyboardSwitcher.onKey(0); // dummy key code.
    mJustRevertedSeparator = null;
    mJustAddedAutoSpace = false;
    mEnteredText = text;
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:23,代碼來源:KP2AKeyboard.java

示例3: swapPunctuationAndSpace

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void swapPunctuationAndSpace() {
    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    CharSequence lastTwo = ic.getTextBeforeCursor(2, 0);
    if (lastTwo != null && lastTwo.length() == 2
            && lastTwo.charAt(0) == KEYCODE_SPACE && isSentenceSeparator(lastTwo.charAt(1))) {
        ic.beginBatchEdit();
        ic.deleteSurroundingText(2, 0);
        ic.commitText(lastTwo.charAt(1) + " ", 1);
        ic.endBatchEdit();
        updateShiftKeyState(getCurrentInputEditorInfo());
        mJustAddedAutoSpace = true;
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:15,代碼來源:KP2AKeyboard.java

示例4: reswapPeriodAndSpace

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void reswapPeriodAndSpace() {
    final InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    CharSequence lastThree = ic.getTextBeforeCursor(3, 0);
    if (lastThree != null && lastThree.length() == 3
            && lastThree.charAt(0) == KEYCODE_PERIOD
            && lastThree.charAt(1) == KEYCODE_SPACE
            && lastThree.charAt(2) == KEYCODE_PERIOD) {
        ic.beginBatchEdit();
        ic.deleteSurroundingText(3, 0);
        ic.commitText(" ..", 1);
        ic.endBatchEdit();
        updateShiftKeyState(getCurrentInputEditorInfo());
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:16,代碼來源:KP2AKeyboard.java

示例5: setOldSuggestions

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void setOldSuggestions() {
    
    if (mCandidateView != null && mCandidateView.isShowingAddToDictionaryHint()) {
        return;
    }
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    if (!mPredicting) {
        // Extract the selected or touching text
        EditingUtil.SelectedWord touching = EditingUtil.getWordAtCursorOrSelection(ic,
                mLastSelectionStart, mLastSelectionEnd, mWordSeparators);

        if (touching != null && touching.word.length() > 1) {
            ic.beginBatchEdit();

            if (!applyTypedAlternatives(touching)) {
                abortCorrection(true);
            } else {
                TextEntryState.selectedForCorrection();
                EditingUtil.underlineWord(ic, touching);
            }

            ic.endBatchEdit();
        } else {
            abortCorrection(true);
            setNextSuggestions();  // Show the punctuation suggestions list
        }
    } else {
        abortCorrection(true);
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:32,代碼來源:KP2AKeyboard.java

示例6: onText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public void onText(CharSequence text) {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    ic.beginBatchEdit();
    if (mComposing.length() > 0) {
        commitTyped(ic);
    }
    ic.commitText(text, 0);
    ic.endBatchEdit();
    updateShiftKeyState(getCurrentInputEditorInfo());

}
 
開發者ID:VladThodo,項目名稱:behe-keyboard,代碼行數:13,代碼來源:PCKeyboard.java

示例7: onText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public void onText(CharSequence text) {
//        Log.v("SpartacusRex","SOFT : onText "+text.toString());

        InputConnection ic = getCurrentInputConnection();
        if (ic == null) return;
        ic.beginBatchEdit();
        if (mComposing.length() > 0) {
            commitTyped(ic);
        }
        ic.commitText(text, 0);
        ic.endBatchEdit();
        updateShiftKeyState(getCurrentInputEditorInfo());
    }
 
開發者ID:tranleduy2000,項目名稱:javaide,代碼行數:14,代碼來源:TerminalKeyboard.java

示例8: onText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public void onText(CharSequence text) {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    ic.beginBatchEdit();
    if (mComposing.length() > 0) {
        commitTyped(ic);
    }
    ic.commitText(text, 0);
    ic.endBatchEdit();
}
 
開發者ID:cdjalel,項目名稱:QuranKeyboard,代碼行數:11,代碼來源:QuranKeyboardIME.java

示例9: onText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public void onText(CharSequence text) {
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;
    ic.beginBatchEdit();
    if (mComposing.length() > 0) {
        commitTyped(ic);
    }
    ic.commitText(text, 0);
    ic.endBatchEdit();
    updateShiftKeyState(getCurrentInputEditorInfo());
}
 
開發者ID:YehtutHl,項目名稱:myan,代碼行數:12,代碼來源:SmartMyan.java

示例10: handleBackspace

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void handleBackspace() {
    boolean deleteChar = false;
    InputConnection ic = getCurrentInputConnection();
    if (ic == null) return;

    ic.beginBatchEdit();
   
    if (mPredicting) {
        final int length = mComposing.length();
        if (length > 0) {
            mComposing.delete(length - 1, length);
            mWord.deleteLast();
            ic.setComposingText(mComposing, 1);
            if (mComposing.length() == 0) {
                mPredicting = false;
            }
            postUpdateSuggestions();
        } else {
            ic.deleteSurroundingText(1, 0);
        }
    } else {
        deleteChar = true;
    }
    postUpdateShiftKeyState();
    TextEntryState.backspace();
    if (TextEntryState.getState() == TextEntryState.State.UNDO_COMMIT) {
        revertLastWord(deleteChar);
        ic.endBatchEdit();
        return;
    } else if (mEnteredText != null && sameAsTextBeforeCursor(ic, mEnteredText)) {
        ic.deleteSurroundingText(mEnteredText.length(), 0);
    } else if (deleteChar) {
        if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
            // Go back to the suggestion mode if the user canceled the
            // "Touch again to save".
            // NOTE: In gerenal, we don't revert the word when backspacing
            // from a manual suggestion pick.  We deliberately chose a
            // different behavior only in the case of picking the first
            // suggestion (typed word).  It's intentional to have made this
            // inconsistent with backspacing after selecting other suggestions.
            revertLastWord(deleteChar);
        } else {
            sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
            if (mDeleteCount > DELETE_ACCELERATE_AT) {
                sendDownUpKeyEvents(KeyEvent.KEYCODE_DEL);
            }
        }
    }
    mJustRevertedSeparator = null;
    ic.endBatchEdit();
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:52,代碼來源:KP2AKeyboard.java

示例11: handleSeparator

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void handleSeparator(int primaryCode) {
    // Should dismiss the "Touch again to save" message when handling separator
    if (mCandidateView != null && mCandidateView.dismissAddToDictionaryHint()) {
        postUpdateSuggestions();
    }

    boolean pickedDefault = false;
    // Handle separator
    InputConnection ic = getCurrentInputConnection();
    if (ic != null) {
        ic.beginBatchEdit();
        abortCorrection(false);
    }
    if (mPredicting) {
        // In certain languages where single quote is a separator, it's better
        // not to auto correct, but accept the typed word. For instance,
        // in Italian dov' should not be expanded to dove' because the elision
        // requires the last vowel to be removed.
        if (mAutoCorrectOn && primaryCode != '\'' &&
                (mJustRevertedSeparator == null
                        || mJustRevertedSeparator.length() == 0
                        || mJustRevertedSeparator.charAt(0) != primaryCode)) {
            pickedDefault = pickDefaultSuggestion();
            // Picked the suggestion by the space key.  We consider this
            // as "added an auto space".
            if (primaryCode == KEYCODE_SPACE) {
                mJustAddedAutoSpace = true;
            }
        } else {
            commitTyped(ic);
        }
    }
    if (mJustAddedAutoSpace && primaryCode == KEYCODE_ENTER) {
        removeTrailingSpace();
        mJustAddedAutoSpace = false;
    }
    sendKeyChar((char)primaryCode);

    // Handle the case of ". ." -> " .." with auto-space if necessary
    // before changing the TextEntryState.
    if (TextEntryState.getState() == TextEntryState.State.PUNCTUATION_AFTER_ACCEPTED
            && primaryCode == KEYCODE_PERIOD) {
        reswapPeriodAndSpace();
    }

    TextEntryState.typedCharacter((char) primaryCode, true);
    if (TextEntryState.getState() == TextEntryState.State.PUNCTUATION_AFTER_ACCEPTED
            && primaryCode != KEYCODE_ENTER) {
        swapPunctuationAndSpace();
    } else if (isPredictionOn() && primaryCode == KEYCODE_SPACE) {
        doubleSpace();
    }
    if (pickedDefault) {
        TextEntryState.backToAcceptedDefault(mWord.getTypedWord());
    }
    updateShiftKeyState(getCurrentInputEditorInfo());
    if (ic != null) {
        ic.endBatchEdit();
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:61,代碼來源:KP2AKeyboard.java

示例12: commitResult

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void commitResult() {
    if (mLastRecognitionResult == null) {
        return;
    }

    String result = mLastRecognitionResult;

    InputConnection conn = mInputMethodService.getCurrentInputConnection();

    if (conn == null) {
        Log.i(TAG, "Unable to commit recognition result, as the current input connection "
                + "is null. Did someone kill the IME?");
        return;
    }

    if (!conn.beginBatchEdit()) {
        Log.i(TAG, "Unable to commit recognition result, as a batch edit cannot start");
        return;
    }

    try {
        ExtractedTextRequest etr = new ExtractedTextRequest();
        etr.flags = InputConnection.GET_TEXT_WITH_STYLES;

        ExtractedText et = conn.getExtractedText(etr, 0);

        if (et == null) {
            Log.i(TAG, "Unable to commit recognition result, as extracted text is null");
            return;
        }

        if (et.text != null) {

            if (et.selectionStart != et.selectionEnd) {
                conn.deleteSurroundingText(et.selectionStart, et.selectionEnd);
            }

            result = format(et, result);
        }

        if (!conn.commitText(result, 0)) {
            Log.i(TAG, "Unable to commit recognition result");
            return;
        }

        mLastRecognitionResult = null;
    } finally {
        conn.endBatchEdit();
    }
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:51,代碼來源:IntentApiTrigger.java


注:本文中的android.view.inputmethod.InputConnection.beginBatchEdit方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。