385 Commits

Author SHA1 Message Date
Xavier Ducrohet
9223b6737c Layoutlib: support for editing embedded layouts.
When Resources.getLayout(int) is called to return a parser
for an embedded layout, this queries the current parser for
a custom parser (Eclipse will provide one on top of the current
XML model being edited)

Change-Id: Ia9e837358f67daed0a835e1b3f4f50c0516ceee9
2010-11-19 16:17:27 -08:00
Xavier Ducrohet
fb25cae191 LayoutLib: use the new expand API.
Change-Id: I248de70ebe97aa6fb1cbcb5b6572a4a46c5ca1ba
2010-11-19 14:27:37 -08:00
Xavier Ducrohet
d73868859b LayoutLib: fix some tests
Change-Id: Iacd641e2fac663ff12fe2a08ba093c4eaa2e8862
2010-11-19 12:53:20 -08:00
Xavier Ducrohet
55acd60be3 Layoutlib: support viewkey in include nodes.
When an include tag is parsed, the custom bridge
code never has access to both parsers at the same
time.
The child parser is created out of an in (representing
the layout id), and the code inflating the content of
the include layout doesn't see the parent parser either.

This changeset adds a parser stack in the BridgeContext
in order to allow access to the parent parser when setting
the viewkey. This is only used if the current parser depth
is 1 (top node), as we only want to set the include
node to the top node of the included layout.

Change-Id: I2ac3b72a0c84a269d9019f44f98cbc0b615ab959
2010-11-18 22:17:14 -08:00
Xavier Ducrohet
755b46d597 Layoutlib: use int[] wrapper to use as map keys.
This fixes the SlidingDrawer that failed to load.

For some reason, in case of the SlidingDrawer, when the constructor
uses android.R.styleable.SlidingDrawer it's the same values but not
the same instance as the array read from android.R through reflection.

So what works for all other widgets, and has worked since the very first
layoutlib isn't working anymore, and we'll now have to use a wrapper
similarly to what we use in ADT in the project callback.

We should probably provide a single int[] wrapper class in layoutlib
API for all to use.

Change-Id: I4d7d038540f8a24541a588696f1059a020b589e5
2010-11-18 19:51:30 -08:00
Xavier Ducrohet
5a09488a15 Layoutlib: Properly dispose of bitmap delegate.
This is done by initializing the android.util.Finalizers that's
reponsible for calling out to the native bitmap destructor.
Also implemented the native bitmap destructor

Also fix Bridge by removing obsolete API methods, and removing
some unneeded synchronized blocks now that the whole rendering
(and scene creation) is protected by a synchronized on the bridge
object anyway.

Change-Id: Ie1792da6db354836542dfc11f457fe4a6d78ddfb
2010-11-18 18:26:55 -08:00
Xavier Ducrohet
4d9e32f07c Layoutlib: support XML based ColorStateList.
This fixes the rendering of the TabHost in Eclipse.

Change-Id: I333c4d65b18df76871e24a04f0a888ae42ba40ef
2010-11-17 18:26:04 -08:00
Xavier Ducrohet
9e27936e4a Layoutlib: Fix alpha support in Canvas/Paint.
Change-Id: I359098cfc542a7a0b7d99478c0eb13587b4439d0
2010-11-12 14:20:45 -08:00
Xavier Ducrohet
cf52390eee Layoutlib: Fill the default prop value map for View objects.
Change-Id: I35426ced17a10eb092fac2153276f1202692876f
2010-11-12 14:02:49 -08:00
Tor Norbye
135f80dcb4 Fix fill color alpha in layoutlib
new Color(int) ignores the upper 8 bits - it creates a color without
an alpha channel.  In order to pass in rgba we have to use a different
constructor, new Color(int,true).

(In the layout library API we should also specify that the custom
color, if specified, needs to include an alpha, or in particular add
in 0xFF<<24 if the color is opaque.)

Change-Id: I1c44caed8a5780e61b1c799f3b45bef3eb7bc97b
2010-11-11 21:59:23 -08:00
Xavier Ducrohet
071dee288c Misc fix in layoutlib bridge + View.isIneditMode as delegate.
Change-Id: Ideab29167e933203da99d4270cebcb777726201f
2010-11-11 17:39:50 -08:00
Xavier Ducrohet
c2e9651bf3 Layoutlib: New bridge implementation using the new API 5.
Since the new API prepare for stateful layoutlib, major
reorganization of the code.

