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

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

Merge branch 'klp-dev' of...

parents d49f9b25 ab6c61b2
Loading
Loading
Loading
Loading
+0 −28
Original line number Diff line number Diff line
@@ -23,11 +23,8 @@ 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.ActionMenuView;
import com.android.internal.view.menu.MenuBuilder;
import com.android.internal.view.menu.MenuBuilderAccessor;
import com.android.internal.view.menu.MenuItemImpl;
@@ -60,8 +57,6 @@ 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.
 */
@@ -175,29 +170,6 @@ public class ActionBarLayout extends LinearLayout {
            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) {
                    ViewGroup.LayoutParams lp = view.getLayoutParams();
                    return lp instanceof ActionMenuView.LayoutParams &&
                            ((ActionMenuView.LayoutParams) lp).isOverflowButton;
                }
            };
            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));
            }
        }
    }

+40 −4
Original line number Diff line number Diff line
@@ -37,8 +37,10 @@ import com.android.ide.common.rendering.api.Result.Status;
import com.android.ide.common.rendering.api.SessionParams;
import com.android.ide.common.rendering.api.SessionParams.RenderingMode;
import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.ViewType;
import com.android.internal.util.XmlUtils;
import com.android.internal.view.menu.ActionMenuItemView;
import com.android.internal.view.menu.ActionMenuView;
import com.android.internal.view.menu.BridgeMenuItemImpl;
import com.android.internal.view.menu.IconMenuItemView;
import com.android.internal.view.menu.ListMenuItemView;
@@ -83,6 +85,7 @@ import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.ViewParent;
import android.view.WindowManagerGlobal_Delegate;
import android.widget.AbsListView;
import android.widget.AbsSpinner;
@@ -1473,16 +1476,49 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {

        ViewInfo result;
        if (isContentFrame) {
            // The view is part of the layout added by the user. Hence,
            // the ViewCookie may be obtained only through the Context.
            result = new ViewInfo(view.getClass().getName(),
                    getViewKey(view),
                    getContext().getViewKey(view),
                    view.getLeft(), view.getTop() + offset, view.getRight(),
                    view.getBottom() + offset, view, view.getLayoutParams());

        } else {
            result = new SystemViewInfo(view.getClass().getName(),
            // We are part of the system decor.
            SystemViewInfo r = new SystemViewInfo(view.getClass().getName(),
                    getViewKey(view),
                    view.getLeft(), view.getTop(), view.getRight(),
                    view.getBottom(), view, view.getLayoutParams());
            result = r;
            // We currently mark three kinds of views:
            // 1. Menus in the Action Bar
            // 2. Menus in the Overflow popup.
            // 3. The overflow popup button.
            if (view instanceof ListMenuItemView) {
                // Mark 2.
                // All menus in the popup are of type ListMenuItemView.
                r.setViewType(ViewType.ACTION_BAR_OVERFLOW_MENU);
            } else {
                // Mark 3.
                ViewGroup.LayoutParams lp = view.getLayoutParams();
                if (lp instanceof ActionMenuView.LayoutParams &&
                        ((ActionMenuView.LayoutParams) lp).isOverflowButton) {
                    r.setViewType(ViewType.ACTION_BAR_OVERFLOW);
                } else {
                    // Mark 1.
                    // A view is a menu in the Action Bar is it is not the overflow button and of
                    // its parent is of type ActionMenuView. We can also check if the view is
                    // instanceof ActionMenuItemView but that will fail for menus using
                    // actionProviderClass.
                    ViewParent parent = view.getParent();
                    while (parent != mViewRoot && parent instanceof ViewGroup) {
                        if (parent instanceof ActionMenuView) {
                            r.setViewType(ViewType.ACTION_BAR_MENU);
                            break;
                        }
                        parent = parent.getParent();
                    }
                }
            }
        }

        if (setExtendedInfo) {
@@ -1501,7 +1537,7 @@ public class RenderSessionImpl extends RenderAction<SessionParams> {
        return result;
    }

    /**
    /* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
+15 −2
Original line number Diff line number Diff line
@@ -17,9 +17,15 @@
package com.android.layoutlib.bridge.impl;

import com.android.ide.common.rendering.api.ViewInfo;
import com.android.ide.common.rendering.api.ViewType;

/**
 * ViewInfo for views added by the platform.
 */
public class SystemViewInfo extends ViewInfo {

    private ViewType mViewType;

    public SystemViewInfo(String name, Object cookie, int left, int top,
            int right, int bottom) {
        super(name, cookie, left, top, right, bottom);
@@ -32,7 +38,14 @@ public class SystemViewInfo extends ViewInfo {
    }

    @Override
    public boolean isSystemView() {
        return true;
    public ViewType getViewType() {
        if (mViewType != null) {
            return mViewType;
        }
        return ViewType.SYSTEM_UNKNOWN;
    }

    public void setViewType(ViewType type) {
        mViewType = type;
    }
}