From 52be8a5de7feddf0e0af3cf977cc3a0f37e6ac0a 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 c59db95dc..6dfd6c7d9 100644 --- a/src/com/android/dialer/DialtactsActivity.java +++ b/src/com/android/dialer/DialtactsActivity.java @@ -171,6 +171,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; @@ -627,6 +633,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); } @@ -830,6 +841,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 From 266b8e67c5b7817710b3e72f2ed5bdbca3a6fc2e Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Thu, 17 Apr 2014 11:46:59 -0700 Subject: Reattach listener when fragment is destroyed and recreated Bug: 14136602 Change-Id: I49796b7a545c6c650680cb0ee6152a93381b2736 --- src/com/android/dialer/list/AllContactsFragment.java | 15 ++++++++++----- src/com/android/dialer/list/ListsFragment.java | 16 ---------------- 2 files changed, 10 insertions(+), 21 deletions(-) diff --git a/src/com/android/dialer/list/AllContactsFragment.java b/src/com/android/dialer/list/AllContactsFragment.java index 40d5c14b7..47476e686 100644 --- a/src/com/android/dialer/list/AllContactsFragment.java +++ b/src/com/android/dialer/list/AllContactsFragment.java @@ -24,6 +24,7 @@ import android.view.View; import android.view.ViewGroup; import com.android.contacts.common.list.ContactListItemView; +import com.android.contacts.common.list.OnPhoneNumberPickerActionListener; import com.android.contacts.common.list.PhoneNumberPickerFragment; import com.android.dialer.R; @@ -32,11 +33,6 @@ import com.android.dialer.R; */ public class AllContactsFragment extends PhoneNumberPickerFragment{ - @Override - public void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - } - @Override public void onAttach(Activity activity) { super.onAttach(activity); @@ -46,6 +42,15 @@ public class AllContactsFragment extends PhoneNumberPickerFragment{ setDarkTheme(false); setPhotoPosition(ContactListItemView.getDefaultPhotoPosition(true /* opposite */)); setUseCallableUri(true); + + try { + OnPhoneNumberPickerActionListener mNumberPickerListener = + (OnPhoneNumberPickerActionListener) activity; + setOnPhoneNumberPickerActionListener(mNumberPickerListener); + } catch (ClassCastException e) { + throw new ClassCastException(activity.toString() + + " must implement OnPhoneNumberPickerActionListener"); + } } @Override diff --git a/src/com/android/dialer/list/ListsFragment.java b/src/com/android/dialer/list/ListsFragment.java index 768d3601e..f1d421c46 100644 --- a/src/com/android/dialer/list/ListsFragment.java +++ b/src/com/android/dialer/list/ListsFragment.java @@ -28,8 +28,6 @@ public class ListsFragment extends Fragment { private PhoneFavoriteFragment mSpeedDialFragment; private AllContactsFragment mAllContactsFragment; - private OnPhoneNumberPickerActionListener mNumberPickerListener; - private static final int TAB_INDEX_SPEED_DIAL = 0; private static final int TAB_INDEX_ALL_CONTACTS = 1; @@ -50,8 +48,6 @@ public class ListsFragment extends Fragment { return mSpeedDialFragment; case TAB_INDEX_ALL_CONTACTS: mAllContactsFragment = new AllContactsFragment(); - mAllContactsFragment.setOnPhoneNumberPickerActionListener( - mNumberPickerListener); return mAllContactsFragment; } throw new IllegalStateException("No fragment at position " + position); @@ -85,16 +81,4 @@ public class ListsFragment extends Fragment { tabs.setViewPager(mViewPager); return parentView; } - - @Override - public void onAttach(Activity activity) { - super.onAttach(activity); - - try { - mNumberPickerListener = (OnPhoneNumberPickerActionListener) activity; - } catch (ClassCastException e) { - throw new ClassCastException(activity.toString() - + " must implement OnPhoneNumberPickerActionListener"); - } - } } -- cgit v1.2.3 From 1a7e10162a668d2a433364f7fabd2168b97308f3 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Tue, 22 Apr 2014 11:50:33 -0700 Subject: Correctly bind contact tile listeners in PhoneFavoritesTileAdapter Bug: 14254076 Change-Id: I969fda15e0e8c56374fe51a600422cc2bc96ffe8 --- src/com/android/dialer/list/PhoneFavoritesTileAdapter.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java index 95f53c59e..c4ff0b07b 100644 --- a/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java +++ b/src/com/android/dialer/list/PhoneFavoritesTileAdapter.java @@ -391,6 +391,7 @@ public class PhoneFavoritesTileAdapter extends BaseAdapter implements R.layout.phone_favorite_tile_view, null); } tileView.setPhotoManager(mPhotoManager); + tileView.setListener(mListener); tileView.loadFromContact(getItem(position)); return tileView; } -- cgit v1.2.3 From 38f65cf60a5ac8c74587657bd3537bb8db2aabf5 Mon Sep 17 00:00:00 2001 From: Yorke Lee Date: Wed, 14 May 2014 12:03:29 -0700 Subject: Fix NPE in dispatchViewReleased Bug: 14911975 Change-Id: I9899f6dbe9808dd88dc40261c7d27bf06afebe32 --- src/com/android/dialer/widget/ViewDragHelper.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/com/android/dialer/widget/ViewDragHelper.java b/src/com/android/dialer/widget/ViewDragHelper.java index 83e870775..6881e4b8f 100644 --- a/src/com/android/dialer/widget/ViewDragHelper.java +++ b/src/com/android/dialer/widget/ViewDragHelper.java @@ -1464,6 +1464,7 @@ public class ViewDragHelper { * @param target The child view that is dispatching the nested scroll. */ public void stopNestedScroll(View target) { + mCapturedView = target; dispatchViewReleased(0, 0); } -- cgit v1.2.3