當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。