am 73d3c81c: am fb15b0e2: Merge "Use action bar theme for action modes, fix ViewStub inflation theme" into lmp-dev
* commit '73d3c81ce3ea5b3179b9ed7d0e4e0bbdf322ea66': Use action bar theme for action modes, fix ViewStub inflation theme
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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" />
|
||||
|
||||
<!-- Title bar -->
|
||||
<RelativeLayout android:id="@android:id/title_container"
|
||||
|
||||
@@ -26,7 +26,8 @@ This is a custom layout for a screen.
|
||||
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" />
|
||||
|
||||
<FrameLayout android:id="@android:id/title_container"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -31,7 +31,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" />
|
||||
|
||||
<RelativeLayout android:id="@android:id/title_container"
|
||||
style="?android:attr/windowTitleBackgroundStyle"
|
||||
|
||||
@@ -30,7 +30,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" />
|
||||
<FrameLayout
|
||||
android:id="@android:id/content"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -35,5 +35,6 @@ 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" />
|
||||
</FrameLayout>
|
||||
|
||||
@@ -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" />
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="?android:attr/windowTitleSize"
|
||||
|
||||
@@ -28,7 +28,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"/>
|
||||
<RelativeLayout android:id="@android:id/title_container"
|
||||
style="?android:attr/windowTitleBackgroundStyle"
|
||||
android:layout_width="match_parent"
|
||||
|
||||
@@ -2640,19 +2640,35 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
} else {
|
||||
if (mActionModeView == null) {
|
||||
if (isFloating()) {
|
||||
mActionModeView = new ActionBarContextView(mContext);
|
||||
mActionModePopup = new PopupWindow(mContext, null,
|
||||
// Use the action bar theme.
|
||||
final TypedValue outValue = new TypedValue();
|
||||
final Theme baseTheme = mContext.getTheme();
|
||||
baseTheme.resolveAttribute(R.attr.actionBarTheme, outValue, true);
|
||||
|
||||
final Context actionBarContext;
|
||||
if (outValue.resourceId != 0) {
|
||||
final Theme actionBarTheme = mContext.getResources().newTheme();
|
||||
actionBarTheme.setTo(baseTheme);
|
||||
actionBarTheme.applyStyle(outValue.resourceId, true);
|
||||
|
||||
actionBarContext = new ContextThemeWrapper(mContext, 0);
|
||||
actionBarContext.getTheme().setTo(actionBarTheme);
|
||||
} else {
|
||||
actionBarContext = mContext;
|
||||
}
|
||||
|
||||
mActionModeView = new ActionBarContextView(actionBarContext);
|
||||
mActionModePopup = new PopupWindow(actionBarContext, null,
|
||||
R.attr.actionModePopupWindowStyle);
|
||||
mActionModePopup.setWindowLayoutType(
|
||||
WindowManager.LayoutParams.TYPE_APPLICATION);
|
||||
mActionModePopup.setContentView(mActionModeView);
|
||||
mActionModePopup.setWidth(MATCH_PARENT);
|
||||
|
||||
TypedValue heightValue = new TypedValue();
|
||||
mContext.getTheme().resolveAttribute(
|
||||
R.attr.actionBarSize, heightValue, true);
|
||||
final int height = TypedValue.complexToDimensionPixelSize(heightValue.data,
|
||||
mContext.getResources().getDisplayMetrics());
|
||||
actionBarContext.getTheme().resolveAttribute(
|
||||
R.attr.actionBarSize, outValue, true);
|
||||
final int height = TypedValue.complexToDimensionPixelSize(outValue.data,
|
||||
actionBarContext.getResources().getDisplayMetrics());
|
||||
mActionModeView.setContentHeight(height);
|
||||
mActionModePopup.setHeight(WRAP_CONTENT);
|
||||
mShowActionModePopup = new Runnable() {
|
||||
@@ -2673,8 +2689,8 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
|
||||
|
||||
if (mActionModeView != null) {
|
||||
mActionModeView.killMode();
|
||||
mode = new StandaloneActionMode(getContext(), mActionModeView, wrappedCallback,
|
||||
mActionModePopup == null);
|
||||
mode = new StandaloneActionMode(mActionModeView.getContext(), mActionModeView,
|
||||
wrappedCallback, mActionModePopup == null);
|
||||
if (callback.onCreateActionMode(mode, mode.getMenu())) {
|
||||
mode.invalidate();
|
||||
mActionModeView.initForMode(mode);
|
||||
|
||||
Reference in New Issue
Block a user