Android Subtle Prompt library

How to create a Guardian style subtle prompt to highlight your new features

Jesús Gumiel

Published on Friday, 6 March 2015

Android   Software  

Subtle prompt on the Guardian’s Android app.
Subtle prompt on the Guardian’s Android app. Photograph: Android app screenshot

Sometimes the difference between a brilliant feature and one that nobody will use is a simple detail. Not an algorithm, not the quality of the code, nor how easy it can make the life of users. You can develop the best feature in the world, but if nobody knows about it, you’ve got nothing.

That thought was at the top of our minds a few months ago, when we faced the challenge of showing the users what’s new on the Guardian mobile app. And believe me, something so simple (in theory), can be quite tricky if you want to do it well.

There are some common patterns to achieve this target:

These were the criteria we had when we started the work: It should be clear but non-intrusive, beautiful and effective. And this was the idea our wonderful UX team proposed. They called it subtle prompts.

The idea is to show an inline prompt at the top of the page pointing to the action bar button that allows you to access the new feature. The prompt contains a simple explanation of the feature, and can be dismissed either explicitly through clicking, or implicitly by scrolling down the page. The prompt itself slides into view smoothly, while an additional animation makes the button it is pointing to ‘pop’ to attract the attention of the user. Simple, clean and effective.

When we were developing the subtle prompt code, we felt it would be useful enough to create a library with it. In our app we have different kinds of subtle prompts: one for expandable lists and another for webviews. Sometimes they are attached to an action button, at other times they simply notify the user about a feature without being directly attached to a UI element. Different UX, with images, without them… this certainly seemed like a good candidate for a standard library, easy to reuse and extend, to cover all our requirements.

Of course, at the Guardian, ‘be open’ is one of our guiding principles, so we made the library public so any Android developer can use it. Here is the GitHub project.

Let’s look at how to implement our save for later articles subtle prompt. This example shows a subtle prompt with an image, that appears attached to an animated action button.

In this case, the subtle prompt appears on an ExpandableList. This is probably the more difficult case, as we have to add the prompt as a header, and manage the scrolling.

We use our Helper class to create the type of subtle prompt we need. In this case, on a ExpandableList:

BaseSubtlePrompt baseSubtlePrompt = SubtlePromptHelper.getPromptOnExpandableList(context);

Now we assign some custom values: The view to animate, a listener to be notified when the prompt collapses, the text on the prompt and the different states of the animated button.

baseSubtlePrompt.setAnimation(animatedView, listener);
baseSubtlePrompt.setPromptTitle(promptTitle);
baseSubtlePrompt.setPoppingIcon(poppingIconDrawable);
baseSubtlePrompt.setStandardIcon(standardIconDrawable);

Our prompt includes some body text and an image, as well as the title, so we add them.

baseSubtlePrompt.setBodyText(bodyString;
baseSubtlePrompt.setPromptImage(promptDrawable);

We use a custom drawable for the ‘close’ button of our subtle prompt.

baseSubtlePrompt.setPromptCloseButton(closeDrawable);

And this would be an example of the listener we assigned on the first step. The listener allows us to control what happens when the subtle prompt is collapsed. For example, we could save some data to preferences.

new BaseSubtlePrompt.Listener() {
    @Override
    public void onCollapseStart() {
        // Do something when the subtlePrompt starts to collapse
    }
    @Override
    public void onCollapseEnd() {
        // Do something when the subtlePrompt finishes to collapse
    }
});

It is possible to programatically dismiss a prompt by calling collapsePrompt – for instance, when the user scrolls, we could call it from within a scroll listener.

@Override
public void onScroll(AbsListView view, int firstVisibleItem, int visibleItemCount, int totalItemCount) {
    if (lastScrollState == SCROLL_STATE_FLING || lastScrollState == SCROLL_STATE_TOUCH_SCROLL) {
        PromptHelper.collapsePrompt(baseSubtlePrompt);
    }
}

There are lots of options to customise your subtle prompt: typeface, padding, margins, etc. Visit our public repo on GitHub and give it a try.

Continue reading

Fullstack 2014 - conference report Upgrading Elasticsearch: Content API’s dual stack strategy