Search in sources :

Example 41 with InputMethodManager

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;
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) RemoteException(android.os.RemoteException)

Example 42 with InputMethodManager

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);
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 43 with InputMethodManager

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;
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) ClickableSpan(android.text.style.ClickableSpan) TextPaint(android.text.TextPaint) Paint(android.graphics.Paint) Spannable(android.text.Spannable)

Example 44 with InputMethodManager

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();
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) Paint(android.graphics.Paint) Point(android.graphics.Point)

Example 45 with InputMethodManager

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();
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)631 View (android.view.View)120 TextView (android.widget.TextView)67 Paint (android.graphics.Paint)43 Spannable (android.text.Spannable)34 Editable (android.text.Editable)33 EditText (android.widget.EditText)33 ImageView (android.widget.ImageView)31 Intent (android.content.Intent)29 RemoteException (android.os.RemoteException)23 KeyEvent (android.view.KeyEvent)22 TextPaint (android.text.TextPaint)21 Point (android.graphics.Point)18 InputMethodInfo (android.view.inputmethod.InputMethodInfo)18 AdapterView (android.widget.AdapterView)18 Button (android.widget.Button)16 RemoteView (android.widget.RemoteViews.RemoteView)16 Resources (android.content.res.Resources)15 ListView (android.widget.ListView)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)14