The Secret Diary of a Xamarin Android Developer, Aged 48 1/3

WallpaperColors

I have been trying to update Catfood Earth for Android to support Material You in Android 12. This sets a color palette from your wallpaper and other than making notifications harder to manage seems to be the main thing that Google has been working on for the past year. Live wallpaper isn't automatically supported, it's up to you to tell the system about your colors.

Happily there is an overridable OnComputeColors in WallpaperService.Engine, and you can create a WallpaperColors object from a bitmap so this looked like a five minute update. Hahahahahahhahahahah.

I spent a few weeks waiting for the Android 12 SDK to be available in Xamarin. I found some pointers to their GitHub and assumed it would show up there and so waited a few weeks. It still isn't there. I found some article about forcing it to install in Visual Studio 2019 that didn't work for me, and then realized that Visual Studio 2019 update checks were crashing. While trying to fix that I found that Visual Studio 2022 has been released and this installs with the Android 12 SDK!

These days I work on side projects when I get the occasional free hour. Almost inevitably that hour is consumed with updating two or three things and then hoping that the next time I get some time at least I'll be ready to go. But when that hour arrives I'm back to updating again.

So finally I have the right SDK and drop in an OnComputeColors and a call to NotifyColorsChanged when my wallpaper is updated. Time to start testing. The good news is that Material You is now working with Catfood Earth selected as the current wallpaper. The bad news is that every time I call NotifyColorsChanged the launcher disappears and I'm just left with the wallpaper and no icons or search box. Probably not a good experience. I try moving the NotifyColorsChanged call around to different points in code and it makes no difference. This simple update is rapidly spiraling from minutes to days to weeks.

Maybe it's some Xamarin bug, or something in Android 12 or maybe a change in the solemn contract between live wallpaper services and the rest of the system. Can't find any hint of any of this on the Internet.

It's also possible that the bitmap I'm passing is too large or too complex or too something else. So let's try just sending back a simple WallpaperColors in OnComputeColors and see if that helps.

The Android documentation for WallpaperColors suggests that you can construct it from three colors which seems sensible. The Xamarin implementation takes ColorObject instead of Color. What is a ColorObject? The sparse Xamarin documentation suggests that it has an empty constructor that creates an opaque black color and then properties like Red that are read only. So an immutable black? That can't be right? When constructing a color the constructor would seem like a great place to tell the class what color it is. Failing that, a FromColor or FromArgb would seem to follow the right sort of convention. But no. You need to find ValueOf. To create a color that is a class and not a value. Sigh. Maybe that is some kind of deep Android convention that I would just know if I did this more often than once a year or so.

Although, maybe most Google Developers can't figure out how to make a non-black color and that's the origin of Material Design 2. Everything else is just marketing rationalization on top of a terrible API.

Finally I have a simple WallpaperColors to test with but my build has broken. At some point while figuring out how to get a ColorObject that isn't black I thought a NuGet package would help. My project is now completely broken. My experience with touching NuGet is that you can either spend several days unpicking the carnage or just start over. Git reset --hard  HEAD it is then.

After quickly reimplementing the changes so far, returning a vanilla WallpaperColors object works... and so does the FromBitmap version. So 90% chance that I bodged something subtle the first time and didn't make the mistake on the second pass. 10% chance it was something strange in Visual Studio.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: The Secret Diary of a Xamarin Android Developer, Aged 48 1/3 #code #android #xamarin #catfood #earth An adventure in persuading Android live wallpaper to support Material You colors via the magic of Xamarin and weeks of frustration. )

Catfood Earth

Updated on Saturday, January 20, 2024

Catfood Earth

Catfood Earth uses satellite imagery and data feeds to create live wallpaper for Windows and Android. Earth shows you the current extent of day and night combined with global cloud cover (clouds updated every hour). You can also choose to display time zones, places, earthquakes, volcanoes and weather radar. The Windows version includes a screen saver. Catfood Earth was first released in 2003. Version 4 was fully remastered to support 4K resolution on both platforms.

Download Catfood Earth

Catfood Earth Themes

