13e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/*
23e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Copyright (C) 2009 The Android Open Source Project
33e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *
43e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License");
53e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * you may not use this file except in compliance with the License.
63e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * You may obtain a copy of the License at
73e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *
83e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *      http://www.apache.org/licenses/LICENSE-2.0
93e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *
103e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Unless required by applicable law or agreed to in writing, software
113e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS,
123e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
133e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * See the License for the specific language governing permissions and
143e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * limitations under the License.
153e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */
163e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
173e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertpackage com.android.quicksearchbox;
183e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
19e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwoodimport com.android.quicksearchbox.util.NowOrLater;
20e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood
213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.content.ContentResolver;
223e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.graphics.drawable.Drawable;
233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.net.Uri;
243e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
253e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/**
263e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Interface for icon loaders.
273e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *
283e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */
293e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertpublic interface IconLoader {
303e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
313e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
323e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets a drawable given an ID.
333e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
343e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * The ID could be just the string value of a resource id
353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * (e.g., "2130837524"), in which case we will try to retrieve a drawable from
363e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * the provider's resources. If the ID is not an integer, it is
373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * treated as a Uri and opened with
383e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * {@link ContentResolver#openOutputStream(android.net.Uri, String)}.
393e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
403e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * All resources and URIs are read using the suggestion provider's context.
413e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
42e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood     * @return a {@link NowOrLater} for retrieving the icon. If the ID is not formatted as expected,
43e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood     *      or no drawable can be found for the provided value, the value from this will be null.
443e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
453e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @param drawableId a string like "2130837524",
463e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *        "android.resource://com.android.alarmclock/2130837524",
473e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *        or "content://contacts/photos/253".
483e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
49e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood    NowOrLater<Drawable> getIcon(String drawableId);
503e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
513e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
523e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Converts a drawable ID to a Uri that can be used from other packages.
533e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
543e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    Uri getIconUri(String drawableId);
553e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
563e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert}
57