Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e668051b authored by Makoto Onuki's avatar Makoto Onuki
Browse files

New search behavior for empty query

It's a very lightweight change to implment the new spec, which says:
- Don't start searching until the user types the first letter
- But if the search view is shown, make the ALL tab current, and disable swipe

With this CL,
- No changes to ActionBarAdapter.isSearchMode().  It still returns true
  if the search view is visible, even if it's empty.
- However, in order to make the all fragment show the normal list for
  empty query, only turn the fragment into the search mode if the query is
  non-empty.

Also reverts I25908651 as we no longer do a search with empty query.

Bug 5104010

Change-Id: I50038994c6d65aab71ceefdf9218f3c7ad2bc6a4
parent a424cd98
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -211,6 +211,10 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
        return mSearchMode;
    }

    public boolean shouldShowSearchResult() {
        return mSearchMode && !TextUtils.isEmpty(mQueryString);
    }

    public void setSearchMode(boolean flag) {
        if (mSearchMode != flag) {
            mSearchMode = flag;
+3 −3
Original line number Diff line number Diff line
@@ -867,11 +867,11 @@ public class PeopleActivity extends ContactsActivity
    }

    private void configureContactListFragment() {
        final boolean searchMode = mActionBarAdapter.isSearchMode();
        mAllFragment.setSearchMode(searchMode);
        final boolean showSearchResult = mActionBarAdapter.shouldShowSearchResult();
        mAllFragment.setSearchMode(showSearchResult);

        final boolean useTwoPane = PhoneCapabilityTester.isUsingTwoPanes(this);
        mAllFragment.setVisibleScrollbarEnabled(!searchMode);
        mAllFragment.setVisibleScrollbarEnabled(!showSearchResult);
        mAllFragment.setVerticalScrollbarPosition(
                useTwoPane
                        ? View.SCROLLBAR_POSITION_LEFT
+0 −4
Original line number Diff line number Diff line
@@ -455,10 +455,6 @@ public abstract class ContactEntryListAdapter extends IndexerListAdapter {
        if (!mEmptyListEnabled) {
            return false;
        } else if (isSearchMode()) {
            // TODO Do we really need this?  DefaultContactListAdapter overrides it and always
            // return false, as it returns all contacts if in the search mode and the query is
            // empty.  If there's no places relying on this behavior, we can just return false
            // here.
            return TextUtils.isEmpty(getQueryString());
        } else if (mLoading) {
            // We don't want the empty state to show when loading.
+5 −21
Original line number Diff line number Diff line
@@ -66,15 +66,11 @@ public class DefaultContactListAdapter extends ContactListAdapter {
            }
            query = query.trim();
            if (TextUtils.isEmpty(query)) {
                // Special case: if the query string is empty, show all contacts, regardless of the
                // current filter.
                // (We can't use the FILTER_URI for this, as the contacts provider would return
                // an empty cursor if the query is empty.)
                final ContactListFilter allFilter = ContactListFilter.createFilterWithType(
                        ContactListFilter.FILTER_TYPE_ALL_ACCOUNTS);
                configureUri(loader, directoryId, allFilter);
                configureProjection(loader, directoryId, allFilter);
                configureSelection(loader, directoryId, allFilter);
                // Regardless of the directory, we don't want anything returned,
                // so let's just send a "nothing" query to the local directory.
                loader.setUri(Contacts.CONTENT_URI);
                loader.setProjection(PROJECTION_CONTACT);
                loader.setSelection("0");
            } else {
                Builder builder = Contacts.CONTENT_FILTER_URI.buildUpon();
                builder.appendPath(query);      // Builder will encode the query
@@ -256,16 +252,4 @@ public class DefaultContactListAdapter extends ContactListAdapter {
        return prefs.getBoolean(ContactsPreferences.PREF_DISPLAY_ONLY_PHONES,
                ContactsPreferences.PREF_DISPLAY_ONLY_PHONES_DEFAULT);
    }

    @Override
    public boolean isEmpty() {
        // ContactEntryListAdapter.isEmpty() returns false when in the search mode && the query is
        // empty.  Here, we want to return all contacts in this case, override it and make it
        // always return false.  See the TODO there -- we may not need this method entirely.
        if (isSearchMode()) {
            return false;
        } else {
            return super.isEmpty();
        }
    }
}