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
This commit is contained in:
Andrew Sapperstein 2016-06-20 12:48:22 -07:00
parent 26def23702
commit 5f7750d75c
9 changed files with 47 additions and 8 deletions

View File

@ -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>
</shape>

View File

@ -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>

View File

@ -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"

View File

@ -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"

24
res/values-v25/styles.xml Normal file
View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -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>

View File

@ -26,6 +26,7 @@ import android.content.pm.PackageInfo;
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 @@ public class IconCache {
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.