Time to update your support library

Fragmentation is an often cited issue of the Android ecosystem, but the people who really bear the brunt of it are not so much the end users, but the developers who have to create applications to support multiple versions of the platform. It’s for this reason Google created the Android Support Library – used to provide backwards compatibility for newer features of Android.

Originally released in March 2011, just after the introduction of fragments in Honeycomb (Android 3.0), the support library (originally called the “Android Compatibility package”) provided developers the means to use Fragments, LoaderManagers and a few other classes across mostly all versions of the platform, going back to Donut, version 1.6. This library, combined with the excellent ActionBarSherlock , gives developers the means to write a single codebase which can support multiple versions of the platform without having to write platform specific code – the only exception that comes to mind being the ActionBar action view widgets which need specific pre-ICS implementations.

Fast forward a couple of years to Google I/O 2012 and the, now named, Support Library is on revision 9 and has brought with it a lot of updates. Google is slowly implementing functionality which has, up until now, been developed by other people. For example, revision 9 includes a lot of bug fixes and new functionality to the ViewPager class, however note currently the ViewPageIndicator library still offers better functionality. The Notification Builder has also been updated, but again note that a third party library, in the form of the NotificationCompat2 library, is still the recommended way to provide complete support for notifications across all platform versions without sacrificing the newer functionality where available.

Of particular interest, and the reason for the title of this blog post, are the ‘many bug fixes’ for the Fragment class, which by now should be core building blocks used by all Android developers (if you aren’t using them yet – what are you doing?!) – this in itself should be reason enough to update.

Google seems to update Android everytime it release a new Nexus device, and if the rumour-mill is correct then we should be seeing a new Nexus handset at some point towards the end of the year. If past updates are anything to go by, Google should be releasing another updated version of the Support Library sometime in August 2012 or shortly after. It’s strongly adviced to keep an eye on the Support Library updates and implement new versions as soon as they’re released in order to take advantage of the new features and bug fixes.


Android UI: CoinKeeper

https://play.google.com/store/apps/details?id=com.ifree.coinkeeper


Good Android UI

I’m going to start keeping a record of nice Android UI that I find.

First one up is Safe In Cloud

https://play.google.com/store/apps/details?id=com.safeincloud


How to get ADB to work with the Lenovo Thinkpad Tablet in Windows 7

Lenovo has a dedicated driver for the Lenovo Thinkpad Tablet, so it won’t work out of the box.

Here’s the steps to get it working:

  1. Download the ADB Interface Driver – ThinkPad Tablet from http://support.lenovo.com/en_US/downloads/detail.page?DocID=DS022366
  2. Turn on the ThinkPad Tablet.
  3. Press the slider bar icon to display the Settings property page.
  4. Press Applications on the left side of the page.
  5. Press Development and check USB debugging.
  6. Press the OK button on the dialog.
  7. Connect the Tablet to the computer.
  8. Open Device Manager.
  9. Expand the Other devices node.
  10. Right click the ThinkPad Tablet node and select Update Driver Software.
  11. Select Browse my computer for software.
  12. Browse to the folder that contains the driver files.
  13. Select the driver folder and continue the driver installation

Learning Vim – Part 2

After a few days of using Vim, I’m starting to feel more comfortable navigating around and editing files. I’m missing the ability to manipulate areas of text, and to repeatedly find patterns once I’ve searched for them, but I assume that’ll come later.

The commands I’ve been using recently are:

  • o → insert after the cursor
  • 0 → go to first column
  • ^ → go to first non-blank character of the line
  • $ → go to the end of line
  • /pattern → search for pattern
  • <ctrl + r> → redo
  • :e → open
  • :w → save
  • :bn or :bp → show next or previous file

I’ve had a little look ahead at a few of the other things that vim can do, and it looks really powerful, but it’s not at all intuitive, so there’s going to be a fair amount of learning to be done before it’s my main text editor!


Making Gmail Tap

This morning my brother posted a message on Google+ about Gmail Tap – Google’s April Fools joke this year. I looked at it and though “I can do that” – so I did. Here’s the Google Play link (until they pull it!)

EDIT

After less than 24 hours the app got pulled from the store by Google, but still managed to get an impressive 5,646 downloads with 143 comments and a 4.7 / 5 user rating. I’ve removed all the Google branding and repackaged it – Here’s the Google Play link


test


Learning Vim

Today I decided to level up and start learning Vim (VI improved) – I know it’s a long road ahead but there are many benefits:

I’m going to start out using Learn Vim Progressively, but I’m going to adapt as I go. So, from that page – first lessons:

  • i → Insert mode. Type ESC to return to Normal mode.
  • x → Delete the char under the cursor
  • :wq → Save and Quit (:w save, :q quit)
  • dd → Delete (and copy) current line
  • p → Paste
  • Recommended:
  • hjkl (highly recommended but not mandatory) → basic cursor move (←↓↑→). Hint: j look like a down arrow.
  • :help → Show help about , you can start using :help without anything else.

And a few of my own:

  • u → Undo the last change
  • :q! → force quit without saving

Reversing primitives without creating a temp

I’ve been working my way through a load of practise challenges recently to make sure I’m keeping my brain active and I worked out a way of swapping two primitive values without the overhead of creating a third value to use as a temporary storage value.

Lets say you have two characters, to swap them you would execute a series of binary XORs:

	char charOne = 'i';
	char charTwo = 'H';

	charOne ^= charTwo;
	charTwo ^= charOne;
	charOne ^= charTwo;

	System.out.println(String.valueOf(new char[] {charOne, charTwo}));

you would get an output of ‘Hi’.

Note that

charOne ^= charTwo;

is the shorthand version of

charOne = (char) (charOne ^ charTwo);

If you have a look at what’s happening: charOne is ‘i’ which is 1101001 in binary and charTwo is ‘H’ which is 1001000 in binary.

First we XOR the two values and assign back to charOne:

charOne: 1 1 0 1 0 0 1
charTwo: 1 0 0 1 0 0 0
charOne: 0 1 0 0 0 0 1

charOne is reassigned the binary representation of 0100001.

We then XOR the new value of charOne with the initial value of charTwo and assign to charTwo:

charTwo: 1 0 0 1 0 0 0
charOne: 0 1 0 0 0 0 1
charTwo: 1 1 0 1 0 0 1

so now charTwo has a binary representation of 1101001, which was the initial value of charOne.

we then XOR the third time and assign back to charOne:

charOne: 0 1 0 0 0 0 1
charTwo: 1 1 0 1 0 0 1
charOne: 1 0 0 1 0 0 0

and we see that the binary representations of the two characters have swapped.

Just thought that was a pretty nice way of doing it.


How to install packages from the command line in (K)Ubuntu

This is more a note for myself, but recently I had an instance where I had a deb package to install but it needed me to accept a license – thing is that it wouldn’t work using the GUI – it’d just display a window saying ‘Done’. I worked out I had to install from the CLI to get it to show the license so that I could accept it.

Anyway – here’s the command :

sudo dpkg -i <location of deb file>