예제 #1
0
  public void testHiddenMenuItems() throws InterruptedException {
    // Get the menu items
    MenuItem actionXmlHidden = getActivity().menuItemActionXmlHidden;
    MenuItem actionCodeHidden = getActivity().menuItemActionCodeHidden;
    MenuItem nativeXmlHidden = getActivity().menuItemNativeXmlHidden;
    MenuItem nativeCodeHidden = getActivity().menuItemNativeCodeHidden;

    // Make sure they all were created properly
    assertNotNull(actionXmlHidden);
    assertNotNull(actionCodeHidden);
    assertNotNull(nativeXmlHidden);
    assertNotNull(nativeCodeHidden);

    // Make sure the items think they're hidden
    assertFalse(actionXmlHidden.isVisible());
    assertFalse(actionCodeHidden.isVisible());
    assertFalse(nativeXmlHidden.isVisible());
    assertFalse(nativeCodeHidden.isVisible());

    // Test native items are not present
    assertFalse(getInstrumentation().invokeMenuActionSync(getActivity(), Issue0033.ID_HIDDEN, 0));
    assertFalse(getInstrumentation().invokeMenuActionSync(getActivity(), R.id.issue0033_native, 0));

    // Test action items are not present
    View codeView = findActionItem(Issue0033.TEXT_HIDDEN);
    assertNotNull(codeView);
    assertEquals(View.GONE, codeView.getVisibility());
    View xmlView = findActionItem(getActivity().getXmlHiddenText());
    assertNotNull(xmlView);
    assertEquals(View.GONE, xmlView.getVisibility());
  }
예제 #2
0
  public void testVisibleMenuItemHiding() throws InterruptedException {
    // Get native item
    MenuItem nativeItem = getActivity().menuItemNativeVisible;
    assertNotNull(nativeItem);
    assertTrue(nativeItem.isVisible());
    assertTrue(getInstrumentation().invokeMenuActionSync(getActivity(), Issue0033.ID_VISIBLE, 0));

    // Get action item
    MenuItem actionItem = getActivity().menuItemActionVisible;
    assertNotNull(actionItem);
    assertTrue(actionItem.isVisible());

    // Get action item view
    View actionItemView = findActionItem(Issue0033.TEXT_VISIBLE);
    assertNotNull(actionItemView);
    assertEquals(View.VISIBLE, actionItemView.getVisibility());

    // Hide and test hidden
    getActivity().hideVisibleMenuItems();
    assertFalse(nativeItem.isVisible());
    assertFalse(getInstrumentation().invokeMenuActionSync(getActivity(), Issue0033.ID_VISIBLE, 0));
    assertFalse(actionItem.isVisible());
    assertEquals(View.GONE, actionItemView.getVisibility());
  }
예제 #3
0
 @Override
 public void enableActionBarProgress(boolean enable) {
   if (mMenuButtonCheckMail != null && mMenuButtonCheckMail.isVisible()) {
     mActionBarProgress.setVisibility(ProgressBar.GONE);
     if (enable) {
       mMenuButtonCheckMail.setActionView(mActionButtonIndeterminateProgress);
     } else {
       mMenuButtonCheckMail.setActionView(null);
     }
   } else {
     if (mMenuButtonCheckMail != null) mMenuButtonCheckMail.setActionView(null);
     if (enable) {
       mActionBarProgress.setVisibility(ProgressBar.VISIBLE);
     } else {
       mActionBarProgress.setVisibility(ProgressBar.GONE);
     }
   }
 }
    public ActionButtonSubmenu(Context context, SubMenuBuilder subMenu) {
      super(context, subMenu);
      // UNUSED mSubMenu = subMenu;

      MenuItemImpl item = (MenuItemImpl) subMenu.getItem();
      if (!item.isActionButton()) {
        // Give a reasonable anchor to nested submenus.
        setAnchorView(mOverflowButton == null ? (View) mMenuView : mOverflowButton);
      }

      setCallback(mPopupPresenterCallback);

      boolean preserveIconSpacing = false;
      final int count = subMenu.size();
      for (int i = 0; i < count; i++) {
        MenuItem childItem = subMenu.getItem(i);
        if (childItem.isVisible() && childItem.getIcon() != null) {
          preserveIconSpacing = true;
          break;
        }
      }
      setForceShowIcon(preserveIconSpacing);
    }