Merge "Remove usages of ActionBarActivity." into oc-dev
diff --git a/wearable/wear/WatchFace/Application/src/main/AndroidManifest.xml b/wearable/wear/WatchFace/Application/src/main/AndroidManifest.xml
index 4092097..9d06364 100644
--- a/wearable/wear/WatchFace/Application/src/main/AndroidManifest.xml
+++ b/wearable/wear/WatchFace/Application/src/main/AndroidManifest.xml
@@ -23,12 +23,6 @@
     <!-- Permissions required by the wearable app -->
     <uses-permission android:name="android.permission.WAKE_LOCK" />
 
-    <!-- Requests to calendar are only made on the wear side (CalendarWatchFaceService.java), so
-    no runtime permissions are needed on the phone side. -->
-    <uses-permission android:name="android.permission.READ_CALENDAR" />
-
-    <!-- Location permission used by FitDistanceWatchFaceService -->
-    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
 
     <!-- All intent-filters for config actions must include the categories
         com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION and
@@ -40,17 +34,6 @@
             android:theme="@style/AppTheme" >
 
         <activity
-                android:name=".AnalogAndCardBoundsWatchFaceConfigActivity"
-                android:label="@string/app_name">
-            <intent-filter>
-                <action android:name="com.example.android.wearable.watchface.CONFIG_ANALOG" />
-                <action android:name="com.example.android.wearable.watchface.CONFIG_CARD_BOUNDS" />
-                <category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
-        <activity
                 android:name=".DigitalWatchFaceCompanionConfigActivity"
                 android:label="@string/app_name">
             <intent-filter>
@@ -60,18 +43,6 @@
             </intent-filter>
         </activity>
 
-        <!-- This activity is needed to allow the user to authorize Google Fit for the Fit Distance
-             WatchFace (required to view distance). -->
-        <activity
-            android:name=".FitDistanceWatchFaceConfigActivity"
-            android:label="@string/app_name">
-            <intent-filter>
-                <action android:name="com.example.android.wearable.watchface.CONFIG_FIT_DISTANCE" />
-                <category android:name="com.google.android.wearable.watchface.category.COMPANION_CONFIGURATION" />
-                <category android:name="android.intent.category.DEFAULT" />
-            </intent-filter>
-        </activity>
-
         <activity
                 android:name=".OpenGLWatchFaceConfigActivity"
                 android:label="@string/app_name">
@@ -87,5 +58,4 @@
                 android:value="@integer/google_play_services_version" />
 
     </application>
