Sunday, June 28, 2015

Android Camera2 API talk

Since I started helping with GDG Boulder, I have been only organizing beginner events, especially for Android, because I sensed that the audience does not have a lot of Android experience.

At our Android Hack Night in April, someone came up to me and said, "Can we have more advanced events? I haven't been coming because I am looking for more advanced material". I did a mental face palm when I heard that. Of course! I have been organizing beginner events. Beginners come. That doesn't mean we don't have members who want advanced events. I have been hungry for advanced Android talks myself, and should have just gone for it instead of tiptoeing around imaginary audience preferences.

Camera2 API

After hearing that I happily scheduled an advanced Android talk for June. Huyen gave an informative and entertaining talk on Camera2 API, and I really enjoyed it.

Raffle for ideas

I always ask people to tell me what topics interest them, but they never actually do. This time, my friend Dave Smith said he wants to give a way a couple of Android books, so we ran a raffle. To enter, people need to put in their name and also a suggestion for future event. I collected quite a few ideas this way. Win!

Friday, June 19, 2015

Android Dialogs: Launch!

My favorite part about going to conferences is to chat with people. I learn so much by talking shop. I was chatting with my friend Huyen about that, one thing led to another, and we ended up collaborating on a YouTube channel!

I present to you Android Dialogs, where we have bite-sized conversations with people from the Android community. In our first episode, Huyen and I interviewed each other.

We talked with quite a few people at Google I/O, so stayed tuned for more! Best way to stay tuned? Subscribe:

https://www.youtube.com/channel/UCMEmNnHT69aZuaOrE-dF6ug

Yes, the URL is awful. We need 500 subscribers to get a custom one. So, subscribe, pretty please?

Monday, June 15, 2015

A day in Colorado Springs

I have been reading a lot more graphic novels since I started sketchnoting. Right now I am reading An Age of License by Lucy Knisley, a travelogue with delightful illustrations. I am not even half done, and I already wanted to make a travelogue. So I did, with my trip to Colorado Springs last weekend!




Sunday, June 7, 2015

Espresso: Elapsed time

IdlingResource is a powerful concept in Espresso that is a little difficult to grasp. I have already written an example to wait for an IntentService to be idle, but I thought I'd write another example where it literally waits for time to pass.

Timer game

You start the timer, wait for a minute, and stop it. The game mocks you if you don't wait long enough:

If you wait for longer than a minute, the game congratulates you:

IdlingResource

To test this, we need to ask Espresso to wait. We could use SystemClock.sleep(60000), but that blocks the testing thread. Instead, we write a custom IdlingResource.

public ElapsedTimeIdlingResource(long waitingTime) {
  this.startTime = System.currentTimeMillis();
  this.waitingTime = waitingTime;
}

@Override
public boolean isIdleNow() {
  long elapsed = System.currentTimeMillis() - startTime;
  boolean idle = (elapsed >= waitingTime);
  if (idle) {
    resourceCallback.onTransitionToIdle();
  }
  return idle;
}

In the constructor, we save the current time, and also how long we need to wait. When Espresso wants to know if it should wait more, it calls isIdleNow(), which computes how much time has elapsed, and returns true if it is longer than the amount of time we need to wait.

Timeout policies

Besides the IdlingResource, we also need to change Espresso's timeout policies.

long waitingTime = DateUtils.SECOND_IN_MILLIS * 75;

IdlingPolicies.setMasterPolicyTimeout(
    waitingTime * 2, TimeUnit.MILLISECONDS);
IdlingPolicies.setIdlingResourceTimeout(
    waitingTime * 2, TimeUnit.MILLISECONDS);

IdlingResource idlingResource 
    = new ElapsedTimeIdlingResource(waitingTime);
Espresso.registerIdlingResources(idlingResource);

By default, Espresso times out the app if it has been idle for 60 seconds, and times out an IdlingResource that has been idle for 26 seconds. We change the timeout policies to be twice our waiting time to make sure Espresso does not kill our test.

How does Espresso wait?

