As part of my computer science program's curriculum, we are required to create a senior project in our last semester. The format of the class was that we would meet up with our professor once a week and discuss our progress. Really, the hardest part of this class for me was coming up with an idea. I usually have tons of ideas, but the difference between this and just programming for fun was that I wasnít allowed to abandon the project when I realize my idea isnít working. Thatís why most of my projects on my projects page are rapid prototypes, some of them have been refactored and re-versioned, but most of them are just products of interesting ideas I had, made purely to test a concept.
I had tons of ideas to start with, but the idea I originally pitched was a couch surfing type service for people who want somewhere to stay in a motorhome, and people who have empty spots on their property to rent or give away. Thus eliminating the need for RV parks. I looked into the law and realized this was probably illegal, so I came back a week later with another idea. An Android app that acted like futureme.org. You send a message to be delivered sometime in the future, one day, one week, sixty years, it doesnít matter. I liked that idea because Iíve used and enjoyed that futureme.org website. I also liked the idea because I just got a new Android phone and it would give me an opportunity to learn the Android environment. Iíve previously worked on the Maze game, but I was just a helping hand, and didnít really delve into the details of the Android ecosystem. So I got to work on that idea.
About 4 weeks into the semester I realized my idea was too easy, I would probably be completely done in another 4 weeks. So I changed it. I made it into a game. The game is called TimeCap.
Hereís the poster I had to make!
I made the backend in Rails, that was easy because I already kind of know rails. I scaffolded it all out. These are my models: User, friendship, image, and prompt. A user has many friendships, images, and prompts. A prompt has many users, and images. An image has a score. Nothing too complicated, I just had to program my rules into the controllers and itís good to go.
Which in Rails, after setting up my relationships, itís as simple as:
Android was the big learning curve for me. I used postman to test my backend API to ensure I was delivering the right JSON data, and then used a library called Volley to retrieve that data asynchronously on Android. Authentication was a big hassle, but I eventually figured out a simple token authenticator that works with the popular Rails library Devise.
I used the Java library Gson wherever I can to simplify the translation between JSON and my Java classes. Calling Gson on some Json data, while specifying a Java class, will automatically return a new object of that class with all the Json data in the appropriate member variables. Itís magic!
Hereís some example code of Gson in action:
I simply loop through my array of images that the query returned and pump them through Gson, I then add the returned objects to an array for later use.
Thereís a million ways to do anything in Android, thatís kind of what makes it so powerful. I followed so many tutorials making this app, I kept track of them all here. I didnít really do anything too crazy in terms of my Android frontend, I was just learning, and was on a deadline, so I kept it pretty straightforward. In my main view I have a sliding page viewer, same thing in my friends view. I manage my images using a library called Picasso, and blur the images in the ďcontributeĒ section to give some stylistic hint that you arenít allowed to see them yet. I have sort and search options, infinite scroll, a creation page, a custom built camera activity using a library called caw, a profile page, and all sorts of other goodies Iím probably forgetting.
Perhaps one of the most difficult things to wrap my mind around, coming from a web background, is the navigation. Stylistically, Iím used to keeping breadcrumbs or having a main menu. At first, I just had back buttons that linked directly to a certain activity. This stopped working when I had multiple entry points into an activity. This forced me to make some functionality changes, the first thing I did was make the back button ďkillĒ an activity. This essentially puts you back onto the activity that was under the current one in the stack. The second thing I did was implement a slider menu to make navigation around the main parts of the app more straight forward. Hereís a screenshot of the slider menu:
The most difficult thing to implement the backend was definitely notifications. A notification allows me to display an alert on your phone. I notify a user whenever someone adds them as a friend, theyíre invited to a prompt, or a prompt closes for contributing and opens for viewing. The first two were easy, because a user has direct action on those events. The last one required some finesse in Rails. First of all I had to implement a cronjob to automatically trigger this task.
This is as simple as:
This runs this Ruby script every minute of every day:
Iím using a Rails gem called PushMeUp. This will notify all users of the viewable prompt and then update that prompt so that we never update anyone about it ever again. The receiving end, on Android, was pretty much just copied and pasted from their documentation and then massaged a little bit.
I learned a fair bit of Android over that 4 month period. Considering I knew next to nothing when I started. I also refined my Rails skills. All in all, I feel like I could make another Android app with relative ease, perhaps something a bit more complicated. I definitely have plenty of ideas floating around in my head.