Interesting post on Hungarian Notation and its (mis)uses

An excellent article on hungarian notation – how it is used, misused and often misunderstood.

http://www.joelonsoftware.com/articles/Wrong.html

I particularly like the idea of using hungarian notation for tracking a strings safety, i.e.

//unsafe string from user so mark as unsafe ('us')
 String usDesc = form.getDescription();
...
//sanitising the string so mark as safe ('s')
String sDesc = sanitiseString(usString);
Posted in Programming | Tagged , | Leave a comment

Some Amazing Pictures of the Chilean Volcano

I was recently grounded in Launceston Tasmania for over a week due to the Chilean volcanic eruptions.

Luckily I had taken out travel insurance (to reduce my excess on the hire car) so I was laughing… a week of hiking and winery tours rather than work was a welcome rest.

Meanwhile on the other side of the world, there was some incredible images being taken of the eruptions (courtesy Routers).

In comparison, Tasmania had brilliant weather, not showing any sign that flights were grounded (Photos taken on my Desire HD).

Posted in Uncategorized | Tagged , , | Leave a comment

The Annus Horribilis for Sony

There isn’t a tech company more hated by the hacker community than Sony it seems, a string of major security breaches – first the PSN hack which exposed millions of users personal information. Following that Qriocity suffered the same, racking up 77 million accounts compromised. The latest word is that the 3.61 firmware update for ps3 is overheating older consoles, and a rep from inside Rockstar announced that during testing their new game LA Noire they have noticed older ‘fat’ PS3 60GB and 80GB models shutting themselves down after as little as 30 minutes play. This has only been noticed on the consoles running 3.61 and on multiple (rockstar and non rockstar) games.

“At this time we are recommending contacting Sony directly to report the overheating issue. However, this is not the end of our support; we are continuing to test L.A. Noire on all firmware versions and hardware models to isolate the issues and see what can be done. As always, we will update this article as soon as we have updates.”

The article has subsequently disappeared and rockstar have published the usual boilerplate (most probably co-written by the Sony legal team) claiming there was no problem and the representatives opinion did not reflect that of Rockstar.

On one hand, the fact is, these consoles are pretty old, and due to regulations around the lead content of solder, they just don’t last like the older consoles as the lead free solder is known to be brittle. Coupled with the alarmist nature of many outspoken internet denizens who tend to look for a conspiracy under every stone, means things like this very quickly get blown out of proportion. The update features changelog seems to indicate all changes are solely security related so you’d think that it would have little impact on the system.

On the other, Sony, and in particular, their playstations have had a very sketchy build quality history. At last count I believe I went through 4 PS1 consoles (luckily all within warranty) with the last one still chugging along last I heard, being donated to a cousin. I also remember how prone the PSone slim consoles were to overheating after a couple of hours of play too. I’d like to see Sony produce some proof, or a rational, honest dissection of the rumours rather than legalese boilerplate.

I’ve found my 60GB PS3 has been hanging, lagging and running hot since the update. While that could well be coincidence, taking into account my experience with Sony and their build quality, I’m inclined to believe the Rockstar rep was onto something. Covering up something like this is going to just exacerbate customers distrust of the company and while I’m sure they want to avoid any further bad press, covering it up with ‘no comment’ or, even worse ‘everything is fine’ press releases can only be bad.

Posted in ps3, Uncategorized | Tagged , , | Leave a comment

Desire HD 2.3 update – OTA update being rolled out!

Finally we are seeing the OTA update for the Desire HD being rolled out. Going off comments, it seems to be only to a small segment of the population so far:-

http://androidcommunity.com/htc-desire-hd-and-incredible-s-android-2-3-gingerbread-going-ota-now-20110504/

With any luck, everyone else shouldn’t be too far behind!

Posted in Desire HD | Tagged , , | Leave a comment

New Exhibit at GoMA – 21st Century: Art in the First Decade

I’m not usually a fan of modern art, but this was certainly a fun day. We went expecting to burn an hour or two – three hours later and we were just leaving the first table…. the reason? It was a MASSIVE lego table. Piles and piles of the stuff. Everyone was free to build what they wanted and the table looked like a miniature metropolis, each building trying to rival the next in size and intricacy.

The entire gallery was dominated by two large metal and perspex slides (the line being equally large) running the three levels of the gallery. Other rooms held some more displays that were more than the usual:- a room full of live finches and coathangar nests and a mirrored room where you can see infinitely far in all directions.

