This include a fix in layoutlib_create to properly handle
delegating a static method of an inner class (was broken and
only worked on non static method).
Added a few comments here and there to *_Accessor classes so
that it's a bit more obvious what they are for and how they are
used.
Change-Id: Ifc31dd1a006393bb0c08e22b6a17f500dd62e090
We had replaced the accessibility Manager but it lacked some new API. Obvisouly
this is fragile and should be fixed, but this works for now.
After fixing this there was another issue with the lack of InputMethodManager.
To fix this I had to create an implementation of IInputMethodManager which
normally comes from a binder object.
I may want to do a similar trick with the accessibility manager later.
Change-Id: I28c6494e333f39072f348d0199124efac93256a5
This allows ViewConfiguration to be properly implemented which is now
required for the rendering to happen.
Change-Id: I55629689fa8f5f874b43fcac2aa0789ce02d58f4
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
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: 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
When generating delegates, LayoutLib.Create support renaming
inner classes. Only one level of inner class is supported.
The method Outer$Inner#get(...) generates a call to:
static Outer_Inner_Delegate#get(Outer instance, Outer$Inner instance, ...)
Change-Id: Ie70f2b8e5e5f311ed9c7f26b7f64637ae6157a51
android.os.Build is now initialized from the build properties
parsed from the SDK build.prop file.
Change-Id: If16953215ca90fb0beacb51bf405b89a5c8a34fa
All items directly under the <merge> tag now return the view cookie
of the referencing <include> tag using a special class for
easy differentiation in the calling client.
Change-Id: I7a2a4e642be9564f47e256fd1586012497d34792
It looks like the device implementation of Integer.parseInt
is able to handle converting hexa value > 80000000 while the
desktop VM cannot.
This patch provide a fix for this.
While implementing it and running the TestDegates test I realized
that some delegate methods for Region were mising, so this adds them
too.
Change-Id: Ifee1efd47c8c52adc2f4658ec4fc8bd55adb84b4
DrawFilter, Rasterizer, ColorFilter and MaskFilter
are not supported but we need to provide their
JNI counterparts anyway, to at least display warnings
when they are used.
Also improved the API to query Paint for Shaders
and PathEffects, and clean up some code by
moving asserts into the DelegateManager.
Change-Id: I8942514565d28576d5608c6373bda25d86d42ff2
Also created delegates for all missing shader, xfermode
and patheffect classes. Moved the logic of the xfermode,
and patheffects that was in Canvas_Delegate into the
xfermode/patheffect classes, and added support (in all
3 clases) for knowing if the shader/xfermode/patheffect
is actually supported or not. Make use of fidelityWarning
in LayoutLog if they are not.
New locking mechanims to prevent concurrent renderings.
There's now a thread specific prepareThread() method (only
prepares the looper) and its associated cleanupThread().
For the rendering itself, acquire must be called before doing
any type of Android specific work on the scene (inflate or rendering)
After instantiation, init() must be called, which also acts as acquire.
Added a lot of checks to make sure method aren't called without
acquire or if scenes try to be rendered while acquire was called
from the same thread but on another scene.
Animation implementation:
- Handler delegate to use our own queue (since the animation runs
through handler messages). This uses a callback to process
the message. This callback is per-thread and only used in
animation threads.
- SystemClock delegate to provide clock implementation.
- AnimationThread to handle playing the animation and calling back
to the animation listener.
Change-Id: Ia39aba7ed476759df1da3200e413fe3e92590d15
Move away from using our own implementation of NinePatchDrawable.
Now use native delegate for a few methods of NinePatch.
The byte[] used to describe the 9-patch chunk is entirely controlled
by the delegate. Therefore, while the default version (JNI) use the
array as a representation of a C struct, this version uses the array
as a serialized version of NinePatchChunk.
A cache mechanism using SoftReferences allows us to not deserialize
the array every time rendering needs to access the chunk itself.
The Bridge-level cache mechanism for bitmaps and nine-patches as
changed. Since the new nine-patches doesn't hold the bitmap
data anymore (it's stored in a normal Android bitmap which
is cached itself through the cache), then the nine-patch cache
has been changed to only contain the nine patch chunk.
Also initialize the canvas with the display metrics to prepare
for correct scaling when density of the assets don't match the target
density.
Still to come: actual density support in the 9-patch drawing code.
Change-Id: Ibefcccf4432e1986e8436e0c41a0107741593536
This change does the following:
- Make the bridge context extend Activity instead of Context
so that it can act as a view factory. This is needed because
the Activity is used as factory for Fragment objects.
- Override the default Fragment.instantiate(...) method
through a delegate. This is done to load the Fragment
classes located in the project (similar to custom views).
Change-Id: If62e7c9ff2b7585677077ad825aa1c3591d1b5e0
While the difference is pretty minor since it's a small class,
the point is that the unit test will ensure that we detect
new methods added to FloatMath more easily.
Change-Id: Ia8bfee231cc4ae0cfeb18692be86d02649c187d5
Also fix native delegate generation to put "this" parameter even
for methods that don't have any parameters.
Change-Id: I5dd0c505871370ff7b4cda16de84a5b3ae438f73
This does not implement all the native methods of the
android.graphics.Bitmap class, only what's needed to draw an
ImageView object. The rest will be implemented after Canvas and
Paint have been moved to the native delegate.
Change-Id: Ia0c3b2cafa03871c298deaef5817a25ac1c35521
Instead of renaming the old Matrix class into _Original_Matrix
and have layoutlib provide a full new implementation of Matrix,
we keep the old one by only modifying it to implement the native
methods which calls out to a new Matrix_Delegate class.
The goal is to not have to maintain the java portion in
sync between the framework and the layoutlib version.
Change-Id: I3e1aefffbae45e91b75331c0c6ff2260323deacd
- Some new parameters are added to CreateInfo with the list of methods
or classes to override with delegates.
- DelegateClassAdapter and DelegateMethodAdapter do the work... see javadoc.
Change-Id: I0657cd929837181d81c65db7051d8ccbdc59c741