Home | History | Annotate | Download | only in quicksearchbox
      1 /*
      2  * Copyright (C) 2010 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.ComponentName;
     19 
     20 /**
     21  * Interface for individual suggestions.
     22  */
     23 public interface Suggestion {
     24 
     25     /**
     26      * Gets the source that produced the current suggestion.
     27      */
     28     Source getSuggestionSource();
     29 
     30     /**
     31      * Gets the shortcut ID of the current suggestion.
     32      */
     33     String getShortcutId();
     34 
     35     /**
     36      * Whether to show a spinner while refreshing this shortcut.
     37      */
     38     boolean isSpinnerWhileRefreshing();
     39 
     40     /**
     41      * Gets the format of the text returned by {@link #getSuggestionText1()}
     42      * and {@link #getSuggestionText2()}.
     43      *
     44      * @return {@code null} or "html"
     45      */
     46     String getSuggestionFormat();
     47 
     48     /**
     49      * Gets the first text line for the current suggestion.
     50      */
     51     String getSuggestionText1();
     52 
     53     /**
     54      * Gets the second text line for the current suggestion.
     55      */
     56     String getSuggestionText2();
     57 
     58     /**
     59      * Gets the second text line URL for the current suggestion.
     60      */
     61     String getSuggestionText2Url();
     62 
     63     /**
     64      * Gets the left-hand-side icon for the current suggestion.
     65      *
     66      * @return A string that can be passed to {@link Source#getIcon(String)}.
     67      */
     68     String getSuggestionIcon1();
     69 
     70     /**
     71      * Gets the right-hand-side icon for the current suggestion.
     72      *
     73      * @return A string that can be passed to {@link Source#getIcon(String)}.
     74      */
     75     String getSuggestionIcon2();
     76 
     77     /**
     78      * Gets the intent action for the current suggestion.
     79      */
     80     String getSuggestionIntentAction();
     81 
     82     /**
     83      * Gets the name of the activity that the intent for the current suggestion will be sent to.
     84      */
     85     ComponentName getSuggestionIntentComponent();
     86 
     87     /**
     88      * Gets the extra data associated with this suggestion's intent.
     89      */
     90     String getSuggestionIntentExtraData();
     91 
     92     /**
     93      * Gets the data associated with this suggestion's intent.
     94      */
     95     String getSuggestionIntentDataString();
     96 
     97     /**
     98      * Gets the query associated with this suggestion's intent.
     99      */
    100     String getSuggestionQuery();
    101 
    102     /**
    103      * Gets the suggestion log type for the current suggestion. This is logged together
    104      * with the value returned from {@link Source#getName()}.
    105      * The value is source-specific. Most sources return {@code null}.
    106      */
    107     String getSuggestionLogType();
    108 
    109     /**
    110      * Checks if this suggestion is a shortcut.
    111      */
    112     boolean isSuggestionShortcut();
    113 
    114     /**
    115      * Checks if this is a web search suggestion.
    116      */
    117     boolean isWebSearchSuggestion();
    118 
    119     /**
    120      * Checks whether this suggestion comes from the user's search history.
    121      */
    122     boolean isHistorySuggestion();
    123 
    124     /**
    125      * Returns any extras associated with this suggestion, or {@code null} if there are none.
    126      */
    127     SuggestionExtras getExtras();
    128 
    129 }
    130