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

Commit ccdd4ee4 authored by Adam Powell's avatar Adam Powell
Browse files

Fix bug 5087980 - MenuItem#expandActionView should work from within

onCreateOptionsMenu

Initialize menu presenters early enough to respond to expanding an
action view within onCreateOptionsMenu.

Have SearchView show the IME as an async post to handle attempts to
show it while the UI is still in initial setup.

Change-Id: I77f3a94ed4397737edb5a7a15bf54993b6723f5e
parent b6f7a27c
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
@@ -118,6 +118,21 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
    private SearchableInfo mSearchable;
    private Bundle mAppSearchData;

    /*
     * SearchView can be set expanded before the IME is ready to be shown during
     * initial UI setup. The show operation is asynchronous to account for this.
     */
    private Runnable mShowImeRunnable = new Runnable() {
        public void run() {
            InputMethodManager imm = (InputMethodManager)
                    getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

            if (imm != null) {
                imm.showSoftInputUnchecked(0, null);
            }
        }
    };

    // For voice searching
    private final Intent mVoiceWebSearchIntent;
    private final Intent mVoiceAppSearchIntent;
@@ -650,16 +665,15 @@ public class SearchView extends LinearLayout implements CollapsibleActionView {
        mSubmitArea.getBackground().setState(focused ? FOCUSED_STATE_SET : EMPTY_STATE_SET);
    }

    private void setImeVisibility(boolean visible) {
    private void setImeVisibility(final boolean visible) {
        if (visible) {
            post(mShowImeRunnable);
        } else {
            removeCallbacks(mShowImeRunnable);
            InputMethodManager imm = (InputMethodManager)
                    getContext().getSystemService(Context.INPUT_METHOD_SERVICE);

        // We made sure the IME was displayed, so also make sure it is closed
        // when we go away.
            if (imm != null) {
            if (visible) {
                imm.showSoftInputUnchecked(0, null);
            } else {
                imm.hideSoftInputFromWindow(getWindowToken(), 0);
            }
        }
+0 −1
Original line number Diff line number Diff line
@@ -27,7 +27,6 @@ import android.content.res.Resources;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.Log;
import android.util.SparseArray;
import android.view.ActionProvider;
import android.view.ContextMenu.ContextMenuInfo;
+7 −7
Original line number Diff line number Diff line
@@ -343,6 +343,13 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                    }
                }

                if (mActionBar != null) {
                    if (mActionMenuPresenterCallback == null) {
                        mActionMenuPresenterCallback = new ActionMenuPresenterCallback();
                    }
                    mActionBar.setMenu(st.menu, mActionMenuPresenterCallback);
                }

                // Call callback, and return if it doesn't want to display menu.

                // Creating the panel menu will involve a lot of manipulation;
@@ -356,13 +363,6 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
                }
                
                st.refreshMenuContent = false;

                if (mActionBar != null) {
                    if (mActionMenuPresenterCallback == null) {
                        mActionMenuPresenterCallback = new ActionMenuPresenterCallback();
                    }
                    mActionBar.setMenu(st.menu, mActionMenuPresenterCallback);
                }
            }

            // Callback and return if the callback does not want to show the menu