1/* 2 * Copyright (C) 2010 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 */ 16package com.android.quicksearchbox; 17 18import com.android.quicksearchbox.util.NamedTaskExecutor; 19 20import android.content.Context; 21import android.graphics.drawable.Drawable; 22import android.net.Uri; 23import android.os.Handler; 24 25/** 26 * Abstract implementation of a source that is not backed by a searchable activity. 27 */ 28public abstract class AbstractInternalSource extends AbstractSource { 29 30 public AbstractInternalSource(Context context, Handler uiThread, NamedTaskExecutor iconLoader) { 31 super(context, uiThread, iconLoader); 32 } 33 34 @Override 35 public String getSuggestUri() { 36 return null; 37 } 38 39 @Override 40 public boolean canRead() { 41 return true; 42 } 43 44 @Override 45 public String getDefaultIntentData() { 46 return null; 47 } 48 49 @Override 50 protected String getIconPackage() { 51 return getContext().getPackageName(); 52 } 53 54 @Override 55 public int getQueryThreshold() { 56 return 0; 57 } 58 59 @Override 60 public Drawable getSourceIcon() { 61 return getContext().getResources().getDrawable(getSourceIconResource()); 62 } 63 64 @Override 65 public Uri getSourceIconUri() { 66 return Uri.parse("android.resource://" + getContext().getPackageName() 67 + "/" + getSourceIconResource()); 68 } 69 70 protected abstract int getSourceIconResource(); 71 72 @Override 73 public boolean queryAfterZeroResults() { 74 return true; 75 } 76 77} 78