diff options
author | Brandon Maxwell <maxwelb@google.com> | 2015-11-10 00:04:49 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2015-11-10 00:04:49 +0000 |
commit | f4581212026a3a2543d81f21b16666f29d97c03e (patch) | |
tree | 94aadb1e57431c11891381706a3c77e36437cf52 | |
parent | bf9369839b9bce92a39fd9877728a4190018ca49 (diff) | |
parent | d78dbf88dd17ba1661639a0bfa62a0bca5f6df04 (diff) |
Show blank screen when adding new blocked number
am: d78dbf88dd
* commit 'd78dbf88dd17ba1661639a0bfa62a0bca5f6df04':
Show blank screen when adding new blocked number
-rw-r--r-- | src/com/android/dialer/list/BlockedListSearchFragment.java | 48 |
1 files changed, 19 insertions, 29 deletions
diff --git a/src/com/android/dialer/list/BlockedListSearchFragment.java b/src/com/android/dialer/list/BlockedListSearchFragment.java index bddd3d49d..717cf9e46 100644 --- a/src/com/android/dialer/list/BlockedListSearchFragment.java +++ b/src/com/android/dialer/list/BlockedListSearchFragment.java @@ -31,7 +31,6 @@ import android.widget.Toast; import com.android.contacts.common.GeoUtil; import com.android.contacts.common.list.ContactEntryListAdapter; -import com.android.contacts.common.list.ContactListItemView; import com.android.contacts.common.util.ContactDisplayUtils; import com.android.dialer.R; import com.android.dialer.database.FilteredNumberAsyncQueryHandler; @@ -48,22 +47,18 @@ public class BlockedListSearchFragment extends RegularSearchFragment private FilteredNumberAsyncQueryHandler mFilteredNumberAsyncQueryHandler; private EditText mSearchView; - private String mSearchQuery; private final TextWatcher mPhoneSearchQueryTextListener = new TextWatcher() { @Override - public void beforeTextChanged(CharSequence s, int start, int count, int after) { - } + public void beforeTextChanged(CharSequence s, int start, int count, int after) {} @Override public void onTextChanged(CharSequence s, int start, int before, int count) { - mSearchQuery = s.toString(); - setQueryString(mSearchQuery, false); + setQueryString(s.toString(), false); } @Override - public void afterTextChanged(Editable s) { - } + public void afterTextChanged(Editable s) {} }; private final SearchEditTextLayout.Callback mSearchLayoutCallback = @@ -82,14 +77,17 @@ public class BlockedListSearchFragment extends RegularSearchFragment public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - // Show list of all phone numbers when search query is empty. - setShowEmptyListForNullQuery(false); - + setShowEmptyListForNullQuery(true); + /* + * Pass in the empty string here so ContactEntryListFragment#setQueryString interprets it as + * an empty search query, rather than as an uninitalized value. In the latter case, the + * adapter returned by #createListAdapter is used, which populates the view with contacts. + * Passing in the empty string forces ContactEntryListFragment to interpret it as an empty + * query, which results in showing an empty view + */ + setQueryString(getQueryString() == null ? "" : getQueryString(), false); mFilteredNumberAsyncQueryHandler = new FilteredNumberAsyncQueryHandler( getContext().getContentResolver()); - if (savedInstanceState != null) { - mSearchQuery = savedInstanceState.getString(KEY_SEARCH_QUERY); - } } @Override @@ -115,8 +113,8 @@ public class BlockedListSearchFragment extends RegularSearchFragment searchEditTextLayout.findViewById(R.id.search_box_expanded) .setBackgroundColor(getContext().getResources().getColor(android.R.color.white)); - if (!TextUtils.isEmpty(mSearchQuery)) { - mSearchView.setText(mSearchQuery); + if (!TextUtils.isEmpty(getQueryString())) { + mSearchView.setText(getQueryString()); } // TODO: Don't set custom text size; use default search text size. @@ -125,21 +123,17 @@ public class BlockedListSearchFragment extends RegularSearchFragment } @Override - public void onSaveInstanceState(Bundle outState) { - super.onSaveInstanceState(outState); - outState.putString(KEY_SEARCH_QUERY, getAdapter().getQueryString()); - } - - @Override protected ContactEntryListAdapter createListAdapter() { BlockedListSearchAdapter adapter = new BlockedListSearchAdapter(getActivity()); adapter.setDisplayPhotos(true); // Don't show SIP addresses. adapter.setUseCallableUri(false); - adapter.setQueryString(mSearchQuery); + // Keep in sync with the queryString set in #onCreate + adapter.setQueryString(getQueryString() == null ? "" : getQueryString()); return adapter; } + @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { super.onItemClick(parent, view, position, id); @@ -152,7 +146,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment case DialerPhoneNumberListAdapter.SHORTCUT_INVALID: // Handles click on a search result, either contact or nearby places result. number = adapter.getPhoneNumber(adapterPosition); - blockContactNumber(adapter, (ContactListItemView) view, number, blockId); + blockContactNumber(number, blockId); break; case DialerPhoneNumberListAdapter.SHORTCUT_BLOCK_NUMBER: // Handles click on 'Block number' shortcut to add the user query as a number. @@ -217,11 +211,7 @@ public class BlockedListSearchFragment extends RegularSearchFragment getAdapter().notifyDataSetChanged(); } - private void blockContactNumber( - final BlockedListSearchAdapter adapter, - final ContactListItemView view, - final String number, - final Integer blockId) { + private void blockContactNumber(final String number, final Integer blockId) { if (blockId != null) { Toast.makeText(getContext(), ContactDisplayUtils.getTtsSpannedPhoneNumber( getResources(), R.string.alreadyBlocked, number), |