summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrandon Maxwell <maxwelb@google.com>2015-11-09 13:24:57 -0800
committerBrandon Maxwell <maxwelb@google.com>2015-11-09 16:01:24 -0800
commitd78dbf88dd17ba1661639a0bfa62a0bca5f6df04 (patch)
tree0f62e3941b5367e2c495eea6ddc4166035b727be
parent1febe8b1542d6038787754c0749527a66b58b01d (diff)
Show blank screen when adding new blocked number
-Changed BlockedListSearchFragment to save queryString in the super class, rather than duplicating logic ~ Changed BlockedListSearchFragment to show a blank screen when the user initially clicks on the 'Add number' button Bug:25568357 Change-Id: I649294ebb4ee6e96be67ee27039ac6543644f763
-rw-r--r--src/com/android/dialer/list/BlockedListSearchFragment.java48
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),