RichEditorView extends RelativeLayout implements TextWatcher, QueryTokenReceiver, SuggestionsResultListener, SuggestionsVisibilityManager { public void displaySuggestions(boolean display) { if (display == isDisplayingSuggestions() || mMentionsEditText == null) { return; } if (display) { disableSpellingSuggestions(true); mTextCounterView.setVisibility(View.GONE); mSuggestionsList.setVisibility(View.VISIBLE); mPrevEditTextParams = mMentionsEditText.getLayoutParams(); mPrevEditTextBottomPadding = mMentionsEditText.getPaddingBottom(); mMentionsEditText.setPadding(mMentionsEditText.getPaddingLeft(), mMentionsEditText.getPaddingTop(), mMentionsEditText.getPaddingRight(), mMentionsEditText.getPaddingTop()); int height = mMentionsEditText.getPaddingTop() + mMentionsEditText.getLineHeight() + mMentionsEditText.getPaddingBottom(); mMentionsEditText.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT, height)); mMentionsEditText.setVerticalScrollBarEnabled(false); int cursorLine = getCurrentCursorLine(); Layout layout = mMentionsEditText.getLayout(); if (layout != null) { int lineTop = layout.getLineTop(cursorLine); mMentionsEditText.scrollTo(0, lineTop); } if (mActionListener != null) { mActionListener.onSuggestionsDisplayed(); } } else { disableSpellingSuggestions(false); mTextCounterView.setVisibility(mDisplayTextCount ? View.VISIBLE : View.GONE); mSuggestionsList.setVisibility(View.GONE); mMentionsEditText.setPadding(mMentionsEditText.getPaddingLeft(), mMentionsEditText.getPaddingTop(), mMentionsEditText.getPaddingRight(), mPrevEditTextBottomPadding); if (mPrevEditTextParams == null) { mPrevEditTextParams = new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT); } mMentionsEditText.setLayoutParams(mPrevEditTextParams); mMentionsEditText.setVerticalScrollBarEnabled(true); if (mActionListener != null) { mActionListener.onSuggestionsHidden(); } } requestLayout(); invalidate(); } RichEditorView(@NonNull Context context);  RichEditorView(@NonNull Context context, @Nullable AttributeSet attrs);  RichEditorView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void init(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr); void setInputFilters(@Nullable InputFilter... filters); @NonNull List<MentionSpan> getMentionSpans(); void setEditTextShouldWrapContent(boolean enabled); int getCurrentCursorLine(); void displayTextCounter(boolean display); boolean isDisplayingTextCounter(); @Override void beforeTextChanged(CharSequence s, int start, int count, int after); @Override void onTextChanged(CharSequence s, int start, int before, int count); @Override void afterTextChanged(Editable s); @NonNull @Override List<String> onQueryReceived(@NonNull QueryToken queryToken); @Override void onReceiveSuggestionsResult(final @NonNull SuggestionsResult result, final @NonNull String bucket); void displaySuggestions(boolean display); boolean isDisplayingSuggestions(); @NonNull String getCurrentTokenString(); @NonNull String getCurrentKeywordsString(); void updateSpan(@NonNull MentionSpan span); void deselectAllSpans(); void addTextChangedListener(@NonNull final TextWatcher hostTextWatcher); @NonNull MentionsEditable getText(); @Nullable Tokenizer getTokenizer(); void setText(final @NonNull CharSequence text); void setHint(final @NonNull CharSequence hint); void setInputType(final int type); void setSelection(final int index); void setTokenizer(final @NonNull Tokenizer tokenizer); void setMentionSpanFactory(@NonNull final MentionsEditText.MentionSpanFactory factory); void addMentionWatcher(@NonNull MentionsEditText.MentionWatcher watcher); void removeMentionWatcher(@NonNull MentionsEditText.MentionWatcher watcher); void setTextCountLimit(final int limit); void setWithinCountLimitTextColor(final int color); void setBeyondCountLimitTextColor(final int color); void setQueryTokenReceiver(final @Nullable QueryTokenReceiver client); void setOnRichEditorActionListener(final @Nullable OnSuggestionsVisibilityChangeListener listener); void setSuggestionsManager(final @NonNull SuggestionsVisibilityManager suggestionsVisibilityManager); void setSuggestionsListBuilder(final @NonNull SuggestionsListBuilder suggestionsListBuilder);  }
@Test public void testSuggestionsListDisablesSpellingSuggestions() throws Exception { EditText input = TestUtils.getPrivateField(mRichEditor, "mMentionsEditText"); int originalInputType = input.getInputType(); mRichEditor.displaySuggestions(true); assertEquals(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS, input.getInputType()); mRichEditor.displaySuggestions(false); assertEquals(originalInputType, input.getInputType()); }