Change color option and grid option layout

- Add color option horizontal padding
- Change color option layout
- Make grid option LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX comes from resource file

Before: https://screenshot.googleplex.com/opwP97p7X8Qi6nL
        https://screenshot.googleplex.com/3igtadNkX5SUJzy

After: https://screenshot.googleplex.com/AJZ43pWwCnGh6fr
       https://screenshot.googleplex.com/9SBxam4MTRM2gwN

Bug: 193374285
Test: Manual
Change-Id: I3dcc4a97caa0919053b7d1db9844d6d341d70209
diff --git a/res/values-w600dp-port/dimens.xml b/res/values-w600dp-port/dimens.xml
new file mode 100644
index 0000000..1be52bb
--- /dev/null
+++ b/res/values-w600dp-port/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2022 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
+  -->
+<resources>
+    <!-- Dimensions for the customization option tiles -->
+    <dimen name="option_tile_width">79dp</dimen>
+    <dimen name="option_tile_grid_padding_horizontal">8dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values-w840dp/attrs.xml b/res/values-w840dp/attrs.xml
new file mode 100644
index 0000000..f63f574
--- /dev/null
+++ b/res/values-w840dp/attrs.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+     Copyright (C) 2022 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.
+-->
+<resources>
+    <item name="linear_layout_horizontal_display_options_max" format="float" type="dimen">6.35
+    </item>
+</resources>
\ No newline at end of file
diff --git a/res/values-w840dp/dimens.xml b/res/values-w840dp/dimens.xml
new file mode 100644
index 0000000..4cd6242
--- /dev/null
+++ b/res/values-w840dp/dimens.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+  ~ Copyright (C) 2022 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
+  -->
+<resources>
+    <!-- Dimensions for the customization option tiles -->
+    <dimen name="option_tile_width">87dp</dimen>
+    <dimen name="option_tile_grid_padding_horizontal">8dp</dimen>
+</resources>
\ No newline at end of file
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
new file mode 100644
index 0000000..288dd19
--- /dev/null
+++ b/res/values/attrs.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+     Copyright (C) 2022 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.
+-->
+<resources>
+    <item name="linear_layout_horizontal_display_options_max" format="float" type="dimen">4.35
+    </item>
+</resources>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 2086480..4aa43b4 100644
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -38,6 +38,7 @@
     <dimen name="option_tile_margin_horizontal">6dp</dimen>
     <dimen name="option_tile_padding_vertical">12dp</dimen>
     <dimen name="option_tile_padding_horizontal">12dp</dimen>
+    <dimen name="option_tile_grid_padding_horizontal">4dp</dimen>
     <dimen name="option_icon_size">16dp</dimen>
     <dimen name="theme_option_icon_sample_height">22dp</dimen>
     <dimen name="theme_option_icon_sample_width">22dp</dimen>
diff --git a/src/com/android/customization/widget/OptionSelectorController.java b/src/com/android/customization/widget/OptionSelectorController.java
index 952bc55..a66dd44 100644
--- a/src/com/android/customization/widget/OptionSelectorController.java
+++ b/src/com/android/customization/widget/OptionSelectorController.java
@@ -24,6 +24,7 @@
 import android.graphics.drawable.LayerDrawable;
 import android.text.TextUtils;
 import android.util.DisplayMetrics;
+import android.util.TypedValue;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -43,6 +44,7 @@
 import com.android.customization.model.CustomizationManager;
 import com.android.customization.model.CustomizationOption;
 import com.android.wallpaper.R;
+import com.android.wallpaper.widget.GridPaddingDecoration;
 
 import java.util.HashSet;
 import java.util.List;
@@ -77,7 +79,7 @@
         int CENTER_CHANGE_COLOR_WHEN_NOT_SELECTED = 3;
     }
 
-    private static final float LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX = 4.35f;
+    private float mLinearLayoutHorizontalDisplayOptionsMax;
 
     private final RecyclerView mContainer;
     private final List<T> mOptions;
@@ -99,6 +101,10 @@
         mOptions = options;
         mUseGrid = useGrid;
         mCheckmarkStyle = checkmarkStyle;
+        TypedValue typedValue = new TypedValue();
+        mContainer.getResources().getValue(R.dimen.linear_layout_horizontal_display_options_max,
+                typedValue, true);
+        mLinearLayoutHorizontalDisplayOptionsMax = typedValue.getFloat();
     }
 
     public void addListener(OptionSelectedListener listener) {
@@ -312,6 +318,11 @@
             if (mContainer.getLayoutManager() != null) {
                 ((GridLayoutManager) mContainer.getLayoutManager()).setSpanCount(numColumns);
             }
+            if (mContainer.getItemDecorationCount() == 0) {
+                mContainer.addItemDecoration(new GridPaddingDecoration(
+                        mContainer.getContext().getResources().getDimensionPixelSize(
+                                R.dimen.option_tile_grid_padding_horizontal), 0));
+            }
             return;
         }
 
@@ -320,12 +331,12 @@
             mContainer.setOverScrollMode(View.OVER_SCROLL_NEVER);
         }
 
-        if (mAdapter.getItemCount() >= LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX) {
+        if (mAdapter.getItemCount() >= mLinearLayoutHorizontalDisplayOptionsMax) {
             int spaceBetweenItems = availableWidth
-                    - Math.round(widthPerItem * LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX)
+                    - Math.round(widthPerItem * mLinearLayoutHorizontalDisplayOptionsMax)
                     - mContainer.getPaddingLeft();
             int itemEndMargin =
-                    spaceBetweenItems / (int) LINEAR_LAYOUT_HORIZONTAL_DISPLAY_OPTIONS_MAX;
+                    spaceBetweenItems / (int) mLinearLayoutHorizontalDisplayOptionsMax;
             if (itemEndMargin <= 0) {
                 itemEndMargin = res.getDimensionPixelOffset(R.dimen.option_tile_margin_horizontal);
             }