summaryrefslogtreecommitdiffstats
path: root/policy/src
diff options
context:
space:
mode:
authorAlan Viverette <alanv@google.com>2014-06-04 01:17:25 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2014-06-04 01:17:25 +0000
commitef8f79a9286e87a0d46bfe408d78b9a4f339953d (patch)
treeaa23b42a16faf11589500f661be81d90a08fc9ce /policy/src
parentbc1ff4dd7e074dfbb73269539fe037c5d3db93c5 (diff)
parent4b002d3251307cb5b82480963bf4089e91b67898 (diff)
downloadframeworks_base-ef8f79a9286e87a0d46bfe408d78b9a4f339953d.zip
frameworks_base-ef8f79a9286e87a0d46bfe408d78b9a4f339953d.tar.gz
frameworks_base-ef8f79a9286e87a0d46bfe408d78b9a4f339953d.tar.bz2
Merge "Fix action bar menu inflation context" into lmp-preview-dev
Diffstat (limited to 'policy/src')
-rw-r--r--policy/src/com/android/internal/policy/impl/PhoneWindow.java38
1 files changed, 29 insertions, 9 deletions
diff --git a/policy/src/com/android/internal/policy/impl/PhoneWindow.java b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
index 2eee853..5b786c1 100644
--- a/policy/src/com/android/internal/policy/impl/PhoneWindow.java
+++ b/policy/src/com/android/internal/policy/impl/PhoneWindow.java
@@ -46,6 +46,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.content.res.Resources;
+import android.content.res.Resources.Theme;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
@@ -1159,22 +1160,41 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
protected boolean initializePanelMenu(final PanelFeatureState st) {
Context context = getContext();
- // If we have an action bar, initialize the menu with a context themed for it.
+ // If we have an action bar, initialize the menu with the right theme.
if ((st.featureId == FEATURE_OPTIONS_PANEL || st.featureId == FEATURE_ACTION_BAR) &&
mDecorContentParent != null) {
- TypedValue outValue = new TypedValue();
- Resources.Theme currentTheme = context.getTheme();
- currentTheme.resolveAttribute(com.android.internal.R.attr.actionBarWidgetTheme,
- outValue, true);
- final int targetThemeRes = outValue.resourceId;
+ // TODO: We should pull the theme directly from the ActionBar.
+ final TypedValue outValue = new TypedValue();
+ final Theme baseTheme = context.getTheme();
+ baseTheme.resolveAttribute(com.android.internal.R.attr.actionBarTheme, outValue, true);
+
+ Theme widgetTheme = null;
+ if (outValue.resourceId != 0) {
+ widgetTheme = context.getResources().newTheme();
+ widgetTheme.setTo(baseTheme);
+ widgetTheme.applyStyle(outValue.resourceId, true);
+ widgetTheme.resolveAttribute(
+ com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
+ } else {
+ baseTheme.resolveAttribute(
+ com.android.internal.R.attr.actionBarWidgetTheme, outValue, true);
+ }
+
+ if (outValue.resourceId != 0) {
+ if (widgetTheme == null) {
+ widgetTheme = context.getResources().newTheme();
+ widgetTheme.setTo(baseTheme);
+ }
+ widgetTheme.applyStyle(outValue.resourceId, true);
+ }
- if (targetThemeRes != 0 && context.getThemeResId() != targetThemeRes) {
- context = new ContextThemeWrapper(context, targetThemeRes);
+ if (widgetTheme != null) {
+ context = new ContextThemeWrapper(context, 0);
+ context.getTheme().setTo(widgetTheme);
}
}
final MenuBuilder menu = new MenuBuilder(context);
-
menu.setCallback(this);
st.setMenu(menu);