New "android" sub-package for all extended android classes.
  Also moved BridgeInflater in here so that all extended classes
  are in this package. Only delegates and classes replacing
  renamed classes are in their original android.* packages.
  Also created full file for the empty implementations of
  IWindow and IWindowSession.
New "impl" for the dirty work implementation.
Main package contains the basic implementation of the API.

Most of the code that was in Bridge is now in .impl.LayoutSceneImpl,
with the main init/inflate/render code split into the contrustrutor,
inflate() and render().

Change-Id: Ie15b15e5a1b2388cd6ef82e518345b1fc02ec981
2010-11-11 10:08:19 -08:00
Xavier Ducrohet
7f77524395 Layoutlib: Load fragments
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
2010-11-08 18:38:12 -08:00
Xavier Ducrohet
e0c763f54f Layoutlib: more text drawing.
Change-Id: I32f46d23e746b095be0577a53b61567a868f0b8a
2010-11-08 16:13:28 -08:00
Xavier Ducrohet
9c05b39728 Layoutlib native delegate: FloatMath.
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
2010-11-03 19:15:07 -07:00
Xavier Ducrohet
4b606da91d Layoutlib native delegate: path effects and xfermode.
Change-Id: Iafaac6dbaf452e2dba3e77c801089dad33ac4ea9
2010-11-03 19:15:07 -07:00
Xavier Ducrohet
251d2e9924 Layoutlib native delegate: primitive shapes and shaders
Change-Id: Id2b0c6231589e82d8e96c9f019042eba348a6583
2010-11-03 13:23:22 -07:00
Xavier Ducrohet
abff653ce8 More layout Canvas/Paint implementation.
Change-Id: Ib3da4a4b2259dc7c53b24444b5c0b78cee15d387
2010-11-01 18:45:20 -07:00
Xavier Ducrohet
5802deabf0 More implementation of the layoutlib Paint/Canvas delegates.
Change-Id: I0c0029b9a679af4ae0178488f70b2a90292ea42d
2010-11-01 17:52:42 -07:00
Xavier Ducrohet
9f63ff263b Layoutlib Canvas and Paint implementation through native delegates
Also fix native delegate generation to put "this" parameter even
for methods that don't have any parameters.

Change-Id: I5dd0c505871370ff7b4cda16de84a5b3ae438f73
2010-11-01 13:31:47 -07:00
Xavier Ducrohet
5de11a18e9 Implement the layoutlib Bitmap through a native delegate.
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
2010-10-29 16:01:40 -07:00
Xavier Ducrohet
65dc3974a1 Fix the layoutlib_bridge .classpath to not use the full layoutlib
Instead this uses the actual output of layoutlib_create, which is
all the modified classes before the content of the bridge is added
to form layoutlib.

Change-Id: I22755f38800cd69206834ff9594a99cb0c1d2139
2010-10-27 18:22:03 -07:00
Xavier Ducrohet
5e7ed8da0d Move layoutlib typeface implementation to delegate.
Also move BridgeContentProvider to its own class to make it
less messy in BridgeContentResolver.

Change-Id: Id3462218b500d43d4c9b20b25326ad24e4106fa5
2010-10-27 18:12:27 -07:00
Xavier Ducrohet
4c9d691a01 am 57f7ccc4: am 63e5d07e: Merge "Fix issue with project resources overriding framework resources." into gingerbread 2010-10-27 11:59:05 -07:00
Xavier Ducrohet
57f7ccc422 am 63e5d07e: Merge "Fix issue with project resources overriding framework resources." into gingerbread 2010-10-27 11:23:58 -07:00
Xavier Ducrohet
4f291d33e1 Reimplement the native matrix method using the new delegate way.
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
2010-10-27 09:55:58 -07:00
Xavier Ducrohet
c2e28dd748 Fix issue with project resources overriding framework resources.
Framework resources loaded through Drawable.createFromXml could
be overriden by project resources if there were loaded through
a  state list drawable where the final resource name was used
by a project resource (of the same type).

This ensures that the XML parser knows that it's a framework
resource being parsed and that the resource resolution uses
that information.

