summaryrefslogtreecommitdiffstats
path: root/core/java
diff options
context:
space:
mode:
authorAmith Yamasani <yamasani@google.com>2010-02-24 19:05:35 -0800
committerAmith Yamasani <yamasani@google.com>2010-02-25 10:25:45 -0800
commitd368572f8e0c9bd851aacb71ea57adecfbd5d1a4 (patch)
treec037ea91d1d6c75be476cef2212a80761f437bc0 /core/java
parentba289966c644bf54a747ba9b003f86ea7f12bfed (diff)
downloadframeworks_base-d368572f8e0c9bd851aacb71ea57adecfbd5d1a4.zip
frameworks_base-d368572f8e0c9bd851aacb71ea57adecfbd5d1a4.tar.gz
frameworks_base-d368572f8e0c9bd851aacb71ea57adecfbd5d1a4.tar.bz2
Fix for voice search crash in maps and youtube. Bug 2453182
No need to nullify the context variable. Also fix 2463128 : No voice icon when text is present in text field
Diffstat (limited to 'core/java')
-rw-r--r--core/java/android/app/SearchDialog.java15
1 files changed, 8 insertions, 7 deletions
diff --git a/core/java/android/app/SearchDialog.java b/core/java/android/app/SearchDialog.java
index 6a02a58..cb6aab6 100644
--- a/core/java/android/app/SearchDialog.java
+++ b/core/java/android/app/SearchDialog.java
@@ -313,7 +313,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
mLaunchComponent = null;
mAppSearchData = null;
mSearchable = null;
- mActivityContext = null;
mUserQuery = null;
}
@@ -411,7 +410,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
updateSearchAppIcon();
updateSearchBadge();
updateQueryHint();
- updateVoiceButton();
+ updateVoiceButton(TextUtils.isEmpty(mUserQuery));
// In order to properly configure the input method (if one is being used), we
// need to let it know if we'll be providing suggestions. Although it would be
@@ -560,10 +559,13 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
/**
* Update the visibility of the voice button. There are actually two voice search modes,
* either of which will activate the button.
+ * @param empty whether the search query text field is empty. If it is, then the other
+ * criteria apply to make the voice button visible. Otherwise the voice button will not
+ * be visible - i.e., if the user has typed a query, remove the voice button.
*/
- private void updateVoiceButton() {
+ private void updateVoiceButton(boolean empty) {
int visibility = View.GONE;
- if (mSearchable.getVoiceSearchEnabled()) {
+ if (mSearchable.getVoiceSearchEnabled() && empty) {
Intent testIntent = null;
if (mSearchable.getVoiceSearchLaunchWebSearch()) {
testIntent = mVoiceWebSearchIntent;
@@ -666,6 +668,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
// The user changed the query, remember it.
mUserQuery = s == null ? "" : s.toString();
}
+ updateVoiceButton(TextUtils.isEmpty(s));
}
public void afterTextChanged(Editable s) {
@@ -746,9 +749,6 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
return;
}
SearchableInfo searchable = mSearchable;
- // First stop the existing search before starting voice search, or else we'll end
- // up showing the search dialog again once we return to the app.
- cancel();
try {
if (searchable.getVoiceSearchLaunchWebSearch()) {
getContext().startActivity(mVoiceWebSearchIntent);
@@ -762,6 +762,7 @@ public class SearchDialog extends Dialog implements OnItemClickListener, OnItemS
// voice search before showing the button. But just in case...
Log.w(LOG_TAG, "Could not find voice search activity");
}
+ dismiss();
}
};