Older blog entries for lucasr (starting at number 275)

Multi-part items in Smoothie

Smoothie makes it really easy to load ListView/GridView items asynchronously, off the UI thread. It handles all the complexity from gestures, threads, scrolling state, preloading, and view recycling behind a simple API.

Up until now, one of the biggest limitations of the Smoothie API has been the lack of proper support for multi-part items. What is a multi-part item? It’s a ListView/GridView item composed by multiple parts that have to be loaded asynchronously with different priorities as you scroll.

Classic example: a list of photos with items composed by the photo image and the author’s avatar—both loaded from the cloud. With the existing API,  Smoothie would force you to load the whole content of each item in one go. This means you were forced to load both the main photo image and the avatar image for each item before loading the next item in the list.

What if you wanted to start loading the main photo image of all visible items before loading their respective avatars? The photos are probably the content your users are actually interested in after all. That’s what the multi-part item support is about. It allows you to split the loading of each item into multiple asynchronous operations with different global priorities.

So, how would you implement the above example assigning higher priority to the main photo image over the avatar using Smoothie? Assuming you’re already familiar with Smoothie’s API, just follow these steps:

  1. Override the getItemPartCount() method from ItemLoader. Return the number of parts the item in the given Adapter position has.
  2. Handle the new itemPart argument accordingly in loadItemPartFromMemory(), loadItemPart(), and displayItemPart(). These methods will be called once for each item part.

The item parts will have indexes starting from zero. e.g. for items with 2 parts, the part indexes will be 0 and 1. The indexes also define the relative priority between parts. Smoothie will load the part with index 0 for all visible items before loading part with index 1.

Important note: I had to break the API backwards compatibility. If you don’t really need multi-part items, the only change you’ll have to make in your code is to subclass from SimpleItemLoader instead of ItemLoader. SimpleItemLoader is an ItemLoader specialized in single-part items that hides all the part-related bits from the API.

The updated documentation contains code samples and a more detailed overview of the new API. Grab the latest code while it’s hot. Feedback, bug reports, and patches are all very welcome as usual.

Syndicated 2013-04-22 11:51:24 from Lucas Rocha

Firefox for Android’s UI polishing Hackathon

We’ve been discussing the idea of doing periodic topic-oriented hackathons in the front-end team. The idea is simple: pick a topic—a specific part or aspect of the product—and have the whole team focused on it for a couple days. The goal is to bring substantial and fast improvements on specific areas.

As an initial experiment, we’ll be doing the first hackathon this week from Wednesday to Friday and we’re going to focus on UI polishing bugs—those UI papercuts that are not so prominent in isolation but, when fixed en masse, make a whole lot of difference.

It’s important to have a good list of bugs before we begin. So, you can start nominating Fennec bugs for the hackathon now by tagging them with “ui-hackathon”. We’ll cleanup this list and maybe prioritize them a bit during the planning session on the first day of the hackathon.

As usual, everyone is welcome to participate. You can help us by tagging bugs, or better yet, fixing them. Have a look at the wiki page for more details on the agenda.

Syndicated 2013-04-22 09:51:49 from Lucas Rocha

UI improvements in Firefox for Android

Now that we’ve landed all the major changes for our next UI iteration, it’s probably a good time to spread the word about it and get some more feedback.

The goals with these changes are: keeping a clear distinction between different types of tabs; making better use of the screen real estate on different form-factors and orientations; and being more compliant with Android’s design language. So, what’s new?

Tab types

With the introduction of private browsing support in Firefox 21—now in Aurora—came the need for a clear distinction between regular and private tabs. We’ve done two UI changes to accomplish that.

First of all, the tabs tray is now divided into sections for each type of tab—regular, private, and remote—so that you always keep things separate and organized. Furthermore, once you select a private tab, the main toolbar becomes dark as a clear sign that you’re in a different browsing mode.

Two-way tabs tray

We now use a horizontal scrolling tabs tray whenever it improves our use of the screen space. This is achieved with a TwoWayViewannounced a few days ago.

On phones, the tabs tray is vertical in portrait mode and horizontal in landscape mode. On tablets, the tabs tray is a vertical scrolling side bar in landscape mode and a horizontal strip in portrait mode. Small tablets (7″ or so) now share the exact same tabs UI than large tablets.


