Merge "Fix bug 5174755 - Adjust action bar overflow limits for ifRoom items"
diff --git a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
index dd75925..df4243a 100644
--- a/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
+++ b/core/java/com/android/internal/view/menu/ActionMenuPresenter.java
@@ -19,6 +19,7 @@
 import com.android.internal.view.menu.ActionMenuView.ActionMenuChildView;
 
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.os.Parcel;
 import android.os.Parcelable;
@@ -109,6 +110,16 @@
         mScrapActionButtonView = null;
     }
 
+    public void onConfigurationChanged(Configuration newConfig) {
+        if (!mMaxItemsSet) {
+            mMaxItems = mContext.getResources().getInteger(
+                    com.android.internal.R.integer.max_action_buttons);
+            if (mMenu != null) {
+                mMenu.onItemsChanged(true);
+            }
+        }
+    }
+
     public void setWidthLimit(int width, boolean strict) {
         mWidthLimit = width;
         mStrictWidthLimit = strict;
diff --git a/core/java/com/android/internal/widget/ActionBarContextView.java b/core/java/com/android/internal/widget/ActionBarContextView.java
index 5645a6f..45d38ae 100644
--- a/core/java/com/android/internal/widget/ActionBarContextView.java
+++ b/core/java/com/android/internal/widget/ActionBarContextView.java
@@ -25,6 +25,7 @@
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
 import android.content.Context;
+import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
 import android.text.TextUtils;
@@ -92,6 +93,14 @@
         a.recycle();
     }
 
+    @Override
+    public void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+        if (mActionMenuPresenter != null) {
+            mActionMenuPresenter.onConfigurationChanged(newConfig);
+        }
+    }
+
     public void setHeight(int height) {
         mContentHeight = height;
     }
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 078e08a..28181ba 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -259,6 +259,9 @@
                 com.android.internal.R.attr.actionBarStyle, 0);
         setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
         a.recycle();
+        if (mActionMenuPresenter != null) {
+            mActionMenuPresenter.onConfigurationChanged(newConfig);
+        }
     }
 
     @Override
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w360dp/dimens.xml
similarity index 94%
copy from core/res/res/values-port/dimens.xml
copy to core/res/res/values-w360dp/dimens.xml
index bf0a342..0f5d656 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w360dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">3</integer>
 </resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w500dp/dimens.xml
similarity index 94%
rename from core/res/res/values-port/dimens.xml
rename to core/res/res/values-w500dp/dimens.xml
index bf0a342..68841ca 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w500dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">4</integer>
 </resources>
diff --git a/core/res/res/values-port/dimens.xml b/core/res/res/values-w600dp/dimens.xml
similarity index 94%
copy from core/res/res/values-port/dimens.xml
copy to core/res/res/values-w600dp/dimens.xml
index bf0a342..83c45b5 100644
--- a/core/res/res/values-port/dimens.xml
+++ b/core/res/res/values-w600dp/dimens.xml
@@ -20,5 +20,5 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">2</integer>
+    <integer name="max_action_buttons">5</integer>
 </resources>
diff --git a/core/res/res/values/dimens.xml b/core/res/res/values/dimens.xml
index 83e8693..c522c1e 100644
--- a/core/res/res/values/dimens.xml
+++ b/core/res/res/values/dimens.xml
@@ -28,7 +28,7 @@
     <!-- The maximum number of action buttons that should be permitted within
          an action bar/action mode. This will be used to determine how many
          showAsAction="ifRoom" items can fit. "always" items can override this. -->
-    <integer name="max_action_buttons">3</integer>
+    <integer name="max_action_buttons">2</integer>
     <dimen name="toast_y_offset">64dip</dimen>
     <!-- Height of the status bar -->
     <dimen name="status_bar_height">25dip</dimen>