Clean up MainActivity by factoring UI actions out into their own
functions.