Tuesday, October 6, 2015

Espresso: Save and restore state

Do you save and restore state of your activities, fragments and custom views? Do you test them?

One way to test saving and restoring state is to rotate the screen in your Espresso test.

private void rotateScreen() {
  Context context = InstrumentationRegistry.getTargetContext();
  int orientation 
    = context.getResources().getConfiguration().orientation;

  Activity activity = activityRule.getActivity();
      (orientation == Configuration.ORIENTATION_PORTRAIT) ?

With this helper function, you can write tests like this:

public void incrementTwiceAndRotateScreen() {

      .perform(click(), click());



Source code

https://github.com/chiuki/espresso-samples/ under rotate-screen

Like this article? Take a look at the outline of my Espresso book and fill in this form to push me to write it! Also check out the published courses: https://gumroad.com/chiuki

Saturday, October 3, 2015

How I prepared my keynote

The idea

My speaking buddy Corey Latislaw and I were both speaking at Write/Speak/Code. We talked about taking our speaking career further, and decided that keynote will be the logical next step. We were not sure how people get to keynote, but figured that we can brainstorm ideas and submit them as conference proposals.

Corey ended up keynoting at Droidcon NYC and I gave my keynote at Android Summit, just half a year since that day we brainstormed. Not bad!


This is a fancy word for cutting paper into little pieces, write one point on each, and arrange them on the table. This is how I organize my ideas. I like the transient feeling of pencil and paper. Nothing is set in stone, and I am free to rearrange everything.

Talk it out

Once I organized the storyboard into a linear narrative, I sounded out the ideas i.e. I gave a very early version of the talk to a lovely white wall in my house.

It was horrible. I stumbled in many places, unable to vocalize my thoughts. Normally I just talk to my technical slides without any scripts, but a keynote is very different. I need a strong narrative, and I decided that scripting is the way to go.

Write the script

I started writing my talk as if it was a blog post. Unlike speaking to my pencil-and-paper slides, I can jump from place to place to flesh out the paragraphs. I wrote 5 pages of text, and felt really good about it.

Read the script to time it

Next I read my script aloud to see how long it would be. It was 11 minutes, and I panicked, because my keynote was supposed to be 30 minutes.

Add more material

I knew I needed to add more material, but I was not sure what. At that point I was hosting the Technically Speaking hangout, and after we got off air I told Caroline Goyder that I am short on material. She told me to tell stories. Of course!

I added some personal stories, and also added a section at the end to give some counter points to balance the rosy picture I painted in the early part of the talk.

Make slides

My talk was much more meaty at this point, and it was time to try talk it out aloud to actual slides. That meant I had to make the slides.

My slides had a lot of illustrations. I redrew the pencil-and-paper slides on a drawing app on my tablet and imported them into Keynote, adding drop shadows to make them pop.

You can read more about how I draw the slides here: How to make hand-drawn slides.

Practice with my slides

Once the slides are done, I read my script while advancing the slides. It was 25 minutes long, which was perfect. Next I gave the talk to myself with just the slides, no script or speaker notes, to make sure there were enough visual cues for me to remember the flow. I recorded this version with Quicktime so I can make timing adjustments as necessary.

Live audience via Google Hangout

I want to get some feedbacks for my talk, so I scheduled a Google Hangout with my friends to give it to a live audience. We had quite some technical hiccups, namely, they could not see the slides. As a result some part of the talk was a bit confusing, but overall they liked the content, and gave me some pointers to improve.

Schedule tweets

Finally, I scheduled some tweets with Buffer so the audience can get relevant links as I speak.

I wrote a separate blog post to explain how I did it: Live tweet my own talk.

My outfit

I want to wear a dress for my keynote, but I need somewhere to clip the microphone. A belt wouldn't work since the dress I picked didn't have belt loops, and I didn't want to wear a jacket. I ended up wearing shorts under my dress.

The bad news is that I had to run to the bathroom to clip the microphones onto my shorts and thread them up to my neckline. The good news is that the shorts were robust enough to support the weight of two microphones, one for the sound system in the room, one for the video recording.

Show time

I went to the venue early to test the projector, walking to the back of the room to make sure that the text is readable. I also tried my presentation remote. After that I spoke with the cameraman and AV person to make sure that everything was in order. With that, I was ready for show time!

How to make hand-drawn slides

I have been doodling quite a bit for my sketchnotes, and I wanted to use them to illustrate my Android Summit keynote.

Pencil-and-paper draft

When I organized my thoughts for the talk, I cut paper into small pieces and draw one picture on each. These are the draft illustrations.

Some of them I was not sure how to draw, so I searched on the web for outline images of the concept, and copied it.

Copy pictures from the web

When I first started sketchnoting, I was really hung up on the idea that I was doing art, and copying is a big no no. But I copy code from StackOverflow all the time, and had no problem with that whatsoever. So I started copying drawings, and found that it always comes out as my own style (due to the lack of artistic skills to make precise copies), so I don't feel bad at all about copying.

Elephant I tried to copy

My elephant

I pick images that have simple outlines, and not too many curves. I found it difficult to copy curves, and if the drawing depends on the curvature to convey the idea, my copy will look horrendous. So I just avoid those.

Redraw on tablet

Once I was happy with the draft slide deck, I redrew the slides on my tablet.

I did not have time to investigate which software I want to use, so I just did a search on a drawing app on Android that supports layers. I ended up using MediBang Paint.

I wanted layers because I reuse some components of my drawing. For instance, I have a book icon to describe experts as people who wrote books, and then later I have a "Rant Book" where I jot down talk ideas.

It was much harder to draw on the tablet than on paper. The tactile feedback was very different. Also if I rest my hand on the tablet, it will make marks in unexpected places. Frustrated, I wore a glove to prevent accidental touches.

Also, the export UX flow for MediBang Paint was quite clumsy, so I spent quite a lot of time preparing the image files.

Import to Keynote

After I exported all the images as transparent pngs, I imported them into Keynote. I added drop shadows to make them pop on the page. I then add reveals and animations as appropriate.

My style

It was a lot of work to make my own illustrations, especially since I am a developer by trade and did not have a good workflow. But it was totally worth it. I really like the final look-and-feel, which adds a personal touch to my talk.

Live tweet my own talk

My Android Summit keynote refers to many of my blog posts, and I want to provide links for people to read more. I could stuff all the links in the slide deck, but I decided to try something fun: Live tweet my own talk.


I used Quicktime to record my talk rehearsal, and watch the video with a pencil and note pad to jot down the minute marks that I am on a topic with a relevant blog post.


With the timings, I schedule the tweets to using Buffer so they go live as I speak.

Ask people to follow

I put my twitter handle on every slide, and tell people to follow me so they can get the relevant links as I speak. People were really surprised to get notifications for my tweets while I was clearly still on stage busy speaking!

Thursday, September 10, 2015

Sketchnotes 2015

I started sketchnoting in March 2015, and love how it connects me with people and ideas. Most of these sketchnotes are already posted on my twitter account using my phone, but I thought it’ll be nice to collect the scanned version for easy browsing. They are much higher resolution, and also color corrected.

I was waiting until the end of the year make this collection. Then I realized, hey, we live in the internet age, where things can be updated!

I am hosting the PDF at http://gum.co/Sketchnotes2015​ so I can add more sketchnotes until the end of the year, and you will get email notifications when I do.

Download Sketchnotes 2015

Enjoy, and looking forward to your sketchnotes!

Thursday, September 3, 2015

Droidcon NYC 2015

I was really excited about Droidcon NYC, not only to learn the latest in Android development, but also to hang out with my fellow female developers. With 22% women speakers, it was not difficult to bump into them during the conference. And I loved it.

Android Dialogs

Huyen and I flew in a day early to record for Android Dialogs, and we got a lot of footage to edit. Here is a recap video to thank everyone who helped us, especially Yash who booked a conference room at her office for us.


My talk, Advanced Android Espresso, was assigned to a smaller room upstairs. I have to admit I was disappointed when I saw that. However, everything changed when I was actually in the room. It was packed, and people were staying at the back. The energy was way better than the main stage, which can hold all the attendee so by definition will be rather empty during the 4-track sessions. I much prefer to have a full house!

Droidcon NYC talks are 40 minutes each, and I had so much to share on Espresso that I took them all up. At the end of my talk, I said, “I won’t be taking live questions. Please come up to chat off stage.” Afterwards, my friends told me that they were quite impressed that I dared to defy the norm of taking questions after a talk. Hey, it’s my stage, and I get to call the shots :)

Diversity panel

Besides the Espresso talk, I was invited to be on the diversity panel at Droidcon NYC. We got an audience question on how to cope with a misogynist boss. A female panelist replied that sometimes the best thing to do is to walk away, only to be contradicted by a male panelist, who suggested talking to HR.

“Go to HR? That will destroy your career!”, I thought to myself. “Why would he say that? Are we now touting the party line?” I was so shocked that I did not know what to do. Fortunately, Corey jumped on stage and said what I wanted to say: HR is there to protect the company, not the employee.

We had a discussion off stage after the panel, and to my surprise, the men actually did not know the horror stories of women going to HR only to face retaliation! It was so widely circulated in my circle that I assumed everybody knows.

This panel was truly an eye opener.


I started sketchnoting in March, and it was been amazing to see the community pick up on it. There were so many of us sketch noting at Droidcon NYC, including a professional who recorded the keynote by Corey Latislaw.


One of the speakers had an emergency and could not make it to the conference. The other speakers want him to be there in spirit, so they inserted a meme slide to their deck!

Droidcon is a truly special community. We are fun and helpful, always ready to step up and make things happen. So honored to be a part of it!

Monday, August 31, 2015

Speaker outreach: Your turn

I launched a grassroots campaign to bring more women to the stage of Droidcon NYC, because I was sick and tired of conference organizers saying that they tried to diversify their speaker lineup, only to see the same composition over and over again. I did it to prove a point, that it is possible.

Proof of concept

The proof of concept was a great success: we had 22% women at Droidcon NYC. But it was also a lot of work. A LOT of work. I published what I did so others can use it as a blueprint to do the same, because I cannot go make this happen again and again for other conferences. It is not scalable.

I need you to step up.

Up the ante

Conference organizers, you are not off the hook. The fact that I did it as a grassroots effort means that you need to do better. It does not mean that you can now offload the responsibility.

There are so many more things you can do in an official capacity:

  1. Clear guidelines. To diversify your speaker lineup, you need to encourage more first-time speakers, whose default is to believe that they don’t have anything worth talking about. However, if you give a concrete list of topics and provide the schedule and description to previous editions, chances are they will see something that matches what they do, and be more compelled to submit a proposal.
  2. Official feedback. An outside mentor can only guess how the conference curates content. As the organizer, you can work with the potential speakers to tweak their proposals so that they are more appropriate for the audience and avoid clashing with other proposals.
  3. Find more sponsors.To level the playing field for people from underprivileged backgrounds, cover the travel expenses for the speakers. This removes a major roadblock for many people, and is much more difficult for a grassroots effort to provide.

Doing is caring

Lip service is not enough to move the needle. You need to put in the effort, and keep at it. I hope my example at Droidcon NYC motivates you to step up and take action!

Reference: blog.sqisland.com/2015/08/droidcon-nyc-22-percent-female-speakers.html