Use colorSecondary for darker bg color.

Used for widget headers and a few other places.

In order to support pre-API 25, an app-local version of colorSecondary
is created and used throughout the app. A new WidgetContainerTheme
sets colorSecondary to a canned value. On API 25+, colorSecondary
is set to the platform value.

Change-Id: Ie0dd66333052b7346eea5d82d1c88417c6a2cd00
Fixes: 28625102
diff --git a/res/drawable/quantum_panel_shape_dark.xml b/res/drawable/quantum_panel_shape_dark.xml
index c3821c4..b299eb8 100644
--- a/res/drawable/quantum_panel_shape_dark.xml
+++ b/res/drawable/quantum_panel_shape_dark.xml
@@ -16,7 +16,7 @@
 -->
 <shape xmlns:android="http://schemas.android.com/apk/res/android"
        android:shape="rectangle">
-    <solid android:color="@color/quantum_panel_bg_color_dark" />
+    <solid android:color="?attr/colorSecondary" />
     <corners
         android:radius="2dp" />
-</shape>
\ No newline at end of file
+</shape>
diff --git a/res/drawable/widgets_row_divider.xml b/res/drawable/widgets_row_divider.xml
index bb5b6b5..2c3c7a2 100644
--- a/res/drawable/widgets_row_divider.xml
+++ b/res/drawable/widgets_row_divider.xml
@@ -15,5 +15,5 @@
 -->
 <shape xmlns:android="http://schemas.android.com/apk/res/android" >
     <size android:width="@dimen/widget_row_divider" />
-    <solid android:color="@color/quantum_panel_bg_color_dark" />
+    <solid android:color="?attr/colorSecondary" />
 </shape>
diff --git a/res/layout/widgets_list_row_view.xml b/res/layout/widgets_list_row_view.xml
index c0219b9..4687b38 100644
--- a/res/layout/widgets_list_row_view.xml
+++ b/res/layout/widgets_list_row_view.xml
@@ -30,7 +30,7 @@
         android:id="@+id/section"
         android:layout_width="match_parent"
         android:layout_height="@dimen/widget_section_height"
-        android:background="@color/quantum_panel_bg_color_dark"
+        android:background="?attr/colorSecondary"
         android:drawablePadding="@dimen/widget_section_horizontal_padding"
         android:ellipsize="end"
         android:focusable="true"
diff --git a/res/layout/widgets_view.xml b/res/layout/widgets_view.xml
index e9bbd37..74f7ca1 100644
--- a/res/layout/widgets_view.xml
+++ b/res/layout/widgets_view.xml
@@ -26,7 +26,7 @@
     android:paddingBottom="@dimen/container_bounds_inset"
     android:descendantFocusability="afterDescendants"
     launcher:revealBackground="@drawable/quantum_panel_shape_dark"
-    android:theme="@android:style/Theme.DeviceDefault.Settings">
+    android:theme="@style/WidgetContainerTheme">
 
     <View
         android:id="@+id/reveal_view"
diff --git a/res/values-v25/styles.xml b/res/values-v25/styles.xml
new file mode 100644
index 0000000..ed670a9
--- /dev/null
+++ b/res/values-v25/styles.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+* Copyright (C) 2016 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>
+    <!-- Theme for the widget container. -->
+    <style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
+        <item name="colorSecondary">?android:attr/colorSecondary</item>
+    </style>
+</resources>
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index ca28ad3..21a05c0 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -82,4 +82,7 @@
     <declare-styleable name="ButtonDropTarget">
         <attr name="hideParentOnDisable" format="boolean" />
     </declare-styleable>
+
+    <!-- Fallback attr for pre-API 25 support -->
+    <attr name="colorSecondary" format="reference|color" />
 </resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 44e77e2..1af449c 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -34,7 +34,6 @@
 
     <color name="quantum_panel_text_color">#FF666666</color>
     <color name="quantum_panel_bg_color">#FFF5F5F5</color>
-    <color name="quantum_panel_bg_color_dark">#FF374248</color>
 
     <color name="outline_color">#FFFFFFFF</color>
 
@@ -44,4 +43,7 @@
     <!-- Widgets view -->
     <color name="widgets_view_section_text_color">#FFFFFF</color>
     <color name="widgets_view_item_text_color">#C4C4C4</color>
+
+    <!-- Used as a fallback since colorSecondary doesn't exist pre-API 25 -->
+    <color name="fallback_secondary_color">#FF37474F</color>
 </resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 0bfd0a0..8ea772b 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -30,12 +30,19 @@
 
     <style name="Theme" parent="@style/LauncherTheme"></style>
 
+    <!-- Theme for the widget container. Overridden on API 25. -->
+    <style name="WidgetContainerTheme" parent="@android:style/Theme.DeviceDefault.Settings">
+        <item name="colorSecondary">@color/fallback_secondary_color</item>
+    </style>
+
     <!-- Overscroll effect -->
+    <style name="CustomOverscroll" />
+
     <style name="CustomOverscroll.Light" parent="@android:style/Theme.DeviceDefault.Light">
         <item name="android:colorEdgeEffect">@color/folder_edge_effect_color</item>
     </style>
 
-    <style name="CustomOverscroll.Dark" parent="@android:style/Theme.DeviceDefault">
+    <style name="CustomOverscroll.Dark">
         <item name="android:colorEdgeEffect">@color/workspace_edge_effect_color</item>
     </style>
 
diff --git a/src/com/android/launcher3/IconCache.java b/src/com/android/launcher3/IconCache.java
index ac9a8aa..1fea6b4 100644
--- a/src/com/android/launcher3/IconCache.java
+++ b/src/com/android/launcher3/IconCache.java
@@ -26,6 +26,7 @@
 import android.content.pm.PackageManager;
 import android.content.pm.PackageManager.NameNotFoundException;
 import android.content.res.Resources;
+import android.content.res.TypedArray;
 import android.database.Cursor;
 import android.database.sqlite.SQLiteDatabase;
 import android.database.sqlite.SQLiteException;
@@ -126,7 +127,9 @@
         mWorkerHandler = new Handler(LauncherModel.getWorkerLooper());
 
         mActivityBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color);
-        mPackageBgColor = context.getResources().getColor(R.color.quantum_panel_bg_color_dark);
+        TypedArray ta = context.obtainStyledAttributes(new int[]{R.attr.colorSecondary});
+        mPackageBgColor = ta.getColor(0, 0);
+        ta.recycle();
         mLowResOptions = new BitmapFactory.Options();
         // Always prefer RGB_565 config for low res. If the bitmap has transparency, it will
         // automatically be loaded as ALPHA_8888.