Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 43b15371 authored by Deepanshu Gupta's avatar Deepanshu Gupta
Browse files

Action bar rendering in layoutlib [DO NOT MERGE]

This also makes a couple of changes to the framework:
1. ShareActionProvider - Use edit mode to execute activity chooser code.
2. ActionBarImpl - 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
(cherry-picked from fe38489f)
parent 770e40f8
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -166,9 +166,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);
        if (!activityChooserView.isInEditMode()) {
            ActivityChooserModel dataModel = ActivityChooserModel.get(mContext, mShareHistoryFileName);
            activityChooserView.setActivityChooserModel(dataModel);
        }

        // Lookup and set the expand action icon.
        TypedValue outTypedValue = new TypedValue();
+12 −3
Original line number Diff line number Diff line
@@ -162,6 +162,15 @@ public class ActionBarImpl extends ActionBar {
        init(dialog.getWindow().getDecorView());
    }

    /**
     * Only for edit mode.
     * @hide
     */
    public ActionBarImpl(View layout) {
        assert layout.isInEditMode();
        init(layout);
    }

    private void init(View decor) {
        mContext = decor.getContext();
        mOverlayLayout = (ActionBarOverlayLayout) decor.findViewById(
@@ -552,8 +561,8 @@ public class ActionBarImpl 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) {
@@ -571,7 +580,7 @@ public class ActionBarImpl extends ActionBar {
            }
        }

        if (!trans.isEmpty()) {
        if (trans != null && !trans.isEmpty()) {
            trans.commit();
        }
    }
+3 −4
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android">
    <include layout="@android:layout/action_bar_home" />
    <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

<include layout="@android:layout/screen_action_bar" />

</merge>
+2 −1
Original line number Diff line number Diff line
@@ -211,7 +211,8 @@ public final class Bridge extends com.android.ide.common.rendering.api.Bridge {
                Capability.ANIMATED_VIEW_MANIPULATION,
                Capability.ADAPTER_BINDING,
                Capability.EXTENDED_VIEWINFO,
                Capability.FIXED_SCALABLE_NINE_PATCH);
                Capability.FIXED_SCALABLE_NINE_PATCH,
                Capability.ACTION_BAR);


        BridgeAssetManager.initSystem();
+5 −0
Original line number Diff line number Diff line
@@ -63,6 +63,11 @@ public class BridgeRenderSession extends RenderSession {
        return mSession.getViewInfos();
    }

    @Override
    public List<ViewInfo> getSystemRootViews() {
        return mSession.getSystemViewInfos();
    }

    @Override
    public Map<String, String> getDefaultProperties(Object viewObject) {
        return mSession.getDefaultProperties(viewObject);
Loading