Bug 947281 - Fix calcuations for how many actionbar items to show. r=sriram,margaret

This commit is contained in:
Wes Johnston 2013-12-17 09:41:55 -08:00
parent 2eace53387
commit 348ee881e7
2 changed files with 14 additions and 8 deletions

View File

@ -119,9 +119,12 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
maxWidth = mActionButtonBar.getMeasuredWidth();
}
// Since we don't know how many items will be added, we always reserve space for the overflow menu
mMenuButton.measure(SPEC, SPEC);
maxWidth -= mMenuButton.getMeasuredWidth();
// If the menu button is already visible, no need to account for it
if (mMenuButton.getVisibility() == View.GONE) {
// Since we don't know how many items will be added, we always reserve space for the overflow menu
mMenuButton.measure(SPEC, SPEC);
maxWidth -= mMenuButton.getMeasuredWidth();
}
if (mActionButtonsWidth <= 0) {
mActionButtonsWidth = 0;
@ -142,12 +145,14 @@ class ActionModeCompatView extends LinearLayout implements GeckoMenu.ActionItemB
mActionButtonBar.addView(actionItem);
return true;
}
return false;
}
/* GeckoMenu.ActionItemBarPresenter */
@Override
public void removeActionItem(View actionItem) {
actionItem.measure(SPEC, SPEC);
mActionButtonsWidth -= actionItem.getMeasuredWidth();
mActionButtonBar.removeView(actionItem);
}

View File

@ -171,11 +171,12 @@ public class GeckoMenu extends ListView
}
});
mActionItems.put(menuItem, actionView);
mActionItemBarPresenter.addActionItem(actionView);
mItems.add(menuItem);
return true;
if (mActionItemBarPresenter.addActionItem(actionView)) {
mActionItems.put(menuItem, actionView);
mItems.add(menuItem);
return true;
}
return false;
}
@Override