-
-</manifest>
+</manifest>
\ No newline at end of file
diff --git a/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/AnalogAndCardBoundsWatchFaceConfigActivity.java b/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/AnalogAndCardBoundsWatchFaceConfigActivity.java
deleted file mode 100644
index 5943e6b..0000000
--- a/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/AnalogAndCardBoundsWatchFaceConfigActivity.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2014 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.example.android.wearable.watchface;
-
-import android.app.Activity;
-import android.content.ComponentName;
-import android.os.Bundle;
-import android.support.wearable.companion.WatchFaceCompanion;
-import android.widget.TextView;
-
-public class AnalogAndCardBoundsWatchFaceConfigActivity extends Activity {
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_analog_watch_face_config);
-
-        ComponentName name =
-                getIntent().getParcelableExtra(WatchFaceCompanion.EXTRA_WATCH_FACE_COMPONENT);
-        TextView label = (TextView) findViewById(R.id.label);
-        label.setText(label.getText() + " (" + name.getClassName() + ")");
-    }
-}
diff --git a/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/FitDistanceWatchFaceConfigActivity.java b/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/FitDistanceWatchFaceConfigActivity.java
deleted file mode 100644
index 1d8e4c9..0000000
--- a/wearable/wear/WatchFace/Application/src/main/java/com/example/android/wearable/watchface/FitDistanceWatchFaceConfigActivity.java
+++ /dev/null
@@ -1,255 +0,0 @@
-package com.example.android.wearable.watchface;
-
-import com.google.android.gms.common.ConnectionResult;
-import com.google.android.gms.common.GooglePlayServicesUtil;
-import com.google.android.gms.common.Scopes;
-import com.google.android.gms.common.api.GoogleApiClient;
-import com.google.android.gms.common.api.PendingResult;
-import com.google.android.gms.common.api.ResultCallback;
-import com.google.android.gms.common.api.Scope;
-import com.google.android.gms.common.api.Status;
-import com.google.android.gms.fitness.Fitness;
-
-import android.app.Activity;
-import android.content.Context;
-import android.content.Intent;
-import android.content.IntentSender;
-import android.content.SharedPreferences;
-import android.os.Bundle;
-import android.util.Log;
-import android.view.View;
-import android.widget.Switch;
-import android.widget.Toast;
-
-import java.util.concurrent.TimeUnit;
-
-/**
- * Allows users of the Fit WatchFace to tie their Google Fit account to the WatchFace.
- */
-public class FitDistanceWatchFaceConfigActivity extends Activity implements
-        GoogleApiClient.ConnectionCallbacks,
-        GoogleApiClient.OnConnectionFailedListener {
-
-    private static final String TAG = "FitDistanceConfig";
-
-    // Request code for launching the Intent to resolve authorization.
-    private static final int REQUEST_OAUTH = 1;
-
-    // Shared Preference used to record if the user has enabled Google Fit previously.
-    private static final String PREFS_FIT_ENABLED_BY_USER =
-            "com.example.android.wearable.watchface.preferences.FIT_ENABLED_BY_USER";
-
-    /* Tracks whether an authorization activity is stacking over the current activity, i.e., when
-     *  a known auth error is being resolved, such as showing the account chooser or presenting a
-     *  consent dialog. This avoids common duplications as might happen on screen rotations, etc.
-     */
-    private static final String EXTRA_AUTH_STATE_PENDING =
-            "com.example.android.wearable.watchface.extra.AUTH_STATE_PENDING";
-
-    private static final long FIT_DISABLE_TIMEOUT_SECS = TimeUnit.SECONDS.toMillis(5);;
-
-    private boolean mResolvingAuthorization;
-
-    private boolean mFitEnabled;
-
-    private GoogleApiClient mGoogleApiClient;
-
-    private Switch mFitAuthSwitch;
-
-    @Override
-    protected void onCreate(Bundle savedInstanceState) {
-        super.onCreate(savedInstanceState);
-        setContentView(R.layout.activity_fit_watch_face_config);
-
-        mFitAuthSwitch = (Switch) findViewById(R.id.fit_auth_switch);
-
-        if (savedInstanceState != null) {
-            mResolvingAuthorization =
-                    savedInstanceState.getBoolean(EXTRA_AUTH_STATE_PENDING, false);
-        } else {
-            mResolvingAuthorization = false;
-        }
-
-        // Checks if user previously enabled/approved Google Fit.
-        SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
-        mFitEnabled =
-                sharedPreferences.getBoolean(PREFS_FIT_ENABLED_BY_USER, false);
-
-        mGoogleApiClient = new GoogleApiClient.Builder(this)
-                .addApi(Fitness.HISTORY_API)
-                .addApi(Fitness.RECORDING_API)
-                .addApi(Fitness.CONFIG_API)
-                .addScope(new Scope(Scopes.FITNESS_LOCATION_READ_WRITE))
-                .addConnectionCallbacks(this)
-                .addOnConnectionFailedListener(this)
-                .build();
-    }
-
-    @Override
-    protected void onStart() {
-        super.onStart();
-
-        if ((mFitEnabled) && (mGoogleApiClient != null)) {
-
-            mFitAuthSwitch.setChecked(true);
-            mFitAuthSwitch.setEnabled(true);
-
-            mGoogleApiClient.connect();
-
-        } else {
-
-            mFitAuthSwitch.setChecked(false);
-            mFitAuthSwitch.setEnabled(true);
-        }
-    }
-
-    @Override
-    protected void onStop() {
-        super.onStop();
-
-        if ((mGoogleApiClient != null) && (mGoogleApiClient.isConnected())) {
-            mGoogleApiClient.disconnect();
-        }
-    }
-
-    @Override
-    protected void onSaveInstanceState(Bundle bundle) {
-        super.onSaveInstanceState(bundle);
-        bundle.putBoolean(EXTRA_AUTH_STATE_PENDING, mResolvingAuthorization);
-    }
-
-    @Override
-    protected void onRestoreInstanceState(Bundle savedInstanceState) {
-        super.onRestoreInstanceState(savedInstanceState);
-
-        if (savedInstanceState != null) {
-            mResolvingAuthorization =
-                    savedInstanceState.getBoolean(EXTRA_AUTH_STATE_PENDING, false);
-        }
-    }
-
-    @Override
-    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
-        Log.d(TAG, "onActivityResult()");
-
-        if (requestCode == REQUEST_OAUTH) {
-            mResolvingAuthorization = false;
-
-            if (resultCode == RESULT_OK) {
-                setUserFitPreferences(true);
-
-                if (!mGoogleApiClient.isConnecting() && !mGoogleApiClient.isConnected()) {
-                    mGoogleApiClient.connect();
-                }
-            } else {
-                // User cancelled authorization, reset the switch.
-                setUserFitPreferences(false);
-            }
-        }
-    }
-
-    @Override
-    public void onConnected(Bundle connectionHint) {
-        Log.d(TAG, "onConnected: " + connectionHint);
-    }
-
-    @Override
-    public void onConnectionSuspended(int cause) {
-
-        if (cause == GoogleApiClient.ConnectionCallbacks.CAUSE_NETWORK_LOST) {
-            Log.i(TAG, "Connection lost.  Cause: Network Lost.");
-        } else if (cause == GoogleApiClient.ConnectionCallbacks.CAUSE_SERVICE_DISCONNECTED) {
-            Log.i(TAG, "Connection lost.  Reason: Service Disconnected");
-        } else {
-            Log.i(TAG, "onConnectionSuspended: " + cause);
-        }
-
-        mFitAuthSwitch.setChecked(false);
-        mFitAuthSwitch.setEnabled(true);
-    }
-
-    @Override
-    public void onConnectionFailed(ConnectionResult result) {
-        Log.d(TAG, "Connection to Google Fit failed. Cause: " + result.toString());
-
-        if (!result.hasResolution()) {
-            // User cancelled authorization, reset the switch.
-            mFitAuthSwitch.setChecked(false);
-            mFitAuthSwitch.setEnabled(true);
-            // Show the localized error dialog
-            GooglePlayServicesUtil.getErrorDialog(result.getErrorCode(), this, 0).show();
-            return;
-        }
-
-        // Resolve failure if not already trying/authorizing.
-        if (!mResolvingAuthorization) {
-            try {
-                Log.i(TAG, "Attempting to resolve failed GoogleApiClient connection");
-                mResolvingAuthorization = true;
-                result.startResolutionForResult(this, REQUEST_OAUTH);
-            } catch (IntentSender.SendIntentException e) {
-                Log.e(TAG, "Exception while starting resolution activity", e);
-            }
-        }
-    }
-
-    public void onSwitchClicked(View view) {
-
-        boolean userWantsToEnableFit = mFitAuthSwitch.isChecked();
-
-        if (userWantsToEnableFit) {
-
-            Log.d(TAG, "User wants to enable Fit.");
-            if ((mGoogleApiClient != null) && (!mGoogleApiClient.isConnected())) {
-                mGoogleApiClient.connect();
-            }
-
-        } else {
-            Log.d(TAG, "User wants to disable Fit.");
-
-            // Disable switch until disconnect request is finished.
-            mFitAuthSwitch.setEnabled(false);
-
-            PendingResult<Status> pendingResult = Fitness.ConfigApi.disableFit(mGoogleApiClient);
-
-            pendingResult.setResultCallback(new ResultCallback<Status>() {
-                @Override
-                public void onResult(Status status) {
-
-                    if (status.isSuccess()) {
-                        Toast.makeText(
-                                FitDistanceWatchFaceConfigActivity.this,
-                                "Disconnected from Google Fit.",
-                                Toast.LENGTH_LONG).show();
-
-                        setUserFitPreferences(false);
-
-                        mGoogleApiClient.disconnect();
-
-
-                    } else {
-                        Toast.makeText(
-                                FitDistanceWatchFaceConfigActivity.this,
-                                "Unable to disconnect from Google Fit. See logcat for details.",
-                                Toast.LENGTH_LONG).show();
-
-                        // Re-set the switch since auth failed.
-                        setUserFitPreferences(true);
-                    }
-                }
-            }, FIT_DISABLE_TIMEOUT_SECS, TimeUnit.SECONDS);
-        }
-    }
-
-    private void setUserFitPreferences(boolean userFitPreferences) {
-
-        mFitEnabled = userFitPreferences;
-        SharedPreferences sharedPreferences = getPreferences(Context.MODE_PRIVATE);
-        SharedPreferences.Editor editor = sharedPreferences.edit();
-        editor.putBoolean(PREFS_FIT_ENABLED_BY_USER, userFitPreferences);
-        editor.commit();
-
-        mFitAuthSwitch.setChecked(userFitPreferences);
-        mFitAuthSwitch.setEnabled(true);
-    }
-}
diff --git a/wearable/wear/WatchFace/Application/src/main/res/layout/activity_analog_watch_face_config.xml b/wearable/wear/WatchFace/Application/src/main/res/layout/activity_analog_watch_face_config.xml
deleted file mode 100644
index ec816c2..0000000
--- a/wearable/wear/WatchFace/Application/src/main/res/layout/activity_analog_watch_face_config.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent">
-
-    <TextView
-        android:id="@+id/label"
-        android:text="@string/analog_config_text"
-        android:layout_width="wrap_content"
-        android:layout_height="wrap_content" />
-
-</FrameLayout>
diff --git a/wearable/wear/WatchFace/Application/src/main/res/layout/activity_fit_watch_face_config.xml b/wearable/wear/WatchFace/Application/src/main/res/layout/activity_fit_watch_face_config.xml
deleted file mode 100644
index 73d1489..0000000
--- a/wearable/wear/WatchFace/Application/src/main/res/layout/activity_fit_watch_face_config.xml
+++ /dev/null
@@ -1,33 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!-- Copyright (C) 2014 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
-      http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-    xmlns:tools="http://schemas.android.com/tools"
-    android:layout_width="match_parent"
-    android:layout_height="match_parent"
-    android:paddingTop="@dimen/activity_vertical_margin"
-    android:paddingLeft="@dimen/activity_horizontal_margin"
-    android:paddingRight="@dimen/activity_horizontal_margin"
-    tools:context="com.example.android.wearable.watchface.FitDistanceWatchFaceConfigActivity">
-
-    <Switch
-        android:id="@+id/fit_auth_switch"
-        android:text="@string/fit_config_switch_text"
-        android:enabled="false"
-        android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:onClick="onSwitchClicked"/>
-
-</RelativeLayout>
\ No newline at end of file
diff --git a/wearable/wear/WatchFace/Application/src/main/res/values/strings.xml b/wearable/wear/WatchFace/Application/src/main/res/values/strings.xml
index 275dcd3..06f380f 100644
--- a/wearable/wear/WatchFace/Application/src/main/res/values/strings.xml
+++ b/wearable/wear/WatchFace/Application/src/main/res/values/strings.xml
@@ -14,15 +14,13 @@
  limitations under the License.
 -->
 <resources>
