Showing posts with label android. Show all posts
Showing posts with label android. Show all posts

Sunday, October 6, 2013

Getting started with animations on Android

Want to get started with animations on Android? It turns out, things are surprisingly easy.


There are two ways to create animations:
  1. Using OpenGL --- See documentation here
  2. Using built-in View animations --- More here and here.
I explored the later. Basically the code boils down to the following:

1- Create an animation template. For example the following can be used to rotate an imageview back and forth:
2- You can then apply the animation to the view using the following code:
I created the following app to demonstrate various animations on arbitrary images:
Read the README.md for more details.

Saturday, September 7, 2013

Developing Trackpad: An 18 second Vine documentary

My goal was simple. I wanted to be able to control my Mac's mouse from my Nexus 7. These following Vines document an evening's attempt at that.

Phase 1 - Basic Android application. Just getting set up.

Phase 2 - Server setup. My mouse now speaks http.

Phase 3 - Hook server up to application. World's hackiest wireless mouse.

Check out the android app here
Accompanying scala Play service here.

Sunday, September 1, 2013

Triggered breakpoints in Android Studio

I found a nice timesaver in Android Studio. The IDE can automatically set a breakpoint whenever an exception is thrown. This is instead of waiting for one to happen, looking at the callstack, manually placing a breakpoint, restarting the debugger and trying to repro.

To do this:
1- Start the debugger

2- Click "View Breakpoints"

3- Check "Any Exception"

4- You'll see a triggered breakpoint appear any time there is an exception

Saturday, August 24, 2013

Formatting code blocks from Kindle

I was ramping up on android using a Kindle book and realized Kindle for Mac app does a terrible job of copy/pasting contents to an IDE/text editor. I created a simple ruby script which tries to properly format code blocks copied from the Kindle app and then replaces the contents of your clipboard with *somewhat* better formatted code. Not perfect by any means, but made my life a little easier. 
 
Before:












After:























Check it out on github -> here <-

Saturday, December 15, 2012

Push notification + Terminal = Win!

Developing with Pushover

I was compiling ruby on my new Raspberry Pi (a process that takes about 2 hours) and I thought to myself, wouldn't it be great if I had some way of knowing when it was done? Wouldn't it be even more awesome if I could get info about any task in my terminal completing wherever I was?

I decided to give Pushover (https://pushover.net/) a spin during a late night hacking session. Pushover is essentially a (paid) app that allows you to receive push notifications on your phone through their simple API.

I was quickly able to hack together a bash/ruby function that I think will be pretty useful for me given how much time I spend in the terminal.

usage example: 
>sleep 2 ; notify "I slept for 2 seconds and woke up!"

The result (after ~2 seconds):

One could easily imagine kicking off a sereis of lengthy operations in the terminal, interspersing a couple of calls to notify, then going for a coffee until your phone says its all over. 
Ex: ./build_code.sh ; notify "Build complete" ; ./deploy_to_server ; notify "deploy complete, come back!" 

If this sounds interesting, follow the steps below to get setup:

1- First, you'll need to get the Pushover app for iOS or Android. It's not free, so you'l need to deal with that. Once you've download the app, create an account on your phone.

2- Go to their site(https://pushover.net/) and login. Once logged in, you'll see your user key in the dashboard. Note that down. 
3- You should have the option of creating a new application. Go through their application creation flow
4- Once you create the application, you'll get an application API token:
5- The last step is to add the following code to the end of your ~/.bashrc (or ~/.zshrc if you like to live on the edge). NOTE: replace application token with data from #4 and user key with data from #2.

Thats it! Now go kick off a build and wait for a pleasant ring to bring you back.