AbstractInternalSource.java revision e29d52aa72c96c3147fa91d83aeb8dafc6d1f578
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 android.content.Context; 19import android.graphics.drawable.Drawable; 20import android.net.Uri; 21import android.os.Handler; 22 23/** 24 * Abstract implementation of a source that is not backed by a searchable activity. 25 */ 26public abstract class AbstractInternalSource extends AbstractSource { 27 28 public AbstractInternalSource(Context context, Handler uiThread) { 29 super(context, uiThread); 30 } 31 32 public String getSuggestUri() { 33 return null; 34 } 35 36 public boolean canRead() { 37 return true; 38 } 39 40 public String getDefaultIntentData() { 41 return null; 42 } 43 44 @Override 45 protected String getIconPackage() { 46 return getContext().getPackageName(); 47 } 48 49 public int getQueryThreshold() { 50 return 0; 51 } 52 53 public Drawable getSourceIcon() { 54 return getContext().getResources().getDrawable(getSourceIconResource()); 55 } 56 57 public Uri getSourceIconUri() { 58 return Uri.parse("android.resource://" + getContext().getPackageName() 59 + "/" + getSourceIconResource()); 60 } 61 62 protected abstract int getSourceIconResource(); 63 64 public int getVersionCode() { 65 return QsbApplication.get(getContext()).getVersionCode(); 66 } 67 68 /** 69 * Shortcuts from previous version are compatible with shortcuts from this version, so we just 70 * return true. If shortcuts become incompatible during an upgrade, some examination of the 71 * version code should be added here. 72 */ 73 @Override 74 public boolean isVersionCodeCompatible(int version) { 75 return true; 76 } 77 78 public boolean queryAfterZeroResults() { 79 return true; 80 } 81 82} 83