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

Commit 966cc74c authored by Makoto Onuki's avatar Makoto Onuki Committed by Android (Google) Code Review
Browse files

Merge "Fix the double query issue on phone"

parents 699b1f20 1db00f68
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -220,14 +220,16 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
        return mCurrentTab;
    }

    /**
     * @return Whether in search mode, i.e. if the search view is visible/expanded.
     *
     * Note even if the action bar is in search mode, if the query is empty, the search fragment
     * will not be in search mode.
     */
    public boolean isSearchMode() {
        return mSearchMode;
    }

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

    public void setSearchMode(boolean flag) {
        if (mSearchMode != flag) {
            mSearchMode = flag;
@@ -244,7 +246,7 @@ public class ActionBarAdapter implements OnQueryTextListener, OnCloseListener {
    }

    public String getQueryString() {
        return mQueryString;
        return mSearchMode ? mQueryString : null;
    }

    public void setQueryString(String query) {
+0 −8
Original line number Diff line number Diff line
@@ -327,7 +327,6 @@ public class ContactSelectionActivity extends ContactsActivity

            case ContactsRequest.ACTION_PICK_CONTACT: {
                ContactPickerFragment fragment = new ContactPickerFragment();
                fragment.setSearchMode(mRequest.isSearchMode());
                fragment.setIncludeProfile(mRequest.shouldIncludeProfile());
                mListFragment = fragment;
                break;
@@ -341,8 +340,6 @@ public class ContactSelectionActivity extends ContactsActivity

            case ContactsRequest.ACTION_CREATE_SHORTCUT_CONTACT: {
                ContactPickerFragment fragment = new ContactPickerFragment();
                fragment.setSearchMode(mRequest.isSearchMode());
                fragment.setQueryString(mRequest.getQueryString(), false);
                fragment.setShortcutRequested(true);
                mListFragment = fragment;
                break;
@@ -362,7 +359,6 @@ public class ContactSelectionActivity extends ContactsActivity
            case ContactsRequest.ACTION_CREATE_SHORTCUT_CALL: {
                PhoneNumberPickerFragment fragment = new PhoneNumberPickerFragment();
                fragment.setShortcutAction(Intent.ACTION_CALL);
                fragment.setSearchMode(mRequest.isSearchMode());

                mListFragment = fragment;
                break;
@@ -387,9 +383,6 @@ public class ContactSelectionActivity extends ContactsActivity
        }

        mListFragment.setLegacyCompatibilityMode(mRequest.isLegacyCompatibilityMode());
        mListFragment.setContactsRequest(mRequest);
        mListFragment.setSearchMode(mRequest.isSearchMode());
        mListFragment.setQueryString(mRequest.getQueryString(), false);
        mListFragment.setDirectoryResultLimit(DEFAULT_DIRECTORY_RESULT_LIMIT);

        getFragmentManager().beginTransaction()
@@ -537,7 +530,6 @@ public class ContactSelectionActivity extends ContactsActivity
    @Override
    public boolean onQueryTextChange(String newText) {
        mListFragment.setQueryString(newText, true);
        mListFragment.setSearchMode(!TextUtils.isEmpty(newText));
        return false;
    }

+0 −1
Original line number Diff line number Diff line
@@ -363,7 +363,6 @@ public class DialtactsActivity extends Activity {
                public boolean onQueryTextChange(String newText) {
                    // Show search result with non-empty text. Show a bare list otherwise.
                    mSearchFragment.setQueryString(newText, true);
                    mSearchFragment.setSearchMode(!TextUtils.isEmpty(newText));
                    return true;
                }
    };
+5 −16
Original line number Diff line number Diff line
@@ -567,12 +567,12 @@ public class PeopleActivity extends ContactsActivity
                invalidateOptionsMenu();
                break;
            case STOP_SEARCH_MODE:
                clearSearch();
                setQueryTextToFragment("");
                updateFragmentsVisibility();
                invalidateOptionsMenu();
                break;
            case CHANGE_SEARCH_QUERY:
                loadSearch(mActionBarAdapter.getQueryString());
                setQueryTextToFragment(mActionBarAdapter.getQueryString());
                break;
            default:
                throw new IllegalStateException("Unkonwn ActionBarAdapter action: " + action);
@@ -843,26 +843,19 @@ public class PeopleActivity extends ContactsActivity
        }
    }

    private void clearSearch() {
        loadSearch("");
    }

    private void loadSearch(String query) {
        configureFragments(false /* from request */);
    private void setQueryTextToFragment(String query) {
        mAllFragment.setQueryString(query, true);
        mAllFragment.setVisibleScrollbarEnabled(!mAllFragment.isSearchMode());
    }

    private void configureContactListFragmentForRequest() {
        mAllFragment.setContactsRequest(mRequest);

        Uri contactUri = mRequest.getContactUri();
        if (contactUri != null) {
            mAllFragment.setSelectedContactUri(contactUri);
        }

        mAllFragment.setFilter(mContactListFilterController.getFilter());
        mAllFragment.setSearchMode(mActionBarAdapter.isSearchMode());
        mAllFragment.setQueryString(mActionBarAdapter.getQueryString(), false);
        setQueryTextToFragment(mActionBarAdapter.getQueryString());

        if (mRequest.isDirectorySearchEnabled()) {
            mAllFragment.setDirectorySearchMode(DirectoryListLoader.SEARCH_MODE_DEFAULT);
@@ -875,11 +868,7 @@ public class PeopleActivity extends ContactsActivity
        // Filter may be changed when this Activity is in background.
        mAllFragment.setFilter(mContactListFilterController.getFilter());

        final boolean showSearchResult = mActionBarAdapter.shouldShowSearchResult();
        mAllFragment.setSearchMode(showSearchResult);

        final boolean useTwoPane = PhoneCapabilityTester.isUsingTwoPanes(this);
        mAllFragment.setVisibleScrollbarEnabled(!showSearchResult);
        mAllFragment.setVerticalScrollbarPosition(
                useTwoPane
                        ? View.SCROLLBAR_POSITION_LEFT
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ public abstract class ContactBrowseListFragment extends
    }

    @Override
    public void setSearchMode(boolean flag) {
    protected void setSearchMode(boolean flag) {
        if (isSearchMode() != flag) {
            if (!flag) {
                restoreSelectedUri(true);
Loading