Those of you who have been following my progress on the rewrite of Smooth Calendar have probably figured out that its slow, super slow. Its just hard to work up the drive to do something that I have already done before, and that for me works fine.
Today I found the drive to play around a bit with the rendering of the widget, trying to solve the one issue that I feel the current implementation has, namely that you can not position the time/date/event in a fixed position, that is maintained for each row. This is due to the widget being a list, and each row is just a line of text in that list. This is turn is due to limits set in Android on RemoteViews which is the component used to build a widget.
I had a couple of ideas on how I could solve this, the first one was to use a GridView and letting each part of the row be its own item in the GridView, and by setting the numColumns to four each row would consist of the needed number of items. The reason this approach didn't work was that there is no way to control the width of the items, which in turn means that there is no way to control that the items "on top" of each other are the same size.
Android has a Layout that allows you to have a Grid, its fittingly called GridLayout and it is available to the RemoveViews, but its not scrollable, which is a feature that I wasn't prepared to sacrifice to get the positioning support, so this is the solution i now have come up with.
The main interface will contain a ListView that is scrollable, in turn backed by an adapter that only ever contains one item, a GridLayout. The ListView is then used as a RemoteViews able ScrollView, and allows the GridLayout to be scrolled if it is higher than widget. The GridLayout in turn has its own limitations, the first is that it is of a fixed size, we can not change the number of rows and columns at runtime, so what I have done is created a number of layouts, with increasing number of rows, that will be loaded when the widget is rendered to match the number of items the user has set the widget to show. The number of columns is easier handled since I can just set any elements I don't want to GONE and they will disappear. Since we still cant set the width of the columns in the GridView dynamically another trick was needed to allow the user to be able to add the desired amount of padding between the items, and this is by using ImageViews with dynamically created transparent images matching the padding the user wants.
So, the conclusion to all this is that I now have a layout for the calendar items that allow them to be positioned in straight columns, while still being scrollable if the number of items is larger than the display area of the widget.
Hopefully it wont be another year until my next update.
<< The journey to Smooth Calendar 2.0 State of Smooth Calendar 2.0 >>