summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTreeHugger Robot <treehugger-gerrit@google.com>2017-06-20 16:11:17 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2017-06-20 16:11:18 +0000
commit7e2e2aa80baa4458e086f59e8c55ee016174593c (patch)
treec50cddf0db2d2c9bd37db8238fe0c7ad75d5444e
parent5a1ca5756ecea6784743f5cd1540844c1a83b36f (diff)
parent5931ca04155a7fcdfc1dc0665011a44101afda5f (diff)
downloadandroid_packages_apps_Trebuchet-7e2e2aa80baa4458e086f59e8c55ee016174593c.tar.gz
android_packages_apps_Trebuchet-7e2e2aa80baa4458e086f59e8c55ee016174593c.tar.bz2
android_packages_apps_Trebuchet-7e2e2aa80baa4458e086f59e8c55ee016174593c.zip
Merge "Fixing dark tint for ShadowDrawable. Updating the dark theme for empty all-apps search drawable." into ub-launcher3-dorval-polish
-rw-r--r--res/color-v24/all_apps_bg_hand_fill_dark.xml28
-rw-r--r--res/drawable/ic_all_apps_bg_hand.xml4
-rw-r--r--res/drawable/ic_all_apps_bg_icon_1.xml2
-rw-r--r--res/drawable/ic_all_apps_bg_icon_2.xml2
-rw-r--r--res/drawable/ic_all_apps_bg_icon_3.xml4
-rw-r--r--res/drawable/ic_all_apps_bg_icon_4.xml2
-rw-r--r--res/values/attrs.xml2
-rw-r--r--res/values/colors.xml1
-rw-r--r--res/values/styles.xml11
-rw-r--r--src/com/android/launcher3/ButtonDropTarget.java4
-rw-r--r--src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java27
-rw-r--r--src/com/android/launcher3/graphics/ShadowDrawable.java49
12 files changed, 91 insertions, 45 deletions
diff --git a/res/color-v24/all_apps_bg_hand_fill_dark.xml b/res/color-v24/all_apps_bg_hand_fill_dark.xml
new file mode 100644
index 000000000..bb9c71cbc
--- /dev/null
+++ b/res/color-v24/all_apps_bg_hand_fill_dark.xml
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2017 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.
+-->
+<gradient
+ xmlns:android="http://schemas.android.com/apk/res/android"
+ android:startX="158.5"
+ android:startY="141.5"
+ android:endX="196.0"
+ android:endY="206.5"
+ android:type="linear" >
+ <item android:offset="0" android:color="#9AA0A6" />
+ <item android:offset="0.1013" android:color="#E5A5ABB0" />
+ <item android:offset="0.4946" android:color="#81CDCFD1" />
+ <item android:offset="0.8079" android:color="#31E5E6E6" />
+ <item android:offset="1" android:color="#00EEEEEE" />
+</gradient> \ No newline at end of file
diff --git a/res/drawable/ic_all_apps_bg_hand.xml b/res/drawable/ic_all_apps_bg_hand.xml
index 94af00870..7f3fe14fb 100644
--- a/res/drawable/ic_all_apps_bg_hand.xml
+++ b/res/drawable/ic_all_apps_bg_hand.xml
@@ -42,7 +42,7 @@
c0.3,1.7,1.9,2.9,3.6,2.7l40-6.1c1.7-0.3,2.9-1.9,2.7-3.6L54.4,21L41.7,23z M37.5,23.6l-12.6,1.9l-0.3-2.1l12.6-1.9L37.5,23.6z"/>
</group>
<path
- android:fillColor="#BDBDBD"
+ android:fillColor="?android:attr/colorControlHighlight"
android:pathData="M87.5,62.9h-4.4l-1.6-1.5c5.5-6.4,8.8-14.7,8.8-23.7C90.3,17.7,74,1.4,54,1.4
S17.6,17.7,17.6,37.7S33.9,74.1,54,74.1c9,0,17.3-3.3,23.7-8.8l1.5,1.6v4.4l40.5,40.4l8.3-8.3L87.5,62.9z M54,64.2
c-14.7,0-26.5-11.8-26.5-26.5S39.3,11.2,54,11.2s26.5,11.8,26.5,26.5S68.6,64.2,54,64.2z"/>
@@ -92,7 +92,7 @@
c-0.7-0.1-1.3-0.2-2,0.2c-1,0.6-1.2,1.5-1.3,2.4c-0.2,1.8,0.6,3.9,1.6,5.9L107,87.3l0.2,0.4l6.6,11.7l0,0
c2.5,4.5,4.4,10.5,4.4,10.7L129.7,125.1"/>
<path
- android:fillColor="@color/all_apps_bg_hand_fill"
+ android:fillColor="?android:attr/colorForeground"
android:pathData="M202.3,183.1c-5.4-14.1-23.8-44.3-26.7-49c-0.2-0.3-0.6-0.3-0.8,0
c-5.1,6.6-19,11.4-26.5,13.6c-0.3,0.1-1,0.1-1.2,0.6c-0.2,0.4,0.1,1,0.2,1.1c7.8,12.9,14.7,27.9,15.3,29.3c0,0.1,0.1,0.1,0.1,0.2
l9.6,22.9c0,0,0,0,0,0l1.7,4.1c1.4,2.7,3,4.3,5.3,5.1c1.5,0.5,2.1,0.6,3.2,0.6c4.8,0.1,15.2-6.1,20.5-9.4c2.7-1.7,3.3-4.4,2.9-7.6
diff --git a/res/drawable/ic_all_apps_bg_icon_1.xml b/res/drawable/ic_all_apps_bg_icon_1.xml
index c9c0a7549..d226ac600 100644
--- a/res/drawable/ic_all_apps_bg_icon_1.xml
+++ b/res/drawable/ic_all_apps_bg_icon_1.xml
@@ -25,7 +25,7 @@
android:pathData="M44.28,30.96c4.84-10.68,0.09-23.27-10.59-28.11S10.42,2.74,5.58,13.42
C1,23.54,6.5,35.92,16.62,40.51l0,0l-3.23,7.12C27.84,47,39.79,40.86,44.28,30.96z" />
<path
- android:fillColor="#E0E0E0"
+ android:fillColor="?android:attr/colorPrimary"
android:pathData="M41.75,30.05c4.84-10.68,0.09-23.27-10.59-28.11S7.9,1.83,3.06,12.51
c-4.59,10.12,0.92,22.5,11.03,27.09l0,0l-3.23,7.12C25.31,46.09,37.26,39.94,41.75,30.05z" />
</vector> \ No newline at end of file
diff --git a/res/drawable/ic_all_apps_bg_icon_2.xml b/res/drawable/ic_all_apps_bg_icon_2.xml
index b6269e3ab..5966d9969 100644
--- a/res/drawable/ic_all_apps_bg_icon_2.xml
+++ b/res/drawable/ic_all_apps_bg_icon_2.xml
@@ -26,7 +26,7 @@
c-0.25-0.58-0.9-0.99-1.89-1.1L6.2,5.99C5.39,5.91,4.74,6.08,4.32,6.44l0,0C3.7,6.97,3.55,7.88,4.01,8.96l14.54,34.09
C19,44.13,19.75,44.65,20.54,44.59L20.54,44.59z" />
<path
- android:fillColor="#E0E0E0"
+ android:fillColor="?android:attr/colorPrimary"
android:pathData="M18.49,43.22c0.57-0.04,1.15-0.38,1.67-1.04l24.23-30.62c0.62-0.78,0.77-1.54,0.52-2.12
c-0.25-0.58-0.9-0.99-1.89-1.1L4.15,4.62C3.34,4.54,2.69,4.71,2.27,5.08l0,0C1.65,5.6,1.5,6.52,1.96,7.6L16.5,41.69
C16.96,42.76,17.7,43.28,18.49,43.22L18.49,43.22z" />
diff --git a/res/drawable/ic_all_apps_bg_icon_3.xml b/res/drawable/ic_all_apps_bg_icon_3.xml
index 4c255a909..b18f8bc47 100644
--- a/res/drawable/ic_all_apps_bg_icon_3.xml
+++ b/res/drawable/ic_all_apps_bg_icon_3.xml
@@ -26,11 +26,11 @@
s22.31-9.99,22.31-22.31S37.5,1.27,25.18,1.27z M25.18,33.55c-5.5,0-14.35-5.1-14.35-10.6s8.32-12.19,13.82-12.19
c5.5,0,10.49,7.33,10.49,12.83S30.68,33.55,25.18,33.55z" />
<path
- android:fillColor="#E0E0E0"
+ android:fillColor="?android:attr/colorPrimary"
android:pathData="M22.93,0.22c-12.32,0-22.31,9.99-22.31,22.31s9.99,22.31,22.31,22.31
s22.31-9.99,22.31-22.31S35.25,0.22,22.93,0.22z M22.93,32.5c-5.5,0-9.97-4.46-9.97-9.97s4.46-9.97,9.97-9.97
c5.5,0,9.97,4.46,9.97,9.97S28.43,32.5,22.93,32.5z" />
<path
- android:fillColor="#E0E0E0"
+ android:fillColor="?android:attr/colorPrimary"
android:pathData="M14.81,22.53a8.12,8.12 0 1,0 16.24,0a8.12,8.12 0 1,0 -16.24,0z" />
</vector>
diff --git a/res/drawable/ic_all_apps_bg_icon_4.xml b/res/drawable/ic_all_apps_bg_icon_4.xml
index 12e05bc6b..8eb4d9012 100644
--- a/res/drawable/ic_all_apps_bg_icon_4.xml
+++ b/res/drawable/ic_all_apps_bg_icon_4.xml
@@ -25,7 +25,7 @@
android:pathData="M11.53,8.02l23.39-5.73c1.61-0.39,3.25,0.6,3.64,2.21l7.64,31.19
c0.39,1.61-0.6,3.25-2.21,3.64L12.8,46.97c-1.61,0.39-3.25-0.6-3.64-2.21L3.43,21.37L11.53,8.02z" />
<path
- android:fillColor="#E0E0E0"
+ android:fillColor="?android:attr/colorPrimary"
android:pathData="M9.2,6.53L32.59,0.8C34.2,0.4,35.84,1.4,36.23,3l7.64,31.19c0.39,1.61-0.6,3.25-2.21,3.64
l-31.19,7.64c-1.61,0.39-3.25-0.6-3.64-2.21L1.11,19.87L9.2,6.53z" />
<path
diff --git a/res/values/attrs.xml b/res/values/attrs.xml
index b7189d17c..27992ceb6 100644
--- a/res/values/attrs.xml
+++ b/res/values/attrs.xml
@@ -130,6 +130,6 @@
<attr name="android:src" />
<attr name="android:shadowColor" />
<attr name="android:elevation" />
- <attr name="android:tint" />
+ <attr name="darkTintColor" format="color"/>
</declare-styleable>
</resources>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index 4f7c1a73d..b44a31e40 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -39,4 +39,5 @@
<color name="legacy_icon_background">#FFFFFF</color>
<color name="all_apps_bg_hand_fill">#E5E5E5</color>
+ <color name="all_apps_bg_hand_fill_dark">#9AA0A6</color>
</resources>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 594c7dbde..b982136da 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -156,4 +156,15 @@
<style name="TextTitle">
<item name="android:fontFamily">sans-serif</item>
</style>
+
+ <style name="AllAppsEmptySearchBackground">
+ <item name="android:colorPrimary">#E0E0E0</item>
+ <item name="android:colorControlHighlight">#BDBDBD</item>
+ <item name="android:colorForeground">@color/all_apps_bg_hand_fill</item>
+ </style>
+ <style name="AllAppsEmptySearchBackground.Dark">
+ <item name="android:colorPrimary">#9AA0A6</item>
+ <item name="android:colorControlHighlight">#DFE1E5</item>
+ <item name="android:colorForeground">@color/all_apps_bg_hand_fill_dark</item>
+ </style>
</resources>
diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java
index 8a477d809..e4a322622 100644
--- a/src/com/android/launcher3/ButtonDropTarget.java
+++ b/src/com/android/launcher3/ButtonDropTarget.java
@@ -102,8 +102,8 @@ public abstract class ButtonDropTarget extends TextView
protected void setDrawable(int resId) {
// We do not set the drawable in the xml as that inflates two drawables corresponding to
// drawableLeft and drawableStart.
- mDrawable = getResources().getDrawable(resId);
- setCompoundDrawablesRelativeWithIntrinsicBounds(mDrawable, null, null, null);
+ setCompoundDrawablesRelativeWithIntrinsicBounds(resId, 0, 0, 0);
+ mDrawable = getCompoundDrawablesRelative()[0];
}
public void setDropTargetBar(DropTargetBar dropTargetBar) {
diff --git a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
index 54c5bd0b2..3830a9333 100644
--- a/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
+++ b/src/com/android/launcher3/allapps/AllAppsBackgroundDrawable.java
@@ -23,10 +23,12 @@ import android.graphics.ColorFilter;
import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
+import android.view.ContextThemeWrapper;
import android.view.Gravity;
import com.android.launcher3.LauncherAnimUtils;
import com.android.launcher3.R;
+import com.android.launcher3.util.Themes;
/**
* This is a custom composite drawable that has a fixed virtual size and dynamically lays out its
@@ -36,7 +38,7 @@ import com.android.launcher3.R;
public class AllAppsBackgroundDrawable extends Drawable {
/**
- * A helper class to positon and orient a drawable to be drawn.
+ * A helper class to position and orient a drawable to be drawn.
*/
protected static class TransformedImageDrawable {
private Drawable mImage;
@@ -49,9 +51,9 @@ public class AllAppsBackgroundDrawable extends Drawable {
* @param gravity If one of the Gravity center values, the x and y offset will take the width
* and height of the image into account to center the image to the offset.
*/
- public TransformedImageDrawable(Resources res, int resourceId, float xPct, float yPct,
+ public TransformedImageDrawable(Context context, int resourceId, float xPct, float yPct,
int gravity) {
- mImage = res.getDrawable(resourceId);
+ mImage = context.getDrawable(resourceId);
mXPercent = xPct;
mYPercent = yPct;
mGravity = gravity;
@@ -98,19 +100,24 @@ public class AllAppsBackgroundDrawable extends Drawable {
public AllAppsBackgroundDrawable(Context context) {
Resources res = context.getResources();
- mHand = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_hand,
+ mWidth = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_width);
+ mHeight = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_height);
+
+ context = new ContextThemeWrapper(context,
+ Themes.getAttrBoolean(context, R.attr.isMainColorDark)
+ ? R.style.AllAppsEmptySearchBackground_Dark
+ : R.style.AllAppsEmptySearchBackground);
+ mHand = new TransformedImageDrawable(context, R.drawable.ic_all_apps_bg_hand,
0.575f, 0.f, Gravity.CENTER_HORIZONTAL);
mIcons = new TransformedImageDrawable[4];
- mIcons[0] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_1,
+ mIcons[0] = new TransformedImageDrawable(context, R.drawable.ic_all_apps_bg_icon_1,
0.375f, 0, Gravity.CENTER_HORIZONTAL);
- mIcons[1] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_2,
+ mIcons[1] = new TransformedImageDrawable(context, R.drawable.ic_all_apps_bg_icon_2,
0.3125f, 0.2f, Gravity.CENTER_HORIZONTAL);
- mIcons[2] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_3,
+ mIcons[2] = new TransformedImageDrawable(context, R.drawable.ic_all_apps_bg_icon_3,
0.475f, 0.26f, Gravity.CENTER_HORIZONTAL);
- mIcons[3] = new TransformedImageDrawable(res, R.drawable.ic_all_apps_bg_icon_4,
+ mIcons[3] = new TransformedImageDrawable(context, R.drawable.ic_all_apps_bg_icon_4,
0.7f, 0.125f, Gravity.CENTER_HORIZONTAL);
- mWidth = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_width);
- mHeight = res.getDimensionPixelSize(R.dimen.all_apps_background_canvas_height);
}
/**
diff --git a/src/com/android/launcher3/graphics/ShadowDrawable.java b/src/com/android/launcher3/graphics/ShadowDrawable.java
index 45c1b6afb..ffcedb26a 100644
--- a/src/com/android/launcher3/graphics/ShadowDrawable.java
+++ b/src/com/android/launcher3/graphics/ShadowDrawable.java
@@ -17,7 +17,6 @@
package com.android.launcher3.graphics;
import android.annotation.TargetApi;
-import android.content.res.ColorStateList;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.graphics.Bitmap;
@@ -28,7 +27,6 @@ import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Rect;
-import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.os.Build;
import android.util.AttributeSet;
@@ -111,12 +109,11 @@ public class ShadowDrawable extends Drawable {
@Override
public void applyTheme(Resources.Theme t) {
- if (mState.canApplyTheme()) {
- // Workaround since ColorStateList does not expose applyTheme method
- ColorDrawable cd = new ColorDrawable();
- cd.setTintList(mState.mTintColor);
- cd.applyTheme(t);
-
+ TypedArray ta = t.obtainStyledAttributes(new int[] {R.attr.isWorkspaceDarkText});
+ boolean isDark = ta.getBoolean(0, false);
+ ta.recycle();
+ if (mState.mIsDark != isDark) {
+ mState.mIsDark = isDark;
mState.mLastDrawnBitmap = null;
invalidateSelf();
}
@@ -132,21 +129,22 @@ public class ShadowDrawable extends Drawable {
d.setBounds(mState.mShadowSize, mState.mShadowSize,
mState.mIntrinsicWidth - mState.mShadowSize,
mState.mIntrinsicHeight - mState.mShadowSize);
- if (mState.mTintColor != null) {
- d.setTint(mState.mTintColor.getDefaultColor());
- }
+ d.setTint(mState.mIsDark ? mState.mDarkTintColor : Color.WHITE);
d.draw(canvas);
- Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
- paint.setMaskFilter(new BlurMaskFilter(mState.mShadowSize, BlurMaskFilter.Blur.NORMAL));
- int[] offset = new int[2];
- Bitmap shadow = bitmap.extractAlpha(paint, offset);
-
- paint.setMaskFilter(null);
- paint.setColor(mState.mShadowColor);
- bitmap.eraseColor(Color.TRANSPARENT);
- canvas.drawBitmap(shadow, offset[0], offset[1], paint);
- d.draw(canvas);
+ // Do not draw shadow on dark theme
+ if (!mState.mIsDark) {
+ Paint paint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG);
+ paint.setMaskFilter(new BlurMaskFilter(mState.mShadowSize, BlurMaskFilter.Blur.NORMAL));
+ int[] offset = new int[2];
+ Bitmap shadow = bitmap.extractAlpha(paint, offset);
+
+ paint.setMaskFilter(null);
+ paint.setColor(mState.mShadowColor);
+ bitmap.eraseColor(Color.TRANSPARENT);
+ canvas.drawBitmap(shadow, offset[0], offset[1], paint);
+ d.draw(canvas);
+ }
if (Utilities.isAtLeastO()) {
bitmap = bitmap.copy(Bitmap.Config.HARDWARE, false);
@@ -162,7 +160,6 @@ public class ShadowDrawable extends Drawable {
final TypedArray a = theme == null
? r.obtainAttributes(attrs, R.styleable.ShadowDrawable)
: theme.obtainStyledAttributes(attrs, R.styleable.ShadowDrawable, 0, 0);
-
try {
Drawable d = a.getDrawable(R.styleable.ShadowDrawable_android_src);
if (d == null) {
@@ -172,7 +169,8 @@ public class ShadowDrawable extends Drawable {
R.styleable.ShadowDrawable_android_shadowColor, Color.BLACK);
mState.mShadowSize = a.getDimensionPixelSize(
R.styleable.ShadowDrawable_android_elevation, 0);
- mState.mTintColor = a.getColorStateList(R.styleable.ShadowDrawable_android_tint);
+ mState.mDarkTintColor = a.getColor(
+ R.styleable.ShadowDrawable_darkTintColor, Color.BLACK);
mState.mIntrinsicHeight = d.getIntrinsicHeight() + 2 * mState.mShadowSize;
mState.mIntrinsicWidth = d.getIntrinsicWidth() + 2 * mState.mShadowSize;
@@ -192,8 +190,9 @@ public class ShadowDrawable extends Drawable {
int mShadowColor;
int mShadowSize;
- ColorStateList mTintColor;
+ int mDarkTintColor;
+ boolean mIsDark;
Bitmap mLastDrawnBitmap;
ConstantState mChildState;
@@ -209,7 +208,7 @@ public class ShadowDrawable extends Drawable {
@Override
public boolean canApplyTheme() {
- return mTintColor != null;
+ return true;
}
}
}