From a9ddb8dc23b253c53f24ceb81e9d596c072d834e Mon Sep 17 00:00:00 2001 From: Alan Viverette Date: Wed, 17 Sep 2014 18:14:32 -0700 Subject: [PATCH] Use action bar theme for action modes, fix ViewStub inflation theme BUG: 17262483 BUG: 17513621 Change-Id: I74764570a11da162a224e94978e21e52d17e2e84 --- core/java/android/view/LayoutInflater.java | 4 +-- .../internal/view/StandaloneActionMode.java | 7 ++-- core/res/res/layout/screen.xml | 3 +- core/res/res/layout/screen_custom_title.xml | 3 +- core/res/res/layout/screen_progress.xml | 3 +- core/res/res/layout/screen_simple.xml | 3 +- .../screen_simple_overlay_action_mode.xml | 3 +- core/res/res/layout/screen_title.xml | 3 +- core/res/res/layout/screen_title_icons.xml | 3 +- .../internal/policy/impl/PhoneWindow.java | 34 ++++++++++++++----- 10 files changed, 45 insertions(+), 21 deletions(-) diff --git a/core/java/android/view/LayoutInflater.java b/core/java/android/view/LayoutInflater.java index 577415e9f7d8a..5f3704224ef9f 100644 --- a/core/java/android/view/LayoutInflater.java +++ b/core/java/android/view/LayoutInflater.java @@ -606,9 +606,9 @@ public abstract class LayoutInflater { constructor.setAccessible(true); final View view = constructor.newInstance(args); if (view instanceof ViewStub) { - // always use ourselves when inflating ViewStub later + // Use the same context when inflating ViewStub later. final ViewStub viewStub = (ViewStub) view; - viewStub.setLayoutInflater(this); + viewStub.setLayoutInflater(cloneInContext((Context) args[0])); } return view; diff --git a/core/java/com/android/internal/view/StandaloneActionMode.java b/core/java/com/android/internal/view/StandaloneActionMode.java index fae7ea12fd832..d5d360243e01f 100644 --- a/core/java/com/android/internal/view/StandaloneActionMode.java +++ b/core/java/com/android/internal/view/StandaloneActionMode.java @@ -46,7 +46,8 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call mContextView = view; mCallback = callback; - mMenu = new MenuBuilder(context).setDefaultShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM); + mMenu = new MenuBuilder(view.getContext()).setDefaultShowAsAction( + MenuItem.SHOW_AS_ACTION_IF_ROOM); mMenu.setCallback(this); mFocusable = isFocusable; } @@ -126,7 +127,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call @Override public MenuInflater getMenuInflater() { - return new MenuInflater(mContext); + return new MenuInflater(mContextView.getContext()); } public boolean onMenuItemSelected(MenuBuilder menu, MenuItem item) { @@ -141,7 +142,7 @@ public class StandaloneActionMode extends ActionMode implements MenuBuilder.Call return true; } - new MenuPopupHelper(mContext, subMenu).show(); + new MenuPopupHelper(mContextView.getContext(), subMenu).show(); return true; } diff --git a/core/res/res/layout/screen.xml b/core/res/res/layout/screen.xml index 902a797fdadc2..403ffd63debb1 100644 --- a/core/res/res/layout/screen.xml +++ b/core/res/res/layout/screen.xml @@ -30,7 +30,8 @@ This is the basic layout for a screen, with all of its features enabled. android:inflatedId="@+id/action_mode_bar" android:layout="@layout/action_mode_bar" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> diff --git a/core/res/res/layout/screen_title.xml b/core/res/res/layout/screen_title.xml index f5134f9faba71..409e9c6ec2b39 100644 --- a/core/res/res/layout/screen_title.xml +++ b/core/res/res/layout/screen_title.xml @@ -27,7 +27,8 @@ enabled. android:inflatedId="@+id/action_mode_bar" android:layout="@layout/action_mode_bar" android:layout_width="match_parent" - android:layout_height="wrap_content" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme" /> + android:layout_height="wrap_content" + android:theme="?attr/actionBarTheme"/>