|
This changeset adds the following features to the layout editor:
(1) Show Included In. For a layout that is included from another
layout, this lets you view and edit the included layout "in place"
in the outer layout. The outer layout is masked out with a
partially translucent mask, and does not respond to edits. The
outline will show the outer layout's name at the root level. The
included rendering is controlled with a tools attribute, and is
therefore persistent. The Extract Include refactoring will
automatically enter show-included-in mode for the extracted
layout.
(2) Highlight the view under the mouse ("hover"). This makes it
easier to see the structure of the layout. In addition to the
faint highlight (same as in ADT) it also shows a faint dashed
outline of the widget bounds.
The above two features are supported for both the layout editor as
well as the XML layout preview. To facilitate sharing between the two,
there is a new "Overlays" concept; each overlay is a mask that is
painted on top of the area, and the hover and include layers are
individual overlays. There can be more in the future, such as an
overlay to show empty components, an overlay to show lint badges, etc.
Prior to this CL, the layout editor built up its component hierarchy
by parsing the XML file, and the reconciling that parse with
layoutlib's set of view infos by comparing element children. This does
not work when the view hierarchy does not correspond to the XML file,
as is the case for show-included-in rendering. This CL replaces this
with a new RadModelBuilder, which does not look at the XML at all; it
instead infers the structure from the layoutlib ViewInfo hierarchy and
the corresponding view cookies. This means that the layout editor will
now only operate on valid layoutlib render results.
There is unit test support for testing the layout editor directly. In
addition to dumping out its inferred component tree using the android
tree decorator, it also has utility methods to drop components and set
attributes using the layout editor itself. In subsequent CLs this will
be used to add tests for more of the layout editor functionality.
This CL also contains misc other fixes as I encountered code in the
layout editor, such as getting rid of all the getClientProperty calls
to look up the current module / file / tree decorator, adding more
nullness annotations and removing warnings, removing the nested
throwables in our crash reports, etc.
Change-Id: I9ce55593a1bf4ec385c8828e4a53050740a72d29
|