diff options
author | Tony Wickham <twickham@google.com> | 2016-09-14 16:46:32 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2016-09-28 14:16:11 -0700 |
commit | 9311387a227d7bd894d880b897fb80ca34b39405 (patch) | |
tree | dde5d216907e0a4930a366d1350997df9e093f0e /src/com/android/launcher3/dynamicui | |
parent | ffad962092e2b42e336918c2f1e8f5ec48cc08a9 (diff) | |
download | android_packages_apps_Trebuchet-9311387a227d7bd894d880b897fb80ca34b39405.tar.gz android_packages_apps_Trebuchet-9311387a227d7bd894d880b897fb80ca34b39405.tar.bz2 android_packages_apps_Trebuchet-9311387a227d7bd894d880b897fb80ca34b39405.zip |
Enable light status bar when top of wallpaper is light.
(Light status bar = dark icons)
Bug: 29452834
Change-Id: I9f61a05d80158827761c8b62ab40fc50971e27a6
Diffstat (limited to 'src/com/android/launcher3/dynamicui')
-rw-r--r-- | src/com/android/launcher3/dynamicui/ColorExtractionService.java | 14 | ||||
-rw-r--r-- | src/com/android/launcher3/dynamicui/ExtractedColors.java | 10 |
2 files changed, 18 insertions, 6 deletions
diff --git a/src/com/android/launcher3/dynamicui/ColorExtractionService.java b/src/com/android/launcher3/dynamicui/ColorExtractionService.java index 89594f407..c15b71040 100644 --- a/src/com/android/launcher3/dynamicui/ColorExtractionService.java +++ b/src/com/android/launcher3/dynamicui/ColorExtractionService.java @@ -26,6 +26,7 @@ import android.support.v7.graphics.Palette; import com.android.launcher3.LauncherProvider; import com.android.launcher3.LauncherSettings; +import com.android.launcher3.R; /** * Extracts colors from the wallpaper, and saves results to {@link LauncherProvider}. @@ -52,16 +53,21 @@ public class ColorExtractionService extends IntentService { Bitmap wallpaper = ((BitmapDrawable) wallpaperManager.getDrawable()).getBitmap(); Palette palette = Palette.from(wallpaper).generate(); extractedColors.updatePalette(palette); - // We extract colors for the hotseat separately, - // since it only considers the lower part of the wallpaper. - // TODO(twickham): update Palette library to 23.3.1 or higher, - // which fixes a bug with using regions (b/28349435). + // We extract colors for the hotseat and status bar separately, + // since they only consider part of the wallpaper. Palette hotseatPalette = Palette.from(wallpaper) .setRegion(0, (int) (wallpaper.getHeight() * (1f - HOTSEAT_FRACTION)), wallpaper.getWidth(), wallpaper.getHeight()) .clearFilters() .generate(); extractedColors.updateHotseatPalette(hotseatPalette); + + int statusBarHeight = getResources().getDimensionPixelSize(R.dimen.status_bar_height); + Palette statusBarPalette = Palette.from(wallpaper) + .setRegion(0, 0, wallpaper.getWidth(), statusBarHeight) + .clearFilters() + .generate(); + extractedColors.updateStatusBarPalette(statusBarPalette); } // Save the extracted colors and wallpaper id to LauncherProvider. diff --git a/src/com/android/launcher3/dynamicui/ExtractedColors.java b/src/com/android/launcher3/dynamicui/ExtractedColors.java index e545288a0..4db0797c0 100644 --- a/src/com/android/launcher3/dynamicui/ExtractedColors.java +++ b/src/com/android/launcher3/dynamicui/ExtractedColors.java @@ -38,6 +38,7 @@ public class ExtractedColors { // loading extracted colors. New colors should always be added at the end. public static final int VERSION_INDEX = 0; public static final int HOTSEAT_INDEX = 1; + public static final int STATUS_BAR_INDEX = 2; // public static final int VIBRANT_INDEX = 2; // public static final int VIBRANT_DARK_INDEX = 3; // public static final int VIBRANT_LIGHT_INDEX = 4; @@ -45,8 +46,8 @@ public class ExtractedColors { // public static final int MUTED_DARK_INDEX = 6; // public static final int MUTED_LIGHT_INDEX = 7; - public static final int NUM_COLOR_PROFILES = 1; - private static final int VERSION = 1; + public static final int NUM_COLOR_PROFILES = 2; + private static final int VERSION = 2; private static final String COLOR_SEPARATOR = ","; @@ -156,4 +157,9 @@ public class ExtractedColors { } setColorAtIndex(HOTSEAT_INDEX, hotseatColor); } + + public void updateStatusBarPalette(Palette statusBarPalette) { + setColorAtIndex(STATUS_BAR_INDEX, ExtractionUtils.isSuperLight(statusBarPalette) ? + DEFAULT_LIGHT : DEFAULT_DARK); + } } |