Login Register

Android and gfx

I've been happily learning and using gfx on Linux and Windows on various browsers. Even fired up my ipod Touch and with 1.2 RC2 it works. Even gets events on shapes in a canvas.

So I went and ordered the Android based Tmobile G1. It's browser is based on webkit, much like chrome. Chrome has no problem with dojox gfx. So everything should be cool right?

Well, I later fired up the android SDK which has the same browser that the phone will have. To my shock and horror, there's no SVG support.

The really cool graphics stuff I've been playing around with in dojo just gives me a blank space in android.

I very much agree with Jon Ferraiolo's article here: http://svgopen.org/2008/papers/63-How_Ajax_Changes_the_Game_for_SVG/

This project is very important for a lot of reasons.

Is there anything we can do to make this work on Android?

Obviously the mobile market

Obviously the mobile market is very important for everybody involved, and we are committed to support it. Even if its market share is small compared with desktop applications, it will be huge in the future. That's why we watch carefully iPhone/iPod and update our code to detect and utilized them correctly. We hope that Android will be as important player as iPhone is/will be.

Having said that we are restricted by what's offered by vendors, in this case it is Google and Android's community. Probably it is worth to check if G1 supports Canvas. If it does we need to update our graphics detection code. If you want to play with it, take a look at dojox/gfx.js code that governs it. Basically it parses the gfxRenderer string and tries each renderer until it finds the supported combination. The example on how to specify it in djConfig can be found in dojox/gfx/tests/test_gfx.html. The default is specified in dojox/gfx.js. Let me know when/if you tested it, and have some results.

Thank you for the response.

Thank you for the response.

It looks like switching to canvas enabled Android to render. Any chance that code could be added to the gfx.js to do that automatically for Android? Possibly before 1.2 release? The Android user-agent is "Mozilla/5.0 (Linux; U; Android 1.0; en-us; generic) AppleWebKit/525.10+ (KHTML, like Gecko) Version/3.0.4 Mobile Safari/523.12.2"
Not sure if that helps to decide which renderer to call.

Does canvas support the same event model that the svg renderer does? In a desktop browser and ipod Touch, (firmware 2.1) I'm able to add images and have click events with them. This isn't working with canvas on the Android SDK.

No, Canvas has a totally

No, Canvas has a totally different model — the procedural API vs. the scene graph API. Presently it doesn't support text (not every vendor implemented it yet), and no events.

I added the Android

I added the Android detection to the gfx. Please re-test with the trunk.

That worked. Thanks! Android

That worked. Thanks!
Android selected canvas.

Should I be able to connect events to a surface (not shape or image) using canvas? If not that, then maybe the container div?

The container div is the

The container div is the best choice for now.

I gave it a shot with the

I gave it a shot with the div yesterday. Quite difficult to implement.

Seems that relative x/y positioning on the mouseevent object is not a standard thing. Does dojo provide anything to help with this?

dojo.coords(),

dojo.coords(), dojo.contentBox(), dojo.marginBox() from the base can help with calculations in absolute coordinates.

That's unfortunate because I

That's unfortunate because I really liked the idea of connecting shapes to events without having to do the math on events against the parent surface myself. However, the rendering of shapes and Images to a canvas as a fallback is still extremely useful.