• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2009 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.quicksearchbox;
18 
19 import java.util.Collection;
20 import java.util.Map;
21 
22 /**
23  * Holds information about shortcuts (results the user has clicked on before), and returns
24  * appropriate shortcuts for a given query.
25  */
26 public interface ShortcutRepository {
27 
28     /**
29      * Checks whether there is any stored history.
30      */
hasHistory()31     boolean hasHistory();
32 
33     /**
34      * Clears all shortcut history.
35      */
clearHistory()36     void clearHistory();
37 
38     /**
39      * Closes any database connections etc held by this object.
40      */
close()41     void close();
42 
43     /**
44      * Reports a click on a suggestion.
45      * Must be called on the UI thread.
46      */
reportClick(SuggestionCursor suggestions, int position)47     void reportClick(SuggestionCursor suggestions, int position);
48 
49     /**
50      * Gets shortcuts for a query.
51      *
52      * @param query The query. May be empty.
53      * @param allowedCorpora The corpora to get shortcuts for.
54      * @return A cursor containing shortcutted results for the query.
55      */
getShortcutsForQuery(String query, Collection<Corpus> allowedCorpora)56     ShortcutCursor getShortcutsForQuery(String query, Collection<Corpus> allowedCorpora);
57 
58     /**
59      * Updates a shortcut in the repository after it's been refreshed.
60      *
61      * @param source The source of the shortcut that's been refreshed
62      * @param shortcutId The ID of the shortcut that's been refershed
63      * @param refreshed The refreshed shortcut suggestion.
64      */
updateShortcut(Source source, String shortcutId, SuggestionCursor refreshed)65     void updateShortcut(Source source, String shortcutId, SuggestionCursor refreshed);
66 
67     /**
68      * @return A map for corpus name to score. A higher score means that the corpus
69      *         is more important.
70      */
getCorpusScores()71     Map<String,Integer> getCorpusScores();
72 }
73