SingleSourceCorpus.java revision fde948e69f59589cf0d217ea414af7947de600bb
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 24/** 25 * A corpus that uses a single source. 26 */ 27public class SingleSourceCorpus extends AbstractCorpus { 28 29 private final Source mSource; 30 31 public SingleSourceCorpus(Source source) { 32 mSource = source; 33 } 34 35 public Drawable getCorpusIcon() { 36 return mSource.getSourceIcon(); 37 } 38 39 public Uri getCorpusIconUri() { 40 return mSource.getSourceIconUri(); 41 } 42 43 public CharSequence getLabel() { 44 return mSource.getLabel(); 45 } 46 47 public CharSequence getSettingsDescription() { 48 return mSource.getSettingsDescription(); 49 } 50 51 public CorpusResult getSuggestions(String query, int queryLimit) { 52 SourceResult sourceResult = mSource.getSuggestions(query, queryLimit); 53 return new SingleSourceCorpusResult(this, query, sourceResult); 54 } 55 56 public String getName() { 57 return mSource.getFlattenedComponentName(); 58 } 59 60 public boolean queryAfterZeroResults() { 61 return mSource.queryAfterZeroResults(); 62 } 63 64 public int getQueryThreshold() { 65 return mSource.getQueryThreshold(); 66 } 67 68 public boolean voiceSearchEnabled() { 69 return mSource.voiceSearchEnabled(); 70 } 71 72 public Intent createSearchIntent(String query, Bundle appData) { 73 return mSource.createSearchIntent(query, appData); 74 } 75 76 public Intent createVoiceSearchIntent(Bundle appData) { 77 return mSource.createVoiceSearchIntent(appData); 78 } 79 80 public boolean isWebCorpus() { 81 return false; 82 } 83 84} 85