android.view.inputmethod.CompletionInfo Java Examples
The following examples show how to use
android.view.inputmethod.CompletionInfo.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SoftKeyboard.java From AndroidKeyboard with GNU General Public License v3.0 | 6 votes |
/** * This tells us about completions that the editor has determined based * on the current text in it. We want to use this in fullscreen mode * to show the completions ourselves, since the editor can not be seen * in that situation. */ @Override public void onDisplayCompletions(CompletionInfo[] completions) { if (mCompletionOn) { mCompletions = completions; if (completions == null) { setSuggestions(null, false, false); return; } List<String> stringList = new ArrayList<>(); for (CompletionInfo ci : completions) { if (ci != null) stringList.add(ci.getText().toString()); } setSuggestions(stringList, true, true); } }
Example #2
Source File: TerminalKeyboard.java From java-n-IDE-for-Android with Apache License 2.0 | 6 votes |
public void pickSuggestionManually(int index) { if (mCompletionOn && mCompletions != null && index >= 0 && index < mCompletions.length) { CompletionInfo ci = mCompletions[index]; getCurrentInputConnection().commitCompletion(ci); if (mCandidateView != null) { mCandidateView.clear(); } updateShiftKeyState(getCurrentInputEditorInfo()); } else if (mComposing.length() > 0) { // If we were generating candidate suggestions for the current // text, we would commit one of them here. But for this sample, // we will just commit the current text. commitTyped(getCurrentInputConnection()); } }
Example #3
Source File: Pathfinder.java From sinovoice-pathfinder with MIT License | 6 votes |
public void pickSuggestionManually(int index, String text) { mComposing.setLength(0); mComposing.append(text); if (mCompletionOn && mCompletions != null && index >= 0 && index < mCompletions.length) { CompletionInfo ci = mCompletions[index]; getCurrentInputConnection().commitCompletion(ci); if (mCandidateView != null) { mCandidateView.clear(); } } else if (mComposing.length() > 0) { // If we were generating candidate suggestions for the current // text, we would commit one of them here. But for this sample, // we will just commit the current text. commitTyped(getCurrentInputConnection()); } }
Example #4
Source File: Pathfinder.java From sinovoice-pathfinder with MIT License | 6 votes |
/** * This tells us about completions that the editor has determined based * on the current text in it. We want to use this in fullscreen mode * to show the completions ourself, since the editor can not be seen * in that situation. */ @Override public void onDisplayCompletions(CompletionInfo[] completions) { if (mCompletionOn) { mCompletions = completions; if (completions == null) { setSuggestions(null, false, false); return; } List<String> stringList = new ArrayList<String>(); for (int i = 0; i < completions.length; i++) { CompletionInfo ci = completions[i]; if (ci != null) stringList.add(ci.getText().toString()); } setSuggestions(stringList, true, true); } }
Example #5
Source File: SoftKeyboard.java From AndroidKeyboard with GNU General Public License v3.0 | 6 votes |
public void pickSuggestionManually(int index) { if (mCompletionOn && mCompletions != null && index >= 0 && index < mCompletions.length) { CompletionInfo ci = mCompletions[index]; getCurrentInputConnection().commitCompletion(ci); if (mCandidateView != null) { mCandidateView.clear(); } updateShiftKeyState(getCurrentInputEditorInfo()); } else if (mComposing.length() > 0) { // If we were generating candidate suggestions for the current // text, we would commit one of them here. But for this sample, // we will just commit the current text. mComposing.setLength(index); mComposing = new StringBuilder(list.get(index) + " "); commitTyped(getCurrentInputConnection()); } }
Example #6
Source File: LatinIME.java From hackerskeyboard with Apache License 2.0 | 6 votes |
@Override public void onDisplayCompletions(CompletionInfo[] completions) { if (mCompletionOn) { mCompletions = completions; if (completions == null) { clearSuggestions(); return; } List<CharSequence> stringList = new ArrayList<CharSequence>(); for (int i = 0; i < (completions != null ? completions.length : 0); i++) { CompletionInfo ci = completions[i]; if (ci != null) stringList.add(ci.getText()); } // When in fullscreen mode, show completions generated by the // application setSuggestions(stringList, true, true, true); mBestWord = null; setCandidatesViewShown(true); } }
Example #7
Source File: SearchBar.java From adt-leanback-support with Apache License 2.0 | 5 votes |
/** * Update the completion list shown by the IME * * @param completions list of completions shown in the IME, can be null or empty to clear them */ public void displayCompletions(List<String> completions) { List<CompletionInfo> infos = new ArrayList<CompletionInfo>(); if (null != completions) { for (String completion : completions) { infos.add(new CompletionInfo(infos.size(), infos.size(), completion)); } } mInputMethodManager.displayCompletions(mSearchTextEditor, infos.toArray(new CompletionInfo[] {})); }
Example #8
Source File: LatinIME.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) { if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "Received completions:"); if (applicationSpecifiedCompletions != null) { for (int i = 0; i < applicationSpecifiedCompletions.length; i++) { Log.i(TAG, " #" + i + ": " + applicationSpecifiedCompletions[i]); } } } if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { return; } // If we have an update request in flight, we need to cancel it so it does not override // these completions. mHandler.cancelUpdateSuggestionStrip(); if (applicationSpecifiedCompletions == null) { setNeutralSuggestionStrip(); return; } final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords, null /* rawSuggestions */, null /* typedWord */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isObsoleteSuggestions */, SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); // When in fullscreen mode, show completions generated by the application forcibly setSuggestedWords(suggestedWords); }
Example #9
Source File: SuggestedWords.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( final CompletionInfo[] infos) { final ArrayList<SuggestedWordInfo> result = new ArrayList<>(); for (final CompletionInfo info : infos) { if (null == info || null == info.getText()) { continue; } result.add(new SuggestedWordInfo(info)); } return result; }
Example #10
Source File: SuggestedWords.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
/** * Create a new suggested word info from an application-specified completion. * If the passed argument or its contained text is null, this throws a NPE. * @param applicationSpecifiedCompletion The application-specified completion info. */ public SuggestedWordInfo(final CompletionInfo applicationSpecifiedCompletion) { mWord = applicationSpecifiedCompletion.getText().toString(); mPrevWordsContext = ""; mApplicationSpecifiedCompletionInfo = applicationSpecifiedCompletion; mScore = SuggestedWordInfo.MAX_SCORE; mKindAndFlags = SuggestedWordInfo.KIND_APP_DEFINED; mSourceDict = Dictionary.DICTIONARY_APPLICATION_DEFINED; mCodePointCount = StringUtils.codePointCount(mWord); mIndexOfTouchPointOfSecondWord = SuggestedWordInfo.NOT_AN_INDEX; mAutoCommitFirstWordConfidence = SuggestedWordInfo.NOT_A_CONFIDENCE; }
Example #11
Source File: EditableInputConnection.java From JotaTextEditor with Apache License 2.0 | 5 votes |
public boolean commitCompletion(CompletionInfo text) { if (DEBUG) Log.v(TAG, "commitCompletion " + text); mTextView.beginBatchEdit(); mTextView.onCommitCompletion(text); mTextView.endBatchEdit(); return true; }
Example #12
Source File: InputMethodService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
/** * Call {@link InputMethodService#onDisplayCompletions * InputMethodService.onDisplayCompletions()}. */ public void displayCompletions(CompletionInfo[] completions) { if (!isEnabled()) { return; } mCurCompletions = completions; onDisplayCompletions(completions); }
Example #13
Source File: LatinIME.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) { if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "Received completions:"); if (applicationSpecifiedCompletions != null) { for (int i = 0; i < applicationSpecifiedCompletions.length; i++) { Log.i(TAG, " #" + i + ": " + applicationSpecifiedCompletions[i]); } } } if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { return; } // If we have an update request in flight, we need to cancel it so it does not override // these completions. mHandler.cancelUpdateSuggestionStrip(); if (applicationSpecifiedCompletions == null) { setNeutralSuggestionStrip(); return; } final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords, null /* rawSuggestions */, null /* typedWord */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isObsoleteSuggestions */, SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); // When in fullscreen mode, show completions generated by the application forcibly setSuggestedWords(suggestedWords); }
Example #14
Source File: RichInputConnection.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public void commitCompletion(final CompletionInfo completionInfo) { if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); CharSequence text = completionInfo.getText(); // text should never be null, but just in case, it's better to insert nothing than to crash if (null == text) text = ""; mCommittedTextBeforeComposingText.append(text); mExpectedSelStart += text.length() - mComposingText.length(); mExpectedSelEnd = mExpectedSelStart; mComposingText.setLength(0); if (isConnected()) { mIC.commitCompletion(completionInfo); } if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); }
Example #15
Source File: CompletionInfoUtils.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public static CompletionInfo[] removeNulls(final CompletionInfo[] src) { int j = 0; final CompletionInfo[] dst = new CompletionInfo[src.length]; for (int i = 0; i < src.length; ++i) { if (null != src[i] && !TextUtils.isEmpty(src[i].getText())) { dst[j] = src[i]; ++j; } } return Arrays.copyOfRange(dst, 0, j); }
Example #16
Source File: SuggestedWords.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( final CompletionInfo[] infos) { final ArrayList<SuggestedWordInfo> result = new ArrayList<>(); for (final CompletionInfo info : infos) { if (null == info || null == info.getText()) { continue; } result.add(new SuggestedWordInfo(info)); } return result; }
Example #17
Source File: SuggestedWords.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
/** * Create a new suggested word info from an application-specified completion. * If the passed argument or its contained text is null, this throws a NPE. * @param applicationSpecifiedCompletion The application-specified completion info. */ public SuggestedWordInfo(final CompletionInfo applicationSpecifiedCompletion) { mWord = applicationSpecifiedCompletion.getText().toString(); mPrevWordsContext = ""; mApplicationSpecifiedCompletionInfo = applicationSpecifiedCompletion; mScore = SuggestedWordInfo.MAX_SCORE; mKindAndFlags = SuggestedWordInfo.KIND_APP_DEFINED; mSourceDict = Dictionary.DICTIONARY_APPLICATION_DEFINED; mCodePointCount = StringUtils.codePointCount(mWord); mIndexOfTouchPointOfSecondWord = SuggestedWordInfo.NOT_AN_INDEX; mAutoCommitFirstWordConfidence = SuggestedWordInfo.NOT_A_CONFIDENCE; }
Example #18
Source File: CompletionInfoUtils.java From openboard with GNU General Public License v3.0 | 5 votes |
public static CompletionInfo[] removeNulls(final CompletionInfo[] src) { int j = 0; final CompletionInfo[] dst = new CompletionInfo[src.length]; for (int i = 0; i < src.length; ++i) { if (null != src[i] && !TextUtils.isEmpty(src[i].getText())) { dst[j] = src[i]; ++j; } } return Arrays.copyOfRange(dst, 0, j); }
Example #19
Source File: LatinIME.java From openboard with GNU General Public License v3.0 | 5 votes |
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) { if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "Received completions:"); if (applicationSpecifiedCompletions != null) { for (int i = 0; i < applicationSpecifiedCompletions.length; i++) { Log.i(TAG, " #" + i + ": " + applicationSpecifiedCompletions[i]); } } } if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { return; } // If we have an update request in flight, we need to cancel it so it does not override // these completions. mHandler.cancelUpdateSuggestionStrip(); if (applicationSpecifiedCompletions == null) { setNeutralSuggestionStrip(); return; } final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords, null /* rawSuggestions */, null /* typedWord */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isObsoleteSuggestions */, SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); // When in fullscreen mode, show completions generated by the application forcibly setSuggestedWords(suggestedWords); }
Example #20
Source File: SuggestedWords.java From openboard with GNU General Public License v3.0 | 5 votes |
public static ArrayList<SuggestedWordInfo> getFromApplicationSpecifiedCompletions( final CompletionInfo[] infos) { final ArrayList<SuggestedWordInfo> result = new ArrayList<>(); for (final CompletionInfo info : infos) { if (null == info || null == info.getText()) { continue; } result.add(new SuggestedWordInfo(info)); } return result; }
Example #21
Source File: SuggestedWords.java From openboard with GNU General Public License v3.0 | 5 votes |
/** * Create a new suggested word info from an application-specified completion. * If the passed argument or its contained text is null, this throws a NPE. * @param applicationSpecifiedCompletion The application-specified completion info. */ public SuggestedWordInfo(final CompletionInfo applicationSpecifiedCompletion) { mWord = applicationSpecifiedCompletion.getText().toString(); mPrevWordsContext = ""; mApplicationSpecifiedCompletionInfo = applicationSpecifiedCompletion; mScore = SuggestedWordInfo.MAX_SCORE; mKindAndFlags = SuggestedWordInfo.KIND_APP_DEFINED; mSourceDict = Dictionary.DICTIONARY_APPLICATION_DEFINED; mCodePointCount = StringUtils.codePointCount(mWord); mIndexOfTouchPointOfSecondWord = SuggestedWordInfo.NOT_AN_INDEX; mAutoCommitFirstWordConfidence = SuggestedWordInfo.NOT_A_CONFIDENCE; }
Example #22
Source File: RichInputConnection.java From openboard with GNU General Public License v3.0 | 5 votes |
public void commitCompletion(final CompletionInfo completionInfo) { if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); CharSequence text = completionInfo.getText(); // text should never be null, but just in case, it's better to insert nothing than to crash if (null == text) text = ""; mCommittedTextBeforeComposingText.append(text); mExpectedSelStart += text.length() - mComposingText.length(); mExpectedSelEnd = mExpectedSelStart; mComposingText.setLength(0); if (isConnected()) { mIC.commitCompletion(completionInfo); } if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); }
Example #23
Source File: AutoCompleteTextView.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
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); } } }
Example #24
Source File: InputMethodService.java From android_9.0.0_r45 with Apache License 2.0 | 5 votes |
private void resetStateForNewConfiguration() { boolean visible = mWindowVisible; int showFlags = mShowInputFlags; boolean showingInput = mShowInputRequested; CompletionInfo[] completions = mCurCompletions; initViews(); mInputViewStarted = false; mCandidatesViewStarted = false; if (mInputStarted) { doStartInput(getCurrentInputConnection(), getCurrentInputEditorInfo(), true); } if (visible) { if (showingInput) { // If we were last showing the soft keyboard, try to do so again. if (dispatchOnShowInputRequested(showFlags, true)) { showWindow(true); if (completions != null) { mCurCompletions = completions; onDisplayCompletions(completions); } } else { doHideWindow(); } } else if (mCandidatesVisibility == View.VISIBLE) { // If the candidates are currently visible, make sure the // window is shown for them. showWindow(false); } else { // Otherwise hide the window. doHideWindow(); } // If user uses hard keyboard, IME button should always be shown. boolean showing = onEvaluateInputViewShown(); mImm.setImeWindowStatus(mToken, mStartInputToken, IME_ACTIVE | (showing ? IME_VISIBLE : 0), mBackDisposition); } }
Example #25
Source File: LatinIME.java From Android-Keyboard with Apache License 2.0 | 5 votes |
@Override public void onDisplayCompletions(final CompletionInfo[] applicationSpecifiedCompletions) { if (DebugFlags.DEBUG_ENABLED) { Log.i(TAG, "Received completions:"); if (applicationSpecifiedCompletions != null) { for (int i = 0; i < applicationSpecifiedCompletions.length; i++) { Log.i(TAG, " #" + i + ": " + applicationSpecifiedCompletions[i]); } } } if (!mSettings.getCurrent().isApplicationSpecifiedCompletionsOn()) { return; } // If we have an update request in flight, we need to cancel it so it does not override // these completions. mHandler.cancelUpdateSuggestionStrip(); if (applicationSpecifiedCompletions == null) { setNeutralSuggestionStrip(); return; } final ArrayList<SuggestedWords.SuggestedWordInfo> applicationSuggestedWords = SuggestedWords.getFromApplicationSpecifiedCompletions( applicationSpecifiedCompletions); final SuggestedWords suggestedWords = new SuggestedWords(applicationSuggestedWords, null /* rawSuggestions */, null /* typedWord */, false /* typedWordValid */, false /* willAutoCorrect */, false /* isObsoleteSuggestions */, SuggestedWords.INPUT_STYLE_APPLICATION_SPECIFIED /* inputStyle */, SuggestedWords.NOT_A_SEQUENCE_NUMBER); // When in fullscreen mode, show completions generated by the application forcibly setSuggestedWords(suggestedWords); }
Example #26
Source File: EditableInputConnection.java From PowerFileExplorer with GNU General Public License v3.0 | 5 votes |
public boolean commitCompletion(CompletionInfo text) { if (DEBUG) Log.v(TAG, "commitCompletion " + text); mTextView.beginBatchEdit(); mTextView.onCommitCompletion(text); mTextView.endBatchEdit(); return true; }
Example #27
Source File: CompletionInfoUtils.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
public static CompletionInfo[] removeNulls(final CompletionInfo[] src) { int j = 0; final CompletionInfo[] dst = new CompletionInfo[src.length]; for (int i = 0; i < src.length; ++i) { if (null != src[i] && !TextUtils.isEmpty(src[i].getText())) { dst[j] = src[i]; ++j; } } return Arrays.copyOfRange(dst, 0, j); }
Example #28
Source File: RichInputConnection.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
public void commitCompletion(final CompletionInfo completionInfo) { if (DEBUG_BATCH_NESTING) checkBatchEdit(); if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); CharSequence text = completionInfo.getText(); // text should never be null, but just in case, it's better to insert nothing than to crash if (null == text) text = ""; mCommittedTextBeforeComposingText.append(text); mExpectedSelStart += text.length() - mComposingText.length(); mExpectedSelEnd = mExpectedSelStart; mComposingText.setLength(0); if (isConnected()) { mIC.commitCompletion(completionInfo); } if (DEBUG_PREVIOUS_TEXT) checkConsistencyForDebug(); }
Example #29
Source File: AutoCompleteTextView.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void onCommitCompletion(CompletionInfo completion) { if (isPopupShowing()) { mPopup.performItemClick(completion.getPosition()); } }
Example #30
Source File: IInputMethodSessionWrapper.java From android_9.0.0_r45 with Apache License 2.0 | 4 votes |
@Override public void displayCompletions(CompletionInfo[] completions) { mCaller.executeOrSendMessage(mCaller.obtainMessageO( DO_DISPLAY_COMPLETIONS, completions)); }