Change-Id: I39cf9eba755e55f1604b968637aeecff969a558d
2010-10-26 17:14:55 -07:00
Xavier Ducrohet
d815e37048 Fix rendering of digitalClock/Gallery in Eclipse editors.
Change-Id: Iedcd3184cd9f34be8d0695a51eda953ac68683ce
2010-10-26 14:29:23 -07:00
Raphael
f241c40476 Revert "Fix rendering of digitalClock/Gallery in Eclipse editors."
This reverts commit 25e96ce7b99f9736a6024d25bd65a83774c7640f.
2010-10-26 13:55:10 -07:00
Xavier Ducrohet
68404a0125 am a44a5e02: am 1b6180ec: Merge "Fix rendering of digitalClock/Gallery in Eclipse editors." into gingerbread 2010-10-26 12:13:32 -07:00
Xavier Ducrohet
a44a5e02d2 am 1b6180ec: Merge "Fix rendering of digitalClock/Gallery in Eclipse editors." into gingerbread 2010-10-26 12:10:28 -07:00
Xavier Ducrohet
25e96ce7b9 Fix rendering of digitalClock/Gallery in Eclipse editors.
Change-Id: I80f4f90b173529632eaf2fbc3bb5471b7ede8216
2010-10-26 11:18:39 -07:00
Xavier Ducrohet
a6ca66af0c Merge "Layoutlib_Create: Fix order of class adapters." 2010-10-22 15:42:40 -07:00
Xavier Ducrohet
c08e175f14 Merge "Layoutlib_create: fix binary name of delegate methods." 2010-10-22 15:42:26 -07:00
Raphael
e2e8ba904b Layoutlib_Create: Fix order of class adapters.
The Transform adapter was running last, instead of
running on the output of the Delegate adapter.

Change-Id: I2cd777add7b0972c6bb197aaac6693d39dd5a103
2010-10-22 15:29:04 -07:00
Xavier Ducrohet
2191b4b22f Merge "Remove dependency on ASM util classes." 2010-10-22 14:03:07 -07:00
Raphael
280372e2c7 Layoutlib_create: fix binary name of delegate methods.
Change-Id: Iebd7d730b23e12f770e6ecadafb2f5c3459958db
2010-10-22 13:58:31 -07:00
Xavier Ducrohet
ee9642c2ba am 2051a1be: am c5371fad: Merge "Make layoutlib use the prebuilt of layoutlib_api" 2010-10-22 13:41:08 -07:00
Xavier Ducrohet
2051a1be52 am c5371fad: Merge "Make layoutlib use the prebuilt of layoutlib_api" 2010-10-22 13:38:58 -07:00
Raphael
d556d8ba36 Remove dependency on ASM util classes.
Change-Id: I975b103f8c207e727699e4135170755f6ba2a084
2010-10-22 13:33:50 -07:00
Xavier Ducrohet
0db3844925 Make layoutlib use the prebuilt of layoutlib_api
Change-Id: Ie04a9e847acacf7b2aeb179589517fc75688c75b
2010-10-21 18:32:37 -07:00
Chris Tate
d4533f1469 Report drag success/fail in the DRAG_ENDED message
DragEvent.getResult() returns 'true' if the drop was ultimately accepted;
false otherwise.  The validity of this datum is only guaranteed when the
DragEvent's action verb is ACTION_DRAG_ENDED.

Also fixes the drag-start timeout handling (though the offending app is
not yet officially declared ANR).

Implements bug 3097807

Change-Id: I6908ac628c72ff7d6193d87060d769a559a78d0e
2010-10-21 14:25:06 -07:00
Xavier Ducrohet
79d433dd87 am 556866a2: am 656d2165: Merge "Parser is optional in obtainStyledAttributes." into gingerbread
Merge commit '556866a2ea1f4758a79fe4f207153b71815ed400'

* commit '556866a2ea1f4758a79fe4f207153b71815ed400':
  Parser is optional in obtainStyledAttributes.
2010-10-08 17:59:13 -07:00
Xavier Ducrohet
556866a2ea am 656d2165: Merge "Parser is optional in obtainStyledAttributes." into gingerbread
Merge commit '656d21656ad9b33f7d7e1e4960a2f03076a5fc7a' into gingerbread-plus-aosp

