m@munday

Dead Simple Android SlidingMenu

I’ve been working a bit on a new Android application project and one of the recent design patterns that has had my attention for a while is the left hand slide out menu. I found several implementations but they all seemed to be a bit heavy for such a simple concept so I was compelled to attempt my hand at one. The end result of a bit of hacking is this: https://github.com/munday/sliding-menu – a dead simple sliding menu.

The concept was to place two FrameLayouts (represented as Menu and Content below) into a RelativeLayout side-by-side and then scroll the outer RelativeLayout with an animation that adjusted the scroll position to change the viewport:

And that’s it. No magic, just a simple position animation and 3 layouts. It does, however, leave you on your own to implement an action bar of your own (or use a lib like actionbarsherlock) if you want it to slide away with the content layout.

 

Swarm v1.4 released

I released swarm v1.4 this weekend. Check out the post at swarmbt.com for more details.

A new site due to ec2 failure, or why backups can be useful.

Backups. They are useful. I found that out rather abruptly when Amazon’s us-east datacenter had some power issues at the end of last week. I lost the data files for several sites. Data that went back for several years. Data that should have been OK, except I had no backups of my database drive. I had  snapshots of other drives, but over time I had migrated databases off of my root drives to a new drive on ebs and NEVER backed it up, EVER. The worst part is that running automated backups is insanely easy with Amazon’s ec2 toolkit.

Here’s the script I adapted from sources around the web (Note that paths are default install locations on Ubuntu Precise LTS):

#!/bin/bash

#this is the default dir of openjdk path, change it if your's differs
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk

#this the default ec2 tools path, change it if yours differs 
export EC2_HOME=/user/lib/ec2-api-tools 
export PATH=$PATH:$EC2_HOME/bin

#the following 2 exports are the locations of your cert and a
#private key used when you set up your account
export EC2_CERT=/etc/ec2/cert-ec2.pem
export EC2_PRIVATE_KEY=/etc/ec2/pk-ec2.pem 
export PATH=$PATH:$JAVA_HOME/bin:/EC2_HOME/bin

# your volume names (space separated)
VOLUME_LIST=(vol-XXXXXXXX vol-XXXXXXXY vol-XXXXXXXZ)

sync
DAY=$(date +%d%m%Y)
#creating the snapshots
for volume in ${VOLUME_LIST[*]}; do
ec2-create-snapshot -C $EC2_CERT -K $EC2_PRIVATE_KEY $volume -d snap-$DAY
done

Just replace the required values for your cert, private key and volumes and throw it in a cron folder (/etc/cron.weekly/, /etc/cron.monthly/) or your crontab.

New York Times With A Poop Flinging Monkey [Chrome Extension]

There was a post on G+ calling for a Chrome Extension to be made which adds “With A Poop Flinging Monkey” to every headline.

I, obviously, had no other choice than to create it.

Download NYTimes With A Poop Flinging Monkey, the chrome extension

Kindle Fire useragent WTF

Update: Based on Scott’s comment on the post I dug deeper. There are 2 settings that affect the UserAgent string on the fire: The “Accelerate page loading” and “Desktop or mobile view setting” (both under menu-> settings while in the browser)

Update: I made a simple javascript that can detect a Kindle Fire based on the existence of Silk/ and Silk-Accelerated in the UserAgent.

Is it a Kindle Fire?

Here’s the breakdown:

Mobile – no Silk

Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.1.0-84) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=false

Mobile – Silk

Mozilla/5.0 (Linux; U; Android 2.3.4; en-us; Silk/1.1.0-84) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1 Silk-Accelerated=true

Desktop – no Silk

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=false

Desktop – Silk

Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_3; en-us; Silk/1.1.0-80) AppleWebKit/533.16 (KHTML, like Gecko) Version/5.0 Safari/533.16 Silk-Accelerated=true

Automatic – no Silk

Either Mobile – no Silk or Desktop – no Silk (Depending on the site visited)

Automatic – Silk

Either Mobile – Silk or Desktop – Silk (Depending on the site visited)

Based on this, the best bet at marking Fire traffic is to search for Silk and/or Silk-Accelerated in the UA.

I started seeing a lot of traffic with a network named “amazon.com inc.” in my Google Analytics account, specifically to my Kindle Fire market opener post and apk. The browser data showed Mac OS X and Safari, I was puzzled until I figured out that the Fire pretends to be Safari on OSX 10.6.3 and shows amazon.com inc. as the network instead of the actual network. Is it an Amazon oversight or is there a reason for this? It kinda messes with trying to decipher how much kindle traffic you are getting. It’s got Silk references so it can be identified but, as far as I know, GA does not offer up the entire UA string.


Weekend project – AndInstant

Andinstant - a [sort of] Instant android API docs search

A few weeks back, I was inspired by an instant css documentation search: http://instacss.com so I took a couple hours and threw together an instant android SDK reference search.

The hardware behind the search is a little lacking,
so under load I assume that it would be not quite as instant :O

The source is available on github too!

Kindle Fire – Market Opener

Kindle Fire Market Opener

If you’ve rooted your Kindle Fire and installed the Android market APK, you may have noticed that the Market icon does not appear in the stock launcher’s app list. Market opener fixes for that problem. It’s a simple shortcut that launches the underlying apk via an intent.

Update: Irock23 has made an updated version with the new play icons, and my market opener now has 2 versions, on with market icons and one with Play icons. You can download any of the apps below. All apps now appear properly in the MRU list thanks to Irock23 as well.

If you haven’t rooted your Fire and want to, try one of these threads:
Windows: http://forum.xda-developers.com/showthread.php?t=1348830
OSX or Linux:  http://forum.xda-developers.com/showthread.php?t=1349613

Also, the thread for info on installing the android market:
 http://forum.xda-developers.com/showthread.php?t=1351283

Get The Kindle Fire Market Opener
Get Kindle Fire Market Opener With the Play Store Icon
Get the source

Get Irock23′s Play Store Opener
Get Irock23′s source

Elasticfox for Firefox 7 beta and up

Note: When firefox updates, it shows the add-on as not compatible. It is actually compatible, but there seems to be some crossed wires somewhere and I’m looking in to it. In the mean time just re-install the add-on from here and it will work again (verified on Firefox 7.0.1 and 8 beta) This should be fixed now, if you download elasticfox from here again, firefox should not disable the plugin after updates.

I was unable to find a version of elasticfox that was compatible with newer versions of firefox, so I pulled the code and made a simple update to the install files and the chrome (in ff>5 the menus in elasticfox went transparent and made it annoying to use.) The result is basically the same plugin with extended compatibility. I punched the max version to 20.0 to avoid having to rebuild each version, but can’t guarantee it will work for any version above 7beta.  Anyway, click the link below to download the xpi.

Get Elasticfox for Firefox 7 beta and up

Wp admin bar not working?

Just in case you are lost and wondering why like I was: If you have a wordpress site and the admin bar isn’t showing up, make sure you have a call to wp_footer in your footer.php file. The function to add the admin bar is called from there.

Complete face palm

I am pleased an appalled with myself today. Last night I located and fixed a major bug in Swarm that was holding off the v1.2 release. It was a ridiculously simple error in a loop. heres the post on swarmbt.com: http://swarmbt.com/2010/09/29/complete-face-palm/