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.ContentResolver 19 import android.graphics.drawable.Drawable 20 import android.net.Uri 21 import com.android.quicksearchbox.util.NowOrLater 22 23 /** Interface for icon loaders. */ 24 interface IconLoader { 25 /** 26 * Gets a drawable given an ID. 27 * 28 * The ID could be just the string value of a resource id (e.g., "2130837524"), in which case we 29 * will try to retrieve a drawable from the provider's resources. If the ID is not an integer, it 30 * is treated as a Uri and opened with [ContentResolver.openOutputStream]. 31 * 32 * All resources and URIs are read using the suggestion provider's context. 33 * 34 * @return a [NowOrLater] for retrieving the icon. If the ID is not formatted as expected, or no 35 * drawable can be found for the provided value, the value from this will be null. 36 * 37 * @param drawableId a string like "2130837524", 38 * "android.resource://com.android.alarmclock/2130837524", or "content://contacts/photos/253". 39 */ getIconnull40 fun getIcon(drawableId: String?): NowOrLater<Drawable?>? 41 42 /** Converts a drawable ID to a Uri that can be used from other packages. */ 43 fun getIconUri(drawableId: String?): Uri? 44 } 45