1185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert/*
2fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Copyright (C) 2010 The Android Open Source Project
3185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert *
4185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * Licensed under the Apache License, Version 2.0 (the "License");
5185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * you may not use this file except in compliance with the License.
6185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * You may obtain a copy of the License at
7185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert *
8185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert *      http://www.apache.org/licenses/LICENSE-2.0
9185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert *
10185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * Unless required by applicable law or agreed to in writing, software
11185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * distributed under the License is distributed on an "AS IS" BASIS,
12185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * See the License for the specific language governing permissions and
14185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert * limitations under the License.
15185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert */
16185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringertpackage com.android.quicksearchbox.ui;
17185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
185229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.Promoter;
195229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.SuggestionCursor;
207a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwoodimport com.android.quicksearchbox.SuggestionPosition;
215229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwoodimport com.android.quicksearchbox.Suggestions;
225229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood
2366ee1cc883f77fee930587503ecdcd8d18f12b23Mathew Inwoodimport android.view.View.OnFocusChangeListener;
24fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodimport android.widget.ExpandableListAdapter;
25fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodimport android.widget.ListAdapter;
26b83882b9efa37ec0f20a0f1c85cf5ccc93194aeeBjorn Bringert
27185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert/**
28fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * Interface for suggestions adapters.
29fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood *
30fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood * @param <A> the adapter class used by the UI, probably either {@link ListAdapter} or
31fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood *      {@link ExpandableListAdapter}.
32185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert */
33fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwoodpublic interface SuggestionsAdapter<A> {
341e938ea2f5edefab446b9562b316bc5dc72adebbBryan Mawhinney
35fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
36fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Sets the maximum number of promoted suggestions to be provided by this adapter.
37fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
38fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    void setMaxPromoted(int maxPromoted);
395229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood
40fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
41fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Sets the suggestion promoter.
42fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
43fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    void setPromoter(Promoter promoter);
44185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
45fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
46fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Sets the listener to be notified of clicks on suggestions.
47fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
48fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    void setSuggestionClickListener(SuggestionClickListener listener);
49185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
50713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert    /**
51fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Sets the listener to be notified of focus change events on suggestion views.
52ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert     */
53fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    void setOnFocusChangeListener(OnFocusChangeListener l);
54ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert
55ca78085bb2127559e6f55276a307bfa857018ecaBjorn Bringert    /**
56fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Sets the current suggestions.
57713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert     */
58fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    void setSuggestions(Suggestions suggestions);
59185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
60713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert    /**
617a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * Indicates if there's any suggestions in this adapter.
627a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     */
637a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    boolean isEmpty();
647a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood
657a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    /**
66fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Gets the current suggestions.
67713194910648268c094fa81b81f40ce2f7e39333Bjorn Bringert     */
68fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    Suggestions getSuggestions();
69185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
70fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
717a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * Gets the cursor and position corresponding to the given suggestion ID.
727a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * @param suggestionId Suggestion ID.
737a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     */
747a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    SuggestionPosition getSuggestion(long suggestionId);
757a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood
767a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    /**
77fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Gets the current list of promoted suggestions.
78fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
79fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    SuggestionCursor getCurrentPromotedSuggestions();
807010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert
81fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
82fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Handles a regular click on a suggestion.
837a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *
847a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this
857a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *      will be the position within the list.
86fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
877a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    void onSuggestionClicked(long suggestionId);
887010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert
89fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
90fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Handles a click on a quick contact badge.
917a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *
927a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this
937a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *      will be the position within the list.
94fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
957a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    void onSuggestionQuickContactClicked(long suggestionId);
967010c51b51c97fa43d7b24d2158ecbc1d064e0a6Bjorn Bringert
97fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
98fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Handles a request to remove a suggestion from history.
997a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *
1007a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this
1017a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *      will be the position within the list.
102fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
1037a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    void onSuggestionRemoveFromHistoryClicked(long suggestionId);
10466ee1cc883f77fee930587503ecdcd8d18f12b23Mathew Inwood
105fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
106fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Handles a click on the query refinement button.
1077a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *
1087a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     * @param suggestionId The ID of the suggestion clicked. If the suggestion list is flat, this
1097a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood     *      will be the position within the list.
110fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
1117a0c3a7c6fdabce949b59e0a2c6ec1d44a140c24Mathew Inwood    void onSuggestionQueryRefineClicked(long suggestionId);
112185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert
113fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    /**
114fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     * Gets the adapter to be used by the UI view.
115fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood     */
116fd4a4cbc1143a734d357897531daa7105db6459bMathew Inwood    A getListAdapter();
1175229b06f00d20aac76cd8519b37f2a579d61c54fMathew Inwood
118185bb2e3881452c084fde44d9bee657f65881b0eBjorn Bringert}
119