Action bar rendering in layoutlib

This also makes a couple of changes to the framework:
1. ShareActionProvider - Use edit mode to execute activity chooser code.
2. WindowDecorActionBar - add a new constructor for use by layoutlib.

This also relies on some changes to the plugin to pass the correct params.

Change-Id: Ia30fef816afd91ec1e439734d56b59b1323bfee2
This commit is contained in:
Deepanshu Gupta
2013-12-12 12:16:24 -08:00
parent 2271a91c32
commit 14bf0cef7e
12 changed files with 457 additions and 162 deletions

View File

@@ -161,9 +161,11 @@ public class ShareActionProvider extends ActionProvider {
@Override
public View onCreateActionView() {
// Create the view and set its data model.
ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
ActivityChooserView activityChooserView = new ActivityChooserView(mContext);
activityChooserView.setActivityChooserModel(dataModel);
if (!activityChooserView.isInEditMode()) {
ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
activityChooserView.setActivityChooserModel(dataModel);
}
// Lookup and set the expand action icon.
TypedValue outTypedValue = new TypedValue();

View File

@@ -170,6 +170,15 @@ public class WindowDecorActionBar extends ActionBar {
init(dialog.getWindow().getDecorView());
}
/**
* Only for edit mode.
* @hide
*/
public WindowDecorActionBar(View layout) {
assert layout.isInEditMode();
init(layout);
}
private void init(View decor) {
mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(
com.android.internal.R.id.action_bar_overlay_layout);
@@ -559,8 +568,8 @@ public class WindowDecorActionBar extends ActionBar {
return;
}
final FragmentTransaction trans = mActivity.getFragmentManager().beginTransaction()
.disallowAddToBackStack();
final FragmentTransaction trans = mActionView.isInEditMode() ? null :
mActivity.getFragmentManager().beginTransaction().disallowAddToBackStack();
if (mSelectedTab == tab) {
if (mSelectedTab != null) {
@@ -578,7 +587,7 @@ public class WindowDecorActionBar extends ActionBar {
}
}
if (!trans.isEmpty()) {
if (trans != null && !trans.isEmpty()) {
trans.commit();
}
}