Author Archives: Jon

Using 3rd Party Libraries

Task Butler uses two open source third party libraries: ActionBar Sherlock and AmbilWarna

ActionBarSherlock is an excellent library that emulates the Ice Cream Sandwich action bar in older versions of Android. This was crucial for our app because we were developing for 2.2+, and having to design an entirely different UI would have been inelegant and a massive amount of extra work. Jake Wharton’s ABS uses the same API calls as Android’s official library, so one can follow Google’s API specification to use his library. Google has its own support library with limited features available, but ABS is a much more complete solution. It was critical to the design of our UI and I thank him for developing it and releasing it for free.

The AmbilWarna color picker dialog is a neat piece of code that provides a color selector for users. We needed a way for users to pick colors for their categories and this seemed like a much nicer solution than giving users limited choices like other apps do. Picture attached.

ColorPicker_1

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Task Butler available on Google Play!

As of this writing, our summer/fall project Task Butler is available to be downloaded on the Google Play store! I am very proud of what we accomplished and I invite anyone with an Android device to check it out. Feedback is always appreciated, of course.

 

Grab it here.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Setting up your development environment

This is a guide for creating a new Android Eclipse project from source code on GitHub. It is tailored to my independent study project for the benefit of my partners, but it could be easily adapted to any Android project.

Note: This guide was created for Windows 7 64-bit. Other versions of Windows should be similar.

1. Download and install Java SE Development Kit for Windows x86

Note: I highly recommend NOT installing to the default C:\Program Files (x86)\Java\ folder. The Program Files folder has very restrictive permissions which may cause file writing/copying errors in the future. I chose to install to C:\Java\.

2. Download and install Android SDK for Windows

Note: Again I recommend NOT installing to the default folder. I chose to install to C:\Android\.

3. Run the Android SDK Manager and install the groups: Tools, Android 4.1 (API 16), and Android 2.2 (API 8).

4. Download either Eclipse Classic for Windows 32-bit or Eclipse for Java Developers for Windows 32-bit

5. Extract the downloaded eclipse\ folder into your Java\jdk*\ folder

6. Download and install GitHub for Windows

7. Run Eclipse, and choose your GitHub folder as your workspace

8. Install Eclipse ADT Plugin

Note: If you get an error after restarting Eclipse about not being able to find the Android SDK, just click the Preferences button and point to your Android\android-sdk\ folder.

9. Create a new Android project, and then close Eclipse afterwards

Name the project Task Butler, and name the package edu.worcester.cs499summer2012. The target SDK should be API 16 and the minimum required SDK should be API 8.

10. Clone the CS499Summer2012 repo to your local GitHub folder

11. Move the local repo files into your Task Butler folder

  • In your GitHub\Task Butler\ folder, delete everything EXCEPT .settings\, .project, and .classpath
  • Move everything from GitHub\CS499Summer2012\ into GitHub\Task Butler\
  • Note: Make sure “Show hidden files, folders, and drives” is enabled in Windows Explorer’s Folder options so you can see the hidden .git folder
  • Delete the now-empty \GitHub\CS499Summer2012\ folder

12. Reopen Eclipse, and the project should now have all of its files (and lots of errors!)

13. Download ActionBarSherlock and extract it somewhere

I chose C:\Android\

14. In Eclipse, import the library\ folder inside the ActionBarSherlock folder as a new project

15. Modify the library’s Android properties and Java Compiler properties to get rid of errors

Make sure the build target is set to 4.1 and the “Is library” checkbox is checked.

Make sure the Compiler compliance level is set to 1.6.

16. Modify Task Butler’s Android properties to include the new library

Make sure the build target is 4.1 and add ActionBarSherlock to Library (if there is one listed already with a question mark, remove it).

17. If necessary, clean the project and it should rebuild itself with no errors.

The project is now ready to be worked on!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Method chaining

While experimenting with adding context menus and alert dialogs to the app, I discovered a cool Java feature that I didn’t know existed: method chaining. By taking normally void methods and instead having them return a reference to their object, you can turn this:

Person p = new Person();
p.setName(“Bill”);
p.setAge(40);
p.setZip(01701);

into this:

Person p = new Person();
p.setName(“Bill”).setAge(40).setZip(01749);

As far as I can tell, efficiency doesn’t change when using method chaining vs. the traditional way. But it looks a lot cleaner and I may start using it.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

My next feature: custom sort menu

I had a burst of inspiration while driving to work and drew this options menu with a Crayola marker when I got there. I will be implementing this shortly:

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Progress pics

Some initial screen grabs of our app:

#1 shows the MainActivity with no tasks.

#2 shows the AddTaskActivity during keyboard input.

#3 shows the full AddTaskActivity.

#4 shows the MainActivity with displayed tasks. Bold tasks are unfinished, and italicized tasks are completed.

#5 is a peek at our text file which stores task data.