If you live in Brisbane (and especially if you have kids) I highly recommend a visit. Their website here

Posted in Events | Tagged , | Leave a comment

Swipe Gestures using Flex 4.5 Hero/Burrito on Android

I’ve been playing a little with the pre-release of Flex 4.5 Hero and checking out what it’s mobile support is like.

I ended up mocking up a simple swiping example – swiping in both vertical and horizontal directions – and quickly found that all the info floating around on the net is not quite right for this release – seems they have changed around the classes a bit.

The one thing that I’ve noticed is swiping in Flex is somewhat more primative than in Android native – in android the swipe speed is more or less dictated by your fingers speed across the screen – you swipe slower, so does the app. You can pause half way and see half of each screen. In Flex 4.5, once it detects a swipe event, across it goes at the speed specified by the code.

I would be interested to see if the native style swipe is possible, as it is a much nicer implementation – probably causes a lot more overhead, so it may be too much of a performance hit.

These sort of little differences, in my opinion, will be what will brand Flex based apps as an inferior product, so it would be good to see some movement there. That being said, this is a pre-release so I’ll give them the benefit of the doubt.

All in all it seems pretty good… close enough to native feel to justify looking into using flex on mobile further.

swipe code:-

Create a new mobile project using the prerelease of Flash Builder Burrito (you’ll need to sign up for the prerelease program for this) and using Flex 4.5 Hero runtime (should be bundled with Burrito)

There will be 5 files in total, Main.mxml, PrevView.mxml, NextView.mxml, TopView.mxml and BottomView.mxml. I will provide the code for Main.mxml and NextView.mxml. The other three files are essentially the same as NextView, just will be using a different event.offsetX/offsetY value and slideViewTransition.direction value, so I’m sure you can work it out.

Main.mxml:-

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
		xmlns:s="library://ns.adobe.com/flex/spark"
		title="Swiping Demo" gestureSwipe="handleSwipe(event)">

	<fx:Script>
		<![CDATA[
			import spark.transitions.SlideViewTransition;
			import spark.transitions.SlideViewTransitionMode;
			import spark.transitions.ViewTransitionDirection;

			private function handleSwipe(event:TransformGestureEvent):void
			{
				// Swipe was to the right
				if (event.offsetX == 1 ) {
					// push the PreviousView without any data using default
					// ViewTransition
					var slideViewTransition:SlideViewTransition = new SlideViewTransition();
					slideViewTransition.duration = 300;
					slideViewTransition.direction = ViewTransitionDirection.RIGHT
					navigator.pushView( PrevView, null,null, slideViewTransition);
				}
					// Swipe was to the left
				else if (event.offsetX == -1 ) {
					// push the NextView withour any data using
					var slideViewTransition2:SlideViewTransition = new SlideViewTransition();
					slideViewTransition2.duration = 300;
					slideViewTransition2.direction = ViewTransitionDirection.LEFT;
					navigator.pushView( NextView, null,null, slideViewTransition2);
				}

				if (event.offsetY == 1 ) {
					var topTrans:SlideViewTransition = new SlideViewTransition();
					topTrans.duration = 300;
					topTrans.direction = ViewTransitionDirection.DOWN
					navigator.pushView( TopView, null, null, topTrans);
				}
				else if (event.offsetY == -1 )
				{
					var bottomTrans:SlideViewTransition = new SlideViewTransition();
					bottomTrans.duration = 300;
					bottomTrans.direction = ViewTransitionDirection.UP
					navigator.pushView( BottomView, null, null, bottomTrans);
				}
			}

		]]>
	</fx:Script>

	<s:layout>
		<s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
	</s:layout>

	<s:Label text="main screen" />

</s:View>

NextView.mxml:-

