• 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 android.content.Context;
20 import android.content.Intent;
21 import android.graphics.drawable.Drawable;
22 import android.net.Uri;
23 import android.os.Bundle;
24 
25 import java.util.Collection;
26 import java.util.Collections;
27 
28 /**
29  * A corpus that uses a single source.
30  */
31 public class SingleSourceCorpus extends AbstractCorpus {
32 
33     private final Source mSource;
34 
SingleSourceCorpus(Context context, Config config, Source source)35     public SingleSourceCorpus(Context context, Config config, Source source) {
36         super(context, config);
37         mSource = source;
38     }
39 
getCorpusIcon()40     public Drawable getCorpusIcon() {
41         return mSource.getSourceIcon();
42     }
43 
getCorpusIconUri()44     public Uri getCorpusIconUri() {
45         return mSource.getSourceIconUri();
46     }
47 
getLabel()48     public CharSequence getLabel() {
49         return mSource.getLabel();
50     }
51 
getHint()52     public CharSequence getHint() {
53         return mSource.getHint();
54     }
55 
getSettingsDescription()56     public CharSequence getSettingsDescription() {
57         return mSource.getSettingsDescription();
58     }
59 
getSuggestions(String query, int queryLimit, boolean onlyCorpus)60     public CorpusResult getSuggestions(String query, int queryLimit, boolean onlyCorpus) {
61         LatencyTracker latencyTracker = new LatencyTracker();
62         SourceResult sourceResult = mSource.getSuggestions(query, queryLimit, true);
63         int latency = latencyTracker.getLatency();
64         return new SingleSourceCorpusResult(this, query, sourceResult, latency);
65     }
66 
getName()67     public String getName() {
68         return mSource.getName();
69     }
70 
queryAfterZeroResults()71     public boolean queryAfterZeroResults() {
72         return mSource.queryAfterZeroResults();
73     }
74 
getQueryThreshold()75     public int getQueryThreshold() {
76         return mSource.getQueryThreshold();
77     }
78 
voiceSearchEnabled()79     public boolean voiceSearchEnabled() {
80         return mSource.voiceSearchEnabled();
81     }
82 
createSearchIntent(String query, Bundle appData)83     public Intent createSearchIntent(String query, Bundle appData) {
84         return mSource.createSearchIntent(query, appData);
85     }
86 
createVoiceSearchIntent(Bundle appData)87     public Intent createVoiceSearchIntent(Bundle appData) {
88         return mSource.createVoiceSearchIntent(appData);
89     }
90 
includeInAll()91     public boolean includeInAll() {
92         return mSource.includeInAll();
93     }
94 
isWebCorpus()95     public boolean isWebCorpus() {
96         return false;
97     }
98 
getSources()99     public Collection<Source> getSources() {
100         return Collections.singletonList(mSource);
101     }
102 
103 }
104