Sunday, September 11, 2011

New Android App: Task Shaker

How about a task list that tells you a fun activity to do when you're bored?  Or gives you something to do to make you feel productive on a lazy Saturday?

I had an idea yesterday for a ToDo list that gives you a random task or activity to do when you shake it, and weights the results by your current mood.  Users will be able to set parameters when they new tasks by setting sliders like "need to do vs want to do", "thinking vs acting", "productive vs relaxing".  Set info on location, timeframe, deadline, flexibility of deadline, dependency on other tasks, etc.  Setting the sliders to reflect your current mood and then shaking your phone will give you a random activity to do, optimized for your current circumstances.

This also gives me an opportunity to work with sensors and databases, which I haven't done up to this point.  I've got a couple of other ideas, but I already started working on this one, so hopefully I'll be able to use the TaskShaker to figure out what to work on after I finish it!

Thursday, June 16, 2011

Update - Barcode check-in

After using my barcode check-in app at the GVCC races on Thursday nights, I noticed that it was still missing a couple of major features.  While the main barcode scanning workflow worked correctly I still had problems with:

  • Assigning a barcode to a new racer - this was annoying because in the beginning of the season I had to hand out quite a few barcodes to new racers.  Unfortunately, I didn't have a good way to track them, so I ended up writing them down on a piece of paper.  Of course this meant that I didn't want to send in the barcodes until I also sent in the updates to the new barcodes.
  • Manually entering a barcode - There really was no way to manually enter a barcode.  I saw that this could become a problem, since many racers have their barcode sticker on their helmet or bike where it's exposed to the elements.  As the season goes on, members may have scratches on the barcode that would prevent it from being read.
I was able to make additions to the app to resolve these issues.  First, I decided to add some buttons to the main view of the app, but I wanted to make sure that I didn't have to take the user away from the main workflow.  This lead me to using a dialog.

A dialog is a panel that is displayed over the top of your current view.  You can add just about anything to it, including text, images, radio buttons, etc.  For the "assign a new barcode" case, I added a dialog with 3 textboxes and a button at the bottom that allowed me to collect first name, last name, and barcode, and then submit the answers to a separate file.  The "manually enter barcode" case was even easier, since it just required a single textbox where I could type in a barcode, and then the button would save it to the same file that the other barcodes were being scanned into.

There were 2 "tricky" parts to creating a dialog.  The first was trying to figure out when in the lifecycle to actually create the dialog.  Apparently, the recommendation is to create it in the onCreateDialog(id) event, and this is what I used.  This event is fired during a call to showDialog(id), where you pass in an integer that identifies which dialog you want to show.  From there, I just used a simple switch statement to differentiate between the 2 types of dialogs, used a layoutInflater to set up the layout from an xml file, and finally call the create() method on the AlertDialog.Builder object.  The create() method actually creates and shows the dialog on the screen.

The second trick that I ran into is realizing that all of the objects that are on the dialog are really on a separate view.  That means that if you want to access the fields on the view, you can't just do something like "this.myTextBox", you need to use "memberDialog.myTextBox".  Obviously that meant that I ended up storing the actual dialog object in a member variable, which I'm not too happy with, but it seemed to work ok.

Other features that I'd like to include in this app are:
  • Look up member barcode by name
  • Look up member eligibility - paperwork turned in, paid - from gvcc racing database
  • Check in marshals - so they can be flagged for not showing up!
I think that I've got the most important cases covered though.  I'd like to publish this to the Android Market so that other gvcc members can access it quickly if there's a need to do a check-in and I'm not there, so that will probably be my next action with this app.

Tuesday, May 10, 2011

A is for Appendix

Yikes...ended up having my appendix out early last week, so I've been out of it for a little bit.  New posts will be on the way shortly.

Thursday, April 14, 2011

Barcode check-in app - Beta Testing


Woohoo! *pumps fist*

Yes, thank you, I will use my barcode app. Oh wait, that means it actually has to be done and (mostly) functional. Better get on that!

What need to function for this app to be useful?
  • Scan barcodes and write them to a file - done
  • View barcodes (for verification) - done
  • Email barcodes to Todd - done
