Esempio n. 1
0
 /** Updates the auto-complete text view. */
 private void updateSearchAutoComplete() {
   mEditorTextView.setThreshold(mSearchable.getSuggestThreshold());
   mEditorTextView.setImeOptions(mSearchable.getImeOptions());
   int inputType = mSearchable.getInputType();
   // We only touch this if the input type is set up for text (which it
   // almost certainly
   // should be, in the case of search!)
   if ((inputType & InputType.TYPE_MASK_CLASS) == InputType.TYPE_CLASS_TEXT) {
     // The existence of a suggestions authority is the proxy for
     // "suggestions
     // are available here"
     inputType &= ~InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
     if (mSearchable.getSuggestAuthority() != null) {
       inputType |= InputType.TYPE_TEXT_FLAG_AUTO_COMPLETE;
       // TYPE_TEXT_FLAG_AUTO_COMPLETE means that the text editor is
       // performing
       // auto-completion based on its own semantics, which it will
       // present to the user
       // as they type. This generally means that the input method
       // should not show its
       // own candidates, and the spell checker should not be in
       // action. The text editor
       // supplies its candidates by calling
       // InputMethodManager.displayCompletions(),
       // which in turn will call
       // InputMethodSession.displayCompletions().
       inputType |= InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
     }
   }
   mEditorTextView.setInputType(inputType);
   if (mSuggestionsAdapter != null && mSuggestionsAdapter instanceof CursorAdapter) {
     ((CursorAdapter) mSuggestionsAdapter).changeCursor(null);
   }
   // attach the suggestions adapter, if suggestions are available
   // The existence of a suggestions authority is the proxy for
   // "suggestions available here"
   if (mSearchable.getSuggestAuthority() != null) {
     LcSuggestionsAdapter adapter =
         new LcSuggestionsAdapter(
             getContext(), mPopupItemLayoutResId, this, mSearchable, mOutsideDrawablesCache);
     mSuggestionsAdapter = adapter;
     adapter.setMatchWordsColor(mMatchColor);
     mEditorTextView.setAdapter((LcSuggestionsAdapter) mSuggestionsAdapter);
     ((LcSuggestionsAdapter) mSuggestionsAdapter)
         .setQueryRefinement(
             mQueryRefinement
                 ? LcSuggestionsAdapter.REFINE_ALL
                 : LcSuggestionsAdapter.REFINE_BY_ENTRY);
   }
 }
Esempio n. 2
0
 /**
  * Specifies if a query refinement button should be displayed alongside each suggestion or if it
  * should depend on the flags set in the individual items retrieved from the suggestions provider.
  * Clicking on the query refinement button will replace the text in the query text field with the
  * text from the suggestion. This flag only takes effect if a SearchableInfo has been specified
  * with {@link #setSearchableInfo(android.app.SearchableInfo)} and not when using a custom
  * adapter.
  *
  * @param enable true if all items should have a query refinement button, false if only those
  *     items that have a query refinement flag set should have the button.
  * @see android.app.SearchManager#SUGGEST_COLUMN_FLAGS
  * @see android.app.SearchManager#FLAG_QUERY_REFINEMENT
  */
 public void setQueryRefinementEnabled(boolean enable) {
   mQueryRefinement = enable;
   if (mSuggestionsAdapter instanceof LcSuggestionsAdapter) {
     ((LcSuggestionsAdapter) mSuggestionsAdapter)
         .setQueryRefinement(
             enable ? LcSuggestionsAdapter.REFINE_ALL : LcSuggestionsAdapter.REFINE_BY_ENTRY);
   }
 }
Esempio n. 3
0
 public void run() {
   if (mSuggestionsAdapter != null && mSuggestionsAdapter instanceof LcSuggestionsAdapter) {
     ((LcSuggestionsAdapter) mSuggestionsAdapter).changeCursor(null);
   }
 }