What Is Happening to Me?

Illustration

Few days ago I wrote instructions for setting-up Android development environment. Since I am mostly known as Windows developer this caused lot of questions in my neighborhood. Here are answers to most common ones and some observations of mine.

1. Yes, I am still C# developer at heart.

2. I still love Windows Mobile. This goes for 6.5. As far as Windows Mobile 7 is concerned, I have my reservations (this is drastic change after all) but it is really hard to comment anything at this time. Most of known limitations and features of that platform are subject to change by the time of launch. Anyhow most of things that bother me are just political decision (e.g. multitasking) and not a real limitation.

3. I do not consider my work in Android as betrayal of my love. While I love Visual Studio and what it does offer, I think that trying other environments can only lead to good things.

4. My phone ratio is 2:1 in favor of Windows Mobile (HP iPAQ 514, HTC S740 and HTC Desire).

5. Exchange ActiveSync is best protocol there is. I am not sure how good it was for Microsoft to allow Google and others to use it in their products but from customer side I must confess it is great decision. It allows all my phones to share same data regardless of their underlying platform and everything gets synchronized by “it-self”.

6. Both Windows Mobile and Android share same hate for letters Đ and đ (latin capital/small letter D with stroke). While I can synchronize existing contacts with this letter, neither of these platforms will allow me to enter this letter via keyboard. When letter is part of your alphabet it gets annoying fast.

7. Yes, I will probably make some comparison of development experience between these platforms in future.

Setting Android Environment

Illustration

Prerequisited

Before we start anything, we need two downloads:

Java SE Development Kit

This one is prerequisite for everything else. Just download it, run it and go wild on “Next”. Installation is as easy as it can be.

Installing Eclipse

Installing Eclipse is as easy as unpacking it. For purpose of this walk-through I will unpack it to root directory of drive D: (eclipse.exe will be located in directory D:\eclipse).

Installing Android SDK

Unpack archive to (D:\eclipse) and run “SDK setup.exe” (from “D:\eclipse\android-sdk-windows\SDK setup.exe”). Location is not set in stone but I like it in subdirectory of eclipse. If you desire some other location, just go for it.

As soon as you start it, it will attempt to download newest repository data. If you are behind proxy, this step will fail. In that case just go to “Settings” and fill proxy server and port fields. Often it is also necessary to check “Force https://… sources to be fetched using http://” for everything to download properly.

Once update is completed, you should get list of packages to install. I just leave it at default, check “Accept All”, and click on “Install”. Brace for lengthy download (around 800 MB for Android 2.2).

ADT Plugin for Eclipse

Once you start Eclipse go to “Help”, “Install new software”. Click “Add” once window opens. Now write “ADT Plugin for Eclipse” under site name (exact naming is not important) and “https://dl-ssl.google.com/android/eclipse/” under location. If your Internet access goes over proxy, you will need to use http location “http://dl.google.com/android/eclipse/”.

When packets are found (“Android DDMS” and “Android Development Tools”) I just select them both and click on “Next”/“I accept …”/“Finish” combo few times and download will start. After restart you need to go to “Window”, “Preferences”. There, under “Android” node, you need to select folder with unpacked Android SDK (in my case “D:\eclipse\android-sdk-windows”). All other things I left as default.

After one more restart (I am not really sure it is necessary) you will be able to create new project under “File”,“New”,“Project”:“Android\Android Project”.

Anything more

As you attempt to start project, you will get prompt to create emulator. If you would like audience as broad as possible, Android 1.6 is reasonable choice. If you want to target only newer devices, 2.1 is one that you should do your testing on. Those are only rule-of-thumb advices - do not take them too seriously.

If you intend to use command-line tools it would be good to add Android SDK tools to path (for me it is under “D:\eclipse\android-sdk-windows\tools”).

It is definitely not as easy as installing Windows Phone Developer Tools but it is not too bad.

Visual Basic 6.0 - Controls

I am preparing to clean my web site and I decided to remove all references to programming source samples. General idea is moving those samples to blog. Here I will start with my old VB 6 controls.

Download is here.

CmnDlg

Substitute for CommonDialog control.