-    <string name="analog_config_text">This is the config activity for the Analog and Card Bounds watch faces</string>
     <string name="digital_config_text">Digital watch face configuration</string>
-    <string name="opengl_config_text">OpenGL watch face configuration</string>
     <string name="digital_config_background">Background</string>
     <string name="digital_config_hours">Hours</string>
     <string name="digital_config_minutes">Minutes</string>
     <string name="digital_config_seconds">Seconds</string>
 
-    <string name="fit_config_switch_text">Google Fit</string>
+    <string name="opengl_config_text">OpenGL watch face configuration</string>
 
     <string name="title_no_device_connected">No wearable device is currently connected.</string>
     <string name="ok_no_device_connected">OK</string>
diff --git a/wearable/wear/WatchFace/screenshots/analog-watch-side-config-all.png b/wearable/wear/WatchFace/screenshots/analog-watch-side-config-all.png
new file mode 100644
index 0000000..a8df49b
--- /dev/null
+++ b/wearable/wear/WatchFace/screenshots/analog-watch-side-config-all.png
Binary files differ
diff --git a/wearable/wear/WatchFace/template-params.xml b/wearable/wear/WatchFace/template-params.xml
index 5644c52..b95995c 100644
--- a/wearable/wear/WatchFace/template-params.xml
+++ b/wearable/wear/WatchFace/template-params.xml
@@ -56,6 +56,7 @@
         <icon>screenshots/icon-web.png</icon>
         <screenshots>
             <img>screenshots/analog-face.png</img>
