Fix bug 5079507 - ICS (phone) : ActionBar tabs don't correctly resize
if activity handles orientation change

Make sure that bar content height and sizing/layout parameters are
properly updated after a configuration change.

Change-Id: I886df5cd9a655ba1bd34fab2b48e8b5be67fcc32
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index c6c4025..fb1570e 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1403,16 +1403,18 @@
     public void onConfigurationChanged(Configuration newConfig) {
         mCalled = true;
 
-        if (mActionBar != null) {
-            mActionBar.onConfigurationChanged(newConfig);
-        }
-
         mFragments.dispatchConfigurationChanged(newConfig);
 
         if (mWindow != null) {
             // Pass the configuration changed event to the window
             mWindow.onConfigurationChanged(newConfig);
         }
+
+        if (mActionBar != null) {
+            // Do this last; the action bar will need to access
+            // view changes from above.
+            mActionBar.onConfigurationChanged(newConfig);
+        }
     }
     
     /**
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 7684bc5..bc87153 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -192,8 +192,7 @@
         mContentHeight = mActionView.getContentHeight();
 
         if (mTabScrollView != null) {
-            mTabScrollView.getLayoutParams().height = mContentHeight;
-            mTabScrollView.requestLayout();
+            mTabScrollView.setContentHeight(mContentHeight);
         }
     }
 
diff --git a/core/java/com/android/internal/widget/ActionBarContainer.java b/core/java/com/android/internal/widget/ActionBarContainer.java
index 9fef2a9..a2d492b 100644
--- a/core/java/com/android/internal/widget/ActionBarContainer.java
+++ b/core/java/com/android/internal/widget/ActionBarContainer.java
@@ -109,6 +109,7 @@
         mTabContainer = tabView;
         if (tabView != null) {
             addView(tabView);
+            tabView.getLayoutParams().width = LayoutParams.MATCH_PARENT;
         }
     }
 
diff --git a/core/java/com/android/internal/widget/ActionBarView.java b/core/java/com/android/internal/widget/ActionBarView.java
index 468f28e..446c842 100644
--- a/core/java/com/android/internal/widget/ActionBarView.java
+++ b/core/java/com/android/internal/widget/ActionBarView.java
@@ -33,6 +33,7 @@
 import android.content.pm.ApplicationInfo;
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
+import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.graphics.drawable.Drawable;
@@ -172,7 +173,8 @@
         // Background is always provided by the container.
         setBackgroundResource(0);
 
-        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar);
+        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ActionBar,
+                com.android.internal.R.attr.actionBarStyle, 0);
 
         ApplicationInfo appInfo = context.getApplicationInfo();
         PackageManager pm = context.getPackageManager();
@@ -250,6 +252,18 @@
     }
 
     @Override
+    protected void onConfigurationChanged(Configuration newConfig) {
+        super.onConfigurationChanged(newConfig);
+
+        // Action bar can change size on configuration changes.
+        // Reread the desired height from the theme-specified style.
+        TypedArray a = getContext().obtainStyledAttributes(null, R.styleable.ActionBar,
+                com.android.internal.R.attr.actionBarStyle, 0);
+        setContentHeight(a.getLayoutDimension(R.styleable.ActionBar_height, 0));
+        a.recycle();
+    }
+
+    @Override
     public void onDetachedFromWindow() {
         super.onDetachedFromWindow();
         removeCallbacks(mTabSelector);
@@ -318,6 +332,7 @@
         mIncludeTabs = tabs != null;
         if (mIncludeTabs && mNavigationMode == ActionBar.NAVIGATION_MODE_TABS) {
             addView(mTabScrollView);
+            mTabScrollView.getLayoutParams().width = LayoutParams.WRAP_CONTENT;
         }
     }
 
diff --git a/core/java/com/android/internal/widget/ScrollingTabContainerView.java b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
index 40e5e8a..fefa223 100644
--- a/core/java/com/android/internal/widget/ScrollingTabContainerView.java
+++ b/core/java/com/android/internal/widget/ScrollingTabContainerView.java
@@ -87,6 +87,11 @@
         }
     }
 
+    public void setContentHeight(int contentHeight) {
+        mTabLayout.getLayoutParams().height = contentHeight;
+        requestLayout();
+    }
+
     public void animateToVisibility(int visibility) {
         if (mVisibilityAnim != null) {
             mVisibilityAnim.cancel();