Adds support for background complications plus minor style fix.

Bug: 32214858
Change-Id: I4fd023758faadc06ad4bc7e3836eda073fa9931b
diff --git a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/config/AnalogComplicationConfigRecyclerViewAdapter.java b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/config/AnalogComplicationConfigRecyclerViewAdapter.java
index 096a380..7e79d22 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/config/AnalogComplicationConfigRecyclerViewAdapter.java
+++ b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/config/AnalogComplicationConfigRecyclerViewAdapter.java
@@ -47,37 +47,35 @@
 import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.BackgroundComplicationConfigItem;
 import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.ColorConfigItem;
 import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.ConfigItemType;
-import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.PreviewAndComplicationsConfigItem;
 import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.MoreOptionsConfigItem;
+import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.PreviewAndComplicationsConfigItem;
 import com.example.android.wearable.watchface.model.AnalogComplicationConfigData.UnreadNotificationConfigItem;
-
 import com.example.android.wearable.watchface.watchface.AnalogComplicationWatchFaceService;
 
 import java.util.ArrayList;
 import java.util.concurrent.Executors;
 
 /**
- * <p>
- * Displays different layouts for configuring watch face's complications and appearance
- * settings (highlight color [second arm], background color, unread notifications, etc.).
- * <p>
- * All appearance settings are saved via {@link SharedPreferences}.
- * <p>
- * Layouts provided by this adapter are split into 5 main view types.
- * <p>
- * A watch face preview including complications. Allows user to tap on the complications to change
- * the complication data and see a live preview of the watch face.
- * <p>
- * Simple arrow to indicate there are more options below the fold.
- * <p>
- * Color configuration options for both highlight (seconds hand) and background color.
- * <p>
- * Toggle for unread notifications.
- * <p>
- * Background image complication configuration for changing background image of watch face.
+ * Displays different layouts for configuring watch face's complications and appearance settings
+ * (highlight color [second arm], background color, unread notifications, etc.).
+ *
+ * <p>All appearance settings are saved via {@link SharedPreferences}.
+ *
+ * <p>Layouts provided by this adapter are split into 5 main view types.
+ *
+ * <p>A watch face preview including complications. Allows user to tap on the complications to
+ * change the complication data and see a live preview of the watch face.
+ *
+ * <p>Simple arrow to indicate there are more options below the fold.
+ *
+ * <p>Color configuration options for both highlight (seconds hand) and background color.
+ *
+ * <p>Toggle for unread notifications.
+ *
+ * <p>Background image complication configuration for changing background image of watch face.
  */
