Example usage for android.app SearchManager SUGGEST_NEVER_MAKE_SHORTCUT

List of usage examples for android.app SearchManager SUGGEST_NEVER_MAKE_SHORTCUT

Introduction

In this page you can find the example usage for android.app SearchManager SUGGEST_NEVER_MAKE_SHORTCUT.

Prototype

String SUGGEST_NEVER_MAKE_SHORTCUT

To view the source code for android.app SearchManager SUGGEST_NEVER_MAKE_SHORTCUT.

Click Source Link

Document

Column value for suggestion column #SUGGEST_COLUMN_SHORTCUT_ID when a suggestion should not be stored as a shortcut in global search.

Usage

From source file:com.ibm.commerce.worklight.android.search.SearchSuggestionsProvider.java

/**
 * Creates the search result row/*from   w w  w .  j  a  va2  s.c  o  m*/
 * @param id
 * @param suggestWord
 * @param icon
 * @return
 */
private Object[] createRow(Integer id, String suggestWord, int icon) {
    return new Object[] { id, suggestWord, icon, suggestWord, Intent.ACTION_SEARCH,
            SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT };
}

From source file:com.android.quicksearchbox.ShortcutRepositoryTest.java

public void testNeverMakeShortcut() {
    final SuggestionData contact = new SuggestionData(CONTACTS_SOURCE).setText1("unshortcuttable contact")
            .setText2("you didn't want to call them again anyway")
            .setShortcutId(SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT);
    reportClick("unshortcuttable", contact);
    assertNoShortcuts("never-shortcutted suggestion should not be there.", "unshortcuttable");
}

From source file:com.android.quicksearchbox.ShortcutRepositoryImplLog.java

@VisibleForTesting
void reportClickAtTime(SuggestionCursor suggestion, int position, long now) {
    suggestion.moveTo(position);/* w  ww .  j a  v a 2s.c  om*/
    if (DBG) {
        Log.d(TAG, "logClicked(" + suggestion + ")");
    }

    if (SearchManager.SUGGEST_NEVER_MAKE_SHORTCUT.equals(suggestion.getShortcutId())) {
        if (DBG)
            Log.d(TAG, "clicked suggestion requested not to be shortcuted");
        return;
    }

    Corpus corpus = mCorpora.getCorpusForSource(suggestion.getSuggestionSource());
    if (corpus == null) {
        Log.w(TAG, "no corpus for clicked suggestion");
        return;
    }

    // Once the user has clicked on a shortcut, don't bother refreshing
    // (especially if this is a new shortcut)
    mRefresher.markShortcutRefreshed(suggestion.getSuggestionSource(), suggestion.getShortcutId());

    // Add or update suggestion info
    // Since intent_key is the primary key, any existing
    // suggestion with the same source+data+action will be replaced
    final ContentValues shortcut = makeShortcutRow(suggestion);
    String intentKey = shortcut.getAsString(Shortcuts.intent_key.name());

    // Log click for shortcut
    final ContentValues click = new ContentValues();
    click.put(ClickLog.intent_key.name(), intentKey);
    click.put(ClickLog.query.name(), suggestion.getUserQuery());
    click.put(ClickLog.hit_time.name(), now);
    click.put(ClickLog.corpus.name(), corpus.getName());

    runTransactionAsync(new SQLiteTransaction() {
        @Override
        protected boolean performTransaction(SQLiteDatabase db) {
            if (DBG)
                Log.d(TAG, "Adding shortcut: " + shortcut);
            db.replaceOrThrow(Shortcuts.TABLE_NAME, null, shortcut);
            db.insertOrThrow(ClickLog.TABLE_NAME, null, click);
            return true;
        }
    });
}