Search in sources :

Example 1 with ListMenuItemView

use of com.android.internal.view.menu.ListMenuItemView in project platform_frameworks_base by android.

the class RenderSessionImpl method createViewInfo.

/**
     * Creates a {@link ViewInfo} for the view. The {@code ViewInfo} corresponding to the children
     * of the {@code view} are not created. Consequently, the children of {@code ViewInfo} is not
     * set.
     * @param offset an offset for the view bounds. Used only if view is part of the content frame.
     */
private ViewInfo createViewInfo(View view, int offset, boolean setExtendedInfo, boolean isContentFrame) {
    if (view == null) {
        return null;
    }
    ViewParent parent = view.getParent();
    ViewInfo result;
    if (isContentFrame) {
        // Account for parent scroll values when calculating the bounding box
        int scrollX = parent != null ? ((View) parent).getScrollX() : 0;
        int scrollY = parent != null ? ((View) parent).getScrollY() : 0;
        // 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(), getContext().getViewKey(view), -scrollX + view.getLeft(), -scrollY + view.getTop() + offset, -scrollX + view.getRight(), -scrollY + view.getBottom() + offset, view, view.getLayoutParams());
    } else {
        // 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;
        // 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 {
                // actionProviderClass.
                while (parent != mViewRoot && parent instanceof ViewGroup) {
                    if (parent instanceof ActionMenuView) {
                        r.setViewType(ViewType.ACTION_BAR_MENU);
                        break;
                    }
                    parent = parent.getParent();
                }
            }
        }
    }
    if (setExtendedInfo) {
        MarginLayoutParams marginParams = null;
        LayoutParams params = view.getLayoutParams();
        if (params instanceof MarginLayoutParams) {
            marginParams = (MarginLayoutParams) params;
        }
        result.setExtendedInfo(view.getBaseline(), marginParams != null ? marginParams.leftMargin : 0, marginParams != null ? marginParams.topMargin : 0, marginParams != null ? marginParams.rightMargin : 0, marginParams != null ? marginParams.bottomMargin : 0);
    }
    return result;
}
Also used : ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) LayoutParams(android.view.ViewGroup.LayoutParams) ActionMenuView(android.widget.ActionMenuView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewInfo(com.android.ide.common.rendering.api.ViewInfo)

Example 2 with ListMenuItemView

use of com.android.internal.view.menu.ListMenuItemView in project android_frameworks_base by DirtyUnicorns.

the class RenderSessionImpl method getViewKey.

/* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
@Nullable
private Object getViewKey(View view) {
    BridgeContext context = getContext();
    if (!(view instanceof MenuView.ItemView)) {
        return context.getViewKey(view);
    }
    MenuItemImpl menuItem;
    if (view instanceof ActionMenuItemView) {
        menuItem = ((ActionMenuItemView) view).getItemData();
    } else if (view instanceof ListMenuItemView) {
        menuItem = ((ListMenuItemView) view).getItemData();
    } else if (view instanceof IconMenuItemView) {
        menuItem = ((IconMenuItemView) view).getItemData();
    } else {
        menuItem = null;
    }
    if (menuItem instanceof BridgeMenuItemImpl) {
        return ((BridgeMenuItemImpl) menuItem).getViewCookie();
    }
    return null;
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) Nullable(android.annotation.Nullable)

Example 3 with ListMenuItemView

use of com.android.internal.view.menu.ListMenuItemView in project android_frameworks_base by DirtyUnicorns.

the class RenderSessionImpl method createViewInfo.

/**
     * Creates a {@link ViewInfo} for the view. The {@code ViewInfo} corresponding to the children
     * of the {@code view} are not created. Consequently, the children of {@code ViewInfo} is not
     * set.
     * @param offset an offset for the view bounds. Used only if view is part of the content frame.
     */
private ViewInfo createViewInfo(View view, int offset, boolean setExtendedInfo, boolean isContentFrame) {
    if (view == null) {
        return null;
    }
    ViewParent parent = view.getParent();
    ViewInfo result;
    if (isContentFrame) {
        // Account for parent scroll values when calculating the bounding box
        int scrollX = parent != null ? ((View) parent).getScrollX() : 0;
        int scrollY = parent != null ? ((View) parent).getScrollY() : 0;
        // 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(), getContext().getViewKey(view), -scrollX + view.getLeft(), -scrollY + view.getTop() + offset, -scrollX + view.getRight(), -scrollY + view.getBottom() + offset, view, view.getLayoutParams());
    } else {
        // 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;
        // 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 {
                // actionProviderClass.
                while (parent != mViewRoot && parent instanceof ViewGroup) {
                    if (parent instanceof ActionMenuView) {
                        r.setViewType(ViewType.ACTION_BAR_MENU);
                        break;
                    }
                    parent = parent.getParent();
                }
            }
        }
    }
    if (setExtendedInfo) {
        MarginLayoutParams marginParams = null;
        LayoutParams params = view.getLayoutParams();
        if (params instanceof MarginLayoutParams) {
            marginParams = (MarginLayoutParams) params;
        }
        result.setExtendedInfo(view.getBaseline(), marginParams != null ? marginParams.leftMargin : 0, marginParams != null ? marginParams.topMargin : 0, marginParams != null ? marginParams.rightMargin : 0, marginParams != null ? marginParams.bottomMargin : 0);
    }
    return result;
}
Also used : ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) LayoutParams(android.view.ViewGroup.LayoutParams) ActionMenuView(android.widget.ActionMenuView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewInfo(com.android.ide.common.rendering.api.ViewInfo)

Example 4 with ListMenuItemView

use of com.android.internal.view.menu.ListMenuItemView in project android_frameworks_base by ResurrectionRemix.

the class RenderSessionImpl method createViewInfo.

/**
     * Creates a {@link ViewInfo} for the view. The {@code ViewInfo} corresponding to the children
     * of the {@code view} are not created. Consequently, the children of {@code ViewInfo} is not
     * set.
     * @param offset an offset for the view bounds. Used only if view is part of the content frame.
     */
private ViewInfo createViewInfo(View view, int offset, boolean setExtendedInfo, boolean isContentFrame) {
    if (view == null) {
        return null;
    }
    ViewParent parent = view.getParent();
    ViewInfo result;
    if (isContentFrame) {
        // Account for parent scroll values when calculating the bounding box
        int scrollX = parent != null ? ((View) parent).getScrollX() : 0;
        int scrollY = parent != null ? ((View) parent).getScrollY() : 0;
        // 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(), getContext().getViewKey(view), -scrollX + view.getLeft(), -scrollY + view.getTop() + offset, -scrollX + view.getRight(), -scrollY + view.getBottom() + offset, view, view.getLayoutParams());
    } else {
        // 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;
        // 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 {
                // actionProviderClass.
                while (parent != mViewRoot && parent instanceof ViewGroup) {
                    if (parent instanceof ActionMenuView) {
                        r.setViewType(ViewType.ACTION_BAR_MENU);
                        break;
                    }
                    parent = parent.getParent();
                }
            }
        }
    }
    if (setExtendedInfo) {
        MarginLayoutParams marginParams = null;
        LayoutParams params = view.getLayoutParams();
        if (params instanceof MarginLayoutParams) {
            marginParams = (MarginLayoutParams) params;
        }
        result.setExtendedInfo(view.getBaseline(), marginParams != null ? marginParams.leftMargin : 0, marginParams != null ? marginParams.topMargin : 0, marginParams != null ? marginParams.rightMargin : 0, marginParams != null ? marginParams.bottomMargin : 0);
    }
    return result;
}
Also used : ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) LayoutParams(android.view.ViewGroup.LayoutParams) ViewParent(android.view.ViewParent) ViewGroup(android.view.ViewGroup) LayoutParams(android.view.ViewGroup.LayoutParams) ActionMenuView(android.widget.ActionMenuView) MarginLayoutParams(android.view.ViewGroup.MarginLayoutParams) ViewInfo(com.android.ide.common.rendering.api.ViewInfo)

