use of android.view.inputmethod.InputMethodManager in project XobotOS by xamarin.
the class ViewRootImpl method getWindowSession.
public static IWindowSession getWindowSession(Looper mainLooper) {
synchronized (mStaticInit) {
if (!mInitialized) {
try {
InputMethodManager imm = InputMethodManager.getInstance(mainLooper);
sWindowSession = Display.getWindowManager().openSession(imm.getClient(), imm.getInputContext());
mInitialized = true;
} catch (RemoteException e) {
}
}
return sWindowSession;
}
}
use of android.view.inputmethod.InputMethodManager in project XobotOS by xamarin.
the class ViewRootImpl method deliverKeyEvent.
private void deliverKeyEvent(KeyEvent event, boolean sendDone) {
if (ViewDebug.DEBUG_LATENCY) {
mInputEventDeliverTimeNanos = System.nanoTime();
}
if (mInputEventConsistencyVerifier != null) {
mInputEventConsistencyVerifier.onKeyEvent(event, 0);
}
// If there is no view, then the event will not be handled.
if (mView == null || !mAdded) {
finishKeyEvent(event, sendDone, false);
return;
}
if (LOCAL_LOGV)
Log.v(TAG, "Dispatching key " + event + " to " + mView);
// Perform predispatching before the IME.
if (mView.dispatchKeyEventPreIme(event)) {
finishKeyEvent(event, sendDone, true);
return;
}
// The IME will eventually call back into handleFinishedEvent.
if (mLastWasImTarget) {
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null) {
int seq = enqueuePendingEvent(event, sendDone);
if (DEBUG_IMF)
Log.v(TAG, "Sending key event to IME: seq=" + seq + " event=" + event);
imm.dispatchKeyEvent(mView.getContext(), seq, event, mInputMethodCallback);
return;
}
}
// Not dispatching to IME, continue with post IME actions.
deliverKeyEventPostIme(event, sendDone);
}
use of android.view.inputmethod.InputMethodManager in project XobotOS by xamarin.
the class TextView method onTouchEvent.
@Override
public boolean onTouchEvent(MotionEvent event) {
final int action = event.getActionMasked();
if (hasSelectionController()) {
getSelectionController().onTouchEvent(event);
}
if (action == MotionEvent.ACTION_DOWN) {
mLastDownPositionX = event.getX();
mLastDownPositionY = event.getY();
// Reset this state; it will be re-set if super.onTouchEvent
// causes focus to move to the view.
mTouchFocusSelected = false;
mIgnoreActionUpEvent = false;
}
final boolean superResult = super.onTouchEvent(event);
/*
* Don't handle the release after a long press, because it will
* move the selection away from whatever the menu action was
* trying to affect.
*/
if (mDiscardNextActionUp && action == MotionEvent.ACTION_UP) {
mDiscardNextActionUp = false;
return superResult;
}
final boolean touchIsFinished = (action == MotionEvent.ACTION_UP) && !shouldIgnoreActionUpEvent() && isFocused();
if ((mMovement != null || onCheckIsTextEditor()) && isEnabled() && mText instanceof Spannable && mLayout != null) {
boolean handled = false;
if (mMovement != null) {
handled |= mMovement.onTouchEvent(this, (Spannable) mText, event);
}
if (touchIsFinished && mLinksClickable && mAutoLinkMask != 0 && mTextIsSelectable) {
// The LinkMovementMethod which should handle taps on links has not been installed
// on non editable text that support text selection.
// We reproduce its behavior here to open links for these.
ClickableSpan[] links = ((Spannable) mText).getSpans(getSelectionStart(), getSelectionEnd(), ClickableSpan.class);
if (links.length != 0) {
links[0].onClick(this);
handled = true;
}
}
if (touchIsFinished && (isTextEditable() || mTextIsSelectable)) {
// Show the IME, except when selecting in read-only text.
final InputMethodManager imm = InputMethodManager.peekInstance();
viewClicked(imm);
if (!mTextIsSelectable) {
handled |= imm != null && imm.showSoftInput(this, 0);
}
boolean selectAllGotFocus = mSelectAllOnFocus && didTouchFocusSelect();
hideControllers();
if (!selectAllGotFocus && mText.length() > 0) {
if (mSpellChecker != null) {
// When the cursor moves, the word that was typed may need spell check
mSpellChecker.onSelectionChanged();
}
if (isCursorInsideEasyCorrectionSpan()) {
showSuggestions();
} else if (hasInsertionController()) {
getInsertionController().show();
}
}
handled = true;
}
if (handled) {
return true;
}
}
return superResult;
}
use of android.view.inputmethod.InputMethodManager in project XobotOS by xamarin.
the class WebView method rebuildWebTextView.
/*
* This method checks the current focus and cursor and potentially rebuilds
* mWebTextView to have the appropriate properties, such as password,
* multiline, and what text it contains. It also removes it if necessary.
*/
/* package */
void rebuildWebTextView() {
// If the WebView does not have focus, do nothing until it gains focus.
if (!hasFocus() && (null == mWebTextView || !mWebTextView.hasFocus())) {
return;
}
boolean alreadyThere = inEditingMode();
// so we can safely call remove() if (alreadyThere)
if (0 == mNativeClass || !nativeFocusCandidateIsTextInput()) {
if (alreadyThere) {
mWebTextView.remove();
}
return;
}
// and create the WebTextView if necessary.
if (mWebTextView == null) {
mWebTextView = new WebTextView(mContext, WebView.this, mAutoFillData.getQueryId());
// Initialize our generation number.
mTextGeneration = 0;
}
mWebTextView.updateTextSize();
updateWebTextViewPosition();
String text = nativeFocusCandidateText();
int nodePointer = nativeFocusCandidatePointer();
// This needs to be called before setType, which may call
// requestFormData, and it needs to have the correct nodePointer.
mWebTextView.setNodePointer(nodePointer);
mWebTextView.setType(nativeFocusCandidateType());
// Gravity needs to be set after setType
mWebTextView.setGravityForRtl(nativeFocusCandidateIsRtlText());
if (null == text) {
if (DebugFlags.WEB_VIEW) {
Log.v(LOGTAG, "rebuildWebTextView null == text");
}
text = "";
}
mWebTextView.setTextAndKeepSelection(text);
InputMethodManager imm = InputMethodManager.peekInstance();
if (imm != null && imm.isActive(mWebTextView)) {
imm.restartInput(mWebTextView);
mWebTextView.clearComposingText();
}
if (isFocused()) {
mWebTextView.requestFocus();
}
}
use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.
the class SearchDialog method onBackPressed.
@Override
public void onBackPressed() {
// If the input method is covering the search dialog completely,
// e.g. in landscape mode with no hard keyboard, dismiss just the input method
InputMethodManager imm = getContext().getSystemService(InputMethodManager.class);
if (imm != null && imm.isFullscreenMode() && imm.hideSoftInputFromWindow(getWindow().getDecorView().getWindowToken(), 0)) {
return;
}
// Close search dialog
cancel();
}
Aggregations