For specific methods, Layoublib_create can rewrite the implementation
of a method to invoke a delegate instead of the original code. This
allows layoutlib to implement native code or override existing behavior.
This patch also 'saves' the original implementation of a rewritten
method so that the delegate can access the original implementation
as needed. Obviously this is only done for non-native methods.
Given a non-native SomeClass.MethodName, we generate 2 methods:
- A copy of the original method named "SomeClass.MethodName_original".
The content is the original method as-is from the reader.
- A brand new implementation of SomeClass.MethodName which calls to a
non-existing method named "SomeClass_delegate.MethodName".
The implementation of this 'delegate' method is done in layoutlib_brigde.
Change-Id: I5ca2cd3ac55991a8e8a51c417e75ee447bf9e9e6
fe051bb2 : Change the way the layoutlib instantiate its XmlPullParser.
A lot of the init code was duplicated so I made a ParserFactory class.
Also created an extension of the KXmlPullParser to override toString().
This allows easier debugging when dealing with multiple parsers (which
is always the case).
Also added some (disabled) debugging printf to deal with parser stack
as it can be tricky figuring out which parsers are in the stack at
which point.
8969147c : Fix case where the int[] attrs doesn't directly match a styleable.
In the case of the FastScroller the int[] is a custom mix of attr
instead of a int[] that exists as R.styleable.foo.
This makes our reflection based mechanism used to find the styleable
fail, so instead we search for each attribute separately (like
we probably should have done from the beginning).
0c264b35: Fix various cases of getDimension to report error if unit is missing.
if getDimention###() is called for a string that has no unit,
then an error is output through LayoutLog, but the rendering keeps
going by using dp as a default.
0beb7eea: Make (Bridge)TypedArray.getInteger() call out to getInt()
Only getInt() resolved attribute flags/enum and I'm not sure why
there's two to begin with.
Fix zombie threads in the Layoutlib.
Some widgets can create (indirectly) HandlerThread which are started
but never stopped.
This patch use the delegate methods to override the thread run method
to record which threads are started to be able to call quit() on them
after a render.
Note that we should really fix layoutlib_create to be able to call
the default implementation from a delegate to remove code duplication.
Change-Id: Iaf5432623e9704bb3114a8e0583c8553282c205e
LayoutLib: custom styles override the default style instead of replacing it.
Intead of reading either the custom or the default style for a widget, we
read both and use the values from the custom style if it exists, or
from the default style otherwise.
Change-Id: Ibcec2e9b1e8a95295ab26ede145c287ff2f30be4
LayoutLib: Fix issue where <include> with no layout params wouldn't display.
The issue is that the layout params from the root element of the included
layout should be used but this failed because loading the layout params
from the <include> tag didn't throw a RuntimeException in our modified
code (BridgeTypedArray).
Because we don't want to throw exception in general we only throw it
when reading the layout params of an include node which is pretty crappy,
but works for now.
Change-Id: I83ccf956e8b476f34dfc9a70aebae2288d53746e
LayoutLib: Fix issue with rendering mode.
When the layout content is embedded inside a decor layout
to emulate system bar (top or bottom) and title bar (or action bar)
then the code computing the full required size based on the RenderingMode
would fail because the decor layout would prevents the content layout to
take as much room as possible.
There is also an issue with the way we know render dialogs as the
dialogs usually as a frame with some padding and the previous measurements
would not take into account the dialog padding when increasing the
screen size.
This fix makes the code measure the size of the content layout in the
normal rendering, and then separately from the root layout with the proper
MeasureSpec to let the content grown. The difference in size is then added
to the screen size.
Bug: http://code.google.com/p/android/issues/detail?id=15892
Change-Id: Ie9a6c5e254b16785f817dcb9fae755d4936880aa
When the layout content is embedded inside a decor layout
to emulate system bar (top or bottom) and title bar (or action bar)
then the code computing the full required size based on the RenderingMode
would fail because the decor layout would prevents the content layout to
take as much room as possible.
There is also an issue with the way we know render dialogs as the
dialogs usually as a frame with some padding and the previous measurements
would not take into account the dialog padding when increasing the
screen size.
This fix makes the code measure the size of the content layout in the
normal rendering, and then separately from the root layout with the proper
MeasureSpec to let the content grown. The difference in size is then added
to the screen size.
Bug: http://code.google.com/p/android/issues/detail?id=15892
Change-Id: Ibb9ca2a67c6c450d10d9f9a8050536e094650f8b
LayoutLib: fix Capabilities and getDimensionPixelSize
Commented out a Capability that is not in ADT 10.
BridgeTypedArray.getDimensionPixelSize shouldn't call
getDimension since most of the code is duplicated, and
it prevents use from properly detecting malformed attribute
values.
Change-Id: I008334af605a89f240247a13c0024009247ec5af
LayoutLib: Fix dimension parsing to handle negative value.
Also make TypedArray.getDimensionPixelSize properly
handle negative values (which are not allowed).
Change-Id: I03ffcef5ab7ec7ef95419566776dcc798845fd88
Commented out a Capability that is not in ADT 10.
BridgeTypedArray.getDimensionPixelSize shouldn't call
getDimension since most of the code is duplicated, and
it prevents use from properly detecting malformed attribute
values.
Change-Id: I005b17061590dc0668729af16e896fad815f1973
Also make TypedArray.getDimensionPixelSize properly
handle negative values (which are not allowed).
Change-Id: I960fc1c9e8ad97852d4a14e4f0f71a2c2034b4e7