本文整理汇总了Java中android.view.inputmethod.BaseInputConnection类的典型用法代码示例。如果您正苦于以下问题:Java BaseInputConnection类的具体用法?Java BaseInputConnection怎么用?Java BaseInputConnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BaseInputConnection类属于android.view.inputmethod包,在下文中一共展示了BaseInputConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreateInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.imeOptions |=
EditorInfo.IME_FLAG_NO_EXTRACT_UI |
EditorInfo.IME_FLAG_NO_ENTER_ACTION |
EditorInfo.IME_ACTION_NONE;
outAttrs.inputType = EditorInfo.TYPE_NULL;
return new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText (int leftLength, int rightLength) {
if (rightLength == 0 && leftLength == 0) {
return this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}
for (int i = 0; i < leftLength; i++) {
this.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL));
}
// TODO: forward delete
return true;
}
};
}
示例2: testViaBackButtonOnView
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
public void testViaBackButtonOnView() {
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
sleep();
String url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample3.html"));
BaseInputConnection viewConnection = new BaseInputConnection(testView, true);
KeyEvent backDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
KeyEvent backUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("index.html"));
}
示例3: testViaBackButtonOnLayout
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
public void testViaBackButtonOnLayout() {
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample2.html");
sleep();
String url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
testView.loadUrl("file:///android_asset/www/backbuttonmultipage/sample3.html");
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample3.html"));
BaseInputConnection viewConnection = new BaseInputConnection(containerView, true);
KeyEvent backDown = new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_BACK);
KeyEvent backUp = new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_BACK);
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("sample2.html"));
viewConnection.sendKeyEvent(backDown);
viewConnection.sendKeyEvent(backUp);
sleep();
url = testView.getUrl();
assertTrue(url.endsWith("index.html"));
}
示例4: 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);
}
示例5: afterTextChanged
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public void afterTextChanged(Editable s) {
boolean isComposing = BaseInputConnection.getComposingSpanStart(s) != -1;
innerWatcher.afterTextChanged(s);
if (isComposing) {
inputMethodManager.restartInput(textView);
}
}
示例6: clean
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
private void clean() {
Editable text = mEditor.getText();
BaseInputConnection.removeComposingSpans(text);
/*
Cleanup ParagraphStyles to:
- make sure spans are applied to whole paragraphs
- remove obsolete spans
- Note: the sequence is important
*/
Effects.cleanupParagraphs(mEditor);
}
示例7: 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);
}
示例8: clean
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
private void clean() {
Editable text = mEditor.getText();
BaseInputConnection.removeComposingSpans(text);
/*
Cleanup ParagraphStyles to:
- make sure spans are applied to whole paragraphs
- remove obsolete spans
- Note: the sequence is important
*/
Effects.cleanupParagraphs(mEditor);
}
示例9: 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);
}
示例10: getEditableDebugString
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
/**
* @param editable The editable.
* @return Debug string for the given {@Editable}.
*/
static String getEditableDebugString(Editable editable) {
return String.format(Locale.US, "Editable {[%s] SEL[%d %d] COM[%d %d]}",
editable.toString(), Selection.getSelectionStart(editable),
Selection.getSelectionEnd(editable),
BaseInputConnection.getComposingSpanStart(editable),
BaseInputConnection.getComposingSpanEnd(editable));
}
示例11: GeckoInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
protected GeckoInputConnection(View targetView,
GeckoEditableClient editable) {
super(targetView, true);
mEditableClient = editable;
mIMEState = IME_STATE_DISABLED;
// InputConnection that sends keys for plugins, which don't have full editors
mKeyInputConnection = new BaseInputConnection(targetView, false);
}
示例12: onCreateInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public InputConnection onCreateInputConnection (EditorInfo outAttrs) {
// add this line, the IME can show the selectable words when use chinese input method editor.
if (outAttrs != null) {
outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
}
BaseInputConnection connection = new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText (int beforeLength, int afterLength) {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion >= 16) {
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
@TargetApi(16)
private void sendDownUpKeyEventForBackwardCompatibility (final int code) {
final long eventTime = SystemClock.uptimeMillis();
super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
};
return connection;
}
示例13: onCreateInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public InputConnection onCreateInputConnection (EditorInfo outAttrs) {
// add this line, the IME can show the selectable words when use chinese input method editor.
if (outAttrs != null) {
outAttrs.imeOptions = outAttrs.imeOptions | EditorInfo.IME_FLAG_NO_EXTRACT_UI;
}
BaseInputConnection connection = new BaseInputConnection(this, false) {
@Override
public boolean deleteSurroundingText (int beforeLength, int afterLength) {
int sdkVersion = android.os.Build.VERSION.SDK_INT;
if (sdkVersion >= 16) {
/*
* In Jelly Bean, they don't send key events for delete. Instead, they send beforeLength = 1, afterLength = 0. So,
* we'll just simulate what it used to do.
*/
if (beforeLength == 1 && afterLength == 0) {
sendDownUpKeyEventForBackwardCompatibility(KeyEvent.KEYCODE_DEL);
return true;
}
}
return super.deleteSurroundingText(beforeLength, afterLength);
}
@TargetApi(16)
private void sendDownUpKeyEventForBackwardCompatibility (final int code) {
final long eventTime = SystemClock.uptimeMillis();
super.sendKeyEvent(new KeyEvent(eventTime, eventTime, KeyEvent.ACTION_DOWN, code, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
super.sendKeyEvent(new KeyEvent(SystemClock.uptimeMillis(), eventTime, KeyEvent.ACTION_UP, code, 0, 0,
KeyCharacterMap.VIRTUAL_KEYBOARD, 0, KeyEvent.FLAG_SOFT_KEYBOARD | KeyEvent.FLAG_KEEP_TOUCH_MODE));
}
};
return connection;
}
示例14: onCreateInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
return new BaseInputConnection(this, false) {
@Override
public boolean commitText(CharSequence text, int newCursorPosition) {
// TODO Auto-generated method stub
return super.commitText(text, newCursorPosition);
}
};
}
示例15: onCreateInputConnection
import android.view.inputmethod.BaseInputConnection; //导入依赖的package包/类
@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
outAttrs.actionLabel = null;
outAttrs.inputType = InputType.TYPE_NULL;
/* TODO: If people complain about kbd not working, this is a possible workaround to
* test and add an option for.
// Workaround for IME's that don't support InputType.TYPE_NULL.
outAttrs.inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
outAttrs.imeOptions |= EditorInfo.IME_FLAG_NO_FULLSCREEN;
*/
return new BaseInputConnection(this, false);
}