Correctly set query string for new SmartDialSearchFragment instance
If DialtactsActivity is created for the first time by launching a
DIAL intent, the SmartDialSearchFragment is not correctly populated
with the correct number for the "Create new contact" and "Add to
contact" shortcuts since it is not attached yet when the callback is
fired. Fix this by persisting the number and setting it on the
fragment when it is attached.
Bug: 24358325
Change-Id: I24d4603376e739a7c9368a9b115109ba23753585
diff --git a/src/com/android/dialer/DialtactsActivity.java b/src/com/android/dialer/DialtactsActivity.java
index bfb908f..0893b1c 100644
--- a/src/com/android/dialer/DialtactsActivity.java
+++ b/src/com/android/dialer/DialtactsActivity.java
@@ -230,6 +230,7 @@
private View mVoiceSearchButton;
private String mSearchQuery;
+ private String mDialpadQuery;
private DialerDatabaseHelper mDialerDatabaseHelper;
private DragDropController mDragDropController;
@@ -604,6 +605,9 @@
} else if (fragment instanceof SmartDialSearchFragment) {
mSmartDialSearchFragment = (SmartDialSearchFragment) fragment;
mSmartDialSearchFragment.setOnPhoneNumberPickerActionListener(this);
+ if (!TextUtils.isEmpty(mDialpadQuery)) {
+ mSmartDialSearchFragment.setAddToContactNumber(mDialpadQuery);
+ }
} else if (fragment instanceof SearchFragment) {
mRegularSearchFragment = (RegularSearchFragment) fragment;
mRegularSearchFragment.setOnPhoneNumberPickerActionListener(this);
@@ -1142,6 +1146,7 @@
@Override
public void onDialpadQueryChanged(String query) {
+ mDialpadQuery = query;
if (mSmartDialSearchFragment != null) {
mSmartDialSearchFragment.setAddToContactNumber(query);
}