本文整理汇总了Java中android.view.inputmethod.BaseInputConnection.getComposingSpanEnd方法的典型用法代码示例。如果您正苦于以下问题:Java BaseInputConnection.getComposingSpanEnd方法的具体用法?Java BaseInputConnection.getComposingSpanEnd怎么用?Java BaseInputConnection.getComposingSpanEnd使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.view.inputmethod.BaseInputConnection
的用法示例。
在下文中一共展示了BaseInputConnection.getComposingSpanEnd方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: shouldAutocomplete
import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
* Whether we want to be showing inline autocomplete results. We don't want to show them as the
* user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
* we must not autocomplete or we'll destroy the composition.
* @return Whether we want to be showing inline autocomplete results.
*/
public boolean shouldAutocomplete() {
if (mLastUrlEditWasDelete) return false;
Editable text = getText();
return isCursorAtEndOfTypedText()
&& !isPastedText()
&& !isHandlingBatchInput()
&& BaseInputConnection.getComposingSpanEnd(text)
== BaseInputConnection.getComposingSpanStart(text);
}
示例2: shouldAutocomplete
import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
* Whether we want to be showing inline autocomplete results. We don't want to show them as the
* user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
* we must not autocomplete or we'll destroy the composition.
* @return Whether we want to be showing inline autocomplete results.
*/
private boolean shouldAutocomplete() {
if (mLastUrlEditWasDelete) return false;
Editable text = mUrlBar.getText();
return mUrlBar.isCursorAtEndOfTypedText()
&& !mUrlBar.isHandlingBatchInput()
&& BaseInputConnection.getComposingSpanEnd(text)
== BaseInputConnection.getComposingSpanStart(text);
}
示例3: shouldAutocomplete
import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
/**
* Whether we want to be showing inline autocomplete results. We don't want to show them as the
* user deletes input. Also if there is a composition (e.g. while using the Japanese IME),
* we must not autocomplete or we'll destroy the composition.
* @return Whether we want to be showing inline autocomplete results.
*/
public boolean shouldAutocomplete() {
if (mLastEditWasDelete) return false;
Editable text = getText();
return isCursorAtEndOfTypedText() && !isHandlingBatchInput()
&& BaseInputConnection.getComposingSpanEnd(text)
== BaseInputConnection.getComposingSpanStart(text);
}
示例4: setComposingText
import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
Editable currentText = getText();
int autoCompleteSpanStart = currentText.getSpanStart(mAutocompleteSpan);
if (autoCompleteSpanStart >= 0) {
int composingEnd = BaseInputConnection.getComposingSpanEnd(currentText);
// On certain device/keyboard combinations, the composing regions are specified
// with a noticeable delay after the initial character is typed, and in certain
// circumstances it does not check that the current state of the text matches the
// expectations of it's composing region.
// For example, you can be typing:
// chrome://f
// Chrome will autocomplete to:
// chrome://f[lags]
// And after the autocomplete has been set, the keyboard will set the composing
// region to the last character and it assumes it is 'f' as it was the last
// character the keyboard sent. If we commit this composition, the text will
// look like:
// chrome://flag[f]
// And if we use the autocomplete clearing logic below, it will look like:
// chrome://f[f]
// To work around this, we see if the composition matches all the characters prior
// to the autocomplete and just readjust the composing region to be that subset.
//
// See crbug.com/366732
if (composingEnd == currentText.length()
&& autoCompleteSpanStart >= text.length()
&& TextUtils.equals(
currentText.subSequence(
autoCompleteSpanStart - text.length(),
autoCompleteSpanStart),
text)) {
setComposingRegion(
autoCompleteSpanStart - text.length(), autoCompleteSpanStart);
}
// Once composing text is being modified, the autocomplete text has been accepted
// or has to be deleted.
mAutocompleteSpan.clearSpan();
Selection.setSelection(currentText, autoCompleteSpanStart);
currentText.delete(autoCompleteSpanStart, currentText.length());
}
return super.setComposingText(text, newCursorPosition);
}
示例5: setComposingText
import android.view.inputmethod.BaseInputConnection; //导入方法依赖的package包/类
@Override
public boolean setComposingText(CharSequence text, int newCursorPosition) {
if (DEBUG) Log.i(TAG, "setComposingText: [%s]", text);
Editable currentText = getText();
int autoCompleteSpanStart = currentText.getSpanStart(mAutocompleteSpan);
if (autoCompleteSpanStart >= 0) {
int composingEnd = BaseInputConnection.getComposingSpanEnd(currentText);
// On certain device/keyboard combinations, the composing regions are specified
// with a noticeable delay after the initial character is typed, and in certain
// circumstances it does not check that the current state of the text matches the
// expectations of it's composing region.
// For example, you can be typing:
// chrome://f
// Chrome will autocomplete to:
// chrome://f[lags]
// And after the autocomplete has been set, the keyboard will set the composing
// region to the last character and it assumes it is 'f' as it was the last
// character the keyboard sent. If we commit this composition, the text will
// look like:
// chrome://flag[f]
// And if we use the autocomplete clearing logic below, it will look like:
// chrome://f[f]
// To work around this, we see if the composition matches all the characters prior
// to the autocomplete and just readjust the composing region to be that subset.
//
// See crbug.com/366732
if (composingEnd == currentText.length() && autoCompleteSpanStart >= text.length()
&& TextUtils.equals(
currentText.subSequence(autoCompleteSpanStart - text.length(),
autoCompleteSpanStart),
text)) {
setComposingRegion(
autoCompleteSpanStart - text.length(), autoCompleteSpanStart);
}
// Once composing text is being modified, the autocomplete text has been accepted
// or has to be deleted.
mAutocompleteSpan.clearSpan();
Selection.setSelection(currentText, autoCompleteSpanStart);
currentText.delete(autoCompleteSpanStart, currentText.length());
}
return super.setComposingText(text, newCursorPosition);
}