-public class AnalogComplicationConfigRecyclerViewAdapter extends
-        RecyclerView.Adapter<RecyclerView.ViewHolder> {
+public class AnalogComplicationConfigRecyclerViewAdapter
+        extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
 
     private static final String TAG = "CompConfigAdapter";
 
@@ -87,7 +85,11 @@
      * complication data types.
      */
     public enum ComplicationLocation {
-        LEFT, RIGHT, TOP, BOTTOM
+        BACKGROUND,
+        LEFT,
+        RIGHT,
+        TOP,
+        BOTTOM
     }
 
     public static final int TYPE_PREVIEW_AND_COMPLICATIONS_CONFIG = 0;
@@ -109,6 +111,7 @@
     // Selected complication id by user.
     private int mSelectedComplicationId;
 
+    private int mBackgroundComplicationId;
     private int mLeftComplicationId;
     private int mRightComplicationId;
 
@@ -131,14 +134,19 @@
         // Default value is invalid (only changed when user taps to change complication).
         mSelectedComplicationId = -1;
 
+        mBackgroundComplicationId =
+                AnalogComplicationWatchFaceService.getComplicationId(
+                        ComplicationLocation.BACKGROUND);
+
         mLeftComplicationId =
                 AnalogComplicationWatchFaceService.getComplicationId(ComplicationLocation.LEFT);
         mRightComplicationId =
                 AnalogComplicationWatchFaceService.getComplicationId(ComplicationLocation.RIGHT);
 
-        mSharedPref = context.getSharedPreferences(
-                context.getString(R.string.analog_complication_preference_file_key),
-                Context.MODE_PRIVATE);
+        mSharedPref =
+                context.getSharedPreferences(
+                        context.getString(R.string.analog_complication_preference_file_key),
+                        Context.MODE_PRIVATE);
 
         // Initialization of code to retrieve active complication data for the watch face.
         mProviderInfoRetriever =
@@ -168,20 +176,29 @@
 
             case TYPE_MORE_OPTIONS:
                 viewHolder =
-                        new MoreOptionsViewHolder(LayoutInflater.from(parent.getContext())
-                                .inflate(R.layout.config_list_more_options_item, parent, false));
+                        new MoreOptionsViewHolder(
+                                LayoutInflater.from(parent.getContext())
+                                        .inflate(
+                                                R.layout.config_list_more_options_item,
+                                                parent,
+                                                false));
                 break;
 
             case TYPE_COLOR_CONFIG:
                 viewHolder =
-                        new ColorPickerViewHolder(LayoutInflater.from(parent.getContext())
-                                .inflate(R.layout.config_list_color_item, parent, false));
+                        new ColorPickerViewHolder(
+                                LayoutInflater.from(parent.getContext())
+                                        .inflate(R.layout.config_list_color_item, parent, false));
                 break;
 
             case TYPE_UNREAD_NOTIFICATION_CONFIG:
                 viewHolder =
-                        new UnreadNotificationViewHolder(LayoutInflater.from(parent.getContext())
-                                .inflate(R.layout.config_list_unread_notif_item, parent, false));
+                        new UnreadNotificationViewHolder(
+                                LayoutInflater.from(parent.getContext())
+                                        .inflate(
+                                                R.layout.config_list_unread_notif_item,
+                                                parent,
+                                                false));
                 break;
 
             case TYPE_BACKGROUND_COMPLICATION_IMAGE_CONFIG:
@@ -206,7 +223,6 @@
         ConfigItemType configItemType = mSettingsDataSet.get(position);
 
         switch (viewHolder.getItemViewType()) {
-
             case TYPE_PREVIEW_AND_COMPLICATIONS_CONFIG:
                 PreviewAndComplicationsViewHolder previewAndComplicationsViewHolder =
                         (PreviewAndComplicationsViewHolder) viewHolder;
@@ -225,12 +241,12 @@
 
             case TYPE_MORE_OPTIONS:
                 MoreOptionsViewHolder moreOptionsViewHolder = (MoreOptionsViewHolder) viewHolder;
-                MoreOptionsConfigItem moreOptionsConfigItem = (MoreOptionsConfigItem) configItemType;
+                MoreOptionsConfigItem moreOptionsConfigItem =
+                        (MoreOptionsConfigItem) configItemType;
 
                 moreOptionsViewHolder.setIcon(moreOptionsConfigItem.getIconResourceId());
                 break;
 
-
             case TYPE_COLOR_CONFIG:
                 ColorPickerViewHolder colorPickerViewHolder = (ColorPickerViewHolder) viewHolder;
                 ColorConfigItem colorConfigItem = (ColorConfigItem) configItemType;
@@ -261,8 +277,7 @@
                 int unreadSharedPrefId = unreadConfigItem.getSharedPrefId();
 
                 unreadViewHolder.setIcons(
-                        unreadEnabledIconResourceId,
-                        unreadDisabledIconResourceId);
+                        unreadEnabledIconResourceId, unreadDisabledIconResourceId);
                 unreadViewHolder.setName(unreadName);
                 unreadViewHolder.setSharedPrefId(unreadSharedPrefId);
                 break;
@@ -294,9 +309,7 @@
         return mSettingsDataSet.size();
     }
 
-    /**
-     * Updates the selected complication id saved earlier with the new information.
-     */
+    /** Updates the selected complication id saved earlier with the new information. */
     public void updateSelectedComplication(ComplicationProviderInfo complicationProviderInfo) {
 
         Log.d(TAG, "updateSelectedComplication: " + mPreviewAndComplicationsViewHolder);
@@ -304,8 +317,7 @@
         // Checks if view is inflated and complication id is valid.
         if (mPreviewAndComplicationsViewHolder != null && mSelectedComplicationId >= 0) {
             mPreviewAndComplicationsViewHolder.updateComplicationViews(
-                    mSelectedComplicationId,
-                    complicationProviderInfo);
+                    mSelectedComplicationId, complicationProviderInfo);
         }
     }
 
