Friday, November 27, 2015

Android Dev Summit: Amazing!

Google ran its first Android Dev Summit this November, and I gotta say, it was amazing.

Session Videos

The AV team edited and posted the videos within 2 hours of the talk, so everyone can enjoy the content. My absolute favorite was "Android Studio for Experts". So many tips and tricks!

Check out the playlist for more.

Sketchnotes

I took many sketchnotes during the summit. Here are a few of them:

I will scan them and add the high-resolution version to this PDF when I get home: gum.co/Sketchnotes2015. Download the current edition to get an email when it is updated.

Encore!

Android Dev Summit gave us Android developer lots of in-depth technical content and easy access to the team. I hope Google will do it again!

Saturday, November 7, 2015

2016 Speaking Goals

I started public speaking in 2012 with a New Year's Resolution. It was a great way to gather my thoughts on what I want to share, and have grown a lot since then as a speaker. Last year Cate and I started Technically Speaking to help other people to start speaking at technical conferences, and we would like to take advantage of the new year to get more people to set speaking goals.

As a part of our birthday celebrations, Technically Speaking is offering 1-hour mentoring sessions to help people turn ideas into reality.

To get the ball rolling, here are my goals:

  1. Revamp my speaker page
  2. Give a keynote
  3. Help 3 first-time speakers give talks at conferences

Revamp my speaker page

Currently my speaker page is a list of all the talks I have given. I would like to update it to highlight certain talks, embed some videos, and also state my speaking requirements. I really like how Rachel Andrew explains her policy, and would like to create something similiar.

Give a keynote

I gave my very first keynote at Android Summit this year. I prepared a lot more than a tech talk, but it was also a lot more rewarding, because as a keynote speaker I try to motivate people to step out of their comfort zone. I would like to do that again.

Help 3 first-time speakers give talks at conferences

Navigating the speaking scene can be quite daunting, especially if you have never given a talk before. I broadcast tips and tricks on Technically Speaking, but nothing beats 1-on-1 mentoring, both for the mentor and mentee. As a mentor, I get the satisfaction of seeing concrete results.

Help me help you achieve your goals and mine. Post yours!

Friday, November 6, 2015

MVP: The Missing Link

I have been wanting to learn the Model View Presenter pattern for a while, and was super excited to get Michael Cameron to give a talk on it at GDG Boulder last night.

View Interface

I have this vague notion that MVP is good for JUnit testing, and I finally figured out why. The secret, the missing link, is View Interface, which is not a part of the MVP acronym. View Interface defines the contract between the view and the presenter, allowing you to mock one while testing the other.

With View Interface, you can compartmentalize your Android UI code into the view (typically a Fragment or Activity), which communicates with your presenter solely through the View Interface. This separation allows you to mock your View Interface with zero Android code, which means you can test your presenter with JUnit on the JVM.

Mocking via build flavors

Mocking is essential for hermetic testing, but people are often intimated by dependency injection frameworks like Dagger. If you prefer, you can provide mocks to your test using build flavors. An excellent technique!

Mockito

Mockito is a great mocking framework with a fluent API. One very nice feature is mocking via annotations. To use that, annotate the fields you want to mock with @Mock, and initialize them all with MockitoAnnotations.initMocks() in your @Before function.

@Mock
private MyThing myThing;

@Mock
private OtherThing otherThing;

@Before
public void setUp() throws Exception {
  MockitoAnnotations.initMocks(this);
}

This is equivalent to:

private MyThing myThing;
private OtherThing otherThing;

@Before public void setUp() throws Exception {
  myThing = Mockito.mock(MyThing.class);
  otherThing = Mockito.mock(OtherThing.class);
}

Slides: http://www.slideshare.net/DarxVal/model-view-presenter-presentation

Codelab

Google has published the excellent Android Testing Codelab going through an app with the MVP architecture. You can see JUnit and Espresso testing in action, mocks via build flavors, and various other techniques. Go check it out!

Thursday, November 5, 2015

Google Games: Leaderboard + Achievements

I have a weakness in cute things. I often play cute games, telling myself that I do it to "learn about game mechanics". This time, I actually integrated Google Play Games Services due to inspiration from playing!

Alphabear

My latest addiction is Alphabear. You earn bears while playing a word game, which gives you extra powers. They show you the list of bears you have collected:

I want that for Fit Cat! A catalog, if you will, showing all the cats that you have seen. Initially I was going to do the UI and tracking myself, but then I came across Google Games Achievements. Perfect!

Leaderboard

When I started looking into Google Games, I learned about Leaderboards as well, which seems a simpler concept to launch with. I just need to submit the number of steps to Google Games, and everything else is handled for me. Great!

One problem though: Fit Cat is a watch face, and the watch does not have direct internet access. To upload the steps, I transfer the data to the phone using the Wearable Data Layer API and send it to Google Games in a WearableListenerService.

To test that, I needed to pace around the house, because the Data Layer API only syncs when the data changes. If I sit on my chair in front of my computer, the number of steps stays the same, and so I will not get a callback. It was pretty hilarious, me pacing around and rushing back to the computer to check the logs and see if the phone received data.

Placeholder achievements

I was going to publish my game with the leaderboard, but got blocked because Google Games requires at least 5 achievements. This was right before Big Android BBQ, and I did not have a lot of time before flying to Texas. So I added 5 placeholder achievements and made them hidden, and launched.

Actual Achievements

After I launched leaderboard, I wanted to go back to repurpose the hidden achievements to show cats. I want them to be public so that you are motivated to reach a goal level to see a certain cat.

Alas, I cannot switch an achievement from hidden to public once I published them. So I created new achievements for the cats.

While "May appear at 10000 steps" gives people a goal to walk more, "Secret" is just really mean if it is not attainable. I was holding off the launch until I came up with 5 achievements to backfill the placeholders. That took a few days, but I now have some fun ones for people to discover!

Play Games app

The nice thing about integrating with Google Play Games Services is that your game will show up in the Play Games app. Friends can compare achievements with each other, which is really fun.

However, Fit Cat was not showing up, and I was not sure why. Turns out you need to categorize your app as "Game" rather than "Application" on Google Play, so now Fit Cat is a "Sports Game".

Usually you play sports games by tapping your fingers on screen and pretending to be playing sports, but this one you actually play with your feet in real life!

Easy gaming

Google Play Games Services has a lot of built-in UI, making it super easy to add gaming to your app, even for a non-game like Fit Cat. There was a few non-obvious requirements (ahem, minimum 5 achievements), so I'd recommend going through the checklist during planning, not before launch like me.

Overall it's a great enhancement to my app, for very little effort. I hope you like it too!