вторник, 30 сентября 2008 г.

Trap

OK, I'm getting in this trap over and over again.
I think I need big sign in front of me, saying:
"Even when you have source code, reimplementing can be better option then porting. First estimate then start working."

PS. I parsed AndroidManifest.xml and resolved MAIN activity, but I'm having problems in putting it all together.

вторник, 23 сентября 2008 г.

Stub!

Wow, android.jar cut down to 2737Kb (from 11Mb).
How did they do it?

They just throw new RuntimeException("Stub!")!

Oh well. Back to work with 0.9.

PS. Hope they eventually release that beautiful, 'Stubbizing' tool :)

New SDK

Hooray, new SDK!
I hope they didn't change much...

Windowing

Windowing in Android is too complex to just "port" it, I mean, get source, hack it here and there, and voila. No voila for me. I need to re-implement it. Ohh.

понедельник, 22 сентября 2008 г.

Exceptions and nulls

Argh, I'm irritated at Android's inconsistency when dealing with errors.
Consider loading a drawable (bitmap).
If you load bitmap by yourself via BitmapFactory.decodeFile, you will get null in case of error.
If you load bitmap drawable via Resources.getDrawable, and there is a problem, you will get NotFoundException with nested IOException.
You can also load via Drawable.createFromPath, and you will again get Drawable or null.

I will add 'Throw' versions of some functions (decodeFileThrow) that will throw exceptions.

System resources

There are many references to android.R class which represents system resources, so for Android4ME we would need 'stripped down' version of system resources (it would not be hard, thanks for lib/res folder). I am thinking of taking drawables for controls from M3 release, as our target resolution is 240x320.

пятница, 19 сентября 2008 г.

!

My head is boiling - I'm trying to understand how activity is created & managed, what is the difference between Window and IWindow, WindowManager & IWindowManager, where Window comes from, and how to emulate all that.

This is no piece of cake.

четверг, 18 сентября 2008 г.

News

Ohh, it's been 6 days again.
The news:
  • I moved my test project from WTK+EclipseME to microemulator. It offers good compromise between developing with J2ME classes and having J2SE classes. So I don't need to hack'n'port SE classes from javolution and harmony in order to do actual porting of Android's classes.
  • I'm slowly implementing AssetManager class. Today I discovered that Resource.Theme have that applyStyle method which allows you to apply many styles to theme. Now I need to implement that.
  • I implemented Resources.obtainStyledAttributes method. It correctly obtains attributes, first from parser, then from style(s).
  • Also, I'm not alone again. Guna, who wished to participate from the day one, showed up again.

пятница, 12 сентября 2008 г.

Puzzle

Here is a puzzle:

It is said that when you obtainStyledAttributes(AttributeSet...) and you have attribute defined in xml - you will get that attribute (not from style, not from theme).
And later you can peekValue on returned TypedArray. And you can check type of that value.

But where did type come from? There is no method in AttributeSet, which returns type.



Hint: try suppliyng your own AttributeSet implementation in obtainStyledAttributes.

1 month!

One month ago I started a topic about porting Android to J2ME in android-developers group.
Originally I didn't want to work on this alone, so I started a topic to find more enthusiasts. Several people responded, so I started to look into ways to port more closely. Unfortunately all those participant soon lose their interest. But I didn't! So I'm working on this alone.
Progress is as follows:
  • Binary xml & arsc files reversed & parsers for them are written
  • Started implementation of AssetManager & Resources classes
  • Nine-patch png chunk reversed, parser written, drawing code implemented
  • Started implementation of Canvas, Paint, Bitmap & Typeface classes
  • Subset of J2SE classes are ported from javolution
  • Possibility of using retroweaver to bring Java 5 features investigated (too many effort needed, left for future)
Hmm, quite alot things are done :)

вторник, 9 сентября 2008 г.

First 9-patch drawable is drawn!

We all love screenshots!
Here you can see 9-patch drawable parsed and drawn.
Code draws image from raw image data and uses drawRGB function (which I took from microemulator), so porting to J2ME is no problem.
Still, I dont know how to scale 9-patches down. The drawable shown has only 2x2 scalability area, so you just can't scale it down beyond [width-2]x[height-2]. I didn't try to scale down in emulator, though. It well may be impossible.

воскресенье, 7 сентября 2008 г.

Status...

Wow, it's been 5 days!

OK, progress is as follows: I am implementing content.res & graphics classes. Yes, in parallel.
I've discovered and partly reversed that npTc PNG chunk, which holds nine patch information.
I've also finished reversing AXML. I am updating AxmlResourceParser now. So now I have only one value that I don't understand - that 0x00140014 flag(?) in START_TAG entry.

среда, 3 сентября 2008 г.

<attr> format types

For some reason, Android's documentation about <attr> values is so poor.
I had to look into aapt.exe to find that you can specify these strings as format attribute value:
  • reference
  • string
  • integer
  • boolean
  • color
  • float
  • dimension
  • fraction
Also, did you know you can specify <enum> inside <attr> to specify set of values?
I will continue investigating this...

UPD: You can specify multiple format values!
Behold: <attr name="test" format="reference|color|fraction"/>

UPD2:You can specify two more attributes: l10n (localization) and type. Their values are ignored though (for now?).

UPD3: You can exclusively specify:
  • min & max attributes
  • enum child tags
  • flags child tags
Although specifying min:max attributes with enum or flag child tags does not result in error, child tags are simply ignored.

UPD4: Min:max values are not checked when specifying attribute value. Also, min can be larger than max. Not implemented, I guess.

понедельник, 1 сентября 2008 г.

Java 5 for J2ME

I'm thinking of starting new project, se4me (name can change) which will provide Java 5 library & features to J2ME users.