Android Date Picker Dialog Weirdness

Recently I needed to add a date picker dialog to a form I was designing. It was pretty straight forward, an EditText with an adjacent button to trigger a DatePickerDialog to quickly select a date.

The following is an example from my project. I create a managed date picker dialog that is set to the date in the EditText. If the EditText is empty or has an invalid date string, the date picker dialog is set to today’s date.

Code snippet from my activity:

...
 
@Override
protected Dialog onCreateDialog(int id) {
	Log.d(TAG, "onCreateDialog() -> id = " + id);
 
	if (id == ID_DIALOG_DATE_PICKER) {
		return new DatePickerDialog(this, searchDateSetListener, 0, 0, 0);
	}
 
	return super.onCreateDialog(id);
}
 
@Override
protected void onPrepareDialog(int id, Dialog dialog) {
	Log.d(TAG, "onPrepareDialog() -> id = " + id);
 
	if (id == ID_DIALOG_DATE_PICKER) {
		DatePickerDialog dlg = (DatePickerDialog) dialog;
 
		// Get today's date
		Calendar c = Calendar.getInstance();
 
		int year = c.get(Calendar.YEAR);
		int month = c.get(Calendar.MONTH);
		int day = c.get(Calendar.DAY_OF_MONTH);
 
		// Get the search filter
		String filter = editSearchFrom.getText().toString().trim();
 
		// Update the date picker dialog
		try {
			Date date = dateFormat.parse(filter);
			c.setTime(date);
			dlg.updateDate(
				c.get(Calendar.YEAR),
				c.get(Calendar.MONTH),
				c.get(Calendar.DAY_OF_MONTH));
		} catch (ParseException e) {
			dlg.updateDate(year, month, day);
		}
	}
}
 
...

Read the rest of this entry »

Critters Update for December

Critters has been updated and includes the following new functionality and enhancements:

  • New – Pet list with thumbnail photos
  • New – Pet list filtering
  • New – Veterinarian search via Google Maps application
  • New – Save custom veterinarian search terms
  • New – User stories added to unit tests
  • Enhancement – Owner list thumbnail photos
  • Enhancement – Owner list filtering

To learn more about Critters and see a few screenshots, visit the project’s home page here. The source snapshot has been updated and is available for download.

Critters Source Snaphot Available for Download

The first source code drop for Critters is available for download.

The application is feature complete for the management of pet owners. Unit and functional tests have been completed and included in this release. I have also provided a link to the coverage report for this release. Don’t laugh too hard while you are reviewing the source. This is the first project I have done in Android and it is still a learning process. If you have any suggestions or pointers, please feel free to let me know.

Critters Update

It has been hard to find the time, but I finally made a bit of progress on Critters. Pet owner management is almost complete and includes the following functionality:

  • Create, edit and delete owners
  • Attach a photo of an owner to their personal record
  • Place a call from the owner’s contact list
  • Send an e-mail from the owner’s contact list

To learn more about Critters and see a few screenshots, visit the project’s home page here.

ActiveRecord Data Model for Android

This month I was researching ways to implement data access for my Android project. I found an interesting tutorial posted by Java Padawan available here. The author presents what is a “sort-of” ActiveRecord data model for Android. I really liked the idea and implemented my own version for use in my project. Today’s article covers most of what was presented in the author’s original tutorial plus a few other items that I felt were missing. Read the rest of this entry »

Android Input Validation

Today’s article will cover a quick and dirty approach to form validation for Android applications. My application has an activity that displays a form to the user for entering personal information. This information is then stored in a SQLite database. I needed a way to validate the data in the form’s widgets before saving that data in the application’s database. The Android framework provides some support for entering valid data into a form. This support includes hints and input filters. Hints are a handy way to help a user enter information when a widget’s text is empty. Read the rest of this entry »

Android Dialog Theme and Window Decorations

While working on my first Android project, I ran into an interesting problem; how to add an icon to the window title of my application’s about dialog. My search for a solution only led to others asking this same question without any answers. Here is my solution to the problem in the hope that it may save you some time engineering your own. Read the rest of this entry »

openEPRS Project Update

It was over two years ago that I embarked on creating an open source electronic medical record. Today I have decided to discontinue work on openEPRS. This rise of other open source projects such as Medsphere put openEPRS at a competitive disadvantage. The complexity and scope of building an EMR is beyond the capabilities of a single developer. That is not to say definitively that it is impossible. However, by the time a single person could complete such a project, it would be obsolete.

In retrospect, the project was not a complete failure. openEPRS was a great opportunity for learning Ruby on Rails which helped me become a better developer. Now, on to the next challenge!

KB: Running Cruise behind Apache with SSL on Ubuntu

Configuration guide for running Cruise behind Apache with SSL on Ubuntu Linux. Read the rest of this entry »

Cruise and Ubuntu System Wide Environment Settings

I discovered a strange little problem the other day. I just completed my install of ThoughtWorks Cruise on a server running Ubuntu 8.04 LTS. In case you haven’t heard of it, Cruise is a continuous integration and release management system. Everything appeared to be running correctly; so I proceeded to setup a pipeline for an Android project I was working on.

Android uses Ant to build and manage a project outside an IDE such as Eclipse. This looked like a no brainer using Cruise’s <ant> task. I had Ant 1.7.1 installed with the following lines in my server’s /etc/environment file: Read the rest of this entry »