Skip to content

Commit

Permalink
Remove the static limit of 3 items in the ActionBar
Browse files Browse the repository at this point in the history
The limit is now set in the theme. The default value is still 3 as this is considered as the maximum number of global actions a screen SHOULD have. Please do not change this value unless you are completely aware of what you are doing. Modifying it may impair user experience. If you really have a large number of actions, please consider QuickActions.

Closes #36
  • Loading branch information
Cyril Mottier committed Sep 1, 2011
1 parent 4164776 commit 1d0b80a
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions GreenDroid/res/values/gd_attrs.xml
Expand Up @@ -86,6 +86,7 @@
<attr name="gdActionBarHomeDrawable" format="reference" />
<attr name="gdActionBarItemColorNormal" format="reference|color" />
<attr name="gdActionBarItemColorAlt" format="reference|color" />
<attr name="gdActionBarMaxItems" format="integer" />

<attr name="gdActionBarStyle" format="reference" />
<attr name="gdActionBarTitleStyle" format="reference" />
Expand Down Expand Up @@ -169,6 +170,7 @@
<attr name="dividerDrawable" />
<attr name="dividerWidth" />
<attr name="homeDrawable" format="reference" />
<attr name="maxItems" format="integer" />
</declare-styleable>

<declare-styleable name="AsyncImageView">
Expand Down
1 change: 1 addition & 0 deletions GreenDroid/res/values/gd_styles.xml
Expand Up @@ -154,6 +154,7 @@
<item name="dividerDrawable">?attr/gdActionBarDividerDrawable</item>
<item name="dividerWidth">?attr/gdActionBarDividerWidth</item>
<item name="homeDrawable">?attr/gdActionBarHomeDrawable</item>
<item name="maxItems">?attr/gdActionBarMaxItems</item>
</style>

<style name="GreenDroid.Widget.ActionBar.Dashboard">
Expand Down
1 change: 1 addition & 0 deletions GreenDroid/res/values/gd_themes.xml
Expand Up @@ -83,6 +83,7 @@
<item name="gdActionBarHomeDrawable">@null</item>
<item name="gdActionBarItemColorNormal">@android:color/white</item>
<item name="gdActionBarItemColorAlt">@android:color/black</item>
<item name="gdActionBarMaxItems">3</item>

<item name="gdActionBarStyle">@style/GreenDroid.Widget.ActionBar</item>
<item name="gdActionBarTitleStyle">@style/GreenDroid.Widget.ActionBar.Title</item>
Expand Down
6 changes: 4 additions & 2 deletions GreenDroid/src/greendroid/widget/ActionBar.java
Expand Up @@ -35,7 +35,6 @@
public class ActionBar extends LinearLayout {

public static final int NONE = 0;
private static final int MAX_ITEMS_COUNT = 3;

public enum Type {
Normal, Dashboard, Empty
Expand Down Expand Up @@ -70,6 +69,8 @@ public interface OnActionBarListener {
private Drawable mDividerDrawable;
private Drawable mHomeDrawable;
private int mDividerWidth;

private int mMaxItemsCount;

public ActionBar(Context context) {
this(context, null);
Expand All @@ -91,6 +92,7 @@ public ActionBar(Context context, AttributeSet attrs, int defStyle) {
mDividerDrawable = a.getDrawable(R.styleable.ActionBar_dividerDrawable);
mDividerWidth = a.getDimensionPixelSize(R.styleable.ActionBar_dividerWidth, -1);
mHomeDrawable = a.getDrawable(R.styleable.ActionBar_homeDrawable);
mMaxItemsCount = a.getInt(R.styleable.ActionBar_maxItems, 3);
if (mHomeDrawable == null) {
mHomeDrawable = new ActionBarDrawable(context, R.drawable.gd_action_bar_home);
}
Expand Down Expand Up @@ -185,7 +187,7 @@ public ActionBarItem addItem(ActionBarItem item) {

public ActionBarItem addItem(ActionBarItem item, int itemId) {

if (mItems.size() >= MAX_ITEMS_COUNT) {
if (mItems.size() >= mMaxItemsCount) {
/*
* An ActionBar must contain as few items as possible. So let's keep
* a limit :)
Expand Down

0 comments on commit 1d0b80a

Please sign in to comment.