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