Example 5 with ListMenuItemView

use of com.android.internal.view.menu.ListMenuItemView in project platform_frameworks_base by android.

the class RenderSessionImpl method getViewKey.

/* (non-Javadoc)
     * The cookie for menu items are stored in menu item and not in the map from View stored in
     * BridgeContext.
     */
@Nullable
private Object getViewKey(View view) {
    BridgeContext context = getContext();
    if (!(view instanceof MenuView.ItemView)) {
        return context.getViewKey(view);
    }
    MenuItemImpl menuItem;
    if (view instanceof ActionMenuItemView) {
        menuItem = ((ActionMenuItemView) view).getItemData();
    } else if (view instanceof ListMenuItemView) {
        menuItem = ((ListMenuItemView) view).getItemData();
    } else if (view instanceof IconMenuItemView) {
        menuItem = ((IconMenuItemView) view).getItemData();
    } else {
        menuItem = null;
    }
    if (menuItem instanceof BridgeMenuItemImpl) {
        return ((BridgeMenuItemImpl) menuItem).getViewCookie();
    }
    return null;
}
Also used : BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) MenuItemImpl(com.android.internal.view.menu.MenuItemImpl) BridgeMenuItemImpl(com.android.internal.view.menu.BridgeMenuItemImpl) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) IconMenuItemView(com.android.internal.view.menu.IconMenuItemView) ListMenuItemView(com.android.internal.view.menu.ListMenuItemView) BridgeContext(com.android.layoutlib.bridge.android.BridgeContext) ActionMenuItemView(com.android.internal.view.menu.ActionMenuItemView) Nullable(android.annotation.Nullable)

Aggregations

ListMenuItemView (com.android.internal.view.menu.ListMenuItemView)10 Nullable (android.annotation.Nullable)5 ViewGroup (android.view.ViewGroup)5 LayoutParams (android.view.ViewGroup.LayoutParams)5 MarginLayoutParams (android.view.ViewGroup.MarginLayoutParams)5 ViewParent (android.view.ViewParent)5 ActionMenuView (android.widget.ActionMenuView)5 ViewInfo (com.android.ide.common.rendering.api.ViewInfo)5 ActionMenuItemView (com.android.internal.view.menu.ActionMenuItemView)5 BridgeMenuItemImpl (com.android.internal.view.menu.BridgeMenuItemImpl)5 IconMenuItemView (com.android.internal.view.menu.IconMenuItemView)5 MenuItemImpl (com.android.internal.view.menu.MenuItemImpl)5 BridgeContext (com.android.layoutlib.bridge.android.BridgeContext)5