From 3c9e7cd12f28c7e79a4b2af442c32f2b519122f1 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 16 Apr 2014 11:37:21 -0700 Subject: Don't set search query immediately if searchview is null The SearchView is assigned only in onCreateOptionsMenu, which can happen after the dialpad query changes if the dialer is launched via a DIAL intent. Make sure we assign the query to the SearchView only after it is created. Bug: 14111006 Change-Id: Ife504362684d8b5e2d3064bf971fabbebb878149 --- src/com/android/dialer/DialtactsActivity.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java index 8b9b71ada..54041b087 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -173,6 +173,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O */ private boolean mFirstLaunch; + /** + * Search query to be applied to the SearchView in the ActionBar once + * onCreateOptionsMenu has been called. + */ + private String mPendingSearchViewQuery; + // This view points to the Framelayout that houses both the search view and remove view // containers. private View mSearchAndRemoveViewContainer; @@ -648,6 +654,11 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O mSearchView.setSearchableInfo(searchManager.getSearchableInfo(getComponentName())); mSearchView.setOnQueryTextListener(mPhoneSearchQueryTextListener); mSearchView.setIconifiedByDefault(false); + + if (mPendingSearchViewQuery != null) { + mSearchView.setQuery(mPendingSearchViewQuery, false); + mPendingSearchViewQuery = null; + } return super.onCreateOptionsMenu(menu); } @@ -826,6 +837,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O } final String normalizedQuery = SmartDialNameMatcher.normalizeNumber(query, SmartDialNameMatcher.LATIN_SMART_DIAL_MAP); + if (mSearchView == null) { + if (!TextUtils.isEmpty(normalizedQuery)) { + mPendingSearchViewQuery = normalizedQuery; + } + return; + } if (!TextUtils.equals(mSearchView.getQuery(), normalizedQuery)) { if (DEBUG) { Log.d(TAG, "onDialpadQueryChanged - new query: " + query); -- cgit v1.2.3