Build 1.0_r1(from source)

android.server.search
Class SearchableInfo

java.lang.Object
  extended by android.server.search.SearchableInfo
All Implemented Interfaces:
Parcelable

public final class SearchableInfo
extends Object
implements Parcelable


Nested Class Summary
 class SearchableInfo.ActionKeyInfo
          Private class used to hold the "action key" configuration
 
Nested classes/interfaces inherited from interface android.os.Parcelable
Parcelable.Creator<T>
 
Field Summary
static Parcelable.Creator<SearchableInfo> CREATOR
          Support for parcelable and aidl operations.
(package private) static int DBG_INHIBIT_SUGGESTIONS
           
(package private) static String LOG_TAG
           
 boolean mBadgeIcon
           
 boolean mBadgeLabel
           
 boolean mQueryRewriteFromData
           
 boolean mQueryRewriteFromText
           
 boolean mSearchable
           
 ComponentName mSearchActivity
           
 
Fields inherited from interface android.os.Parcelable
CONTENTS_FILE_DESCRIPTOR, PARCELABLE_WRITE_RETURN_VALUE
 
Constructor Summary
SearchableInfo(Parcel in)
          Instantiate a new SearchableInfo from the data in a Parcel that was previously written with writeToParcel(Parcel, int).
 
Method Summary
static void buildSearchableList(Context context)
          Super-factory.
 int describeContents()
          Describe the kinds of special objects contained in this Parcelable's marshalled representation.
 SearchableInfo.ActionKeyInfo findActionKey(int keyCode)
          If any action keys were defined for this searchable activity, look up and return.
 Context getActivityContext(Context context)
          Get the context for the searchable activity.
static SearchableInfo getDefaultSearchable()
          Provides the system-default search activity, which you can use whenever getSearchableInfo() returns null;
 int getHintId()
          Return the resource Id of the hint text.
 int getIconId()
          Return the icon Id specified by the Searchable_icon meta-data entry.
 int getLabelId()
          Return the "label" (user-visible name) of this searchable context.
 Context getProviderContext(Context context, Context activityContext)
          Get the context for the suggestions provider.
static SearchableInfo getSearchableInfo(Context context, ComponentName activity)
          Factory.
static ArrayList<SearchableInfo> getSearchablesList()
          Return the list of searchable activities, for use in the drop-down.
 int getSearchButtonText()
          Return the resource Id of replacement text for the "Search" button.
 String getSuggestAuthority()
          Retrieve the authority for obtaining search suggestions.
 String getSuggestIntentAction()
          Retrieve the (optional) intent action for use with these suggestions.
 String getSuggestIntentData()
          Retrieve the (optional) intent data for use with these suggestions.
 String getSuggestPath()
          Retrieve the path for obtaining search suggestions.
 String getSuggestSelection()
          Retrieve the selection pattern for obtaining search suggestions.
static void setDefaultSearchable(Context context, ComponentName activity)
          Set the default searchable activity (when none is specified).
 void writeToParcel(Parcel dest, int flags)
          Flatten this object in to a Parcel.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG_TAG

static final String LOG_TAG
See Also:
Constant Field Values

DBG_INHIBIT_SUGGESTIONS

static final int DBG_INHIBIT_SUGGESTIONS
See Also:
Constant Field Values

mSearchable

public boolean mSearchable

mSearchActivity

public ComponentName mSearchActivity

mBadgeLabel

public boolean mBadgeLabel

mBadgeIcon

public boolean mBadgeIcon

mQueryRewriteFromData

public boolean mQueryRewriteFromData

mQueryRewriteFromText

public boolean mQueryRewriteFromText

CREATOR

public static final Parcelable.Creator<SearchableInfo> CREATOR
Support for parcelable and aidl operations.

Constructor Detail

SearchableInfo

public SearchableInfo(Parcel in)
Instantiate a new SearchableInfo from the data in a Parcel that was previously written with writeToParcel(Parcel, int).

Parameters:
in - The Parcel containing the previously written SearchableInfo, positioned at the location in the buffer where it was written.
Method Detail

setDefaultSearchable

public static void setDefaultSearchable(Context context,
                                        ComponentName activity)
Set the default searchable activity (when none is specified).


getDefaultSearchable

public static SearchableInfo getDefaultSearchable()
Provides the system-default search activity, which you can use whenever getSearchableInfo() returns null;

Returns:
Returns the system-default search activity, null if never defined

getSuggestAuthority

public String getSuggestAuthority()
Retrieve the authority for obtaining search suggestions.

Returns:
Returns a string containing the suggestions authority.

getSuggestPath

public String getSuggestPath()
Retrieve the path for obtaining search suggestions.

Returns:
Returns a string containing the suggestions path, or null if not provided.

getSuggestSelection

public String getSuggestSelection()
Retrieve the selection pattern for obtaining search suggestions. This must include a single ? which will be used for the user-typed characters.

Returns:
Returns a string containing the suggestions authority.

getSuggestIntentAction