Catfood Earth can be quickly configured with three different themes. After installing, run Catfood Earth Settings and click one of the buttons to activate a theme. If you want to customize further then visit the layers and advanced tabs of the settings app, described in detail below. The themes are:

Natural Theme

Natural is the default theme. This combines day, night and cloud cover. The day image uses NASA's blue marble next generation monthly global composite. combined daily so you can see changes in snow, ice and even vegetation throughout the year. Next, global cloud cover is blended on top of the day image (updated hourly). Finally Catfood Earth computes the extent of day and night and blends in NASA's city lights image. You can update the image as frequently as every minute and watch the terminator between day and night move across the planet and change shape with the passing seasons. The video below shows how all three components of the natural theme change over the course of a year:

Time Zones Theme

The time zones theme shows the current time zone in each country and optionally international zones as well. This theme is highly configurable, you can choose to show borders, pick colors, show hours or hours and minutes and control transparency. Catfood Earth can also show the local time for anywhere on Earth, see the places layer for more details. The video below shows how the time zones change by country from May 2021 to June 2022:

Earthquakes Theme

The final theme, earthquakes, uses a different daytime map with a more geological look and adds earthquakes for the past 24 hours. Size is proportional to magnitude and the quakes fade out over 24 hours so the most recent are highly visible. Again it's possible to customize extensively via layers. You can show active volcanoes and control the colors used, transparency and which magnitudes to plot. The video below shows a month of earthquakes as seen in Catfood Earth:

Catfood Earth Layers

The layers tab is where you can fully customize Catfood Earth. Use the checkboxes to activate layers and then click each layer to access detailed settings. Layers are listed in the order that they are drawn (i.e. clouds are drawn on top of the day map, and then night is drawn on top of the clouds and so on).

Day Map

The first layer is the daytime map. Catfood Earth ships with two defaults. The first uses NASA's blue marble 2 monthly images, merged with a more attractive ocean image. Catfood Earth interpolates these images daily so the extent of snow/ice and vegetation will change in a subtle way throughout the year. The other default is a less colorful map that I feel works well with earthquakes and volcanoes. You can also browse to and select a different image if you don't like the defaults.

All the images and data layers in Catfood Earth use an equirectangular projection so if you are using custom images you should make sure that they use the expected projection.

Clouds

Clouds come from the Space Science and Engineering Center at the University of Wisconsin-Madison. These images are web mercator by default, my website downloads the global composite every hour and transforms the image to equirectangular for Catfood Earth. If you have a different source for clouds you can enter a custom URL. You can also set the color and transparency of the clouds layer. The defaults are designed to make the clouds fairly subtle.

Night Map

The last natural layer is the nighttime map. Catfood Earth ships with NASA's 2016 update to city lights. This layer is drawn on top of daytime and clouds where it is currently nighttime (updated as often as every minute, see advanced options below). You can set the transparency of the layer and also the width used to blend the terminator between day and night (in degrees). It's also possible to select a different nighttime image if you prefer.

Time Zones

The time zones layer is based on the IANA time zone database. You can change the colors used to show the time zones and control the transparency of national and international zones. You can also choose if minutes are displayed with the time zone legends at the top of the screen. This is a good layer to use in combination with the Places layer and the Political Borders layer (both described below).

Political Borders

This layer displays political borders in a configurable color.

Places

The places layer shows a list of places optionally combined with the local time for each place. I've used this to show office locations around the world (handy to know if it's a good time to call someone) and also to track my geographically dispersed family. Catfood Earth ships with a default list of major cities. You can add to this, or remove everything and start from scratch. You can even export and import the list to make it easy to share between different devices. For each place you just need to provide the latitude, longitude and time zone (from the same source as the time zones layer).

Earthquakes

