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

Commit 511d388d authored by Tyler Gunn's avatar Tyler Gunn Committed by Divya Sharma
Browse files

Correcting population of search box with voice search results.

The issue is the onActivityResult callback which receives the result of
the voice search is called BEFORE the dialtacts activity is resumed, and
hence the search results fragment is not properly shown (since resume has
not yet completed).

Changed so that the search results are stored until onResume, where they
are applied to the search box.

Bug: 18410823
Change-Id: I2dbaba7eca57e6a9087856074d5be98fa9722509
parent b9d2c264
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -237,6 +237,12 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O

    private int mActionBarHeight;

    /**
     * The text returned from a voice search query.  Set in {@link #onActivityResult} and used in
     * {@link #onResume()} to populate the search box.
     */
    private String mVoiceSearchQuery;

    private class OptionsPopupMenu extends PopupMenu {
        public OptionsPopupMenu(Context context, View anchor) {
            super(context, anchor, Gravity.END);
@@ -488,6 +494,16 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
            showDialpadFragment(false);
            mShowDialpadOnResume = false;
        }

        // If there was a voice query result returned in the {@link #onActivityResult} callback, it
        // will have been stashed in mVoiceSearchQuery since the search results fragment cannot be
        // shown until onResume has completed.  Active the search UI and set the search term now.
        if (!TextUtils.isEmpty(mVoiceSearchQuery)) {
            mActionBarController.onSearchBoxTapped();
            mSearchView.setText(mVoiceSearchQuery);
            mVoiceSearchQuery = null;
        }

        mFirstLaunch = false;
        prepareVoiceSearchButton();
        mDialerDatabaseHelper.startSmartDialUpdateThread();
@@ -637,7 +653,7 @@ public class DialtactsActivity extends TransactionSafeActivity implements View.O
                        RecognizerIntent.EXTRA_RESULTS);
                if (matches.size() > 0) {
                    final String match = matches.get(0);
                    mSearchView.setText(match);
                    mVoiceSearchQuery = match;
                } else {
                    Log.e(TAG, "Voice search - nothing heard");
                }