+            <img>screenshots/analog-watch-side-config-all.png</img>
             <img>screenshots/analog-watch-side-config-1.png</img>
             <img>screenshots/analog-watch-side-config-2.png</img>
             <img>screenshots/digital-face.png</img>
@@ -86,14 +87,34 @@
 
         <intro>
 <![CDATA[
-This sample demonstrates how to create watch faces for android wear and includes a phone app
-and a wearable app. The wearable app has a variety of watch faces including analog, digital,
-opengl, interactive, etc. It also includes a watch-side configuration example.
-The phone app includes a phone-side configuration example.
+This sample demonstrates how to create watch faces for Android Wear.
 
-The analog watch face demonstrates best practices for using complications in Wear 2.0. It also
-includes a configuration Activity for configuring the watch face styles and complications. We
-recommend you follow this UX pattern for your own watch faces.
+The analog watch face covers best practices for Wear 2.0 including complications and a new
+configuration Activity for configuring both the watch face styles and the complications themselves.
+We recommend you reuse the configuration code and follow the UX patterns in your watch face's
+configuration activity. You can see a preview in the screenshots section of the README.
+
+The analog watch face has three main classes:
+
+- AnalogComplicationWatchFaceService.java (watchface folder) - Renders the watch face and active
+complications.
+
+- AnalogComplicationConfigActivity.java (config folder) - Allows user to adjust watch face settings
+(arm and background colors) and watch face complications.
+
+- AnalogComplicationConfigData.java (models folder) - Populates the configuration screen in the
+previous step by returning a list of items. Each item represents something you can customize on the
+watch face. Items include a preview of the watch face (where you can pick your complications),
+marker color, background color, unread notifications, and background image complication. You can
+extend this and add your own.
+
+
+We include several older watch faces to show best practices for Wear 1.0. If you are targeting
+older devices, you may want to review those watch faces (digital, opengl, and interactive).
+
+The digital watch face includes a watch-side and phone-side configuration example.
+
+This sample includes both a phone app and a wearable app.
 
 Because watch face apps do not have a default Activity in their project, you will need to set your
 Configurations to "Do not launch Activity" for both the Wear and Application modules. If you are
diff --git a/wearable/wear/WearMessagingApp/Wearable/build.gradle b/wearable/wear/WearMessagingApp/Wearable/build.gradle
index afa7e2d..8ff4082 100644
--- a/wearable/wear/WearMessagingApp/Wearable/build.gradle
+++ b/wearable/wear/WearMessagingApp/Wearable/build.gradle
@@ -8,15 +8,15 @@
     compile 'com.android.support:design:25.3.1'
     compile 'com.android.support:support-v13:25.3.1'
 
-    compile 'com.google.android.gms:play-services-wearable:10.2.4'
-    compile 'com.google.android.gms:play-services-auth:10.2.4'
+    compile 'com.google.android.gms:play-services-wearable:10.2.6'
+    compile 'com.google.android.gms:play-services-auth:10.2.6'
 
-    provided 'com.google.android.wearable:wearable:2.0.1'
-    compile 'com.google.android.support:wearable:2.0.1'
+    provided 'com.google.android.wearable:wearable:2.0.2'
+    compile 'com.google.android.support:wearable:2.0.2'
 
     compile 'com.google.code.gson:gson:2.8.0'
 
-    compile 'com.github.bumptech.glide:glide:3.7.0'
+    compile 'com.github.bumptech.glide:glide:3.8.0'
 }
 
 // The sample build uses multiple directories to
diff --git a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/SignInActivity.java b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/SignInActivity.java
index 267702a..740631f 100644
--- a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/SignInActivity.java
+++ b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/SignInActivity.java
@@ -15,6 +15,7 @@
  */
 package com.example.android.wearable.wear.messaging;
 
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.support.annotation.NonNull;
@@ -131,48 +132,13 @@
     }
 
     /*
-     * Syncs with mock backend (shared preferences). You will want to put in your
-     * backend logic here.
+     * Syncs with mock backend (shared preferences). You will want to put in your backend logic here.
      */
     private void syncUserWithBackend(GoogleSignInAccount acct) {
-        Log.d(TAG, "syncUserWithBackend:" + acct.getId());
+        Log.d(TAG, "syncUserWithBackend():" + acct.getId());
 
         mProfile = new Profile(acct);
-
-        MockDatabase.getUser(
-                this,
-                mProfile.getId(),
-                // TODO: Move from anonymous class to improve readability. Nested callbacks is hard
-                // to read for me.
-                new MockDatabase.RetrieveUserCallback() {
-                    @Override
-                    public void retrieved(Profile user) {
-                        if (user == null) {
-                            // User did not exists so create the user.
-                            MockDatabase.createUser(
-                                    SignInActivity.this,
-                                    mProfile,
-                                    new MockDatabase.CreateUserCallback() {
-                                        @Override
-                                        public void onSuccess() {
-                                            finishSuccessfulSignin();
-                                        }
-
-                                        @Override
-                                        public void onError(Exception e) {
-                                            setAuthFailedState();
-                                        }
-                                    });
-                        } else {
-                            finishSuccessfulSignin();
-                        }
-                    }
-
-                    @Override
-                    public void error(Exception e) {
-                        setAuthFailedState();
-                    }
-                });
+        MockDatabase.getUser(this, mProfile.getId(), new SimpleRetrieveUserCallback(this));
     }
 
     private void setAuthFailedState() {
@@ -208,4 +174,41 @@
         Log.d(TAG, "onConnectionFailed:" + connectionResult);
         Toast.makeText(this, R.string.connection_failed, Toast.LENGTH_SHORT).show();
     }
