Methods Summary |
---|
private void | addActionKey(android.app.SearchableInfo$ActionKeyInfo keyInfo)
if (mActionKeys == null) {
mActionKeys = new HashMap<Integer,ActionKeyInfo>();
}
mActionKeys.put(keyInfo.getKeyCode(), keyInfo);
|
public boolean | autoUrlDetect()Checks whether this searchable activity has auto URL detection turned on.
return mAutoUrlDetect;
|
private static android.content.Context | createActivityContext(android.content.Context context, android.content.ComponentName activity)Creates a context for another activity.
Context theirContext = null;
try {
theirContext = context.createPackageContext(activity.getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
Log.e(LOG_TAG, "Package not found " + activity.getPackageName());
} catch (java.lang.SecurityException e) {
Log.e(LOG_TAG, "Can't make context for " + activity.getPackageName(), e);
}
return theirContext;
|
public int | describeContents()
return 0;
|
public android.app.SearchableInfo$ActionKeyInfo | findActionKey(int keyCode)If any action keys were defined for this searchable activity, look up and return.
if (mActionKeys == null) {
return null;
}
return mActionKeys.get(keyCode);
|
public android.content.Context | getActivityContext(android.content.Context context)Get the context for the searchable activity.
return createActivityContext(context, mSearchActivity);
|
public static android.app.SearchableInfo | getActivityMetaData(android.content.Context context, android.content.pm.ActivityInfo activityInfo, int userId)Gets search information for the given activity.
Context userContext = null;
try {
userContext = context.createPackageContextAsUser("system", 0,
new UserHandle(userId));
} catch (NameNotFoundException nnfe) {
Log.e(LOG_TAG, "Couldn't create package context for user " + userId);
return null;
}
// for each component, try to find metadata
XmlResourceParser xml =
activityInfo.loadXmlMetaData(userContext.getPackageManager(), MD_LABEL_SEARCHABLE);
if (xml == null) {
return null;
}
ComponentName cName = new ComponentName(activityInfo.packageName, activityInfo.name);
SearchableInfo searchable = getActivityMetaData(userContext, xml, cName);
xml.close();
if (DBG) {
if (searchable != null) {
Log.d(LOG_TAG, "Checked " + activityInfo.name
+ ",label=" + searchable.getLabelId()
+ ",icon=" + searchable.getIconId()
+ ",suggestAuthority=" + searchable.getSuggestAuthority()
+ ",target=" + searchable.getSearchActivity().getClassName()
+ ",global=" + searchable.shouldIncludeInGlobalSearch()
+ ",settingsDescription=" + searchable.getSettingsDescriptionId()
+ ",threshold=" + searchable.getSuggestThreshold());
} else {
Log.d(LOG_TAG, "Checked " + activityInfo.name + ", no searchable meta-data");
}
}
return searchable;
|
private static android.app.SearchableInfo | getActivityMetaData(android.content.Context context, org.xmlpull.v1.XmlPullParser xml, android.content.ComponentName cName)Get the metadata for a given activity
SearchableInfo result = null;
Context activityContext = createActivityContext(context, cName);
if (activityContext == null) return null;
// in order to use the attributes mechanism, we have to walk the parser
// forward through the file until it's reading the tag of interest.
try {
int tagType = xml.next();
while (tagType != XmlPullParser.END_DOCUMENT) {
if (tagType == XmlPullParser.START_TAG) {
if (xml.getName().equals(MD_XML_ELEMENT_SEARCHABLE)) {
AttributeSet attr = Xml.asAttributeSet(xml);
if (attr != null) {
try {
result = new SearchableInfo(activityContext, attr, cName);
} catch (IllegalArgumentException ex) {
Log.w(LOG_TAG, "Invalid searchable metadata for " +
cName.flattenToShortString() + ": " + ex.getMessage());
return null;
}
}
} else if (xml.getName().equals(MD_XML_ELEMENT_SEARCHABLE_ACTION_KEY)) {
if (result == null) {
// Can't process an embedded element if we haven't seen the enclosing
return null;
}
AttributeSet attr = Xml.asAttributeSet(xml);
if (attr != null) {
try {
result.addActionKey(new ActionKeyInfo(activityContext, attr));
} catch (IllegalArgumentException ex) {
Log.w(LOG_TAG, "Invalid action key for " +
cName.flattenToShortString() + ": " + ex.getMessage());
return null;
}
}
}
}
tagType = xml.next();
}
} catch (XmlPullParserException e) {
Log.w(LOG_TAG, "Reading searchable metadata for " + cName.flattenToShortString(), e);
return null;
} catch (IOException e) {
Log.w(LOG_TAG, "Reading searchable metadata for " + cName.flattenToShortString(), e);
return null;
}
return result;
|
public int | getHintId()Gets the resource id of the hint text. This must be
read using the searchable Activity's resources.
return mHintId;
|
public int | getIconId()Gets the icon id specified by the Searchable_icon meta-data entry. This must be
read using the searchable Activity's resources.
return mIconId;
|
public int | getImeOptions()Gets the input method options specified in the searchable attributes.
This will default to {@link EditorInfo#IME_ACTION_GO} if not specified (which is
appropriate for a search box).
return mSearchImeOptions;
|
public int | getInputType()Gets the input type as specified in the searchable attributes. This will default to
{@link InputType#TYPE_CLASS_TEXT} if not specified (which is appropriate
for free text input).
return mSearchInputType;
|
public int | getLabelId()Gets the "label" (user-visible name) of this searchable context. This must be
read using the searchable Activity's resources.
return mLabelId;
|
public android.content.Context | getProviderContext(android.content.Context context, android.content.Context activityContext)Get the context for the suggestions provider.
Context theirContext = null;
if (mSearchActivity.getPackageName().equals(mSuggestProviderPackage)) {
return activityContext;
}
if (mSuggestProviderPackage != null) {
try {
theirContext = context.createPackageContext(mSuggestProviderPackage, 0);
} catch (PackageManager.NameNotFoundException e) {
// unexpected, but we deal with this by null-checking theirContext
} catch (java.lang.SecurityException e) {
// unexpected, but we deal with this by null-checking theirContext
}
}
return theirContext;
|
public android.content.ComponentName | getSearchActivity()Gets the component name of the searchable activity.
return mSearchActivity;
|
public int | getSearchButtonText()Gets the resource id of replacement text for the "Search" button.
return mSearchButtonText;
|
public int | getSettingsDescriptionId()Gets the resource id of the description string to use for this source in system search
settings, or {@code 0} if none has been specified.
return mSettingsDescriptionId;
|
public java.lang.String | getSuggestAuthority()Gets the search suggestion content provider authority. // voiceMaxResults
return mSuggestAuthority;
|
public java.lang.String | getSuggestIntentAction()Gets the optional intent action for use with these suggestions. This is
useful if all intents will have the same action
(e.g. {@link android.content.Intent#ACTION_VIEW})
This can be overriden in any given suggestion using the column
{@link SearchManager#SUGGEST_COLUMN_INTENT_ACTION}.
return mSuggestIntentAction;
|
public java.lang.String | getSuggestIntentData()Gets the optional intent data for use with these suggestions. This is
useful if all intents will have similar data URIs,
but you'll likely need to provide a specific ID as well via the column
{@link SearchManager#SUGGEST_COLUMN_INTENT_DATA_ID}, which will be appended to the
intent data URI.
This can be overriden in any given suggestion using the column
{@link SearchManager#SUGGEST_COLUMN_INTENT_DATA}.
return mSuggestIntentData;
|
public java.lang.String | getSuggestPackage()Gets the name of the package where the suggestion provider lives,
or {@code null}.
return mSuggestProviderPackage;
|
public java.lang.String | getSuggestPath()Gets the content provider path for obtaining search suggestions.
return mSuggestPath;
|
public java.lang.String | getSuggestSelection()Gets the selection for obtaining search suggestions.
return mSuggestSelection;
|
public int | getSuggestThreshold()Gets the suggestion threshold.
return mSuggestThreshold;
|
public int | getVoiceLanguageId()Gets the resource id of the spoken language to recognize in voice search.
return mVoiceLanguageId;
|
public int | getVoiceLanguageModeId()Gets the resource id of the voice search language model string.
return mVoiceLanguageModeId;
|
public int | getVoiceMaxResults()The maximum number of voice recognition results to return.
return mVoiceMaxResults;
|
public int | getVoicePromptTextId()Gets the resource id of the voice prompt text string.
return mVoicePromptTextId;
|
public boolean | getVoiceSearchEnabled()Checks if the searchable activity wants the voice search button to be shown.
return 0 != (mVoiceSearchMode & VOICE_SEARCH_SHOW_BUTTON);
|
public boolean | getVoiceSearchLaunchRecognizer()Checks if voice search should start in-app search.
return 0 != (mVoiceSearchMode & VOICE_SEARCH_LAUNCH_RECOGNIZER);
|
public boolean | getVoiceSearchLaunchWebSearch()Checks if voice search should start web search.
return 0 != (mVoiceSearchMode & VOICE_SEARCH_LAUNCH_WEB_SEARCH);
|
public boolean | queryAfterZeroResults()Checks whether this searchable activity should be queried for suggestions if a prefix
of the query has returned no results.
return mQueryAfterZeroResults;
|
public boolean | shouldIncludeInGlobalSearch()Checks whether the searchable should be included in global search.
return mIncludeInGlobalSearch;
|
public boolean | shouldRewriteQueryFromData()Checks whether the text in the query field should come from the suggestion intent data.
return 0 != (mSearchMode & SEARCH_MODE_QUERY_REWRITE_FROM_DATA);
|
public boolean | shouldRewriteQueryFromText()Checks whether the text in the query field should come from the suggestion title.
return 0 != (mSearchMode & SEARCH_MODE_QUERY_REWRITE_FROM_TEXT);
|
public boolean | useBadgeIcon()Checks whether the badge should be an icon.
return (0 != (mSearchMode & SEARCH_MODE_BADGE_ICON)) && (mIconId != 0);
|
public boolean | useBadgeLabel()Checks whether the badge should be a text label.
return 0 != (mSearchMode & SEARCH_MODE_BADGE_LABEL);
|
public void | writeToParcel(android.os.Parcel dest, int flags)
dest.writeInt(mLabelId);
mSearchActivity.writeToParcel(dest, flags);
dest.writeInt(mHintId);
dest.writeInt(mSearchMode);
dest.writeInt(mIconId);
dest.writeInt(mSearchButtonText);
dest.writeInt(mSearchInputType);
dest.writeInt(mSearchImeOptions);
dest.writeInt(mIncludeInGlobalSearch ? 1 : 0);
dest.writeInt(mQueryAfterZeroResults ? 1 : 0);
dest.writeInt(mAutoUrlDetect ? 1 : 0);
dest.writeInt(mSettingsDescriptionId);
dest.writeString(mSuggestAuthority);
dest.writeString(mSuggestPath);
dest.writeString(mSuggestSelection);
dest.writeString(mSuggestIntentAction);
dest.writeString(mSuggestIntentData);
dest.writeInt(mSuggestThreshold);
if (mActionKeys == null) {
dest.writeInt(0);
} else {
dest.writeInt(mActionKeys.size());
for (ActionKeyInfo actionKey : mActionKeys.values()) {
actionKey.writeToParcel(dest, flags);
}
}
dest.writeString(mSuggestProviderPackage);
dest.writeInt(mVoiceSearchMode);
dest.writeInt(mVoiceLanguageModeId);
dest.writeInt(mVoicePromptTextId);
dest.writeInt(mVoiceLanguageId);
dest.writeInt(mVoiceMaxResults);
|