Example #1
0
 /**
  * Disables spelling suggestions from the user's keyboard. This is necessary because some
  * keyboards will replace the input text with spelling suggestions automatically, which changes
  * the suggestion results. This results in a confusing user experience.
  *
  * @param disable {@code true} if spelling suggestions should be disabled, otherwise {@code false}
  */
 private void disableSpellingSuggestions(boolean disable) {
   // toggling suggestions often resets the cursor location, but we don't want that to happen
   int start = mMentionsEditText.getSelectionStart();
   int end = mMentionsEditText.getSelectionEnd();
   // -1 means there is no selection or cursor.
   if (start == -1 || end == -1) {
     return;
   }
   if (disable) {
     // store the previous input type
     mOriginalInputType = mMentionsEditText.getInputType();
   }
   mMentionsEditText.setInputType(
       disable ? InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS : mOriginalInputType);
   mMentionsEditText.setSelection(start, end);
 }
Example #2
0
 /**
  * Sets the selection within the embedded {@link MentionsEditText}.
  *
  * @param index the index of the selection within the embedded {@link MentionsEditText}
  */
 public void setSelection(final int index) {
   if (mMentionsEditText != null) {
     mMentionsEditText.setSelection(index);
   }
 }