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


Java InputConnection.commitText方法代碼示例

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


在下文中一共展示了InputConnection.commitText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的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: onKey

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
@Override
  public void onKey(int primaryCode, int[] keyCodes) {
      InputConnection ic = getCurrentInputConnection() ;
      playclick(primaryCode);
      switch (primaryCode) {
          case Keyboard.KEYCODE_DELETE:
              ic.deleteSurroundingText(1, 0);
              break;
          case Keyboard.KEYCODE_SHIFT:
              caps = !caps;
              keyboard.setShifted(caps);
              kv.invalidateAllKeys();
              break;
          case Keyboard.KEYCODE_DONE:
              ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
              break;
          default:
              char code = (char) primaryCode;
              if(Character.isLetter(code) && caps) {
                  code = Character.toUpperCase(code);
              }

              ic.commitText(String.valueOf(code), 1);
break;
      }
  }
 
開發者ID:zhaofengli,項目名稱:airboard,代碼行數:27,代碼來源:AirBoard.java

示例4: typeSpaceChar

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public static void typeSpaceChar(InputConnection inputConnection) {
    try {
        boolean textCommitted = inputConnection.commitText(" ", 1);
        if (talkBackChar) {
            String theLastWord = getTheLastWord(inputConnection);
            if (textCommitted && theLastWord != null) {
                defaultTextSpeech.speechText(theLastWord);
            } else if (textCommitted) {
                if ((playAlwaysStoredVoices && currentSystemLanguage.equals("ar") && getSoundPath("ar_message_space") != -1) || (!defaultTextSpeech.isArabicSupported() && currentSystemLanguage.equals("ar") && getSoundPath("ar_message_space") != -1)) {
                    runPatternSoundPronounce(getSoundPath("ar_message_space"), true);
                } else {
                    defaultTextSpeech.speechText(context.getString(R.string.space));
                }
            }
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:20,代碼來源:Common.java

示例5: commitTyped

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void commitTyped(InputConnection inputConnection) {
    if (mPredicting) {
        mPredicting = false;
        if (mComposing.length() > 0) {
            if (inputConnection != null) {
                inputConnection.commitText(mComposing, 1);
            }
            mCommittedLength = mComposing.length();
            TextEntryState.acceptedTyped(mComposing);
            addToDictionaries(mComposing, AutoDictionary.FREQUENCY_FOR_TYPED);
        }
        updateSuggestions();
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:15,代碼來源:KP2AKeyboard.java

示例6: 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

示例7: 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

示例8: pickSuggestion

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
/**
 * Commits the chosen word to the text field and saves it for later
 * retrieval.
 * @param suggestion the suggestion picked by the user to be committed to
 *            the text field
 * @param correcting whether this is due to a correction of an existing
 *            word.
 */
private void pickSuggestion(CharSequence suggestion, boolean correcting) {
    final LatinKeyboardView inputView = mKeyboardSwitcher.getInputView();
    final Locale inputLocale = mLanguageSwitcher.getInputLocale();
    if (mCapsLock) {
        suggestion = suggestion.toString().toUpperCase(inputLocale);
    } else if (preferCapitalization()
            || (mKeyboardSwitcher.isAlphabetMode()
                    && inputView.isShifted())) {
        suggestion = suggestion.toString().toUpperCase(inputLocale).charAt(0)
                + suggestion.subSequence(1, suggestion.length()).toString();
    }
    InputConnection ic = getCurrentInputConnection();
    if (ic != null) {
        rememberReplacedWord(suggestion);
        ic.commitText(suggestion, 1);
    }
    saveWordInHistory(suggestion);
    mPredicting = false;
    mCommittedLength = suggestion.length();
    ((LatinKeyboard) inputView.getKeyboard()).setPreferredLetters(null);
    // If we just corrected a word, then don't show punctuations
    if (!correcting) {
        setNextSuggestions();
    }
    updateShiftKeyState(getCurrentInputEditorInfo());
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:35,代碼來源:KP2AKeyboard.java

示例9: commitTyped

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
/**
 * Helper function to commit any text being composed in to the editor.
 */
private void commitTyped(InputConnection inputConnection) {
    if (mComposing.length() > 0) {
        inputConnection.commitText(mComposing, mComposing.length());
        mComposing.setLength(0);
        updateCandidates();
    }
}
 
開發者ID:VladThodo,項目名稱:behe-keyboard,代碼行數:11,代碼來源:PCKeyboard.java

示例10: 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

示例11: pasteText

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
public static void pasteText(InputConnection inputConnection) {
    try {
        ClipboardManager clipboardManager = (ClipboardManager) context.getSystemService(Context.CLIPBOARD_SERVICE);
        ClipData abc = clipboardManager.getPrimaryClip();
        ClipData.Item myItem = abc.getItemAt(0);
        if (myItem != null) {
            String text = myItem.getText().toString();
            inputConnection.commitText(text, 1);
            defaultTextSpeech.speechText(context.getString(R.string.text_pasted));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
開發者ID:MohammadAlBanna,項目名稱:Swift-Braille-Soft-keyboard,代碼行數:15,代碼來源:Common.java

示例12: 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

示例13: 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

示例14: 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

示例15: commitTyped

import android.view.inputmethod.InputConnection; //導入方法依賴的package包/類
private void commitTyped(InputConnection inputConnection) {
    if (mComposing.length() > 0) {
        int lastCharacter = mComposing.charAt(mComposing.length() - 1);
        if (lastCharacter == 9676 || lastCharacter == 4153) {
            mComposing.delete(mComposing.length() - 1, mComposing.length());
        }
        inputConnection.commitText(mComposing, mComposing.length());
        mComposing.setLength(0);
    }
}
 
開發者ID:YehtutHl,項目名稱:myan,代碼行數:11,代碼來源:SmartMyan.java


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