drawColorTest

What it should look like.

This is a test app with source to hopefully help debug a problem I'm having on ICS tablets.

Below please find the test apk and a separate source code zip archive for the app's source code.

Explanation:

My app Wave Toy uses an Android surfaceView for drawing (while making sounds) and it uses the Canvas method drawColor() to paint a very low alpha black color over everything on the screen each frame. In Froyo and Gingerbread this does a pretty good job of fading out the colors drawn when the user touches the screen.

However, for a couple of new ICS tablets I've gotten reports from QA that the method above doesn't fade the touch point graphics to black as intended.

By installing and running testdc.apk below, one may be able to see a difference between Froyo/Gingerbread tablets and ICS tablets with the starting settings:

color=BLACK

fade method = drawColor()

alpha for fade color = 1 (yes, very low!)

If that works on Froyo/Gingerbread but fails (i.e. doesn't fade out the moving blue circle), then perhaps I need to change the fade method. One idea is to try:

color=BLACK

fade method = drawRect() using PorterDuff SRC_OVER Xfer mode

alpha for fade color = 8 (likely will fade more quickly than 1, unfortunately)

I wonder if that would work on all OS versions??

What's going on?

I'm not sure... The original drawColor() method works for me on my Gingerbread hardware and works (albeit slowly) on all the ICS emulators (AVDs) I've created and tested.

Possibilites:

- perhaps the fact that ICS uses hardwareAcceleration of true by default, and I've read that some Canvas based graphics may be corrupted by that

- the drawColor() method is hacky and I just got lucky that it worked on Froyo and Gingerbread

- there's a another bug in my code somewhere and drawColor() has nothing to do with the touchpoint graphics not fading.

- something else I'm not thinking of

Anyway, thanks for trying the test app!

- Patrick

About the files below:

- all 3 APKs are built against Android API 15 with a minSdkVersion of 8 (Froyo)

- testdc_orig.apk leaves the hardwareAccelerated tag out of the manifest (so on ICS devices hardwareAcceleration will be used by default I think)

- testdc_hwxfalse.apk has hardwareAccelerated set to false in the manifest

- testdc_hwxtrue.apk has hardwareAccelerated set to true in the manifest

- drawColorTest_src is an Eclipse Project with source code for the test app (including a fix for the brain-dead bug I managed to leave in the earlier version -- was setting alpha to 1 for the alpha=8 button... Always seem to do this when I copy-paste code...)