The Firefox UX team has been working on streamlining the Firefox UI across all platforms—both on desktop and mobile. The idea is that Firefox should feel like the same product wherever you use it. Finding the right balance between cross-platform design consistency and native platform compliance can be tricky but I think we’re getting there.

We’ve recently landed a new skin for Firefox for Android that is more aligned with Android’s Holo design language. Almost all textures and gradients were replaced by flat colors giving a much lighter feel to the browser. I love it!

All these UI changes are now available in the Nightly build. Give it a try and let us know what you think—ideally in form of bug reports!

Syndicated 2013-02-25 18:46:52 from Lucas Rocha

Introducing TwoWayView

We’ve been working hard on a new iteration of the tabs UI for Firefox for Android. The new UI includes a horizontal scrolling tabs tray to make better use of the screen real estate on phones and tablets in different orientations.

Unfortunately, the Android platform doesn’t provide any AdapterView with horizontal scrolling support nor could I find any non-naive open source implementation out there.  Enter TwoWayView.

TwoWayView is an AdapterView that can be scrolled either vertically or horizontally. Just set the orientation of the view and it will do the right thing for you. In its current state, it supports all the usual AdapterView APIs (selection handling, adapter, item click and long click listener, etc), view recycling, list selector, choice mode (single and multiple), edge glow, and scrollbars. Have a look at the sample app to see it in action.

The code is based on various bits and pieces of Android’s AdapterView, AbsListView, and ListView. It uses the necessary wrappers from Android’s Support Library in order to keep backwards compatibility.

The big missing features right now are focus handling, keyboard navigation, and accessibility. I’ll be working on those in the next few weeks besides all the necessary bug fixes—I don’t recommend using TwoWayView on production code just yet.

For now, feedback, bug reports, and patches are very welcome! Enjoy!

Syndicated 2013-02-21 14:47:33 from Lucas Rocha

Firefox for Android Talk in London

Chris and I will be giving a talk about Firefox for Android next Friday on the 22nd of February at the London Mozilla Space. Join us to learn a bit more about the current state of Firefox for Android and our plans for 2013.

We’ll talk in detail about how we run Gecko on Android, the past and future UI iterations, our graphics/rendering platform, and more!

The schedule is pretty simple. The doors will be open at 18h30 and we’ll start at 19h. The talk will be followed by free drinks and pizza in our community space. Interested? Register now at the event page. Hope to see you next week!

Syndicated 2013-02-15 17:13:13 from Lucas Rocha

New Blog Design

New year, time for a long overdue design refresh on my blog! The new WordPress theme that I’ve been slowly working on is now live. Here are some quick notes about the making of it.


The main goal of the new design is to bring focus to the content, nothing else. My main source of inspiration was definitely Opoloo’s Squirel Park blog. You’ll notice quite a few similarities in terms of content structure. Other relevant sources: Signal vs. Noise, Simon Foster, and Ian Storm Taylor.


The new theme uses FF Tisa Web Pro, FF Tisa Sans Web Pro, and Futura PT. Tisa has a subtle modern character without getting on the way. I love it. The fonts are served by Typekit. Their Personal plan is not that expensive and I got to choose the fonts from a fairly large library.


My previous WordPress theme had some serious issues: it was full of weird hacks, looked broken on certain browsers, and wasn’t responsive at all. The new theme is based on Bootstrap and adapts the content for different screen sizes nicely. Responsive images are implemented using picturefill. Some DB caching is done on the front page using WordPress’ Transient API. I’m using the Hypercache plugin for an extra performance boost.


I decided to disable comments as part of the switch to the new theme. I usually don’t get a lot of value from them anyway. Also, I don’t feel like spending any time moderating comments anymore. You can always find me on Twitter and Google+ if you got something to add or discuss.

The source code of the new theme is available on Github. Enjoy!

Syndicated 2013-01-25 12:18:18 from Lucas Rocha

Featured bug #2 in Firefox for Android

Before bringing up the next featured bug, it’s probably a good time for a quick update on the state of Firefox for Android’s coding community. Long story short: we have never had as many coding contributors as we have now! Here’s what some of them have been working on.

