Prepare SearchManager framework for adding Genie logging.
- Instead of passing the suggest provider component name as the field EXTRA_DATA, we now pass via the field COMPONENT_NAME - Kept EXTRA_DATA field as is so we can use it for real extra data.
This commit is contained in:
@@ -1100,7 +1100,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
*/
|
||||
protected void launchQuerySearch(int actionKey, String actionMsg) {
|
||||
String query = mSearchAutoComplete.getText().toString();
|
||||
Intent intent = createIntent(Intent.ACTION_SEARCH, null, query, null,
|
||||
Intent intent = createIntent(Intent.ACTION_SEARCH, null, null, query, null,
|
||||
actionKey, actionMsg);
|
||||
launchIntent(intent);
|
||||
}
|
||||
@@ -1170,8 +1170,8 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
// logic for falling back on the searchable default
|
||||
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_ACTION, intent.getAction());
|
||||
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_DATA, intent.getDataString());
|
||||
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA,
|
||||
intent.getStringExtra(SearchManager.EXTRA_DATA_KEY));
|
||||
cv.put(SearchManager.SUGGEST_COLUMN_INTENT_COMPONENT_NAME,
|
||||
intent.getStringExtra(SearchManager.COMPONENT_NAME_KEY));
|
||||
|
||||
// ensure the icons will work for global search
|
||||
cv.put(SearchManager.SUGGEST_COLUMN_ICON_1,
|
||||
@@ -1399,11 +1399,14 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
}
|
||||
Uri dataUri = (data == null) ? null : Uri.parse(data);
|
||||
|
||||
String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
|
||||
String componentName = getColumnString(
|
||||
c, SearchManager.SUGGEST_COLUMN_INTENT_COMPONENT_NAME);
|
||||
|
||||
String query = getColumnString(c, SearchManager.SUGGEST_COLUMN_QUERY);
|
||||
String extraData = getColumnString(c, SearchManager.SUGGEST_COLUMN_INTENT_EXTRA_DATA);
|
||||
|
||||
return createIntent(action, dataUri, query, extraData, actionKey, actionMsg);
|
||||
return createIntent(action, dataUri, extraData, query, componentName, actionKey,
|
||||
actionMsg);
|
||||
} catch (RuntimeException e ) {
|
||||
int rowNum;
|
||||
try { // be really paranoid now
|
||||
@@ -1422,16 +1425,17 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
*
|
||||
* @param action Intent action.
|
||||
* @param data Intent data, or <code>null</code>.
|
||||
* @param query Intent query, or <code>null</code>.
|
||||
* @param extraData Data for {@link SearchManager#EXTRA_DATA_KEY} or <code>null</code>.
|
||||
* @param query Intent query, or <code>null</code>.
|
||||
* @param componentName Data for {@link SearchManager#COMPONENT_NAME_KEY} or <code>null</code>.
|
||||
* @param actionKey The key code of the action key that was pressed,
|
||||
* or {@link KeyEvent#KEYCODE_UNKNOWN} if none.
|
||||
* @param actionMsg The message for the action key that was pressed,
|
||||
* or <code>null</code> if none.
|
||||
* @return The intent.
|
||||
*/
|
||||
private Intent createIntent(String action, Uri data, String query, String extraData,
|
||||
int actionKey, String actionMsg) {
|
||||
private Intent createIntent(String action, Uri data, String extraData, String query,
|
||||
String componentName, int actionKey, String actionMsg) {
|
||||
// Now build the Intent
|
||||
Intent intent = new Intent(action);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
@@ -1444,6 +1448,9 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
|
||||
if (extraData != null) {
|
||||
intent.putExtra(SearchManager.EXTRA_DATA_KEY, extraData);
|
||||
}
|
||||
if (componentName != null) {
|
||||
intent.putExtra(SearchManager.COMPONENT_NAME_KEY, componentName);
|
||||
}
|
||||
if (mAppSearchData != null) {
|
||||
intent.putExtra(SearchManager.APP_DATA, mAppSearchData);
|
||||
}
|
||||
|
||||
@@ -1164,6 +1164,14 @@ public class SearchManager
|
||||
*/
|
||||
public final static String ACTION_KEY = "action_key";
|
||||
|
||||
/**
|
||||
* Intent component name key: This key will be used for the extra populated by the
|
||||
* {@link #SUGGEST_COLUMN_INTENT_COMPONENT_NAME} column.
|
||||
*
|
||||
* {@hide}
|
||||
*/
|
||||
public final static String COMPONENT_NAME_KEY = "intent_component_name_key";
|
||||
|
||||
/**
|
||||
* Intent extra data key: This key will be used for the extra populated by the
|
||||
* {@link #SUGGEST_COLUMN_INTENT_EXTRA_DATA} column.
|
||||
@@ -1363,15 +1371,25 @@ public class SearchManager
|
||||
* it is more efficient to specify it using XML metadata and omit it from the cursor.
|
||||
*/
|
||||
public final static String SUGGEST_COLUMN_INTENT_DATA = "suggest_intent_data";
|
||||
/**
|
||||
* Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i>
|
||||
* this element exists at the given row, this is the data that will be used when
|
||||
* forming the suggestion's intent. If not provided, the Intent's extra data field will be null.
|
||||
* This column allows suggestions to provide additional arbitrary data which will be included as
|
||||
* an extra under the key EXTRA_DATA_KEY.
|
||||
*
|
||||
* @hide Pending API council approval.
|
||||
*/
|
||||
public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
|
||||
/**
|
||||
* Column name for suggestions cursor. <i>Optional.</i> This column allows suggestions
|
||||
* to provide additional arbitrary data which will be included as an extra under the key
|
||||
* {@link #EXTRA_DATA_KEY}. For use by the global search system only - if other providers
|
||||
* {@link #COMPONENT_NAME_KEY}. For use by the global search system only - if other providers
|
||||
* attempt to use this column, the value will be overwritten by global search.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
public final static String SUGGEST_COLUMN_INTENT_EXTRA_DATA = "suggest_intent_extra_data";
|
||||
public final static String SUGGEST_COLUMN_INTENT_COMPONENT_NAME = "suggest_intent_component";
|
||||
/**
|
||||
* Column name for suggestions cursor. <i>Optional.</i> If this column exists <i>and</i>
|
||||
* this element exists at the given row, then "/" and this value will be appended to the data
|
||||
|
||||
Reference in New Issue
Block a user