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

Commit 52d6b4c3 authored by Wenyi Wang's avatar Wenyi Wang Committed by Android (Google) Code Review
Browse files

Merge "Revert "Keep overflow menu button from closing on changing...

Merge "Revert "Keep overflow menu button from closing on changing orientation"" into ub-contactsdialer-b-dev
parents da8fddc1 9eb87f4e
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -27,7 +27,4 @@
    <!-- Max suggestions limit showing in quick contact suggestion card [CHAR LIMIT=30]-->
    <integer name="quickcontact_suggestions_limit">10</integer>

    <!-- The delay (in milliseconds) until the overflow options menu is shown automatically -->
    <integer name="open_overflow_menu_delay_millis">250</integer>

</resources>
+1 −22
Original line number Diff line number Diff line
@@ -75,14 +75,11 @@ public class ActionBarAdapter implements OnCloseListener {
    private static final String EXTRA_KEY_QUERY = "navBar.query";
    private static final String EXTRA_KEY_SELECTED_TAB = "navBar.selectedTab";
    private static final String EXTRA_KEY_SELECTED_MODE = "navBar.selectionMode";
    private static final String EXTRA_KEY_SHOULD_OPEN_OVERFLOW = "navBar.shouldOpenOverflow";

    private static final String PERSISTENT_LAST_TAB = "actionBarAdapter.lastTab";

    private boolean mSelectionMode;
    private boolean mSearchMode;
    private boolean mShouldOverflowOpen;
    private boolean mIsOverflowOpen;
    private String mQueryString;

    private EditText mSearchView;
@@ -203,12 +200,11 @@ public class ActionBarAdapter implements OnCloseListener {
            mQueryString = request.getQueryString();
            mCurrentTab = loadLastTabPreference();
            mSelectionMode = false;
            setShouldOpenOverflow(false);
        } else {
            mSearchMode = savedState.getBoolean(EXTRA_KEY_SEARCH_MODE);
            mSelectionMode = savedState.getBoolean(EXTRA_KEY_SELECTED_MODE);
            mQueryString = savedState.getString(EXTRA_KEY_QUERY);
            setShouldOpenOverflow(savedState.getBoolean(EXTRA_KEY_SHOULD_OPEN_OVERFLOW));

            // Just set to the field here.  The listener will be notified by update().
            mCurrentTab = savedState.getInt(EXTRA_KEY_SELECTED_TAB);
        }
@@ -325,22 +321,6 @@ public class ActionBarAdapter implements OnCloseListener {
        }
    }

    public void setShouldOpenOverflow(boolean shouldOpenOverflow) {
        mShouldOverflowOpen = shouldOpenOverflow;
    }

    public boolean shouldOpenOverflow() {
        return mShouldOverflowOpen;
    }

    public void setOverflowOpen(boolean isOverflowOpen) {
        mIsOverflowOpen = isOverflowOpen;
    }

    public boolean isOverflowOpen() {
        return mIsOverflowOpen;
    }

    public String getQueryString() {
        return mSearchMode ? mQueryString : null;
    }
@@ -573,7 +553,6 @@ public class ActionBarAdapter implements OnCloseListener {
    public void onSaveInstanceState(Bundle outState) {
        outState.putBoolean(EXTRA_KEY_SEARCH_MODE, mSearchMode);
        outState.putBoolean(EXTRA_KEY_SELECTED_MODE, mSelectionMode);
        outState.putBoolean(EXTRA_KEY_SHOULD_OPEN_OVERFLOW, mShouldOverflowOpen);
        outState.putString(EXTRA_KEY_QUERY, mQueryString);
        outState.putInt(EXTRA_KEY_SELECTED_TAB, mCurrentTab);
    }
+0 −31
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@ import android.os.Build;
import android.os.Bundle;
import android.os.Parcelable;
import android.os.UserManager;
import android.os.Handler;
import android.preference.PreferenceActivity;
import android.provider.ContactsContract;
import android.provider.ContactsContract.Contacts;
@@ -438,16 +437,6 @@ public class PeopleActivity extends AppCompatContactsActivity implements
        // Current tab may have changed since the last onSaveInstanceState().  Make sure
        // the actual contents match the tab.
        updateFragmentsVisibility();

        if (mActionBarAdapter.shouldOpenOverflow() && !mActionBarAdapter.isOverflowOpen()) {
            new Handler().postDelayed(new Runnable() {
                @Override
                public void run() {
                    openOptionsMenu();
                }
            }, /* delayMillis = */ getResources().getInteger(R.integer.
                    open_overflow_menu_delay_millis));
        }
    }

    @Override
@@ -1480,24 +1469,4 @@ public class PeopleActivity extends AppCompatContactsActivity implements
        }
        return position;
    }

    @Override
    public boolean onMenuOpened(int featureId, Menu menu) {
        // When the overflow menu button opens (both manually and automatically), we need to
        // update both variables; same for closing event.
        mActionBarAdapter.setOverflowOpen(true);
        mActionBarAdapter.setShouldOpenOverflow(true);
        return super.onMenuOpened(featureId, menu);
    }

    @Override
    public void onPanelClosed(int featureId, Menu menu) {
        // Since onPanelClosed will be called when the activity is destroyed on rotation even if
        // user leaves the menu open, we are relying on onSaveInstanceState being called before
        // onDestroy and onPanelClosed are invoked in order to store the "opening" status of the
        // menu.
        mActionBarAdapter.setOverflowOpen(false);
        mActionBarAdapter.setShouldOpenOverflow(false);
        super.onMenuOpened(featureId, menu);
    }
}