+
+    private class SimpleRetrieveUserCallback implements MockDatabase.RetrieveUserCallback {
+
+        final Context mContext;
+
+        private SimpleRetrieveUserCallback(Context context) {
+            this.mContext = context;
+        }
+
+        @Override
+        public void onUserRetrieved(Profile user) {
+            if (user == null) {
+                // User did not exists so create the user.
+                MockDatabase.createUser(
+                        mContext,
+                        mProfile,
+                        new MockDatabase.CreateUserCallback() {
+                            @Override
+                            public void onSuccess() {
+                                finishSuccessfulSignin();
+                            }
+
+                            @Override
+                            public void onError(Exception e) {
+                                setAuthFailedState();
+                            }
+                        });
+            } else {
+                finishSuccessfulSignin();
+            }
+        }
+
+        @Override
+        public void error(Exception e) {
+            setAuthFailedState();
+        }
+    }
 }
diff --git a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/chatlist/ChatListActivity.java b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/chatlist/ChatListActivity.java
index 2200003..52667ae 100644
--- a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/chatlist/ChatListActivity.java
+++ b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/chatlist/ChatListActivity.java
@@ -15,10 +15,12 @@
  */
 package com.example.android.wearable.wear.messaging.chatlist;
 
+import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
+import android.os.AsyncTask;
 import android.os.Bundle;
 import android.support.v7.widget.LinearLayoutManager;