@@ -371,19 +383,14 @@
                 Log.d(TAG, "Left Complication click()");
 
                 Activity currentActivity = (Activity) view.getContext();
-                launchComplicationHelperActivity(
-                        currentActivity,
-                        ComplicationLocation.LEFT);
+                launchComplicationHelperActivity(currentActivity, ComplicationLocation.LEFT);
 
             } else if (view.equals(mRightComplication)) {
                 Log.d(TAG, "Right Complication click()");
 
                 Activity currentActivity = (Activity) view.getContext();
-                launchComplicationHelperActivity(
-                        currentActivity,
-                        ComplicationLocation.RIGHT);
+                launchComplicationHelperActivity(currentActivity, ComplicationLocation.RIGHT);
             }
-
         }
 
         public void updateWatchFaceColors() {
@@ -397,7 +404,6 @@
 
             mWatchFaceBackgroundPreviewView.getBackground().setColorFilter(backgroundColorFilter);
 
-
             // Updates highlight color (just second arm).
             String highlightSharedPrefString = mContext.getString(R.string.saved_marker_color);
             int currentHighlightColor = mSharedPref.getInt(highlightSharedPrefString, Color.RED);
@@ -411,20 +417,20 @@
         // Verifies the watch face supports the complication location, then launches the helper
         // class, so user can choose their complication data provider.
         private void launchComplicationHelperActivity(
-                Activity currentActivity,
-                ComplicationLocation complicationLocation) {
+                Activity currentActivity, ComplicationLocation complicationLocation) {
 
             mSelectedComplicationId =
                     AnalogComplicationWatchFaceService.getComplicationId(complicationLocation);
 
             if (mSelectedComplicationId >= 0) {
 
-                int[] supportedTypes = AnalogComplicationWatchFaceService
-                        .getSupportedComplicationTypes(complicationLocation);
+                int[] supportedTypes =
+                        AnalogComplicationWatchFaceService.getSupportedComplicationTypes(
+                                complicationLocation);
 
-                ComponentName watchFace = new ComponentName(
-                        currentActivity,
-                        AnalogComplicationWatchFaceService.class);
+                ComponentName watchFace =
+                        new ComponentName(
+                                currentActivity, AnalogComplicationWatchFaceService.class);
 
                 currentActivity.startActivityForResult(
                         ComplicationHelperActivity.createProviderChooserHelperIntent(
@@ -439,7 +445,7 @@
             }
         }
 
-        public void setDefaultComplicationDrawable (int resourceId) {
+        public void setDefaultComplicationDrawable(int resourceId) {
             Context context = mWatchFaceArmsAndTicksView.getContext();
             mDefaultComplicationDrawable = context.getDrawable(resourceId);
 
@@ -451,12 +457,17 @@
         }
 
         public void updateComplicationViews(
-                int watchFaceComplicationId,
-                ComplicationProviderInfo complicationProviderInfo) {
+                int watchFaceComplicationId, ComplicationProviderInfo complicationProviderInfo) {
             Log.d(TAG, "updateComplicationViews(): id: " + watchFaceComplicationId);
             Log.d(TAG, "\tinfo: " + complicationProviderInfo);
 
-            if (watchFaceComplicationId == mLeftComplicationId) {
+            if (watchFaceComplicationId == mBackgroundComplicationId) {
+                if (complicationProviderInfo != null) {
+                    // TODO: Something with icon to show background set?
+                    // complicationProviderInfo.providerIcon
+                }
+
+            } else if (watchFaceComplicationId == mLeftComplicationId) {
                 if (complicationProviderInfo != null) {
                     mLeftComplication.setImageIcon(complicationProviderInfo.providerIcon);
                     mLeftComplicationBackground.setVisibility(View.VISIBLE);
@@ -480,7 +491,10 @@
 
         public void retrieveInitialComplicationsData() {
 
-            final int[] complicationIds = new int[] {mLeftComplicationId, mRightComplicationId};
+            final int[] complicationIds =
+                    new int[] {
+                        mBackgroundComplicationId, mLeftComplicationId, mRightComplicationId
+                    };
 
             mProviderInfoRetriever.retrieveProviderInfo(
                     new OnProviderInfoReceivedCallback() {
@@ -492,8 +506,7 @@
                             Log.d(TAG, "\n\nonProviderInfoReceived: " + complicationProviderInfo);
 
                             updateComplicationViews(
-                                    watchFaceComplicationId,
-                                    complicationProviderInfo);
+                                    watchFaceComplicationId, complicationProviderInfo);
                         }
                     },
                     mWatchFaceComponentName,
@@ -501,9 +514,7 @@
         }
     }
 
-    /**
-     * Displays icon to indicate there are more options below the fold.
-     */
+    /** Displays icon to indicate there are more options below the fold. */
     public class MoreOptionsViewHolder extends RecyclerView.ViewHolder {
 
         private ImageView mMoreOptionsImageView;
@@ -523,8 +534,7 @@
      * Displays color options for the an item on the watch face. These could include marker color,
      * background color, etc.
      */
-    public class ColorPickerViewHolder extends RecyclerView.ViewHolder
-            implements OnClickListener {
+    public class ColorPickerViewHolder extends RecyclerView.ViewHolder implements OnClickListener {
 
         private Button mAppearanceButton;
 
@@ -546,10 +556,7 @@
         public void setIcon(int resourceId) {
             Context context = mAppearanceButton.getContext();
             mAppearanceButton.setCompoundDrawablesWithIntrinsicBounds(
-                    context.getDrawable(resourceId),
-                    null,
-                    null,
-                    null);
+                    context.getDrawable(resourceId), null, null, null);
         }
 
         public void setSharedPrefString(String sharedPrefString) {
@@ -560,15 +567,13 @@
             mLaunchActivityToSelectColor = activity;
         }
 
-
         @Override
         public void onClick(View view) {
             int position = getAdapterPosition();
             Log.d(TAG, "Complication onClick() position: " + position);
 
             if (mLaunchActivityToSelectColor != null) {
-                Intent launchIntent =
-                        new Intent(view.getContext(), mLaunchActivityToSelectColor);
+                Intent launchIntent = new Intent(view.getContext(), mLaunchActivityToSelectColor);
 
                 // Pass shared preference name to save color value to.
                 launchIntent.putExtra(EXTRA_SHARED_PREF, mSharedPrefResourceString);
@@ -598,8 +603,7 @@
         public UnreadNotificationViewHolder(View view) {
             super(view);
 
-            mUnreadNotificationSwitch =
-                    (Switch) view.findViewById(R.id.unread_notification_switch);
+            mUnreadNotificationSwitch = (Switch) view.findViewById(R.id.unread_notification_switch);
             view.setOnClickListener(this);
         }
 
@@ -616,10 +620,7 @@
 
             // Set default to enabled.
             mUnreadNotificationSwitch.setCompoundDrawablesWithIntrinsicBounds(
-                    context.getDrawable(mEnabledIconResourceId),
-                    null,
-                    null,
-                    null);
+                    context.getDrawable(mEnabledIconResourceId), null, null, null);
         }
 
         public void setSharedPrefId(int sharedPrefId) {
@@ -646,13 +647,9 @@
 
             mUnreadNotificationSwitch.setChecked(currentState);
             mUnreadNotificationSwitch.setCompoundDrawablesWithIntrinsicBounds(
-                    context.getDrawable(currentIconResourceId),
-                    null,
-                    null,
-                    null);
+                    context.getDrawable(currentIconResourceId), null, null, null);
         }
 
-
         @Override
         public void onClick(View view) {
             int position = getAdapterPosition();
@@ -672,9 +669,7 @@
         }
     }
 
-    /**
-     * Displays button to trigger background image complication selector.
-     */
+    /** Displays button to trigger background image complication selector. */
     public class BackgroundComplicationViewHolder extends RecyclerView.ViewHolder
             implements OnClickListener {
 
@@ -695,10 +690,7 @@
         public void setIcon(int resourceId) {
             Context context = mBackgroundComplicationButton.getContext();
             mBackgroundComplicationButton.setCompoundDrawablesWithIntrinsicBounds(
-                    context.getDrawable(resourceId),
-                    null,
-                    null,
-                    null);
+                    context.getDrawable(resourceId), null, null, null);
         }
 
         @Override
@@ -706,7 +698,33 @@
             int position = getAdapterPosition();
             Log.d(TAG, "Background Complication onClick() position: " + position);
 
-            // TODO(jewalker): Add custom RecyclerView.ViewHolder for background image complication.
+            Activity currentActivity = (Activity) view.getContext();
+
+            mSelectedComplicationId =
+                    AnalogComplicationWatchFaceService.getComplicationId(
+                            ComplicationLocation.BACKGROUND);
+
+            if (mSelectedComplicationId >= 0) {
+
+                int[] supportedTypes =
+                        AnalogComplicationWatchFaceService.getSupportedComplicationTypes(
+                                ComplicationLocation.BACKGROUND);
+
+                ComponentName watchFace =
+                        new ComponentName(
+                                currentActivity, AnalogComplicationWatchFaceService.class);
+
+                currentActivity.startActivityForResult(
+                        ComplicationHelperActivity.createProviderChooserHelperIntent(
+                                currentActivity,
+                                watchFace,
+                                mSelectedComplicationId,
+                                supportedTypes),
+                        AnalogComplicationConfigActivity.COMPLICATION_CONFIG_REQUEST_CODE);
+
+            } else {
+                Log.d(TAG, "Complication not supported by watch face.");
+            }
         }
     }
-}
\ No newline at end of file
+}
diff --git a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java
index 2779658..9a4cf44 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java
+++ b/wearable/wear/WatchFace/Wearable/src/main/java/com/example/android/wearable/watchface/watchface/AnalogComplicationWatchFaceService.java
@@ -39,8 +39,10 @@
 import android.util.Log;
 import android.util.SparseArray;
 import android.view.SurfaceHolder;
+
 import com.example.android.wearable.watchface.R;
 import com.example.android.wearable.watchface.config.AnalogComplicationConfigRecyclerViewAdapter;
+
 import java.util.Calendar;
 import java.util.TimeZone;
 import java.util.concurrent.TimeUnit;
@@ -51,14 +53,19 @@
 
     // Unique IDs for each complication. The settings activity that supports allowing users
     // to select their complication data provider requires numbers to be >= 0.
-    private static final int LEFT_COMPLICATION_ID = 0;
-    private static final int RIGHT_COMPLICATION_ID = 1;
+    private static final int BACKGROUND_COMPLICATION_ID = 0;
 
-    // Left and right complication IDs as array for Complication API.
-    private static final int[] COMPLICATION_IDS = {LEFT_COMPLICATION_ID, RIGHT_COMPLICATION_ID};
+    private static final int LEFT_COMPLICATION_ID = 100;
+    private static final int RIGHT_COMPLICATION_ID = 101;
+
+    // Background, Left and right complication IDs as array for Complication API.
+    private static final int[] COMPLICATION_IDS = {
+        BACKGROUND_COMPLICATION_ID, LEFT_COMPLICATION_ID, RIGHT_COMPLICATION_ID
+    };
 
     // Left and right dial supported types.
     private static final int[][] COMPLICATION_SUPPORTED_TYPES = {
+        {ComplicationData.TYPE_LARGE_IMAGE},
         {
             ComplicationData.TYPE_RANGED_VALUE,
             ComplicationData.TYPE_ICON,
@@ -79,6 +86,8 @@
             AnalogComplicationConfigRecyclerViewAdapter.ComplicationLocation complicationLocation) {
         // Add any other supported locations here.
         switch (complicationLocation) {
+            case BACKGROUND:
+                return BACKGROUND_COMPLICATION_ID;
             case LEFT:
                 return LEFT_COMPLICATION_ID;
             case RIGHT:
@@ -94,10 +103,12 @@
             AnalogComplicationConfigRecyclerViewAdapter.ComplicationLocation complicationLocation) {
         // Add any other supported locations here.
         switch (complicationLocation) {
-            case LEFT:
+            case BACKGROUND:
                 return COMPLICATION_SUPPORTED_TYPES[0];
-            case RIGHT:
+            case LEFT:
                 return COMPLICATION_SUPPORTED_TYPES[1];
+            case RIGHT:
+                return COMPLICATION_SUPPORTED_TYPES[2];
             default:
                 return new int[] {};
         }
@@ -150,10 +161,6 @@
 
         private Paint mBackgroundPaint;
 
-        /* TODO (jewalker): code to be reused with followup CL for complication Background image.
-        private Bitmap mBackgroundBitmap;
-        private Bitmap mGrayBackgroundBitmap;*/
-
         /* Maps active complication ids to the data for that complication. Note: Data will only be
          * present if the user has chosen a provider via the settings activity for the watch face.
          */
@@ -227,8 +234,7 @@
                             .build());
 
             loadSavedPreferences();
-            initializeBackground();
-            initializeComplication();
+            initializeComplicationsAndBackground();
             initializeWatchFace();
         }
 
@@ -261,36 +267,37 @@
                     mSharedPref.getBoolean(unreadNotificationPreferenceResourceName, true);
         }
 
-        private void initializeBackground() {
-
-            mBackgroundPaint = new Paint();
-            mBackgroundPaint.setColor(mBackgroundColor);
-
-            /* TODO(jewalker): code to be reused with followup CL for complication Background image.
-            mBackgroundBitmap = BitmapFactory.decodeResource(getResources(), R.drawable.bg);*/
-        }
-
-        private void initializeComplication() {
+        private void initializeComplicationsAndBackground() {
             if (Log.isLoggable(TAG, Log.DEBUG)) {
                 Log.d(TAG, "initializeComplications()");
             }
 
+            // Initialize background color (in case background complication is inactive).
+            mBackgroundPaint = new Paint();
+            mBackgroundPaint.setColor(mBackgroundColor);
+
             mActiveComplicationDataSparseArray = new SparseArray<>(COMPLICATION_IDS.length);
 
             // Creates a ComplicationDrawable for each location where the user can render a
-            // complication on the watch face. In this watch face, we only create left and right,
-            // but you could add many more.
+            // complication on the watch face. In this watch face, we create one for left, right,
+            // and background, but you could add many more.
             ComplicationDrawable leftComplicationDrawable =
                     new ComplicationDrawable(getApplicationContext());
 
             ComplicationDrawable rightComplicationDrawable =
                     new ComplicationDrawable(getApplicationContext());
 
+            ComplicationDrawable backgroundComplicationDrawable =
+                    new ComplicationDrawable(getApplicationContext());
+
             // Adds new complications to a SparseArray to simplify setting styles and ambient
             // properties for all complications, i.e., iterate over them all.
             mComplicationDrawableSparseArray = new SparseArray<>(COMPLICATION_IDS.length);
+
             mComplicationDrawableSparseArray.put(LEFT_COMPLICATION_ID, leftComplicationDrawable);
             mComplicationDrawableSparseArray.put(RIGHT_COMPLICATION_ID, rightComplicationDrawable);
+            mComplicationDrawableSparseArray.put(
+                    BACKGROUND_COMPLICATION_ID, backgroundComplicationDrawable);
 
             setComplicationsActiveAndAmbientColors(mWatchHandHighlightColor);
             setActiveComplications(COMPLICATION_IDS);
@@ -325,26 +332,6 @@
             mTickAndCirclePaint.setAntiAlias(true);
             mTickAndCirclePaint.setStyle(Paint.Style.STROKE);
             mTickAndCirclePaint.setShadowLayer(SHADOW_RADIUS, 0, 0, mWatchHandShadowColor);
-
-            /* TODO (jewalker): code to be reused with followup CL for complication Background image
-            // Asynchronous call extract colors from background image to improve watch face style.
-            Palette.from(mBackgroundBitmap).generate(
-                    new Palette.PaletteAsyncListener() {
-                        public void onGenerated(Palette palette) {
-                            */
-            /*
-             * Sometimes, palette is unable to generate a color palette
-             * so we need to check that we have one.
-             */
-            /*
-                    if (palette != null) {
-                        Log.d("onGenerated", palette.toString());
-                     mWatchHandAndComplicationsColor = palette.getVibrantColor(Color.WHITE);
-                        mWatchHandShadowColor = palette.getDarkMutedColor(Color.BLACK);
-                        updateWatchPaintStyles();
-                    }
-                }
-            });*/
         }
 
         /* Sets active/ambient mode colors for all complications.
@@ -355,25 +342,26 @@
          * again if the user changes the highlight color via AnalogComplicationConfigActivity.
          */
         private void setComplicationsActiveAndAmbientColors(int primaryComplicationColor) {
-
+            int complicationId;
             ComplicationDrawable complicationDrawable;
 
             for (int i = 0; i < COMPLICATION_IDS.length; i++) {
-                complicationDrawable = mComplicationDrawableSparseArray.get(COMPLICATION_IDS[i]);
+                complicationId = COMPLICATION_IDS[i];
+                complicationDrawable = mComplicationDrawableSparseArray.get(complicationId);
 
-                // Active mode colors.
-                complicationDrawable.setBorderColorActive(primaryComplicationColor);
-                complicationDrawable.setIconColorActive(primaryComplicationColor);
-                complicationDrawable.setTitleColorActive(primaryComplicationColor);
-                complicationDrawable.setTextColorActive(primaryComplicationColor);
-                complicationDrawable.setRangedValuePrimaryColorActive(primaryComplicationColor);
+                if (complicationId == BACKGROUND_COMPLICATION_ID) {
+                    // It helps for the background color to be black in case the image used for the
+                    // watch face's background takes some time to load.
+                    complicationDrawable.setBackgroundColorActive(Color.BLACK);
+                } else {
+                    // Active mode colors.
+                    complicationDrawable.setBorderColorActive(primaryComplicationColor);
+                    complicationDrawable.setRangedValuePrimaryColorActive(primaryComplicationColor);
 
-                // Ambient mode colors.
-                complicationDrawable.setBorderColorAmbient(Color.WHITE);
-                complicationDrawable.setIconColorAmbient(Color.WHITE);
-                complicationDrawable.setTitleColorAmbient(Color.WHITE);
-                complicationDrawable.setTextColorAmbient(Color.WHITE);
-                complicationDrawable.setRangedValuePrimaryColorAmbient(Color.WHITE);
+                    // Ambient mode colors.
+                    complicationDrawable.setBorderColorAmbient(Color.WHITE);
+                    complicationDrawable.setRangedValuePrimaryColorAmbient(Color.WHITE);
+                }
             }
         }
 
@@ -453,6 +441,13 @@
 
                 if ((complicationData != null)
                         && (complicationData.isActive(currentTimeMillis))
+                        // The line below this comment block disables taps for background
+                        // complications (usually not wanted by the user).
+                        // If you do want to enable this, remove the line below and reverse order
+                        // of the loop so it checks the last elements (non-background complications)
+                        // first. Otherwise, the background complication (since it is the size of
+                        // the whole watch face) will capture all taps.
+                        && (complicationData.getType() != ComplicationData.TYPE_LARGE_IMAGE)
                         && (complicationData.getType() != ComplicationData.TYPE_NOT_CONFIGURED)
                         && (complicationData.getType() != ComplicationData.TYPE_EMPTY)) {
 
@@ -536,12 +531,10 @@
             ComplicationDrawable complicationDrawable;
 
             for (int i = 0; i < COMPLICATION_IDS.length; i++) {
-                complicationDrawable =
-                        mComplicationDrawableSparseArray.get(COMPLICATION_IDS[i]);
+                complicationDrawable = mComplicationDrawableSparseArray.get(COMPLICATION_IDS[i]);
                 complicationDrawable.setInAmbientMode(mAmbient);
             }
 
-
             // Check and trigger whether or not timer should be running (only in active mode).
             updateTimer();
         }
@@ -662,43 +655,13 @@
                     mComplicationDrawableSparseArray.get(RIGHT_COMPLICATION_ID);
             rightComplicationDrawable.setBounds(rightBounds);
 
-            /* Scale loaded background image (more efficient) if surface dimensions change. */
-            /* TODO (jewalker): code to be reused with followup CL for complication Background image
-            float scale = ((float) width) / (float) mBackgroundBitmap.getWidth();
+            Rect screenForBackgroundBound =
+                    // Left, Top, Right, Bottom
+                    new Rect(0, 0, width, height);
 
-            mBackgroundBitmap = Bitmap.createScaledBitmap(mBackgroundBitmap,
-                    (int) (mBackgroundBitmap.getWidth() * scale),
-                    (int) (mBackgroundBitmap.getHeight() * scale), true);*/
-
-            /*
-             * Create a gray version of the image only if it will look nice on the device in
-             * ambient mode. That means we don't want devices that support burn-in
-             * protection (slight movements in pixels, not great for images going all the way to
-             * edges) and low ambient mode (degrades image quality).
-             *
-             * Also, if your watch face will know about all images ahead of time (users aren't
-             * selecting their own photos for the watch face), it will be more
-             * efficient to create a black/white version (png, etc.) and load that when you need it.
-             */
-            if (!mBurnInProtection && !mLowBitAmbient) {
-                initGrayBackgroundBitmap();
-            }
-        }
-
-        private void initGrayBackgroundBitmap() {
-
-            /* TODO (jewalker): code to be reused with followup CL for complication Background image
-            mGrayBackgroundBitmap = Bitmap.createBitmap(
-                    mBackgroundBitmap.getWidth(),
-                    mBackgroundBitmap.getHeight(),
-                    Bitmap.Config.ARGB_8888);
-            Canvas canvas = new Canvas(mGrayBackgroundBitmap);
-            Paint grayPaint = new Paint();
-            ColorMatrix colorMatrix = new ColorMatrix();
-            colorMatrix.setSaturation(0);
-            ColorMatrixColorFilter filter = new ColorMatrixColorFilter(colorMatrix);
-            grayPaint.setColorFilter(filter);
-            canvas.drawBitmap(mBackgroundBitmap, 0, 0, grayPaint);*/
+            ComplicationDrawable backgroundComplicationDrawable =
+                    mComplicationDrawableSparseArray.get(BACKGROUND_COMPLICATION_ID);
+            backgroundComplicationDrawable.setBounds(screenForBackgroundBound);
         }
 
         @Override
@@ -742,13 +705,6 @@
             } else {
                 canvas.drawColor(mBackgroundColor);
             }
-
-            /* TODO (jewalker): code to be reused with followup CL for complication Background image
-            } else if (mAmbient) {
-                canvas.drawBitmap(mGrayBackgroundBitmap, 0, 0, mBackgroundPaint);
-            } else {
-                canvas.drawBitmap(mBackgroundBitmap, 0, 0, mBackgroundPaint);
-            }*/
         }
 
         private void drawComplications(Canvas canvas, long currentTimeMillis) {
diff --git a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_background_complication_item.xml b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_background_complication_item.xml
index 66ae58d..a21bce5 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_background_complication_item.xml
+++ b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_background_complication_item.xml
@@ -18,6 +18,6 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/background_complication_button"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     style="@style/ButtonConfigurationStyle"
     android:text="Background Complication"/>
\ No newline at end of file
diff --git a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_color_item.xml b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_color_item.xml
index 39ca4a8..718712d 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_color_item.xml
+++ b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_color_item.xml
@@ -18,6 +18,6 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/color_picker_button"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     style="@style/ButtonConfigurationStyle"
     android:text="Color"/>
\ No newline at end of file
diff --git a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_unread_notif_item.xml b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_unread_notif_item.xml
index bd02be6..efdbdbb 100644
--- a/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_unread_notif_item.xml
+++ b/wearable/wear/WatchFace/Wearable/src/main/res/layout/config_list_unread_notif_item.xml
@@ -18,6 +18,6 @@
     xmlns:android="http://schemas.android.com/apk/res/android"
     android:id="@+id/unread_notification_switch"
     android:layout_width="match_parent"
-    android:layout_height="match_parent"
+    android:layout_height="wrap_content"
     style="@style/ButtonConfigurationStyle"
     android:text="Notification"/>
\ No newline at end of file