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

Commit d388afad authored by Deepanshu Gupta's avatar Deepanshu Gupta Committed by Android Git Automerger
Browse files

am b6de60e0: am df2da3d7: am 7bc363ba: Add special system view cookie to...

am b6de60e0: am df2da3d7: am 7bc363ba: Add special system view cookie to OverflowButton. [DO NOT MERGE]

* commit 'b6de60e0':
  Add special system view cookie to OverflowButton. [DO NOT MERGE]
parents ebd909cc b6de60e0
Loading
Loading
Loading
Loading
+28 −1
Original line number Diff line number Diff line
@@ -22,8 +22,10 @@ import com.android.ide.common.rendering.api.ActionBarCallback.HomeButtonStyle;
import com.android.ide.common.rendering.api.RenderResources;
import com.android.ide.common.rendering.api.ResourceValue;
import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.SystemViewCookie;
import com.android.internal.R;
import com.android.internal.app.ActionBarImpl;
import com.android.internal.util.Predicate;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuBuilderAccessor;
import com.android.internal.view.menu.MenuItemImpl;
@@ -56,6 +58,8 @@ import android.widget.RelativeLayout;

import java.util.ArrayList;

import static com.android.ide.common.rendering.api.SystemViewCookie.ACTION_BAR_OVERFLOW;

/**
 * A layout representing the action bar.
 */
@@ -165,10 +169,33 @@ public class ActionBarLayout extends LinearLayout {

        if (mActionBarView != null) {
            // Set action bar to be split, if needed.
            mActionBarView.setSplitView((ActionBarContainer) findViewById(R.id.split_action_bar));
            ActionBarContainer splitView = (ActionBarContainer) findViewById(R.id.split_action_bar);
            mActionBarView.setSplitView(splitView);
            mActionBarView.setSplitActionBar(mSplit);

            inflateMenus();

            // Find if the Overflow Menu Button (the three dots) exists. If yes,
            // add the view cookie.
            Predicate<View> overflowMenuButtonTest = new Predicate<View>() {
                @Override
                public boolean apply(View view) {
                    return view.getClass().getName()
                            .equals("android.widget.ActionMenuPresenter$OverflowMenuButton");
                }
            };
            View overflowMenu = null;
            if (mSplit) {
                if (splitView != null) {
                    overflowMenu = splitView.findViewByPredicate(overflowMenuButtonTest);
                }
            }
            else {
                overflowMenu = mActionBarView.findViewByPredicate(overflowMenuButtonTest);
            }
            if (overflowMenu != null) {
                mBridgeContext.addViewKey(overflowMenu, new SystemViewCookie(ACTION_BAR_OVERFLOW));
            }
        }
    }