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

Commit b3944dce authored by Brian Attwell's avatar Brian Attwell
Browse files

Correctly set search string when entering search

Changes
1) When entering search mode, explicitly clear the
 search query
2) Make sure that the cursor starts after the text
 that is programmatically inserted via setQueryText().

Manual tests:
-Type into search bar. Exit app. Resume app.
 Open search bar again. Search bar should be empty.
-Type into search bar. Rotate app. Search bar shouldn't
 be empty.
-Type into search bar. Close search. Open search.
 The search view should be empty.
-execute "$ adb shell input keyboard text abcd". In KK
 the search view will show "dabc". Now this shows "abcd".
-Place cursor in middle of a search term. Enter new text
 using the soft keyboard or use adb shell to enter new text.
 In both cases the new text appears after the cursor
 position.

Bug: 18410365
Change-Id: I7ce260913e3c8e7448678bd2178859fb9c9270ab
parent b6fe3a1a
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ public class ActionBarAdapter implements OnCloseListener {
                new OnClickListener() {
            @Override
            public void onClick(View v) {
                mSearchView.setText(null);
                setQueryString(null);
            }
        });
        mSearchContainer.findViewById(R.id.search_back_button).setOnClickListener(
@@ -254,9 +254,8 @@ public class ActionBarAdapter implements OnCloseListener {
            }
            if (mSearchMode) {
                setFocusOnSearchView();
            } else {
                mSearchView.setText(null);
            }
            setQueryString(null);
        } else if (flag) {
            // Everything is already set up. Still make sure the keyboard is up
            if (mSearchView != null) setFocusOnSearchView();
@@ -271,6 +270,10 @@ public class ActionBarAdapter implements OnCloseListener {
        mQueryString = query;
        if (mSearchView != null) {
            mSearchView.setText(query);
            // When programmatically entering text into the search view, the most reasonable
            // place for the cursor is after all the text.
            mSearchView.setSelection(mSearchView.getText() == null ?
                    0 : mSearchView.getText().length());
        }
    }

+1 −1
Original line number Diff line number Diff line
@@ -1188,8 +1188,8 @@ public class PeopleActivity extends ContactsActivity implements
                        && !Character.isWhitespace(unicodeChar)) {
                    String query = new String(new int[]{ unicodeChar }, 0, 1);
                    if (!mActionBarAdapter.isSearchMode()) {
                        mActionBarAdapter.setQueryString(query);
                        mActionBarAdapter.setSearchMode(true);
                        mActionBarAdapter.setQueryString(query);
                        return true;
                    }
                }