Layouts are quick and dirty for functionality and will be cleaned up before the app is finished. More screenshots soon!

MainActivity without tasks
AddTaskActivity
AddTaskActivity
MainActivity with tasks
Tasks file

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

The basics of an Android app

Learning the structure of an Android app is overwhelming at first, but it’s not too difficult after some familiarization. I recommend using Lars Vogel’s excellent Android tutorials here. They are among the best tutorials I have found, and I am sure I will keep using them as a reference as this project continues.

An Android app is made up of two parts: the front end and the back end. The front end is the visual part of the app that the user interacts with, and the back end, which contains all the code that drives the app.

The front end is written using XML. I have never used XML before, but it is very similar to HTML in that it is a markup language that uses nested tags as its programming structure. Android uses several XML files to create the app’s front end. There is at least one XML layout file for each activity (or several if you are supporting multiple device sizes), as well as layout files for custom views. XML is also used to define constant strings that will be placed in the layouts, such as the text on a button.

The back end is written in Java, which is great because it is a language that I am very familiar with. You can use the Java standard library in addition to the Android library when coding your app. This gives you access to a ton of pre-made objects, and the APIs are thoroughly documented online by Oracle and Google.

Each screen in an app is known as an activity. Activities are classes that you extend from a base activity class. Each activity is tied to an XML layout file which provides the front end visuals. Activities are created, resumed, and closed by the Android OS through a series of callback methods, which are called automatically by the OS at the appropriate times. Some examples of callback methods: onCreate, onPause, onResume, onStop. These methods have to be overwritten for your activity to work correctly.

Information sent between activities is called an intent. Intents carry standard data like strings or can be modified to carry custom extra data. For example, our AddTaskActivity creates a new Task object, adds it to an intent, and sends it back to the MainActivity where it will be displayed for the user.

There are other basics, such as fragments, services, and notifications, but I don’t know enough about them yet. I’ll comment on those after I’ve learned them!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

Code is live on Github

Now that the app is in development, our work is live on Github. Check it out by clicking the Github link at the top of my blog.

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

A focus on personal productivity

We’ve decided on the type of app we are going to develop. It will be a task organizer/to-do list, which personally is a crucial app for my phone to keep my life in order. I’ve tried several different task organization apps from the Play Store, but none of them did exactly what I wanted. I’m currently using Astrid Tasks, which is very popular and close to what I want, but full of feature bloat. So hopefully what we develop will eventually become my
full-time organization app.

Here is an early draft of features that I brainstormed and sent to James:

Task App Features
* Able to assign a due date/time
  – If no time specified, have the alarm go off at a default time (specified in options)
* Able to assign a priority (urgent, standard, trivial)
  – Priorities can change the font of the task (bold/regular/italics)?
* Able to create and categories (Bills, Shopping, Homework, etc)
  – Categories can color code the task background?
* Able to hide/display entire categories (Tabbed page for each category?)
* Able to sort list by name, due date, priority, or smart sort (combination of due date and priority)
* Able to make tasks once-only or recurring
  – Recur every X minutes/hours/days/months/years
* Alarm in the form of a persistent notification
   – Make optional: a popup (may be too intrusive for many)
   – Make optional: non-persistent notification
   – Ringtone, vibrate, LED flash on alarm
       * all able to be changed/turned off via options
   – Able to snooze alarm (by how much time specified at time of snooze or in options?)
   – Only way to get rid of persistent notification is to complete task or keep snoozing
* Optional: A secondary “You are out of time alarm”
   – For procrastinators like me
   – Optionally specificy a time where a task absolutely has to be done by
   – If not done by this time, a popup will appear every 15 minutes until task is completed
   – Cannot be turned off/snoozed without finishing the task
* Completing a task will mark it as completed
   – If a recurring task, immediately create a new task for the next recurrence
   – Give user the option to auto delete completed tasks or keep them
* Visually, each task in the list should show as much info as possible without being too cluttered
   – Name of task
   – Priority of task (font or icon?)
   – Category of task (as text and colored background?)
   – Due date/time of task
   – Whether or not it is recurring (icon?)
 – Whether or not it is overdue (icon or make the font red?)
   – Overdue tasks should always be at the top (user option?)

Advanced Features
* Backup and restore task lists
– XML format
– Manual or automated backup, or both
* Integrate with the user’s Calendar
* Sync with their Google account
* Resizable, scrollable widget to list tasks

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.

A quick note on Jelly Bean

With the release of the Android 4.1 Jelly Bean SDK, our project will now have a build target of 4.1 Jelly Bean and a minimum required version of 2.2 Froyo. Also, a lot of the problems experienced in my post about setting up the SDK have disappeared. The AVD location bug is gone, and the Eclipse ADT Plugin installs just fine from the online repository. It’s nice when things work!

From the blog Code Your Enthusiasm » WSU CS by Jon and used with permission of the author. All other rights reserved by the author.