Muzei Saver 2.0.0

Muzei is a pretty awesome live wallpaper app for Android created by Google developers Roman Nurik and Ian Lake. It has an API that allows it to be extended and use custom sources that change throughout the day. I’ve been using it (somewhat ironically) to change my Android wallpaper to the Bing Image of the Day for the past several years. Because sometimes I like to download the artwork and because Muzei makes this really easy with its API, I created a simple Android app called Muzei Saver.

A user recently emailed me with a feature request. Apparently some Muzei source plugins always publish their artwork with the same title/byline. Since the app constructs the filename from this metadata, downloading subsequent artwork would overwrite the previous file.

The user requested that I add a timestamp to the filename. “No problemo”, I thought. Then as I pulled the source code down from GitHub, I realized it was over three years old! A lot has changed with Android since then and this incredibly simple app needed to be rewritten to support modern standards.

The first step was to update the target SDK version from 21 (Lollipop) to 28 (Pie), Gradle from 2.2.1 to 4.10.1, and the Android Studio Gradle plugin from 1.0.0 to 3.3.1. I also took the opportunity to migrate from the old Android Support Library to the new AndroidX namespace. Then, because the old app was written in Java and I’ve since decided that Kotlin is amazing for Android development, I took the opportunity to rewrite it. The app is incredibly simple, so this was trivial. When I did so, I remembered to add a timestamp to the filename, per the original request. 🙂

Finally, I had one more unanticipated hurdle. Android introduced runtime permissions back in API 23 (Marshmallow). Because the app requires the
WRITE_EXTERNAL_STORAGE permission in order to save the artwork to disk, I now had to prompt the user to authorize this permission before saving the file the first time. At this point I was getting slightly irritated, so I pulled in the EasyPermissions library which made this relatively straightforward.

Finally, what I casually assumed would be a one or two line code change resulted in a complete rewrite over the course of an evening. It was a fun exercise, if for no reason than to remind myself how much Android development has changed over the years. And with that, the brand new version 2.0.0 was christened. Check it out for yourself with the links below.