本文整理匯總了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);
}