-import android.support.wearable.activity.WearableActivity;
 import android.support.wearable.view.WearableRecyclerView;
 import android.util.Log;
 import com.example.android.wearable.wear.messaging.GoogleSignedInActivity;
@@ -30,15 +32,14 @@
 import com.example.android.wearable.wear.messaging.model.Profile;
 import com.example.android.wearable.wear.messaging.util.Constants;
 import com.example.android.wearable.wear.messaging.util.DividerItemDecoration;
-import com.example.android.wearable.wear.messaging.util.SharedPreferencesHelper;
 import java.util.ArrayList;
+import java.util.Collection;
+import java.util.List;
 
 /**
  * Displays list of active chats of user.
  *
  * <p>Uses a simple mocked backend solution with shared preferences.
- *
- * <p>TODO: Processes database activities on the UI thread, move to async.
  */
 public class ChatListActivity extends GoogleSignedInActivity {
 
@@ -47,9 +48,9 @@
     // Triggered by contact selection in ContactsListActivity.
     private static final int CONTACTS_SELECTED_REQUEST_CODE = 9004;
 
-    private WearableRecyclerView mRecyclerView;
     private ChatListAdapter mRecyclerAdapter;
-    private Profile mUser;
+    private RetrieveChatsAsyncTask mRetrieveChatsTask;
+    private CreateNewChatAsyncTask mCreateChatTask;
 
     @Override
     protected void onCreate(Bundle savedInstanceState) {
@@ -57,7 +58,8 @@
         setTheme(R.style.BlueTheme);
         setContentView(R.layout.activity_chat_list);
 
-        mRecyclerView = (WearableRecyclerView) findViewById(R.id.recycler_view);
+        WearableRecyclerView mRecyclerView =
+                (WearableRecyclerView) findViewById(R.id.recycler_view);
 
         mRecyclerView.addItemDecoration(new DividerItemDecoration(this, R.drawable.divider));
         LinearLayoutManager layoutManager = new LinearLayoutManager(this);
@@ -73,24 +75,31 @@
         super.onStart();
         Log.d(TAG, "onStart");
 
-        // Try to get the user if they don't exist, return to login.
-        mUser = SharedPreferencesHelper.readUserFromJsonPref(this);
-        if (mUser == null) {
-            Log.e(TAG, "User is not stored locally");
-            onGoogleSignInFailure();
-        } else {
-            mRecyclerAdapter.setChats(MockDatabase.getAllChats(this));
+        if (getUser() != null) {
+            mRetrieveChatsTask = new RetrieveChatsAsyncTask(this);
+            mRetrieveChatsTask.execute();
         }
     }
 
-    /**
-     * A handler for the adapter to launch the correct activities based on the type of item selected
-     */
+    @Override
+    protected void onPause() {
+        super.onPause();
+        if (mRetrieveChatsTask != null) {
+            mRetrieveChatsTask.cancel(true);
+            mRetrieveChatsTask = null;
+        }
+        if (mCreateChatTask != null) {
+            mCreateChatTask.cancel(true);
+            mCreateChatTask = null;
+        }
+    }
+
+    /** Launches the correct activities based on the type of item selected. */
     private class MyChatListAdapterListener implements ChatListAdapter.ChatAdapterListener {
 
-        private final WearableActivity activity;
+        private final Activity activity;
 
-        MyChatListAdapterListener(WearableActivity activity) {
+        MyChatListAdapterListener(Activity activity) {
             this.activity = activity;
         }
 
@@ -116,17 +125,61 @@
             if (resultCode == RESULT_OK) {
                 ArrayList<Profile> contacts =
                         data.getParcelableArrayListExtra(Constants.RESULT_CONTACTS_KEY);
-                // TODO: this should be moved to the background,
-                Chat newChatWithSelectedContacts =
-                        MockDatabase.createChat(this, contacts, getUser());
-
-                Log.d(TAG, String.format("Starting chat with %d contact(s)", contacts.size()));
-
-                // Launch ChatActivity with new chat.
-                Intent startChat = new Intent(this, ChatActivity.class);
-                startChat.putExtra(Constants.EXTRA_CHAT, newChatWithSelectedContacts);
-                startActivity(startChat);
+                mCreateChatTask = new CreateNewChatAsyncTask(this, getUser(), contacts);
+                mCreateChatTask.execute();
             }
         }
     }
+
+    private class RetrieveChatsAsyncTask extends AsyncTask<Void, Void, Collection<Chat>> {
+
+        final Context mContext;
+
+        private RetrieveChatsAsyncTask(Context context) {
+            this.mContext = context;
+        }
+
+        @Override
+        protected Collection<Chat> doInBackground(Void... params) {
+            return MockDatabase.getAllChats(mContext);
+        }
+
+        @Override
+        protected void onPostExecute(Collection<Chat> chats) {
+            super.onPostExecute(chats);
+            mRecyclerAdapter.setChats(chats);
+        }
+    }
+
+    private class CreateNewChatAsyncTask extends AsyncTask<Void, Void, Chat> {
+
+        final Context mContext;
+        final Profile mUser;
+        final List<Profile> mContacts;
+
+        CreateNewChatAsyncTask(Context context, Profile user, List<Profile> contacts) {
+            this.mContext = context;
+            this.mUser = user;
+            this.mContacts = contacts;
+        }
+
+        @Override
+        protected Chat doInBackground(Void... params) {
+            return MockDatabase.createChat(mContext, mContacts, mUser);
+        }
+
+        @Override
+        protected void onPostExecute(Chat chat) {
+            super.onPostExecute(chat);
+            Log.d(
+                    TAG,
+                    String.format(
+                            "Starting chat with %d partcipants(s)", chat.getParticipants().size()));
+
+            // Launch ChatActivity with new chat.
+            Intent startChat = new Intent(mContext, ChatActivity.class);
+            startChat.putExtra(Constants.EXTRA_CHAT, chat);
+            startActivity(startChat);
+        }
+    }
 }
diff --git a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/mock/MockDatabase.java b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/mock/MockDatabase.java
index 54bb17e..c352670 100644
--- a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/mock/MockDatabase.java
+++ b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/mock/MockDatabase.java
@@ -39,14 +39,14 @@
 
     private static final String TAG = "MockDatabase";
 
-    /** A callback for events when retrieving a user asynchronously */
+    /** Callback for retrieving a user asynchronously. */
     public interface RetrieveUserCallback {
-        void retrieved(Profile user);
+        void onUserRetrieved(Profile user);
 
         void error(Exception e);
     }
 
-    /** A callback for getting events during the creation of a user */
+    /** Callback for creating a user. */
     public interface CreateUserCallback {
         void onSuccess();
 
@@ -251,10 +251,10 @@
     public static void getUser(Context context, String id, RetrieveUserCallback callback) {
         Profile user = SharedPreferencesHelper.readUserFromJsonPref(context);
         if (user != null && user.getId().equals(id)) {
-            callback.retrieved(user);
+            callback.onUserRetrieved(user);
         } else {
             // Could not find user with that id.
-            callback.retrieved(null);
+            callback.onUserRetrieved(null);
         }
     }
 
diff --git a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/model/Profile.java b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/model/Profile.java
index f2796ae..ae858f3 100644
--- a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/model/Profile.java
+++ b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/model/Profile.java
@@ -18,7 +18,6 @@
 import android.os.Parcel;
 import android.os.Parcelable;
 import android.support.annotation.NonNull;
-import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.google.android.gms.auth.api.signin.GoogleSignInAccount;
 
 /** Represents a user profile. Parcelable to pass between activities. */
@@ -89,10 +88,9 @@
         return profileImageUri;
     }
 
-    @JsonIgnore
     public Object getProfileImageSource() {
         if (profileImageUri != null) {
-            return profileImageResource;
+            return profileImageUri;
         }
         if (profileImageResource > 0) {
             return profileImageResource;
diff --git a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/util/SchedulerHelper.java b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/util/SchedulerHelper.java
index 2a6e5b0..e063f11 100644
--- a/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/util/SchedulerHelper.java
+++ b/wearable/wear/WearMessagingApp/Wearable/src/main/java/com/example/android/wearable/wear/messaging/util/SchedulerHelper.java
@@ -24,7 +24,6 @@
 import com.example.android.wearable.wear.messaging.chat.MockIncomingMessageReceiver;
 import com.example.android.wearable.wear.messaging.model.Chat;
 import com.example.android.wearable.wear.messaging.model.Message;
-
 import java.util.concurrent.TimeUnit;
 
 /**
diff --git a/wearable/wear/WearMessagingApp/template-params.xml b/wearable/wear/WearMessagingApp/template-params.xml
index a943550..78afc12 100644
--- a/wearable/wear/WearMessagingApp/template-params.xml
+++ b/wearable/wear/WearMessagingApp/template-params.xml
@@ -35,10 +35,10 @@
     <dependency>com.android.support:cardview-v7:25.3.1</dependency>
     <dependency>com.android.support:design:25.3.1</dependency>
 
-    <dependency>com.google.android.gms:play-services-wearable:10.2.4</dependency>
-    <dependency>com.google.android.gms:play-services-auth:10.2.4</dependency>
+    <dependency>com.google.android.gms:play-services-wearable:10.2.6</dependency>
+    <dependency>com.google.android.gms:play-services-auth:10.2.6</dependency>
 
-    <dependency>com.github.bumptech.glide:glide:3.7.0</dependency>
+    <dependency>com.github.bumptech.glide:glide:3.8.0</dependency>
     <dependency>com.google.code.gson:gson:2.8.0</dependency>
 
     <dependency_wearable>com.android.support:appcompat-v7:25.3.1</dependency_wearable>