* commit '656d21656ad9b33f7d7e1e4960a2f03076a5fc7a':
  Parser is optional in obtainStyledAttributes.
2010-10-07 07:16:51 -07:00
Xavier Ducrohet
f8e4c1f57b Parser is optional in obtainStyledAttributes.
If the parser is null it just means the default style/values are
used.

Change-Id: I5ff3d632fd5dfc5a1ce42796b2fef7b30f9fbf34
2010-10-04 18:11:50 -07:00
Raphael
3cff14ca77 Merge "layoutlib_create: Generate delegate to implement native methods." 2010-10-04 12:46:37 -07:00
Christopher Tate
a53146c556 Drag/drop APIs and infrastructure
A View initiates a drag-and-drop operation (hereafter just called a "drag")
by calling its startDrag(ClipData) method.  Within the processing of that
call, two callbacks are made into the originating View.  The first is to
onMeasureDragThumbnail().  Similarly to the core onMeasure() method, this
callback must respond by calling setDragThumbnailDimension(width, height) to
declare the size of the drag thumbnail image that should be used.  Following
this, the View's onDrawDragThumbnail(canvas) method will be invoked to
actually produce the bits of the thumbnail image.

If all goes well, startDrag() will return 'true', and the drag is off and
running.  (The other arguments to startDrag() provide reconciliation between
the current finger position and where the thumbnail should be placed on
the screen relative to it.)

Potential receipients of the ClipData behind the drag are notified by a
new dispatch mechanism, roughly parallel to motion event dispatch.  The core
routine is the View's onDragEvent(event) callback, with the mechanics of
dispatch itself being routed through dispatchDragEvent(event) -- as in
the case of motion events, the dispatch logic is in ViewGroup, with leaf
View objects not needing to consider the dispatch flow.

Several different event 'actions' are delivered through this dispatch
mechanism:

ACTION_DRAG_STARTED: this event is propagated to every View in every window
(including windows created during the course of a drag).  It serves as a
global notification that a drag has started with a payload whose matching
ClipDescription is supplied with the event.  A View that is prepared to
consume the data described in this event should return 'true' from their
onDragEvent() method, and ideally will also make some visible on-screen
indication that they are a potential target of the drop.

ACTION_DRAG_ENTERED: this event is sent once when the drag point
enters the View's bounds.  It is an opportunity for the View to set up
feedback that they are the one who will see the drop if the finger goes
up now.

ACTION_DRAG_LOCATION: when the drag point is over a given View, that
View will receive a stream of DRAG_LOCATION events, providing an
opportunity for the View to show visual feedback tied to the drag point.

ACTION_DRAG_EXITED: like DRAG_ENTERED, but called when the drag point
leaves the View's bounds.  The View should undo any visuals meant to
emphasize their being the hovered-over target.

ACTION_DROP: when the drag ends at a given point, the View under that
point is sent this event, with the full ClipData of the payload.

ACTION_DRAG_ENDED: paralleling the DRAG_STARTED action, this is the global
broadcast that the drag has ended and all Views should return to their
normal visual state.  This happens after the DROP event.

Change-Id: Ia8d0fb1516bce8c735d87ffd101af0976d7e84b6
2010-09-30 16:29:07 -07:00
Raphael
bc10180624 layoutlib_create: Generate delegate to implement native methods.
- 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
2010-09-29 14:45:20 -07:00
Ying Wang
1e57996f47 am 0e8dc464: am 292c246b: Merge "Call functions to calculate deps and classes.jar" into gingerbread
Merge commit '0e8dc464bdfa29785aab7be6343154fee361f6a0'

* commit '0e8dc464bdfa29785aab7be6343154fee361f6a0':
  Call functions to calculate deps and classes.jar
2010-09-28 17:38:19 -07:00
Ying Wang
0e8dc464bd am 292c246b: Merge "Call functions to calculate deps and classes.jar" into gingerbread
Merge commit '292c246b27319bc2195e2b3dbc3c3adea22db672' into gingerbread-plus-aosp

* commit '292c246b27319bc2195e2b3dbc3c3adea22db672':
  Call functions to calculate deps and classes.jar
2010-09-28 15:09:49 -07:00