1 /* 2 * Copyright (C) 2022 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 package com.android.quicksearchbox 17 18 import android.content.Context 19 import android.graphics.drawable.Drawable 20 import android.net.Uri 21 import android.os.Handler 22 import com.android.quicksearchbox.util.NamedTaskExecutor 23 24 /** Abstract implementation of a source that is not backed by a searchable activity. */ 25 abstract class AbstractInternalSource( 26 context: Context?, 27 uiThread: Handler?, 28 iconLoader: NamedTaskExecutor 29 ) : AbstractSource(context, uiThread, iconLoader) { 30 @get:Override 31 override val suggestUri: String? 32 get() = null 33 34 @Override canReadnull35 override fun canRead(): Boolean { 36 return true 37 } 38 39 override val defaultIntentData: String? 40 get() = null 41 42 @get:Override 43 override val iconPackage: String 44 get() = context!!.getPackageName() 45 46 @get:Override 47 override val queryThreshold: Int 48 get() = 0 49 50 @get:Override 51 override val sourceIcon: Drawable 52 get() = context?.getResources()!!.getDrawable(sourceIconResource, null) 53 54 @get:Override 55 override val sourceIconUri: Uri 56 get() = 57 Uri.parse( 58 "android.resource://" + context!!.getPackageName().toString() + "/" + sourceIconResource 59 ) 60 protected abstract val sourceIconResource: Int 61 62 @Override queryAfterZeroResultsnull63 override fun queryAfterZeroResults(): Boolean { 64 return true 65 } 66 } 67