Loading res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -182,4 +182,8 @@ also happens to equal 19dp--> <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen> <!-- Other --> <!-- Approximates the system status bar height. Not guaranteed to be always be correct. --> <dimen name="status_bar_height">24dp</dimen> </resources> src/com/android/launcher3/Launcher.java +26 −3 Original line number Diff line number Diff line Loading @@ -277,9 +277,10 @@ public class Launcher extends Activity private LauncherAccessibilityDelegate mAccessibilityDelegate; private boolean mIsResumeFromActionScreenOff; @Thunk boolean mUserPresent = true; private boolean mVisible = false; private boolean mHasFocus = false; private boolean mAttached = false; private boolean mVisible; private boolean mHasFocus; private boolean mAttached; private boolean mIsLightStatusBar; /** Maps launcher activity components to their list of shortcut ids. */ private MultiHashMap<ComponentKey, String> mDeepShortcutMap = new MultiHashMap<>(); Loading Loading @@ -488,9 +489,31 @@ public class Launcher extends Activity mExtractedColors.load(this); mHotseat.updateColor(mExtractedColors, !mPaused); mWorkspace.getPageIndicator().updateColor(mExtractedColors); setLightStatusBar(shouldBeLightStatusBar()); } } /** Returns whether a light status bar (dark icons) should be used based on the wallpaper. */ public boolean shouldBeLightStatusBar() { return mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, ExtractedColors.DEFAULT_LIGHT) == ExtractedColors.DEFAULT_LIGHT; } public void setLightStatusBar(boolean lightStatusBar) { // Already set correctly if (mIsLightStatusBar == lightStatusBar) { return; } mIsLightStatusBar = lightStatusBar; int systemUiFlags = getWindow().getDecorView().getSystemUiVisibility(); if (lightStatusBar) { systemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { systemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } getWindow().getDecorView().setSystemUiVisibility(systemUiFlags); } private LauncherCallbacks mLauncherCallbacks; public void onPostCreate(Bundle savedInstanceState) { Loading src/com/android/launcher3/allapps/AllAppsTransitionController.java +4 −18 Original line number Diff line number Diff line Loading @@ -86,8 +86,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private AnimatorSet mCurrentAnimation; private boolean mNoIntercept; private boolean mLightStatusBar; // Used in discovery bounce animation to provide the transition without workspace changing. private boolean mIsTranslateWithoutWorkspace = false; private AnimatorSet mDiscoBounceAnimation; Loading Loading @@ -273,26 +271,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } private void updateLightStatusBar(float shift) { boolean enable = shift <= mStatusBarHeight / 2; // Do not modify status bar on landscape as all apps is not full bleed. if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { return; } // Already set correctly if (mLightStatusBar == enable) { return; } int systemUiFlags = mLauncher.getWindow().getDecorView().getSystemUiVisibility(); if (enable) { mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } else { mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags & ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)); } mLightStatusBar = enable; // Use a light status bar (dark icons) if all apps is behind at least half of the status // bar. If the status bar is already light due to wallpaper extraction, keep it that way. boolean enable = shift <= mStatusBarHeight / 2 || mLauncher.shouldBeLightStatusBar(); mLauncher.setLightStatusBar(enable); } /** Loading src/com/android/launcher3/dynamicui/ColorExtractionService.java +10 −4 Original line number Diff line number Diff line Loading @@ -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}. Loading @@ -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. Loading src/com/android/launcher3/dynamicui/ExtractedColors.java +8 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 = ","; Loading Loading @@ -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); } } Loading
res/values/dimens.xml +4 −0 Original line number Diff line number Diff line Loading @@ -182,4 +182,8 @@ also happens to equal 19dp--> <dimen name="deep_shortcuts_arrow_horizontal_offset">19dp</dimen> <!-- Other --> <!-- Approximates the system status bar height. Not guaranteed to be always be correct. --> <dimen name="status_bar_height">24dp</dimen> </resources>
src/com/android/launcher3/Launcher.java +26 −3 Original line number Diff line number Diff line Loading @@ -277,9 +277,10 @@ public class Launcher extends Activity private LauncherAccessibilityDelegate mAccessibilityDelegate; private boolean mIsResumeFromActionScreenOff; @Thunk boolean mUserPresent = true; private boolean mVisible = false; private boolean mHasFocus = false; private boolean mAttached = false; private boolean mVisible; private boolean mHasFocus; private boolean mAttached; private boolean mIsLightStatusBar; /** Maps launcher activity components to their list of shortcut ids. */ private MultiHashMap<ComponentKey, String> mDeepShortcutMap = new MultiHashMap<>(); Loading Loading @@ -488,9 +489,31 @@ public class Launcher extends Activity mExtractedColors.load(this); mHotseat.updateColor(mExtractedColors, !mPaused); mWorkspace.getPageIndicator().updateColor(mExtractedColors); setLightStatusBar(shouldBeLightStatusBar()); } } /** Returns whether a light status bar (dark icons) should be used based on the wallpaper. */ public boolean shouldBeLightStatusBar() { return mExtractedColors.getColor(ExtractedColors.STATUS_BAR_INDEX, ExtractedColors.DEFAULT_LIGHT) == ExtractedColors.DEFAULT_LIGHT; } public void setLightStatusBar(boolean lightStatusBar) { // Already set correctly if (mIsLightStatusBar == lightStatusBar) { return; } mIsLightStatusBar = lightStatusBar; int systemUiFlags = getWindow().getDecorView().getSystemUiVisibility(); if (lightStatusBar) { systemUiFlags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; } else { systemUiFlags &= ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } getWindow().getDecorView().setSystemUiVisibility(systemUiFlags); } private LauncherCallbacks mLauncherCallbacks; public void onPostCreate(Bundle savedInstanceState) { Loading
src/com/android/launcher3/allapps/AllAppsTransitionController.java +4 −18 Original line number Diff line number Diff line Loading @@ -86,8 +86,6 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private AnimatorSet mCurrentAnimation; private boolean mNoIntercept; private boolean mLightStatusBar; // Used in discovery bounce animation to provide the transition without workspace changing. private boolean mIsTranslateWithoutWorkspace = false; private AnimatorSet mDiscoBounceAnimation; Loading Loading @@ -273,26 +271,14 @@ public class AllAppsTransitionController implements TouchController, VerticalPul } private void updateLightStatusBar(float shift) { boolean enable = shift <= mStatusBarHeight / 2; // Do not modify status bar on landscape as all apps is not full bleed. if (mLauncher.getDeviceProfile().isVerticalBarLayout()) { return; } // Already set correctly if (mLightStatusBar == enable) { return; } int systemUiFlags = mLauncher.getWindow().getDecorView().getSystemUiVisibility(); if (enable) { mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags | View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); } else { mLauncher.getWindow().getDecorView().setSystemUiVisibility(systemUiFlags & ~(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR)); } mLightStatusBar = enable; // Use a light status bar (dark icons) if all apps is behind at least half of the status // bar. If the status bar is already light due to wallpaper extraction, keep it that way. boolean enable = shift <= mStatusBarHeight / 2 || mLauncher.shouldBeLightStatusBar(); mLauncher.setLightStatusBar(enable); } /** Loading
src/com/android/launcher3/dynamicui/ColorExtractionService.java +10 −4 Original line number Diff line number Diff line Loading @@ -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}. Loading @@ -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. Loading
src/com/android/launcher3/dynamicui/ExtractedColors.java +8 −2 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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 = ","; Loading Loading @@ -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); } }