Fix bug 5087752 - Maintain correct contrast against action bars in
inverse-bar themes

Add the actionBarWidgetTheme theme attribute. This lets a theme
specify a wrapper theme that can be used to create views that will
end up in the action bar so that the rest of the code can ignore
differences in contrast. (e.g. the inverse action bar themes.)

Apps can use ActionBar#getThemedContext() to obtain a Context with a
proper theme for views that will end up in the action
bar. MenuInflaters generated by Activities will automatically use this
to properly theme inflated action views.

Change-Id: Ib28c82bf47c25d446cca2a63f617b8a4a0afa6b2
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index 8d03ac7..c6c4025 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -32,6 +32,7 @@
 import android.content.res.Configuration;
 import android.content.res.Resources;
 import android.content.res.TypedArray;
+import android.content.res.Resources.Theme;
 import android.database.Cursor;
 import android.graphics.Bitmap;
 import android.graphics.Canvas;
@@ -54,6 +55,7 @@
 import android.util.EventLog;
 import android.util.Log;
 import android.util.SparseArray;
+import android.util.TypedValue;
 import android.view.ActionMode;
 import android.view.ContextMenu;
 import android.view.ContextMenu.ContextMenuInfo;
@@ -672,6 +674,7 @@
     /*package*/ int mConfigChangeFlags;
     /*package*/ Configuration mCurrentConfig;
     private SearchManager mSearchManager;
+    private MenuInflater mMenuInflater;
 
     static final class NonConfigurationInstances {
         Object activity;
@@ -3083,7 +3086,16 @@
      * Returns a {@link MenuInflater} with this context.
      */
     public MenuInflater getMenuInflater() {
-        return new MenuInflater(this);
+        // Make sure that action views can get an appropriate theme.
+        if (mMenuInflater == null) {
+            initActionBar();
+            if (mActionBar != null) {
+                mMenuInflater = new MenuInflater(mActionBar.getThemedContext());
+            } else {
+                mMenuInflater = new MenuInflater(this);
+            }
+        }
+        return mMenuInflater;
     }
 
     @Override