当前位置: 首页>>代码示例>>Java>>正文


Java BaseInputConnection类代码示例

本文整理汇总了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;
		}
	};
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:22,代码来源:TerminalView.java

示例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"));
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:24,代码来源:BackButtonMultiPageTest.java

示例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"));
}
 
开发者ID:thedracle,项目名称:cordova-android-chromeview,代码行数:24,代码来源:BackButtonMultiPageTest.java

示例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);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:17,代码来源:UrlBar.java

示例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);
	}
}
 
开发者ID:ZalemSoftware,项目名称:Ymir,代码行数:11,代码来源:AndroidBugsUtils.java

示例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);
  }
 
开发者ID:Ronak-LM,项目名称:memoir,代码行数:13,代码来源:RTEditable.java

示例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);
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:16,代码来源:LocationBarLayout.java

示例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);
}
 
开发者ID:1gravity,项目名称:Android-RTEditor,代码行数:13,代码来源:RTEditable.java

示例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);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:15,代码来源:AutocompleteEditText.java

示例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));
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:12,代码来源:ImeUtils.java

示例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);
}
 
开发者ID:jrconlin,项目名称:mc_backup,代码行数:9,代码来源:GeckoInputConnection.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:37,代码来源:GLSurfaceView20.java

示例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;
}
 
开发者ID:basherone,项目名称:libgdxcn,代码行数:37,代码来源:GLSurfaceView20API18.java

示例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);
		}
		
	};
}
 
开发者ID:HunkD,项目名称:Awwl,代码行数:13,代码来源:AmountInputView.java

示例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);
}
 
开发者ID:cmusatyalab,项目名称:vmnetx-android,代码行数:13,代码来源:RemoteCanvas.java


注:本文中的android.view.inputmethod.BaseInputConnection类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。