summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTyler Gunn <tgunn@google.com>2014-11-20 13:22:54 -0800
committerTyler Gunn <tgunn@google.com>2014-11-20 21:23:38 +0000
commitc1cfae553cc08c832155eb5b951690a4e349b5bc (patch)
treecc2e954316eaaed048670eaf6086af9593c9fef2 /src
parent4dbd3a2366c14fca1a514a9e7cfe383e0c28f3b3 (diff)
Correcting population of search box with voice search results.
The issue is the onActivityResult callback which receives the result of the voice search is called BEFORE the dialtacts activity is resumed, and hence the search results fragment is not properly shown (since resume has not yet completed). Changed so that the search results are stored until onResume, where they are applied to the search box. Bug: 18410823 Change-Id: I02985f722643846067678a67f2c1fda76434fbc4
Diffstat (limited to 'src')
-rw-r--r--src/com/android/dialer/DialtactsActivity.java18
1 files changed, 17 insertions, 1 deletions
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index 3c9b870dd..5e6f03597 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -229,6 +229,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
private int mActionBarHeight;
+ /**
+ * The text returned from a voice search query. Set in {@link #onActivityResult} and used in
+ * {@link #onResume()} to populate the search box.
+ */
+ private String mVoiceSearchQuery;
+
private class OptionsPopupMenu extends PopupMenu {
public OptionsPopupMenu(Context context, View anchor) {
super(context, anchor, Gravity.END);
@@ -477,6 +483,16 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
showDialpadFragment(false);
mShowDialpadOnResume = false;
}
+
+ // If there was a voice query result returned in the {@link #onActivityResult} callback, it
+ // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be
+ // shown until onResume has completed. Active the search UI and set the search term now.
+ if (!TextUtils.isEmpty(mVoiceSearchQuery)) {
+ mActionBarController.onSearchBoxTapped();
+ mSearchView.setText(mVoiceSearchQuery);
+ mVoiceSearchQuery = null;
+ }
+
mFirstLaunch = false;
if (mIsRestarting) {
@@ -618,7 +634,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
RecognizerIntent.EXTRA_RESULTS);
if (matches.size() > 0) {
final String match = matches.get(0);
- mSearchView.setText(match);
+ mVoiceSearchQuery = match;
} else {
Log.e(TAG, "Voice search - nothing heard");
}