If you run this test, you will notice that the IdlingResource does not wait for the exact amount of time you specified, but slightly longer. Espresso waits by periodically checking if everything is idle, and your resource is only idle after the amount of time you specified, so it is guaranteed to wait for at least that long, but it could, and usually does, wait longer.

Full example

Check out the source code for a full example. Pay attention to see how the test cleans up by resetting the timeout policies and unregister the IdlingResource.

Source code: https://github.com/chiuki/espresso-samples/ under idling-resource-elapsed-time

Like this article? Take a look at the outline of my Espresso book and fill in this form if you think I should write it!

Saturday, June 6, 2015

Android Developer Backstage Backstage

On a fine April morning, two wonderful things happened:

  1. I got a message from Chet Haase
  2. He invited me to be on the Android Developers Backstage podcast

And of course I said yes! Such an honor to be on the podcast. And fun!

I asked Chet how I should prepare. He said, just come up with a few topics to talk about, and they'll take it from there.

We met for lunch before the recording, and I started listing the topics. I was explaining how Monkey Write scoring works, and Chet stopped me mid-sentence. "Save it for the podcast, " he said, "It gets boring when you talk about the same thing twice in a row."

I was rather nervous to just go on air without any rehearsals. What if I have nothing to say? Or worst, what if I blurted out something stupid? We started chatting, and before I noticed, we were done.

All in all it went pretty well. Give it a listen and let me know what you think!

Tuesday, June 2, 2015

Flashing Android M Developer Preview on Nexus 9

I got a Nexus 9 tablet from Google I/O, which is really exciting because that means I have a device to install Android M Developer Preview. Google is hosting What's New in Android: Hack@Home this Friday to talk about M, so I want to make sure my device is ready before then.

I took a video of the process:

For those of you who prefer text to video, here are the steps, mostly from https://developers.google.com/android/nexus/images#instructions:

  1. Download the volantis image from https://developer.android.com/preview/download.html.
    Unzip it (tar -zxvf filename.tgz on linux). Navigate to the unzipped image directory (For Nexus 9, it starts with volantis).
  2. Become a developer by tapping Build Number 7 times.
  3. Enable USB debugging.
  4. Important! Enable OEM unlocking.
  5. Run adb reboot bootloader.
  6. At this point your device is OEM locked:

    Run fastboot oem unlock.
  7. Press volume up to confirm unlocking the bootloader:
  8. Now your device is OEM unlocked:

    Run flash-all.
  9. Wait for 5 minutes or so.

    And voilĂ ! A dialog warning you that this is a preview. Exactly what we want.
  10. Lock again with adb reboot bootloader, then fastboot oem lock, then disable OEM unlocking from developer options after reboot.

Monday, June 1, 2015

Fit Cat at Google I/O

One of the most exciting things at Google I/O this year for me was to meet Virginia Poltrack in person.

Online introduction

I wanted to make an Android Wear watch face with a cat that does different things depending on how many steps you took that day. The first order of business is to find an illustrator to draw the cute cats. I posted on Google Plus to ask for recommendations, and my friend Macy introduced me to Virginia. At that point I didn't say anything about a watch face, so I was really surprised when I saw this on Virginia's profile:

Yup, not only that she is an amazing illustrator, she has made watch faces before!

Rapid iterations

Once I explained my idea to Virginia, we both got really excited and started working right away.

Our goal was to launch before I/O, and we did it! Twice, in fact: first with just the cat, and then with pedometer integration.

Women Techmakers interview

At this point we have only worked together online, so we were really looking forward to seeing each other at I/O. Then Natalie Villalobos from Women Techmakers gave us a wonderful surprise: she interviewed both of us about Fit Cat!

Fit Cat everywhere!

Google I/O was a perfect place to test Fit Cat since I tend to walk a lot during conferences. I snapped photos of it throughout the day.

My friends started doing the same, and it was so heartwarming to see Fit Cat everywhere!

Only the beginning

It has been such a pleasure working with Virginia. We are already plotting our next projects together, so stay tuned!