本文整理汇总了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;
}
}
示例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;
}
示例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;
}
}
示例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();
}
}
示例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();
}
}
示例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;
}
}
示例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());
}
}
示例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());
}
示例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();
}
}
示例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());
}
示例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();
}
}
示例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());
}
示例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());
}
示例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();
}
示例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);
}
}