Action bar tab layout tweaks.

Let tabs consume the full action bar when the menu is empty and other
elements are disabled when the tab bar would normally split onto a
second row..

Fix bug 4489724 - bug in ActionBarImpl#cleanupTabs.

Change-Id: I28a235d339137add0b106c6e733a6767fa547810
diff --git a/core/java/com/android/internal/app/ActionBarImpl.java b/core/java/com/android/internal/app/ActionBarImpl.java
index 183cfbd..6cfeb87 100644
--- a/core/java/com/android/internal/app/ActionBarImpl.java
+++ b/core/java/com/android/internal/app/ActionBarImpl.java
@@ -176,6 +176,8 @@
             }
             mActionView.setEmbeddedTabView(mTabScrollView);
         }
+        mActionView.setCollapsable(!mHasEmbeddedTabs &&
+                getNavigationMode() == NAVIGATION_MODE_TABS);
 
         TypedArray a = mContext.obtainStyledAttributes(null, R.styleable.ActionBar);
         mContentHeight = a.getLayoutDimension(R.styleable.ActionBar_height, 0);
@@ -307,7 +309,9 @@
             selectTab(null);
         }
         mTabs.clear();
-        mTabScrollView.removeAllTabs();
+        if (mTabScrollView != null) {
+            mTabScrollView.removeAllTabs();
+        }
         mSavedTabPosition = INVALID_POSITION;
     }
 
@@ -887,6 +891,7 @@
                 }
                 break;
         }
+        mActionView.setCollapsable(mode == NAVIGATION_MODE_TABS && !mHasEmbeddedTabs);
     }
 
     @Override