Earthquake data is downloaded from the USGS feed and can show global quakes from magnitude 2.5 up. There is a lot you can fine tune for this layer - The fill and accent colors, number of past hours to show (up to 24), the transparency range (older earthquakes are more transparent) and the minimum magnitude to plot. You can also choose whether to show descriptions or not and the order in which to plot the quakes (time based, or size based which makes it easier to see what's going on when a lot of quakes hit a small area).

Volcanoes

Volcano data comes from the Smithsonian Institution's Global Volcanism Program. This shows currently active volcanoes around the world. You can set the fill and accent colors, the transparency to use and whether to show descriptions or not.

Weather Radar

The final layer shows weather radar from the National Weather Service. This layer is US only. Enter a list of one or more radar stations to display, separated by commas. You can find your local station(s) at the NWS web site.

Catfood Earth Advanced

The advanced tab of Catfood Earth Settings controls how the final image is displayed and also allows you to render sequences of images (this is how I made most of the videos above).

Set how often the image is updated in minutes, as frequently as every minute which is handy if you're displaying the local time for places. You can also skip the first update when Catfood Earth loads (potentially useful at boot time when Windows is starting a lot of programs).

There are some settings relating to text display: a global font size and an option to use drop shadows.

Earth can be centered to a specific longitude (default 0) or to a specific time. If you choose a time then the image will rotate throughout the day to keep that local time at the center of the screen.

It is also possible to set a specific output size and location for the wallpaper. The default is to fill the screen.

Click Render Images to output a sequence of images. If you use a proxy server click Proxy Settings to configure.

Finally there are some troubleshooting options that you might be asked to use if you need help with the product.

Render Images

Render Images allows you to create frames from Catfood Earth based on current settings. This is useful for making animations based on how the Earth image changes over time. Set a start date/time (UTC), how to increment time between frames, the number of frames to generate, the size and an output folder. Earth will then create a sequence of JPEGs. This works well with computed layers like day/night and time zones. It will not work well with live data like clouds and earthquakes. I have made videos from live data as well, but this involves storing many images and/or data points and is not currently supported in Catfood Earth.

Catfood Earth for Android

Catfood Earth is a little different on Android. Because phones are mostly used in a portrait orientation the wallpaper shows the full range of latitude but only a segment of longitude depending on the screen size of the device. The wallpaper is the same as the natural theme in Catfood Earth for Windows (blue marble 2 day map, clouds, city lights night map) with the optional addition of earthquakes.

Run Catfood Earth and click Settings to configure. The slice of Earth displayed is based on a central longitude. By default this will update to your phone's current location. You can also set a manual location. -90 degrees works well to center North America. In addition to the central longitude you can opt to show recent earthquakes, control cloud and night transparency and the width of the terminator between day and night. There are advanced options to ignore screen size changes and reuse the most recent image, and to paint black under the menu bar which is useful on some devices.

After configuring Catood Earth just select it as your current wallpaper. You can do this from device settings or tap the Set Wallpaper button in the Catfood Earth app.

Catfood Earth for Android is optimized for battery life. It will update around every ten minutes and so it might take that long to see any changes to settings. Clouds are downloaded every hour. If using your phone location it accesses the last location fix established by other apps.

Installation and Support for Catfood Earth

Catfood Earth for Windows requires version 4.8 of the .NET Framework. You almost certainly have this already and the installer will download if necessary. The installer for Catfood Earth is digitally signed. You may get a warning about it being infrequently used which you will need to ignore to install.

For support please visit this post, check to see if your issue has already been addressed and if not leave a new comment.

Customer Reviews

Updates

Catfood Earth 4.40

Most of the layers enabled in Catfood Earth 4.40.

Catfood Earth 4.40 is now available to download.

With this release Catfood Earth is 20 years old! This update includes version 2023c of the Time Zone Database and the following bug fixes.

The National Weather Service changed one letter in the URL of their one hour precipitation weather radar product. It needs to be BOHA instead of BOHP. Presumably just checking that data consumers are paying attention? Weather radar is working again.

Not to be left out the Smithsonian Institution Global Vulcanism Program has decided to drop the www from their web site. The convention here is to redirect but they're content with just being unavailable at the former address. Recent volcanoes are working again as well.

The final fix is to the locations layer. Editing a location was crashing. This was due to a new format in the zoneinfo database that was not contemplated by the library that I use. As far as I can tell this isn't maintained any more since the death of CodePlex. While working on this update I started using GitHub Copilot, their AI assistant based on GPT 3.5. I was amazed at how helpful it was figuring out and then fixing this rather fiddly bug. The locations layer is back to normal, and I have regenerated all the time zone mapping as well.

Catfood Earth for Android 4.30

Catfood Earth for Android 4.30

Catfood Earth for Android now supports random locations. The slice of Earth displayed will change periodically throughout the day. You can still set a manual location or have Catfood Earth use your current location. Install from Google Play, existing users will get this update over the next few days.

Catfood Earth 4.30

Catfood Earth Satellite Composite Image of Earth including Volcanoes and Earthquakes

Catfood Earth 4.30 is available to download.

This update fixes a couple of problems with the screensaver. It now has improved support for multiple monitors (the image will repeat rather than stretch). There was a problem with the screensaver not starting in some cases. This should now be fixed. After upgrading to 4.30 please find and run the 'Catfood Earth Screensaver Settings' shortcut to configure the screensaver.

4.30 also includes version 2022d of the time zone database.

Catfood Earth for Android 4.20

Catfood Earth for Android 4.20

Catfood Earth for Android 4.20 adds support for Material You, the custom color scheme introduced in Android 12. By default every wallpaper update will also subtly change your system color palette. You can override this from settings -> Wallpaper & style and switch back to basic colors if you don't like the Catfood Earth colors. This update was surprisingly painful. You can install Catfood Earth from Google Play, or for existing users it will automatically update in the next day or so.

Catfood Earth 4.20

Catfood Earth 4.20

Catfood Earth 4.20 is available to download.

This update includes the 2021d time zone database.

After procrastinating for far too long I have also migrated to .net 4.8 and renewed my code signing certificate. You'll get at least one less warning when installing and you no longer need to enable .net 3.5 on Windows 10 which was a pain. This shouldn't make any difference but please let me know if you have any trouble installing or running this version.

Catfood Earth 4.10

Catfood Earth 4.10

Catfood Earth 4.10 is available for download.

The National Weather Service updated their weather radar API. The weather radar layer has changed a bit, you can enter one or more (comma separated) weather station IDs and Earth will show one hour precipitation for all of them. You used to be limited to a single station but with more options for the rader layer to display. Let me know if you love or hate the new version.

4.10 also includes the latest 2021a time zone database.

(I'm sure there are great reasons for it, but the 'new' NWS API is an XML document per station that links to a HTML folder listing of images where you can enjoy parsing out the latest only to download a TINY GZIPPED TIFF file FFS).

Catfood Earth 4.01

Catfood Earth 4.01 is available for download.

The timezone database has been updated to 2020a. There is also a small fix to a problem with screensaver installation on recent versions of Windows 10.

Catfood Earth for Android 4.00

Catfood Earth for Android 4.00

Catfood Earth for Android 4.00 is available for download and is updating through the Google Play Store.

As with the 4.00 update for Windows all images have been remastered to 4K resolution. Earth for Android has also been updated to better support Android 10 (updates are faster and the settings layout looks much better). You'll need to grant location permission in settings to have Earth automatically center on your current location. It's also possible to set a center longitude manually (I find -90 works well for centering most of the Americas).

Catfood Earth 4.00

Image from Catfood Earth 4.00

Catfood Earth 4.00 is available for download.

The main change is that all of the images shipped with Catfood Earth have been remastered to 4K resolution. This includes NASA Blue Marble 2 monthly images (which Catfood Earth interpolates daily) and the 2016 version of Black Marble (city lights at night). The Catfood Earth clouds service has been updated to full 4K resolution as well.

Earth 4.00 also includes an update to the 2019c version of the Time Zone Database.

As well as providing desktop wallpaper and a screensaver, Catfood Earth can render frames for any time and date. To celebrate the release of 4.00 I created the 4K video below which shows all of 2019, 45 minutes per frame, 9,855 frames. You'll see the shape of the terminator change over the course of the year (I always post the seasonal changes here: Spring Equinox, Summer SolsticeAutumnal Equinox, and Winter Solstice). If you watch closely you'll also see changes in snow and ice cover and even vegetation over the course of the year.

Catfood Earth 3.46

Improved clouds in Catfood Earth

Catfood Earth 3.46 is now available for download. Catfood Earth for Android 1.70 is available in the Google Play Store and will update automatically if you already have it installed.

This follows hot on the heels of the last release as the new clouds layer service running on this blog can update far more frequently than the source used prior to 3.45. You will now get a fresh helping of clouds every hour! Unrelated to this release I've improved the quality of the clouds image as well. If you're interested you can read about this in exhaustive detail here.

Catfood Earth 3.45

New cloud layer image in Catfood Earth

Catfood Earth 3.45 is now available to download. Catfood Earth for Android 1.60 is available on Google Play and will update automatically if you have it installed.

I only just released 3.44 with some timezone updates but in the past week the location I had been using for global cloud cover abruptly shut down. If you like up to date clouds you'll want to install the new versions as soon as possible. With this update I'm building a cloud image every three hours and serving through this blog (and thankfully CloudFlare) so any further changes should not require a code release.

Catfood Earth 3.44

Updated timezones in Catfood Earth 3.44

Catfood Earth 3.44 is now available to download.

The timezone database has been updated to 2018i.

Eric Muller's shapefile map of timezones is no longer maintained and so Catfood Earth has switched to Evan Siroky's timezone boundary builder version.

A bug that could cause all volcanoes to be plotted at 0,0 depending on your system locale has been fixed.

Download Catfood Earth.

(Previously)

Catfood Earth 3.43

North Korea moves back to UTC +09 on May 5, 2018

Catfood Earth 3.43 updates the timezone database to 2018e. The big change is that North Korea is moving back to UTC +09 today (May 5, 2018). The time zones layer in Catfood Earth shows the current time in each zone at the top of your screen and color codes each country and region. You can also display a list of specific places (either an included list of major cities or your own custom locations).

Catfood Earth is dynamic desktop wallpaper for Windows that includes day and night time satellite imagery, the terminator between daytime and nighttime, global cloud cover, time zones, political borders, places, earthquakes, volcanoes and weather radar. You can choose which layers to display an how often the wallpaper updates.

Download Catfood Earth.

(Previously, Previously)

Catfood Earth 3.42

Catfood Earth 3.42

Catfood Earth 3.42 is a small update to the latest (2016d) timezone database and the latest timezone world and countries maps from Eric Muller. If you use the political borders, places or time zones layers in Catfood Earth then you'll want to install this version.

Download the latest Catfood Earth.

(Previously)

Catfood Earth 3.41

Catfood Earth 3.41

Catfood Earth 3.41 fixes a problem that was preventing the weather radar layer from loading.

I've also updated to the latest (2015g) time zone database and the latest time zone map from Eric Muller.

Download the latest Catfood Earth.

(Previously)

Catfood Earth 3.40

Catfood Earth 3.40

I've just released Catfood Earth 3.40 for Windows and 1.50 for Android.

Both updates fix a problem with the clouds layer not updating. The Android update also adds compatibility for Android 5 / Lollipop.

Also, Catfood Earth for Android is now free. I had been charging $0.99 for the Android version but I've reached the conclusion that I'm never going to retire based on this (or even buy more than a couple of beers) so it's not worth the hassle. Catfood Earth for Windows has been free since 3.20.

Enjoy!

Volcanoes Back (Catfood Earth 3.30)

Volcanoes Back (Catfood Earth 3.30)

Catfood Earth fans will want to download Catfood Earth 3.30. This update fixes a problem where volcanoes were all plotted in the middle of the screen.

Catfood Earth for Android 1.40

Catfood Earth for Android 1.40

Catfood Earth for Android now includes the option to display earthquakes (magnitude 5.0 or higher) from the USGS feed.

Catfood Earth 3.20

Catfood Earth 3.20

Catfood Earth 3.20 for Windows is now available for download. This update fixes a change in the feed address for the earthquakes layer. I've also switched to using the new NASA Black Marble night-time image and 3.20 includes the latest time zone and political border data.

Earth for Android has been updated to 1.30. This includes the new Black Marble image.

Catfood Earth for Android 1.20

Catfood Earth for Android 1.20

I recently upgraded to the HTC One which has a transparent notification bar. This makes it hard to see notification icons when using Catfood Earth as your wallpaper, at least in the summer when it's always light at high latitudes and your white icons are displayed on top of polar ice and clouds.

Catfood Earth for Android 1.20 fixes this with an option to paint black under the notification bar. That's the only update other than the latest Xamarin runtime.

Catfood: Earth for Android 1.10

Catfood Earth for Android 1.10

I’ve just released Catfood Earth for Android 1.10. You can control the center of the screen manually (the most requested new feature) and also tweak the transparency of each layer and the width of the terminator between day and night. It also starts a lot faster and has fewer update glitches. Grab it from Google Play if this looks like your sort of live wallpaper.

Catfood: Earth for Android

EarthForAndroid

I’ve just released Catfood Earth for Android. It’s my second app created with Xamarin’s excellent toolkit. Being able to develop in C# allowed me to reuse a lot of code from the Windows version of Catfood Earth. The Android version doesn’t include all the same layers (yet) but it’s got the main ones – daytime (twelve different satellite images included, based on NASA’s Blue Marble Next Generation but with some special processing to make them look better), nighttime (city lights, shaded to show nighttime and the terminator between day and night) and a clouds layer that is downloaded every three hours.

My main worry had been that this would suck the phone battery dry, but after a fair amount of optimization it doesn’t even register on the battery consumption list. Grab it now from Google Play ($3.99, Android 2.2 or better).

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

(Published to the Fediverse as: Catfood Earth #code #earth #catfood #android #c# #xamarin #monodroid #volcanoes #software #windows #weather #radar #timezone #clouds #video #screensaver Live wallpaper for Windows and Android that combines Blue Marble 2 NASA satellite imagery with live feeds of clouds, earthquakes, volcanoes and more. )

Catfood Earth for Android 1.20

Updated on Monday, May 31, 2021

Catfood Earth for Android 1.20

I recently upgraded to the HTC One which has a transparent notification bar. This makes it hard to see notification icons when using Catfood Earth as your wallpaper, at least in the summer when it's always light at high latitudes and your white icons are displayed on top of polar ice and clouds.

Catfood Earth for Android 1.20 fixes this with an option to paint black under the notification bar. That's the only update other than the latest Xamarin runtime.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Catfood: Earth for Android

Updated on Monday, May 31, 2021

EarthForAndroid

I’ve just released Catfood Earth for Android. It’s my second app created with Xamarin’s excellent toolkit. Being able to develop in C# allowed me to reuse a lot of code from the Windows version of Catfood Earth. The Android version doesn’t include all the same layers (yet) but it’s got the main ones – daytime (twelve different satellite images included, based on NASA’s Blue Marble Next Generation but with some special processing to make them look better), nighttime (city lights, shaded to show nighttime and the terminator between day and night) and a clouds layer that is downloaded every three hours.

My main worry had been that this would suck the phone battery dry, but after a fair amount of optimization it doesn’t even register on the battery consumption list. Grab it now from Google Play ($3.99, Android 2.2 or better).

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Share a picture in MonoDroid

Updated on Sunday, November 6, 2022

Here’s how to share a picture to Facebook, Twitter and so forth from MonoDroid:

A fun mix of Java and C#. The directory got me to start with so check to see if the ExternalCacheDir is available and if not fall back to the internal CacheDir. Frustratingly Facebook doesn’t pick up on the text associated with an image regardless of the intent ExtraWhatever specified.

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)

Catfood: WebCams for Android

Updated on Sunday, September 5, 2021

Catfood WebCams for Android

I’ve just released a WebCam app for Android. It’s based on WebCamSaver but allows you to control the webcam – you tap the edges of the screen to pan, pinch to zoom in and out. A fun little time waster.

This is the first app I’ve released using Xamarin’s MonoDroid framework. This integrates nicely into Visual Studio and allows you to program an Android app in C#. This is fantastic for productivity and code reuse and I enjoyed the process a lot more than previous work I’ve done in Java / Eclipse. The main drawback is that the framework adds around 5MB (significant for mobile) and the documentation isn’t always the best, especially when you search for something and find out you’ve been dumped into iOS reference material. Digging around the sample code and cross-referencing the official Android documentation helps a lot. I’m going to take a stab at something a little more ambitious next…

Add your comment...

Related Posts

You Might Also Like

(All Code Posts)