From 303b81010a7f2f533a37b0d0caad628a42058811 Mon Sep 17 00:00:00 2001 From: Bill Yi Date: Fri, 2 Jun 2017 18:15:04 -0700 Subject: Import translations. DO NOT MERGE Change-Id: Iaccfb365895d66930405f7114613bcbadbca1c25 Auto-generated-cl: translation import --- res/values-ja/strings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/values-ja/strings.xml b/res/values-ja/strings.xml index 0d491acad..6182eb5f3 100644 --- a/res/values-ja/strings.xml +++ b/res/values-ja/strings.xml @@ -120,7 +120,7 @@ "ウィジェットのサイズを幅%1$s、高さ%2$sに変更しました" "ショートカット" "%2$s用の %1$d 件のショートカット" - "%3$s: %1$d 件のショートカットと %2$d 件の通知" + "%3$s: %1$d 個のショートカットと %2$d 件の通知" "表示しない" "通知を非表示にしました" -- cgit v1.2.3 From 629a67c5ac33409ebccf13284505a4cadc65656a Mon Sep 17 00:00:00 2001 From: Tony Date: Fri, 2 Jun 2017 15:43:26 -0700 Subject: Migrate ColorExtractionService to JobService IntentService cannot be run in the background, so moving to JobService prevents us from crashing if the wallpaper is changed while we aren't running. Bug: 62065291 Change-Id: Ie0c887e36d0ced43a0b9ab8136bf55eb37697489 --- AndroidManifest-common.xml | 3 +- src/com/android/launcher3/Utilities.java | 3 +- .../dynamicui/ColorExtractionService.java | 93 +++++++++++++++------- .../launcher3/dynamicui/ExtractionUtils.java | 10 ++- 4 files changed, 75 insertions(+), 34 deletions(-) diff --git a/AndroidManifest-common.xml b/AndroidManifest-common.xml index 3a60a9878..ab582feb9 100644 --- a/AndroidManifest-common.xml +++ b/AndroidManifest-common.xml @@ -82,7 +82,8 @@ + android:process=":wallpaper_chooser" + android:permission="android.permission.BIND_JOB_SERVICE"> Date: Tue, 6 Jun 2017 12:12:22 -0700 Subject: Prevent clipping on the top and left side on AdaptiveIconDrawables b/62372639 Change-Id: I0b2c0daecba2904f3e89f7b0b558d9b10f5dcbf6 --- src/com/android/launcher3/graphics/LauncherIcons.java | 5 +++-- src/com/android/launcher3/graphics/ShadowGenerator.java | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/com/android/launcher3/graphics/LauncherIcons.java b/src/com/android/launcher3/graphics/LauncherIcons.java index 53521f22d..19e570247 100644 --- a/src/com/android/launcher3/graphics/LauncherIcons.java +++ b/src/com/android/launcher3/graphics/LauncherIcons.java @@ -266,9 +266,10 @@ public class LauncherIcons { sOldBounds.set(icon.getBounds()); if (Utilities.isAtLeastO() && icon instanceof AdaptiveIconDrawable) { - int offset = Math.min(left, top); + int offset = Math.max((int)(ShadowGenerator.BLUR_FACTOR * iconBitmapSize), + Math.min(left, top)); int size = Math.max(width, height); - icon.setBounds(offset, offset, offset + size, offset + size); + icon.setBounds(offset, offset, size, size); } else { icon.setBounds(left, top, left+width, top+height); } diff --git a/src/com/android/launcher3/graphics/ShadowGenerator.java b/src/com/android/launcher3/graphics/ShadowGenerator.java index 469fe34e9..5d8cca8d2 100644 --- a/src/com/android/launcher3/graphics/ShadowGenerator.java +++ b/src/com/android/launcher3/graphics/ShadowGenerator.java @@ -35,7 +35,7 @@ public class ShadowGenerator { // Percent of actual icon size private static final float HALF_DISTANCE = 0.5f; - private static final float BLUR_FACTOR = 0.5f/48; + public static final float BLUR_FACTOR = 0.5f/48; // Percent of actual icon size private static final float KEY_SHADOW_DISTANCE = 1f/48; -- cgit v1.2.3 From 85b64c7da0f1134fdbae954acbc2925c1433566a Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Thu, 8 Jun 2017 12:12:17 -0700 Subject: Updating icon badging string to "Notification dots" Change-Id: Ie3193c8aae8fee5860274ba6823b0cdfe25b1083 --- res/values/strings.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/values/strings.xml b/res/values/strings.xml index 1fe33aedf..ecc537d0c 100644 --- a/res/values/strings.xml +++ b/res/values/strings.xml @@ -172,12 +172,12 @@ When phone is rotated Current Display setting doesn\'t permit rotation - - Icon badging + + Notification dots - On for all apps + On - Off for all apps + Off Add icon to Home screen -- cgit v1.2.3 From 7092db02410562026da17a7b38f48025cc847de2 Mon Sep 17 00:00:00 2001 From: Tony Wickham Date: Wed, 7 Jun 2017 14:32:23 -0700 Subject: Add support for color extracted notification dots Changing the badge_color in colors.xml to transparent will cause them to be color extracted. When an extracted color is used in the IconPalette, we desaturate the background. Otherwise we respect the exact color specified in colors.xml. Change-Id: Ie82d0c5335fa5f24d4cc47766e4c1719c4916f8b --- res/values/colors.xml | 1 + src/com/android/launcher3/BubbleTextView.java | 13 ++++-- src/com/android/launcher3/FastBitmapDrawable.java | 2 +- src/com/android/launcher3/badge/BadgeRenderer.java | 14 +++--- src/com/android/launcher3/folder/FolderIcon.java | 4 +- .../android/launcher3/graphics/IconPalette.java | 53 ++++++++++++++++++---- .../launcher3/popup/PopupContainerWithArrow.java | 5 +- 7 files changed, 66 insertions(+), 26 deletions(-) diff --git a/res/values/colors.xml b/res/values/colors.xml index 25893088d..67a7544f5 100644 --- a/res/values/colors.xml +++ b/res/values/colors.xml @@ -42,6 +42,7 @@ #E0E0E0 #1DE9B6 + #1DE9B6 @android:color/tertiary_text_light diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 94c7e07fb..3c3e224e4 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -96,7 +96,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private BadgeInfo mBadgeInfo; private BadgeRenderer mBadgeRenderer; - private IconPalette mIconPalette; + private IconPalette mBadgePalette; private float mBadgeScale; private boolean mForceHideBadge; private Point mTempSpaceForBadgeOffset = new Point(); @@ -453,7 +453,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { final int scrollX = getScrollX(); final int scrollY = getScrollY(); canvas.translate(scrollX, scrollY); - mBadgeRenderer.draw(canvas, mBadgeInfo, mTempIconBounds, mBadgeScale, + mBadgeRenderer.draw(canvas, mBadgePalette, mBadgeInfo, mTempIconBounds, mBadgeScale, mTempSpaceForBadgeOffset); canvas.translate(-scrollX, -scrollY); } @@ -578,7 +578,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { float newBadgeScale = isBadged ? 1f : 0; mBadgeRenderer = mLauncher.getDeviceProfile().mBadgeRenderer; if (wasBadged || isBadged) { - mIconPalette = ((FastBitmapDrawable) mIcon).getIconPalette(); + mBadgePalette = IconPalette.getBadgePalette(getResources()); + if (mBadgePalette == null) { + mBadgePalette = ((FastBitmapDrawable) mIcon).getIconPalette(); + } // Animate when a badge is first added or when it is removed. if (animate && (wasBadged ^ isBadged) && isShown()) { ObjectAnimator.ofFloat(this, BADGE_SCALE_PROPERTY, newBadgeScale).start(); @@ -590,6 +593,10 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { } } + public IconPalette getBadgePalette() { + return mBadgePalette; + } + /** * Sets the icon for this view based on the layout direction. */ diff --git a/src/com/android/launcher3/FastBitmapDrawable.java b/src/com/android/launcher3/FastBitmapDrawable.java index a096a1ddf..199baaf58 100644 --- a/src/com/android/launcher3/FastBitmapDrawable.java +++ b/src/com/android/launcher3/FastBitmapDrawable.java @@ -124,7 +124,7 @@ public class FastBitmapDrawable extends Drawable { public IconPalette getIconPalette() { if (mIconPalette == null) { mIconPalette = IconPalette.fromDominantColor(Utilities - .findDominantColorByHue(mBitmap, 20)); + .findDominantColorByHue(mBitmap, 20), true /* desaturateBackground */); } return mIconPalette; } diff --git a/src/com/android/launcher3/badge/BadgeRenderer.java b/src/com/android/launcher3/badge/BadgeRenderer.java index adde4a2fc..ba1977af4 100644 --- a/src/com/android/launcher3/badge/BadgeRenderer.java +++ b/src/com/android/launcher3/badge/BadgeRenderer.java @@ -63,7 +63,6 @@ public class BadgeRenderer { private final Paint mBackgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG | Paint.FILTER_BITMAP_FLAG); private final SparseArray mBackgroundsWithShadow; - private final IconPalette mIconPalette; public BadgeRenderer(Context context, int iconSizePx) { mContext = context; @@ -83,25 +82,24 @@ public class BadgeRenderer { mTextHeight = tempTextHeight.height(); mBackgroundsWithShadow = new SparseArray<>(3); - - mIconPalette = IconPalette.fromDominantColor(context.getColor(R.color.badge_color)); } /** * Draw a circle in the top right corner of the given bounds, and draw * {@link BadgeInfo#getNotificationCount()} on top of the circle. + * @param palette The colors (based on the icon) to use for the badge. * @param badgeInfo Contains data to draw on the badge. Could be null if we are animating out. * @param iconBounds The bounds of the icon being badged. * @param badgeScale The progress of the animation, from 0 to 1. * @param spaceForOffset How much space is available to offset the badge up and to the right. */ - public void draw(Canvas canvas, @Nullable BadgeInfo badgeInfo, + public void draw(Canvas canvas, IconPalette palette, @Nullable BadgeInfo badgeInfo, Rect iconBounds, float badgeScale, Point spaceForOffset) { - mTextPaint.setColor(mIconPalette.textColor); + mTextPaint.setColor(palette.textColor); IconDrawer iconDrawer = badgeInfo != null && badgeInfo.isIconLarge() ? mLargeIconDrawer : mSmallIconDrawer; Shader icon = badgeInfo == null ? null : badgeInfo.getNotificationIconForBadge( - mContext, mIconPalette.backgroundColor, mSize, iconDrawer.mPadding); + mContext, palette.backgroundColor, mSize, iconDrawer.mPadding); String notificationCount = badgeInfo == null ? "0" : String.valueOf(badgeInfo.getNotificationCount()); int numChars = notificationCount.length(); @@ -127,7 +125,7 @@ public class BadgeRenderer { canvas.translate(badgeCenterX + offsetX, badgeCenterY - offsetY); canvas.scale(badgeScale, badgeScale); // Prepare the background and shadow and possible stacking effect. - mBackgroundPaint.setColorFilter(mIconPalette.backgroundColorMatrixFilter); + mBackgroundPaint.setColorFilter(palette.backgroundColorMatrixFilter); int backgroundWithShadowSize = backgroundWithShadow.getHeight(); // Same as width. boolean shouldStack = !isDot && badgeInfo != null && badgeInfo.getNotificationKeys().size() > 1; @@ -149,7 +147,7 @@ public class BadgeRenderer { -backgroundWithShadowSize / 2, mBackgroundPaint); iconDrawer.drawIcon(icon, canvas); } else if (isDot) { - mBackgroundPaint.setColorFilter(mIconPalette.saturatedBackgroundColorMatrixFilter); + mBackgroundPaint.setColorFilter(palette.saturatedBackgroundColorMatrixFilter); canvas.drawBitmap(backgroundWithShadow, -backgroundWithShadowSize / 2, -backgroundWithShadowSize / 2, mBackgroundPaint); } diff --git a/src/com/android/launcher3/folder/FolderIcon.java b/src/com/android/launcher3/folder/FolderIcon.java index 0b356b52c..8d58fef36 100644 --- a/src/com/android/launcher3/folder/FolderIcon.java +++ b/src/com/android/launcher3/folder/FolderIcon.java @@ -75,6 +75,7 @@ import com.android.launcher3.badge.FolderBadgeInfo; import com.android.launcher3.config.FeatureFlags; import com.android.launcher3.dragndrop.DragLayer; import com.android.launcher3.dragndrop.DragView; +import com.android.launcher3.graphics.IconPalette; import com.android.launcher3.util.Thunk; import java.util.ArrayList; @@ -885,7 +886,8 @@ public class FolderIcon extends FrameLayout implements FolderListener { // If we are animating to the accepting state, animate the badge out. float badgeScale = Math.max(0, mBadgeScale - mBackground.getScaleProgress()); mTempSpaceForBadgeOffset.set(getWidth() - mTempBounds.right, mTempBounds.top); - mBadgeRenderer.draw(canvas, mBadgeInfo, mTempBounds, + IconPalette badgePalette = IconPalette.getFolderBadgePalette(getResources()); + mBadgeRenderer.draw(canvas, badgePalette, mBadgeInfo, mTempBounds, badgeScale, mTempSpaceForBadgeOffset); } } diff --git a/src/com/android/launcher3/graphics/IconPalette.java b/src/com/android/launcher3/graphics/IconPalette.java index 60ca7b236..a17ceeb94 100644 --- a/src/com/android/launcher3/graphics/IconPalette.java +++ b/src/com/android/launcher3/graphics/IconPalette.java @@ -18,9 +18,12 @@ package com.android.launcher3.graphics; import android.app.Notification; import android.content.Context; +import android.content.res.Resources; import android.graphics.Color; import android.graphics.ColorMatrix; import android.graphics.ColorMatrixColorFilter; +import android.support.annotation.NonNull; +import android.support.annotation.Nullable; import android.support.v4.graphics.ColorUtils; import android.util.Log; @@ -35,11 +38,12 @@ public class IconPalette { private static final boolean DEBUG = false; private static final String TAG = "IconPalette"; - public static final IconPalette FOLDER_ICON_PALETTE = new IconPalette(Color.parseColor("#BDC1C6")); - private static final float MIN_PRELOAD_COLOR_SATURATION = 0.2f; private static final float MIN_PRELOAD_COLOR_LIGHTNESS = 0.6f; + private static IconPalette sBadgePalette; + private static IconPalette sFolderBadgePalette; + public final int dominantColor; public final int backgroundColor; public final ColorMatrixColorFilter backgroundColorMatrixFilter; @@ -47,15 +51,19 @@ public class IconPalette { public final int textColor; public final int secondaryColor; - private IconPalette(int color) { + private IconPalette(int color, boolean desaturateBackground) { dominantColor = color; - backgroundColor = dominantColor; + backgroundColor = desaturateBackground ? getMutedColor(dominantColor, 0.87f) : dominantColor; ColorMatrix backgroundColorMatrix = new ColorMatrix(); Themes.setColorScaleOnMatrix(backgroundColor, backgroundColorMatrix); backgroundColorMatrixFilter = new ColorMatrixColorFilter(backgroundColorMatrix); - // Get slightly more saturated background color. - Themes.setColorScaleOnMatrix(getMutedColor(dominantColor, 0.54f), backgroundColorMatrix); - saturatedBackgroundColorMatrixFilter = new ColorMatrixColorFilter(backgroundColorMatrix); + if (!desaturateBackground) { + saturatedBackgroundColorMatrixFilter = backgroundColorMatrixFilter; + } else { + // Get slightly more saturated background color. + Themes.setColorScaleOnMatrix(getMutedColor(dominantColor, 0.54f), backgroundColorMatrix); + saturatedBackgroundColorMatrixFilter = new ColorMatrixColorFilter(backgroundColorMatrix); + } textColor = getTextColorForBackground(backgroundColor); secondaryColor = getLowContrastColor(backgroundColor); } @@ -78,8 +86,35 @@ public class IconPalette { return result; } - public static IconPalette fromDominantColor(int dominantColor) { - return new IconPalette(dominantColor); + public static IconPalette fromDominantColor(int dominantColor, boolean desaturateBackground) { + return new IconPalette(dominantColor, desaturateBackground); + } + + /** + * Returns an IconPalette based on the badge_color in colors.xml. + * If that color is Color.TRANSPARENT, then returns null instead. + */ + public static @Nullable IconPalette getBadgePalette(Resources resources) { + int badgeColor = resources.getColor(R.color.badge_color); + if (badgeColor == Color.TRANSPARENT) { + // Colors will be extracted per app icon, so a static palette won't work. + return null; + } + if (sBadgePalette == null) { + sBadgePalette = fromDominantColor(badgeColor, false); + } + return sBadgePalette; + } + + /** + * Returns an IconPalette based on the folder_badge_color in colors.xml. + */ + public static @NonNull IconPalette getFolderBadgePalette(Resources resources) { + if (sFolderBadgePalette == null) { + int badgeColor = resources.getColor(R.color.folder_badge_color); + sFolderBadgePalette = fromDominantColor(badgeColor, false); + } + return sFolderBadgePalette; } /** diff --git a/src/com/android/launcher3/popup/PopupContainerWithArrow.java b/src/com/android/launcher3/popup/PopupContainerWithArrow.java index ccead37dc..4488f6634 100644 --- a/src/com/android/launcher3/popup/PopupContainerWithArrow.java +++ b/src/com/android/launcher3/popup/PopupContainerWithArrow.java @@ -47,7 +47,6 @@ import com.android.launcher3.AbstractFloatingView; import com.android.launcher3.BubbleTextView; import com.android.launcher3.DragSource; import com.android.launcher3.DropTarget; -import com.android.launcher3.FastBitmapDrawable; import com.android.launcher3.ItemInfo; import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAnimUtils; @@ -579,9 +578,7 @@ public class PopupContainerWithArrow extends AbstractFloatingView implements Dra ItemInfo itemInfo = (ItemInfo) mOriginalIcon.getTag(); BadgeInfo badgeInfo = mLauncher.getPopupDataProvider().getBadgeInfoForItem(itemInfo); if (mNotificationItemView != null && badgeInfo != null) { - IconPalette palette = mOriginalIcon.getIcon() instanceof FastBitmapDrawable - ? ((FastBitmapDrawable) mOriginalIcon.getIcon()).getIconPalette() - : null; + IconPalette palette = mOriginalIcon.getBadgePalette(); mNotificationItemView.updateHeader(badgeInfo.getNotificationCount(), palette); } } -- cgit v1.2.3