当前位置: 首页>>代码示例>>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;未经允许,请勿转载。