Sriram Raghuraman implemented a “set wallpaper” context menu option for images in web content. Greg Roodt added mouse wheel scrolling support. Mark Capella fixed a handful of bugs in different parts of our UI. Alex Nagacevschi implemented preliminary support for RTL content in Reader Mode. Ian Patterson fixed some weirdness in how downloaded images are named. Ravisankar Sivasubramaniam fixed  a bug on our input handling when switching tabs. And the list continues!

Want to have your name on this list? Here you go: bug 807990 is our second featured bug. It’s about a small but very useful feature in Reader Mode: adding a double-tap gesture to scroll the article a “screenful” distance. You’ll be mentored by yours truly. I’ve just added some background information to the bug report to get you started. Comment on the bug to take it!

I strongly recommend joining us on IRC (irc.mozilla.org #mobile) to get some support on setting up your development environment.

Syndicated 2013-01-23 21:34:34 from Lucas Rocha

Introducing Smoothie

A big part of Pattrn’s UI is about scrolling through lists of images from the cloud. So I spent a quite some time tuning it to ensure that the scrolling experience is as smooth as possible. In the past few weeks, I’ve been working on factoring out this code into a tiny library called Smoothie.

Smoothie provides a simple API to load ListView/GridView items asynchronously, off the UI thread. It does all the obvious things you’d expect—loading items as they become visible, cancelling item requests for recycled views, etc. But it does a bit more than that.

Smoothie is gesture-aware: it will avoid wasting item requests after a fling gesture and enable incremental item loading while you scroll the list with finger down. Furthermore, it supports offscreen item preloading to reduce the number of placeholder-type items as you scroll. Under the hood, Smoothie uses a thread pool executor backed by blocking queue with dynamic priorities. Offscreen item requests will dynamically get higher priority as they become visible on screen while scrolling.

So, how do you use it? It’s easy:

  1. Add an AsyncListView or AsyncGridView to your layout. They only add one extra setter method to their respective parent classes.
  2. Implement an ItemLoader with your app-specific logic for loading and displaying items. You’ll have to override four methods: getItemParams(), loadItem(), loadItemFromMemory(), and displayItem().
  3. Build an ItemManager with your ItemLoader and set it on the target AsyncListView or AsyncGridView.

Think of Smoothie as a slim backbone for your ListView/GridView‘s asynchronous loading. You can easily hook up your own image loading/caching framework in it. For instance. one of the sample apps implements an ItemLoader backed by Android-BitmapCache with a simple fade-in animation to display images.

Besides the API docs in the code, have a look at the sample apps to get a better idea of how to use the library. Keep in mind that the API is not final yet. Feedback is very welcome! Enjoy!

Syndicated 2013-01-06 23:48:43 from lucasr.org

Featured bug #1 in Firefox for Android

Keeping a list of good first bugs for new contributors is a common practice in some large open source projects. e.g. the Mozilla community marks these bugs with “good first bug” and the GNOME folks tag them with “gnome-love” in Bugzilla. The problem with these lists is that they tend to grow very quickly and become overwhelming to go through­—which kind of kills their original purpose of helping new contributors to find a task to get started.

I’d like to start a little experiment. What if we feature only one good first bug every other week? Featured bugs will have an assigned mentor and some initial overview of what has to be done. The effort to decide if you’re up for the task then gets much smaller, right? And if you don’t have time to work on the current featured bug, you can wait for the next one, no problem!

So, here we go: the first featured bug is bug 774309, mentored by Brian Nicholson (bnicholson). This bug is about adding support for Android’s voice search in Firefox. Brian has provided some initial code pointers in the bug. Interested? Just add a comment to the bug to take it. I strongly recommend joining us on IRC (irc.mozilla.org #mobile) to get some support on setting up your development environment.

Syndicated 2012-12-07 19:30:10 from lucasr.org


Tiago Rocha, my brother, has just released his first album, Humanufaturas! Humanufaturas is a delightful album. It’s sophisticated without sounding complicated.

You can download (and listen to) the complete album for free on the website. Spread the word about it! And while at it, why not donate any amount to help the project move forward? Go!

Syndicated 2012-12-05 14:13:26 from lucasr.org

266 older entries...

New Advogato Features

New HTML Parser: The long-awaited libxml2 based HTML parser code is live. It needs further work but already handles most markup better than the original parser.

Keep up with the latest Advogato features by reading the Advogato status blog.

If you're a C programmer with some spare time, take a look at the mod_virgule project page and help us with one of the tasks on the ToDo list!