Contain Containter for other controls.

Progress

Replacement for ProgressBar Common Control. Doesn’t use .ocx.

TextComplete

AutoComplete TextBox.

TrayIcon

Enables program icons in tray notification area.

P.S. Rest of old stuff can be found in this post.

Java Rfc2898DeriveBytes

I was creating Java port for one program of mine and I stumbled across little issue. Although C# and Java seem quite different, you can almost always rely on one-for-one feature compatibility. Of course I stumbled across one class that was not implemented in Java. That class was Rfc2898DeriveBytes (.NET PBKDF2 implementation).

To be totally correct, I did found quite a few classes that do implement RFC 2898 but they did not give same result as one I used in .NET. While those implementations were also correct ones, they did not ensure compatibility with my existing code.

.NET Reflector comes here as great debugging tool. Quick peek just discovered that core of .NET Rfc2898DeriveBytes class is HMAC SHA-1 algorithm. GetBytes method has some basic buffer management (data gets generated 20 bytes at time) and call to omnipotent Func method. It is in this method that real crypto-magic happens.

Fortunately, building blocks for this functionality is available to Java. Although syntax is somewhat different, general idea is same. Whole getBytes method needed only changes related to array copying. In .NET we would use Buffer.BlockCopy and in Java this translates perfectly to System.arraycopy. Really hard…

Crypto-core is hidden in function named “func”. Notable spot here is incrementing block counter. In C# this is unsigned int but in Java there is no such thing. That is reason for one extra check.

if (this._block == 2147483647) {
    this._block = -2147483648;
} else {
    this._block += 1;
}

With these few changes done our Java implementation of Rfc2898DeriveBytes was done. Source code can be downloaded here.

Targus Laser Presentation Remote

Illustration

As I prepared my WinDays presentation, I noticed that I was missing one key piece of hardware - wireless presenter. While I could jump back and forth toward my keyboard, I decided to take lazy way out and to buy cheapest presenter that I could find. My choice fell on AMP13EU (AMP13US for U.S.A. market) priced at $50.

First sight was spoiled by indestructible plastic package. It took five bazooka shots to open it half-way. Once I opened it, everything got better - batteries ARE included. As I was inserting batteries inside I noticed that only one battery is really needed. You will get two batteries. There will even be place for two batteries inside, but only one battery has electric contact. Other one just sits in it’s compartment as emergency spare. Great idea.

In between batteries there is one additional compartment with small USB receiver. I am usually nervous about loosing such small USB thingies but place for storage inside of presenter made me feel little bit easier. It is not as comfortable as having bluetooth based one but this at least works with Windows Server 2008.

USB was immediately recognized as “Human Interface Device” and system thought of it as generic keyboard. Previous/Next slide buttons are interpreted by Windows as PageUp/PageDown keys and they can be used in any application. If you are Apple fan, support for KeyNote and PowerPoint keyboard shortcuts is available via small hardware switch.

As buttons go, on top you have standard next and previous slide buttons, start/stop presentation, blank screen and laser pointer. On side there is on/off and lock button. Locking device disables all buttons except next, previous and laser. I do like this mode just because of color changes (yes, I am that shallow :)) but I do not find it particularly useful otherwise. Buttons are spaced quite nicely so there is little if no chance of accidental key presses.

Front of device is polished black (a.k.a. as shade that attracts fingerprints) while background is rigged. While I prefer gummy finish myself I also must admit that device wasn’t slippery even in wet hands.

I am not sure about official range for device but it seems to be quite large. During my presentations I moved something like 10 meters from computer and it was still working. I do not think that I need more than that.

Only real problem I had with device is turning it off since you must press on/off button for couple of seconds. Since there is no visual feedback on “shutdown” status this usually results in more than one attempt.

Device did it’s job and I must recommend it for that. There are no advanced features (e.g. mouse control) so I am not sure whether it will be good fit for advanced presenter but for me it is more that enough. And, if they added storage “baggie” in packing it would be near to perfect.

P.S. If you are not interested in laser pointer or any other feature except for next/previous slide, AMP18EU (or AMP12US) has pretty much same features while being slightly cheaper.