Only show query refinement button on web suggestions
Bug: http://b/issue?id=2723969
Change-Id: I7f0d30d2d96fcedd0c417ccf63a9bdad5e4697bb
diff --git a/src/com/android/quicksearchbox/AbstractSuggestionCursor.java b/src/com/android/quicksearchbox/AbstractSuggestionCursor.java
index 7e66aef..58b11db 100644
--- a/src/com/android/quicksearchbox/AbstractSuggestionCursor.java
+++ b/src/com/android/quicksearchbox/AbstractSuggestionCursor.java
@@ -37,16 +37,16 @@
return mUserQuery;
}
+ protected String getSuggestionIntentAction(String action) {
+ if (action != null) return action;
+ String defaultAction = getSuggestionSource().getDefaultIntentAction();
+ if (defaultAction != null) return defaultAction;
+ return Intent.ACTION_SEARCH;
+ }
+
public Intent getSuggestionIntent(Bundle appSearchData) {
Source source = getSuggestionSource();
String action = getSuggestionIntentAction();
- // use specific action if supplied, or default action if supplied, or fixed default
- if (action == null) {
- action = source.getDefaultIntentAction();
- if (action == null) {
- action = Intent.ACTION_SEARCH;
- }
- }
String data = getSuggestionIntentDataString();
String query = getSuggestionQuery();
diff --git a/src/com/android/quicksearchbox/CursorBackedSuggestionCursor.java b/src/com/android/quicksearchbox/CursorBackedSuggestionCursor.java
index 2ed2793..b61e6a0 100644
--- a/src/com/android/quicksearchbox/CursorBackedSuggestionCursor.java
+++ b/src/com/android/quicksearchbox/CursorBackedSuggestionCursor.java
@@ -189,7 +189,8 @@
* Gets the intent action for the current suggestion.
*/
public String getSuggestionIntentAction() {
- return getStringOrNull(SearchManager.SUGGEST_COLUMN_INTENT_ACTION);
+ return getSuggestionIntentAction(
+ getStringOrNull(SearchManager.SUGGEST_COLUMN_INTENT_ACTION));
}
/**
diff --git a/src/com/android/quicksearchbox/DataSuggestionCursor.java b/src/com/android/quicksearchbox/DataSuggestionCursor.java
index 8502b53..c317f20 100644
--- a/src/com/android/quicksearchbox/DataSuggestionCursor.java
+++ b/src/com/android/quicksearchbox/DataSuggestionCursor.java
@@ -130,7 +130,7 @@
}
public String getSuggestionIntentAction() {
- return current().getSuggestionIntentAction();
+ return getSuggestionIntentAction(current().getSuggestionIntentAction());
}
public String getSuggestionIntentDataString() {
diff --git a/src/com/android/quicksearchbox/ui/DefaultSuggestionView.java b/src/com/android/quicksearchbox/ui/DefaultSuggestionView.java
index a4b007f..516e77c 100644
--- a/src/com/android/quicksearchbox/ui/DefaultSuggestionView.java
+++ b/src/com/android/quicksearchbox/ui/DefaultSuggestionView.java
@@ -21,6 +21,7 @@
import com.android.quicksearchbox.SuggestionCursor;
import android.content.Context;
+import android.content.Intent;
import android.content.res.ColorStateList;
import android.graphics.drawable.Drawable;
import android.text.Html;
@@ -104,7 +105,9 @@
}
protected void updateRefinable(SuggestionCursor suggestion) {
- boolean refinable = mIcon2.getDrawable() == null
+ boolean refinable =
+ Intent.ACTION_WEB_SEARCH.equals(suggestion.getSuggestionIntentAction())
+ && mIcon2.getDrawable() == null
&& !TextUtils.isEmpty(suggestion.getSuggestionQuery());
setRefinable(suggestion, refinable);
}