Search in sources :

Example 96 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.

the class SuggestionSpan method notifySelection.

/**
     * Notifies a suggestion selection.
     *
     * @hide
     */
public void notifySelection(Context context, String original, int index) {
    final Intent intent = new Intent();
    if (context == null || mNotificationTargetClassName == null) {
        return;
    }
    // notification.
    if (mSuggestions == null || index < 0 || index >= mSuggestions.length) {
        Log.w(TAG, "Unable to notify the suggestion as the index is out of range index=" + index + " length=" + mSuggestions.length);
        return;
    }
    // is missing, we try to notify the suggestion through the input method manager.
    if (mNotificationTargetPackageName != null) {
        intent.setClassName(mNotificationTargetPackageName, mNotificationTargetClassName);
        intent.setAction(SuggestionSpan.ACTION_SUGGESTION_PICKED);
        intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_BEFORE, original);
        intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_AFTER, mSuggestions[index]);
        intent.putExtra(SuggestionSpan.SUGGESTION_SPAN_PICKED_HASHCODE, hashCode());
        context.sendBroadcast(intent);
    } else {
        InputMethodManager imm = InputMethodManager.peekInstance();
        if (imm != null) {
            imm.notifySuggestionPicked(this, original, index);
        }
    }
}
Also used : Intent(android.content.Intent) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 97 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.

the class AutoCompleteTextView method dismissDropDown.

/**
     * <p>Closes the drop down if present on screen.</p>
     */
public void dismissDropDown() {
    InputMethodManager imm = InputMethodManager.peekInstance();
    if (imm != null) {
        imm.displayCompletions(this, null);
    }
    mPopup.dismiss();
    mPopupCanBeUpdated = false;
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 98 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.

the class AutoCompleteTextView method buildImeCompletions.

private void buildImeCompletions() {
    final ListAdapter adapter = mAdapter;
    if (adapter != null) {
        InputMethodManager imm = InputMethodManager.peekInstance();
        if (imm != null) {
            final int count = Math.min(adapter.getCount(), 20);
            CompletionInfo[] completions = new CompletionInfo[count];
            int realCount = 0;
            for (int i = 0; i < count; i++) {
                if (adapter.isEnabled(i)) {
                    Object item = adapter.getItem(i);
                    long id = adapter.getItemId(i);
                    completions[realCount] = new CompletionInfo(id, realCount, convertSelectionToString(item));
                    realCount++;
                }
            }
            if (realCount != count) {
                CompletionInfo[] tmp = new CompletionInfo[realCount];
                System.arraycopy(completions, 0, tmp, 0, realCount);
                completions = tmp;
            }
            imm.displayCompletions(this, completions);
        }
    }
}
Also used : CompletionInfo(android.view.inputmethod.CompletionInfo) InputMethodManager(android.view.inputmethod.InputMethodManager)

Example 99 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.

the class Editor method onDraw.

void onDraw(Canvas canvas, Layout layout, Path highlight, Paint highlightPaint, int cursorOffsetVertical) {
    final int selectionStart = mTextView.getSelectionStart();
    final int selectionEnd = mTextView.getSelectionEnd();
    final InputMethodState ims = mInputMethodState;
    if (ims != null && ims.mBatchEditNesting == 0) {
        InputMethodManager imm = InputMethodManager.peekInstance();
        if (imm != null) {
            if (imm.isActive(mTextView)) {
                if (ims.mContentChanged || ims.mSelectionModeChanged) {
                    // We are in extract mode and the content has changed
                    // in some way... just report complete new text to the
                    // input method.
                    reportExtractedText();
                }
            }
        }
    }
    if (mCorrectionHighlighter != null) {
        mCorrectionHighlighter.draw(canvas, cursorOffsetVertical);
    }
    if (highlight != null && selectionStart == selectionEnd && mCursorCount > 0) {
        drawCursor(canvas, cursorOffsetVertical);
        // Rely on the drawable entirely, do not draw the cursor line.
        // Has to be done after the IMM related code above which relies on the highlight.
        highlight = null;
    }
    if (mTextView.canHaveDisplayList() && canvas.isHardwareAccelerated()) {
        drawHardwareAccelerated(canvas, layout, highlight, highlightPaint, cursorOffsetVertical);
    } else {
        layout.draw(canvas, highlight, highlightPaint, cursorOffsetVertical);
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager) Paint(android.graphics.Paint)

Example 100 with InputMethodManager

use of android.view.inputmethod.InputMethodManager in project platform_frameworks_base by android.

the class Editor method onWindowFocusChanged.

void onWindowFocusChanged(boolean hasWindowFocus) {
    if (hasWindowFocus) {
        if (mBlink != null) {
            mBlink.uncancel();
            makeBlink();
        }
        final InputMethodManager imm = InputMethodManager.peekInstance();
        if (mTextView.hasSelection() && !extractedTextModeWillBeStarted()) {
            refreshTextActionMode();
        }
    } else {
        if (mBlink != null) {
            mBlink.cancel();
        }
        if (mInputContentType != null) {
            mInputContentType.enterDown = false;
        }
        // Order matters! Must be done before onParentLostFocus to rely on isShowingUp
        hideCursorAndSpanControllers();
        stopTextActionModeWithPreservingSelection();
        if (mSuggestionsPopupWindow != null) {
            mSuggestionsPopupWindow.onParentLostFocus();
        }
        // Don't leave us in the middle of a batch edit. Same as in onFocusChanged
        ensureEndedBatchEdit();
    }
}
Also used : InputMethodManager(android.view.inputmethod.InputMethodManager)

Aggregations

InputMethodManager (android.view.inputmethod.InputMethodManager)601 View (android.view.View)113 TextView (android.widget.TextView)61 Paint (android.graphics.Paint)43 Spannable (android.text.Spannable)34 Editable (android.text.Editable)32 EditText (android.widget.EditText)30 Intent (android.content.Intent)29 ImageView (android.widget.ImageView)29 RemoteException (android.os.RemoteException)23 TextPaint (android.text.TextPaint)21 KeyEvent (android.view.KeyEvent)20 Point (android.graphics.Point)18 InputMethodInfo (android.view.inputmethod.InputMethodInfo)18 AdapterView (android.widget.AdapterView)17 Button (android.widget.Button)17 RemoteView (android.widget.RemoteViews.RemoteView)16 Resources (android.content.res.Resources)15 ListView (android.widget.ListView)15 InputMethodSubtype (android.view.inputmethod.InputMethodSubtype)14