<s:View xmlns:fx="http://ns.adobe.com/mxml/2009"
		xmlns:s="library://ns.adobe.com/flex/spark"
		title="Next Screen" gestureSwipe="handleSwipe(event)">

	<fx:Script>
		<![CDATA[
                        import spark.transitions.SlideViewTransition;
			import spark.transitions.SlideViewTransitionMode;
			import spark.transitions.ViewTransitionDirection;

			private function handleSwipe(event:TransformGestureEvent):void
			{

					// Swipe was to the left
				 if (event.offsetX == 1 ) {
					// push the NextView withour any data using
					var slideViewTransition2:SlideViewTransition = new SlideViewTransition();
					slideViewTransition2.duration = 300;
					slideViewTransition2.direction = ViewTransitionDirection.RIGHT;
					navigator.pushView( ConvulsingChild, null, null, slideViewTransition2);
				}
			}
	</fx:Script>

	<s:layout>
		<s:VerticalLayout verticalAlign="middle" horizontalAlign="center"/>
	</s:layout>

	<s:Label text="Next screen" />

</s:View>
Posted in Android 2.0, Flex | Tagged , , , , , , , | 1 Comment

Some New Android Articles Worth Reading

There were a couple of interesting new blog entries/articles posted recently.

Both are very important best practices for any platform but in the case of Android (or any other mobile/embedded platform) these are crucial.

Posted in Android 2.0 | Tagged , , | Leave a comment

Customising Toast Notifications in Android – Updated

UPDATE: I’ve come across the original documentation here and updated my code snippets as suggested in their doco.

I have also found that interactive controls like buttons don’t seem to work. If anyone has found a way to get it to work let me know, but I guess that if you need to interact with it, an Activity would be a better choice.

Toast notifications are a good way to notify the user about different actions without making them have to click OK buttons, primarily for messages that aren’t absolutely critical.

You can create a standard Toast notification using the following:-

Toast t = Toast.makeText(this, getString(R.string.toast_message),
      Toast.LENGTH_SHORT);
t.show();

however if you want the notification to be any more complex than an image and line of text you have to create a custom view for it.

First we need to create the new layout. In this case we want a layout with a larger (and static) title with the text below being the one that is set dynamically. The following goes in the layout directory as toast_layout.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
	android:id="@+id/toast_layout_root" android:orientation="vertical"
	android:layout_width="fill_parent" android:layout_height="fill_parent"
	android:padding="10dp" android:background="@drawable/toast_shape"
	android:gravity="center">

	<TextView android:id="@+id/title" android:layout_width="wrap_content"
		android:text="@string/toast_title" android:layout_height="fill_parent"
		android:textColor="#999" android:textSize="24dp" android:textStyle="bold"
		android:gravity="center" />

	<TextView android:id="@+id/text" android:layout_width="wrap_content"
		android:layout_height="fill_parent" android:textColor="#FFF"
		android:gravity="center" android:textSize="18dp" android:padding="5dp" />

</LinearLayout>

and the shape that defines the borders so it looks just like the generic toast notification. The following goes in an xml file in the drawable directory as toast_shape.xml:-

<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
	<stroke android:width="2dp" android:color="#ee777777" />
	<solid android:color="#ee444444" />
	<padding android:left="20dp" android:top="2dp" android:right="20dp"
		android:bottom="2dp" />
	<corners android:radius="5dp" />
</shape>

Set the new layout as the view and set the text field

toast = new Toast(getApplicationContext());
toast.setDuration(Toast.LENGTH_LONG);
toast.setGravity(Gravity.TOP | Gravity.CENTER, 0, 0);
LayoutInflater li = (LayoutInflater) context
      .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View toastView = li.inflate(R.layout.toast_layout, null);
toast.setView(toastView);
TextView text = (TextView) toastView.findViewById(R.id.text);
      text.setText(message);
toast.show();

Your toast notification should now show a title above the text you specified.

Posted in Android 2.0 | Tagged , , | Leave a comment

Number Spinner/Picker for Android

Found a handy number spinner for Android based on the Google internal number spinner (not yet made public) used in the Android Time Picker Dialog.

It is released under the Apache 2.0 and can be found here

Posted in Android 2.0 | Tagged , | Leave a comment

How to fetch a contact by phone number in Android

I found myself needing to fetch a contact given a phone number, for example an incoming number. Turns out to be fairly simple, just not so easy to find! For Android 2.x (tested in 2.3)

Cursor c = null;
try {
    Uri lookupUri = Uri.withAppendedPath(
    PhoneLookup.CONTENT_FILTER_URI, Uri.encode(number));
    c = context.getContentResolver().query(lookupUri,
        new String[] { PhoneLookup.DISPLAY_NAME },
        null, null, null);
} finally {
    if (c != null) {
        c.close();
    }
}

Of course you can pass in more PhoneLookup data names to get more info back. if there are 0 results, the number doesn’t currently exist in any contact.

Posted in Android 2.0 | Tagged , | Leave a comment