I took some time to re-work the menus on this app to use xml files and a MenuInflator instead of building each MenuItem programmatically. I also finally figured out how to use intents to move between Activities within my project (Intent intent = new Intent(this, ViewScans.class);). I still have a problem with going back to a previous Activity if I just came from there, but that's just an annoyance, because it puts another instance of that Activity on the top of the stack. I'm sure there's a better way to deal with this, even if it just means that I re-work the menu options.

After getting everything working, I started thinking about other functionality that I could include in this app - yes, the dreaded "feature creep"! Here's what I came up with:
  • Better way to store settings - email address to send to, default subject line, default storage folder
  • View list of barcode files in a folder
  • Edit barcodes within a file
  • Add a nice icon
Here are some "pie in the sky" features that would be cool, but probably won't happen:
  • Pull the name of the rider associated with a barcode from the GVCC database
  • Option to validate that there are no duplicate barcodes within a file
  • Automatically name files by creation date
Beta testing will commence tonight!

Wednesday, April 6, 2011

Nice and Smooth - Sending email

After having a horrible time with permissions last night, I moved on to figuring out how to send an email with an attachment. It turns out that this is the easiest thing that I've done on Android so far! I just had to create an Intent to ACTION_SEND, add some parameters that are pretty standard, and start her up.

Here's the code:
     Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
emailIntent.setType("plain/text");
emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{ "youremail@gmail.com"});
emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Checkins today");
emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Here you go.");
emailIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+Environment.getExternalStorageDirectory()+"/barcodes/checkins.txt"));
emailIntent.setType("text/csv");
startActivity(Intent.createChooser(emailIntent, "Send mail..."));
It's looking more and more like this thing will be ready for prime-time before the B5s race next week. Todd might be pleasantly surprised if he gets the check-ins before the race starts.

Tuesday, April 5, 2011

App Idea - Interval Coach

How many people listen to music while riding the bike trainer inside? I also know that there's a large population of cyclists who listen while riding outside, which I don't recommend, but I know you're out there. How about an app that downloads an interval workout that your coach or yourself sets up online, and provides audio/visual/haptic cues for when to start or stop each interval?

The user would be able to select a set of intervals on the application on their phone (ex: 20min @ 100% LT, 10 min rest, etc), and then click the "start" button. They could have music playing in the background for entertainment. Whenever an interval starts or stops, an audio cue would play, the phone would vibrate, and maybe display a description in large text of what the next command is. An example would be audio plays "Upcoming Interval...20 seconds at max effort...(waits a few seconds)...*beep*beep*beeeeeeeep" and you start the interval. The phone vibrates during the beeps to give some haptic feedback, and if the proximity sensor isn't covered, it displays a description of the interval along with a countdown and some encouraging phrases.

Another feature would allow a coach to set up the athlete's intervals online, and when the athlete was ready to start, the app would download the set of intervals to the phone and start them. Apparently this is a similar feature to what Training Peaks software is already offering, but I think this takes it to a different level by actually participating in the intervals.

Feel free to add any comments or suggestions about any of my app ideas here, or contact me on twitter @mac5mark

Pulling my hair out - Permissions

Don't you hate it when you burn through an hour of work with something that you know should have taken 5 minutes?

I got the barcode intent switches working without any problems the other night, but for some reason I couldn't write a file to the SD card. I only played with it for 5 minutes, and had the correct code written, but it just wasn't working so I moved onto other things (the menus). I decided to sit down and get the file storage working correctly tonight.

First, I did add a line to the AndroidManifest.xml to add permissions for android.permission.WRITE_EXTERNAL_STORAGE. What I didn't realize is that there are multiple places in the Eclipse Manifest tool to specify permissions. There's a drop down under the "Application" tab, and then there's the "Permissions" tab (the obvious place to look). My initial thought was to go to the "Permissions" tab, and add a "Permission" element. Makes sense, right?

Nope, you need to add a "uses-permission" element. Unfortunately, I apparently can't read detail-oriented documentation anymore, so this small difference was lost on me. The worst part about it is that because I wasn't really paying attention to "permission" vs "uses-permission" while I was reading through the websites I looked at, I don't even know what "permission" is used for! All I know is that if you actually want to let your application use some of the phone's resources, you need a "uses-permission" element.

The good news: progress is being made on the app, and I just need to work out some stuff with the menu and some basic cleanup/error handling in the file creation code before it's ready for prime-time. Oh yeah, and the email part too, but as long as I can collect all of the barcodes into a file, that's all I need for now.