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;
205229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood
213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.content.ComponentName;
22fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringertimport android.content.Intent;
233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.graphics.drawable.Drawable;
243e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringertimport android.net.Uri;
25fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringertimport android.os.Bundle;
263e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
273e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert/**
283e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert * Interface for suggestion sources.
293e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert *
303e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert */
31f252dc7a25ba08b973ecc1cfbbce58eb78d42167Bjorn Bringertpublic interface Source extends SuggestionCursorProvider<SourceResult> {
323e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
333e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
3481a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert     * Gets the name activity that intents from this source are sent to.
353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
3681a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert    ComponentName getIntentComponent();
373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
383e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
3909552c760ad82eb90795e98de96c65005d6ebafcMathew Inwood     * Gets the suggestion URI for getting suggestions from this Source.
4009552c760ad82eb90795e98de96c65005d6ebafcMathew Inwood     */
4109552c760ad82eb90795e98de96c65005d6ebafcMathew Inwood    String getSuggestUri();
4209552c760ad82eb90795e98de96c65005d6ebafcMathew Inwood
4309552c760ad82eb90795e98de96c65005d6ebafcMathew Inwood    /**
443e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the localized, human-readable label for this source.
453e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
463e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    CharSequence getLabel();
473e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
483e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
493e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the icon for this suggestion source.
503e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
513e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    Drawable getSourceIcon();
523e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
533e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
543e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the icon URI for this suggestion source.
553e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
563e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    Uri getSourceIconUri();
573e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
583e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
593e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets an icon from this suggestion source.
603e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
613e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @param drawableId Resource ID or URI.
623e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
63e29d52aa72c96c3147fa91d83aeb8dafc6d1f578Mathew Inwood    NowOrLater<Drawable> getIcon(String drawableId);
643e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
653e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
663e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the URI for an icon form this suggestion source.
673e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
683e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @param drawableId Resource ID or URI.
693e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
703e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    Uri getIconUri(String drawableId);
713e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
723e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
735691f9062b2a558ba39c700d65bc522d397ebc75Bjorn Bringert     * Gets the search hint text for this suggestion source.
745691f9062b2a558ba39c700d65bc522d397ebc75Bjorn Bringert     */
755691f9062b2a558ba39c700d65bc522d397ebc75Bjorn Bringert    CharSequence getHint();
765691f9062b2a558ba39c700d65bc522d397ebc75Bjorn Bringert
775691f9062b2a558ba39c700d65bc522d397ebc75Bjorn Bringert    /**
783e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the description to use for this source in system search settings.
793e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
808d9d845323514c34bb07d6eb91146a975324fcedBjorn Bringert    CharSequence getSettingsDescription();
813e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
823e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
833e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
843e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *  Note: this does not guarantee that this source will be queried for queries of
853e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *  this length or longer, only that it will not be queried for anything shorter.
863e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
873e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @return The minimum number of characters needed to trigger this source.
883e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
893e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    int getQueryThreshold();
903e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
913e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
923e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Indicates whether a source should be invoked for supersets of queries it has returned zero
933e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * results for in the past.  For example, if a source returned zero results for "bo", it would
943e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * be ignored for "bob".
953e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
963e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * If set to <code>false</code>, this source will only be ignored for a single session; the next
973e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * time the search dialog is brought up, all sources will be queried.
983e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
993e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @return <code>true</code> if this source should be queried after returning no results.
1003e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
1013e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    boolean queryAfterZeroResults();
1023e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
103fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert    boolean voiceSearchEnabled();
104fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert
105f3f70e5ae88f06ff6dabdec9e7c71a19ca1e7108Bjorn Bringert    /**
106f3f70e5ae88f06ff6dabdec9e7c71a19ca1e7108Bjorn Bringert     * Whether this source should be included in the blended All mode. The source must
107f3f70e5ae88f06ff6dabdec9e7c71a19ca1e7108Bjorn Bringert     * also be enabled to be included in All.
108f3f70e5ae88f06ff6dabdec9e7c71a19ca1e7108Bjorn Bringert     */
109f3f70e5ae88f06ff6dabdec9e7c71a19ca1e7108Bjorn Bringert    boolean includeInAll();
11008ff0a7cb6b99db79508fa3124730eb81411bc56Bjorn Bringert
111fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert    Intent createSearchIntent(String query, Bundle appData);
112fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert
113fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert    Intent createVoiceSearchIntent(Bundle appData);
114fde948e69f59589cf0d217ea414af7947de600bbBjorn Bringert
1153e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
11681a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert     * Checks if the current process can read the suggestions from this source.
11781a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert     */
11881a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert    boolean canRead();
11981a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert
12081a0897ff9685f3313c58294bf7973700c468b2bBjorn Bringert    /**
1213e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets suggestions from this source.
1223e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
1233e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @param query The user query.
1243e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @return The suggestion results.
1253e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
126ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood    @Override
127ecf356c15143ab0583c64682de16d94a57f7dd1cMathew Inwood    SourceResult getSuggestions(String query, int queryLimit);
12894e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney
12994e8a2be78530170f50e7895a558bf8011bbf8e8Bryan Mawhinney    /**
1303e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the default intent action for suggestions from this source.
1313e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
1323e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @return The default intent action, or {@code null}.
1333e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
1343e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    String getDefaultIntentAction();
1353e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
1363e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    /**
1373e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * Gets the default intent data for suggestions from this source.
1383e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     *
1393e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     * @return The default intent data, or {@code null}.
1403e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert     */
1413e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert    String getDefaultIntentData();
1423e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert
143848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani    /**
144848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani     * Gets the root source, if this source is a wrapper around another. Otherwise, returns this
145848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani     * source.
146848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani     */
147848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani    Source getRoot();
148848fa7a19abedc372452073abaf52780c7b6d78dAmith Yamasani
1493e44ff1f2a204db3f479698cf0b3eab3d451dec2Bjorn Bringert}
150