public String getSuggestIntentAction()
Retrieve the (optional) intent action for use with these suggestions. This is useful if all intents will have the same action (e.g. "android.intent.action.VIEW"). Can be overriden in any given suggestion via the AUTOSUGGEST_COLUMN_INTENT_ACTION column.

Returns:
Returns a string containing the default intent action.

getSuggestIntentData

public String getSuggestIntentData()
Retrieve the (optional) intent data for use with these suggestions. This is useful if all intents will have similar data URIs (e.g. "android.intent.action.VIEW"), but you'll likely need to provide a specific ID as well via the column AUTOSUGGEST_COLUMN_INTENT_DATA_ID, which will be appended to the intent data URI. Can be overriden in any given suggestion via the AUTOSUGGEST_COLUMN_INTENT_DATA column.

Returns:
Returns a string containing the default intent data.

getActivityContext

public Context getActivityContext(Context context)
Get the context for the searchable activity. This is fairly expensive so do it on the original scan, or when an app is selected, but don't hang on to the result forever.

Parameters:
context - You need to supply a context to start with
Returns:
Returns a context related to the searchable activity

getProviderContext

public Context getProviderContext(Context context,
                                  Context activityContext)
Get the context for the suggestions provider. This is fairly expensive so do it on the original scan, or when an app is selected, but don't hang on to the result forever.

Parameters:
context - You need to supply a context to start with
activityContext - If we can determine that the provider and the activity are the same, we'll just return this one.
Returns:
Returns a context related to the context provider

getSearchableInfo

public static SearchableInfo getSearchableInfo(Context context,
                                               ComponentName activity)
Factory. Look up, or construct, based on the activity. The activities fall into three cases, based on meta-data found in the manifest entry:
  1. The activity itself implements search. This is indicated by the presence of a "android.app.searchable" meta-data attribute. The value is a reference to an XML file containing search information.
  2. A related activity implements search. This is indicated by the presence of a "android.app.default_searchable" meta-data attribute. The value is a string naming the activity implementing search. In this case the factory will "redirect" and return the searchable data.
  3. No searchability data is provided. We return null here and other code will insert the "default" (e.g. contacts) search. TODO: cache the result in the map, and check the map first. TODO: it might make sense to implement the searchable reference as an application meta-data entry. This way we don't have to pepper each and every activity. TODO: can we skip the constructor step if it's a non-searchable? TODO: does it make sense to plug the default into a slot here for automatic return? Probably not, but it's one way to do it.

    Parameters:
    activity - The name of the current activity, or null if the activity does not define any explicit searchable metadata.

buildSearchableList

public static void buildSearchableList(Context context)
Super-factory. Builds an entire list (suitable for display) of activities that are searchable, by iterating the entire set of ACTION_SEARCH intents. Also clears the hash of all activities -> searches which will refill as the user clicks "search". This should only be done at startup and again if we know that the list has changed. TODO: every activity that provides a ACTION_SEARCH intent should also provide searchability meta-data. There are a bunch of checks here that, if data is not found, silently skip to the next activity. This won't help a developer trying to figure out why their activity isn't showing up in the list, but an exception here is too rough. I would like to find a better notification mechanism. TODO: sort the list somehow? UI choice.

Parameters:
context - a context we can use during this work

findActionKey

public SearchableInfo.ActionKeyInfo findActionKey(int keyCode)
If any action keys were defined for this searchable activity, look up and return.

Parameters:
keyCode - The key that was pressed
Returns:
Returns the ActionKeyInfo record, or null if none defined

getLabelId

public int getLabelId()
Return the "label" (user-visible name) of this searchable context. This must be accessed using the target (searchable) Activity's resources, not simply the context of the caller.

Returns:
Returns the resource Id

getHintId

public int getHintId()
Return the resource Id of the hint text. This must be accessed using the target (searchable) Activity's resources, not simply the context of the caller.

Returns:
Returns the resource Id, or 0 if not specified by this package.

getIconId

public int getIconId()
Return the icon Id specified by the Searchable_icon meta-data entry. This must be accessed using the target (searchable) Activity's resources, not simply the context of the caller.

Returns:
Returns the resource id.

getSearchButtonText

public int getSearchButtonText()
Return the resource Id of replacement text for the "Search" button.

Returns:
Returns the resource Id, or 0 if not specified by this package.

getSearchablesList

public static ArrayList<SearchableInfo> getSearchablesList()
Return the list of searchable activities, for use in the drop-down.


describeContents

public int describeContents()
Description copied from interface: Parcelable
Describe the kinds of special objects contained in this Parcelable's marshalled representation.

Specified by:
describeContents in interface Parcelable
Returns:
a bitmask indicating the set of special object types marshalled by the Parcelable.

writeToParcel

public void writeToParcel(Parcel dest,
                          int flags)
Description copied from interface: Parcelable
Flatten this object in to a Parcel.

Specified by:
writeToParcel in interface Parcelable
Parameters:
dest - The Parcel in which the object should be written.
flags - Additional flags about how the object should be written. May be 0 or Parcelable.PARCELABLE_WRITE_RETURN_VALUE.

Build 1.0_r1(from source)

Please submit a feedback, bug or feature