diff options
-rw-r--r-- | res/layout-land/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout-port/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout-sw720dp/launcher.xml | 2 | ||||
-rw-r--r-- | res/layout/overview_panel.xml | 9 | ||||
-rw-r--r-- | res/values-sw720dp/styles.xml | 6 | ||||
-rw-r--r-- | res/values/attrs.xml | 10 | ||||
-rw-r--r-- | res/values/styles.xml | 25 | ||||
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 13 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 11 | ||||
-rw-r--r-- | src/com/android/launcher3/allapps/AllAppsTransitionController.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragLayer.java | 4 | ||||
-rw-r--r-- | src/com/android/launcher3/dynamicui/WallpaperColorInfo.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/pageindicators/CaretDrawable.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/util/Themes.java | 8 |
14 files changed, 83 insertions, 23 deletions
diff --git a/res/layout-land/launcher.xml b/res/layout-land/launcher.xml index 4e09ef953..2e0357672 100644 --- a/res/layout-land/launcher.xml +++ b/res/layout-land/launcher.xml @@ -27,7 +27,7 @@ android:id="@+id/drag_layer" android:clipChildren="false" android:clipToPadding="false" - android:background="@drawable/workspace_bg" + android:background="?attr/workspaceStatusBarScrim" android:importantForAccessibility="no" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/res/layout-port/launcher.xml b/res/layout-port/launcher.xml index 0f88698f0..93c90780b 100644 --- a/res/layout-port/launcher.xml +++ b/res/layout-port/launcher.xml @@ -29,7 +29,7 @@ android:clipChildren="false" android:importantForAccessibility="no" android:clipToPadding="false" - android:background="@drawable/workspace_bg" + android:background="?attr/workspaceStatusBarScrim" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/res/layout-sw720dp/launcher.xml b/res/layout-sw720dp/launcher.xml index b9b94b6b0..ca4d846f1 100644 --- a/res/layout-sw720dp/launcher.xml +++ b/res/layout-sw720dp/launcher.xml @@ -28,7 +28,7 @@ android:clipChildren="false" android:clipToPadding="false" android:importantForAccessibility="no" - android:background="@drawable/workspace_bg" + android:background="?attr/workspaceStatusBarScrim" android:layout_width="match_parent" android:layout_height="match_parent"> diff --git a/res/layout/overview_panel.xml b/res/layout/overview_panel.xml index 78a0f1596..d1ac56c50 100644 --- a/res/layout/overview_panel.xml +++ b/res/layout/overview_panel.xml @@ -32,12 +32,13 @@ android:layout_weight="1" android:drawablePadding="4dp" android:drawableTop="@drawable/ic_wallpaper" + android:drawableTint="?attr/workspaceTextColor" android:fontFamily="sans-serif-condensed" android:gravity="center_horizontal" android:stateListAnimator="@animator/overview_button_anim" android:text="@string/wallpaper_button_text" android:textAllCaps="true" - android:textColor="@android:color/white" + android:textColor="?attr/workspaceTextColor" android:textSize="12sp" /> <TextView @@ -47,12 +48,13 @@ android:layout_weight="1" android:drawablePadding="4dp" android:drawableTop="@drawable/ic_widget" + android:drawableTint="?attr/workspaceTextColor" android:fontFamily="sans-serif-condensed" android:gravity="center_horizontal" android:stateListAnimator="@animator/overview_button_anim" android:text="@string/widget_button_text" android:textAllCaps="true" - android:textColor="@android:color/white" + android:textColor="?attr/workspaceTextColor" android:textSize="12sp" /> <TextView @@ -62,12 +64,13 @@ android:layout_weight="1" android:drawablePadding="4dp" android:drawableTop="@drawable/ic_setting" + android:drawableTint="?attr/workspaceTextColor" android:fontFamily="sans-serif-condensed" android:gravity="center_horizontal" android:stateListAnimator="@animator/overview_button_anim" android:text="@string/settings_button_text" android:textAllCaps="true" - android:textColor="@android:color/white" + android:textColor="?attr/workspaceTextColor" android:textSize="12sp" /> </LinearLayout>
\ No newline at end of file diff --git a/res/values-sw720dp/styles.xml b/res/values-sw720dp/styles.xml index 168afec4b..0c060ea0d 100644 --- a/res/values-sw720dp/styles.xml +++ b/res/values-sw720dp/styles.xml @@ -31,7 +31,11 @@ <item name="popupColorPrimary">#FFF</item> <item name="popupColorSecondary">#F5F5F5</item> <!-- Gray 100 --> <item name="popupColorTertiary">#E0E0E0</item> <!-- Gray 300 --> - <item name="isPrimaryColorDark">false</item> + <item name="isMainColorDark">false</item> + <item name="isWorkspaceDarkText">false</item> + <item name="workspaceTextColor">?android:textColorPrimary</item> + <item name="workspaceAmbientShadowColor">#22000000</item> + <item name="workspaceKeyShadowColor">#44000000</item> </style> <!-- Workspace --> diff --git a/res/values/attrs.xml b/res/values/attrs.xml index 1799b093e..b7189d17c 100644 --- a/res/values/attrs.xml +++ b/res/values/attrs.xml @@ -23,7 +23,13 @@ <attr name="popupColorPrimary" format="color" /> <attr name="popupColorSecondary" format="color" /> <attr name="popupColorTertiary" format="color" /> - <attr name="isPrimaryColorDark" format="boolean" /> + <attr name="isMainColorDark" format="boolean" /> + <attr name="isWorkspaceDarkText" format="boolean" /> + <attr name="workspaceTextColor" format="color" /> + <attr name="workspaceShadowColor" format="color" /> + <attr name="workspaceAmbientShadowColor" format="color"/> + <attr name="workspaceKeyShadowColor" format="color" /> + <attr name="workspaceStatusBarScrim" format="reference" /> <!-- BubbleTextView specific attributes. --> <declare-styleable name="BubbleTextView"> @@ -39,6 +45,8 @@ <attr name="deferShadowGeneration" format="boolean" /> <attr name="customShadows" format="boolean" /> <attr name="centerVertically" format="boolean" /> + <attr name="ambientShadowColor" format="color" /> + <attr name="keyShadowColor" format="color" /> </declare-styleable> <!-- PagedView specific attributes. These attributes are used to customize diff --git a/res/values/styles.xml b/res/values/styles.xml index 5ef044e98..dd5602914 100644 --- a/res/values/styles.xml +++ b/res/values/styles.xml @@ -30,24 +30,38 @@ <item name="popupColorPrimary">#FFF</item> <item name="popupColorSecondary">#F5F5F5</item> <!-- Gray 100 --> <item name="popupColorTertiary">#E0E0E0</item> <!-- Gray 300 --> - <item name="isPrimaryColorDark">false</item> + <item name="isMainColorDark">false</item> + <item name="isWorkspaceDarkText">false</item> + <item name="workspaceTextColor">?android:textColorPrimary</item> + <item name="workspaceShadowColor">#B0000000</item> + <item name="workspaceAmbientShadowColor">#22000000</item> + <item name="workspaceKeyShadowColor">#44000000</item> + <item name="workspaceStatusBarScrim">@drawable/workspace_bg</item> </style> <style name="LauncherTheme" parent="@style/BaseLauncherTheme"></style> + <style name="LauncherThemeDarkText" parent="@style/LauncherTheme"> + <item name="workspaceTextColor">#FF212121</item> + <item name="workspaceShadowColor">@android:color/transparent</item> + <item name="workspaceAmbientShadowColor">@android:color/transparent</item> + <item name="workspaceKeyShadowColor">@android:color/transparent</item> + <item name="isWorkspaceDarkText">true</item> + <item name="workspaceStatusBarScrim">@null</item> + </style> + <style name="LauncherThemeDark" parent="@style/LauncherTheme"> <item name="android:textColorPrimary">#FFFFFFFF</item> <item name="android:textColorSecondary">#FFFFFFFF</item> <item name="android:textColorTertiary">#CCFFFFFF</item> <item name="android:textColorHint">#A0FFFFFF</item> - <item name="android:colorControlHighlight">#A0FFFFFF</item> <item name="android:colorPrimary">#FF333333</item> <item name="allAppsScrimColor">#33000000</item> <item name="popupColorPrimary">?android:attr/colorPrimary</item> <item name="popupColorSecondary">#424242</item> <!-- Gray 800 --> <item name="popupColorTertiary">#757575</item> <!-- Gray 600 --> - <item name="isPrimaryColorDark">true</item> + <item name="isMainColorDark">true</item> </style> <!-- @@ -55,7 +69,7 @@ Various foreground colors are overridden to be white so that they are properly visible on various wallpapers --> - <style name="HomeScreenElementTheme" parent="@style/LauncherTheme"> + <style name="HomeScreenElementTheme"> <item name="android:colorEdgeEffect">@android:color/white</item> <item name="android:textColorPrimary">@android:color/white</item> <item name="android:textColorSecondary">@android:color/white</item> @@ -110,6 +124,9 @@ <item name="customShadows">true</item> <item name="android:shadowRadius">2.0</item> <item name="android:shadowColor">#B0000000</item> + <item name="android:textColor">?attr/workspaceTextColor</item> + <item name="keyShadowColor">?attr/workspaceKeyShadowColor</item> + <item name="ambientShadowColor">?attr/workspaceAmbientShadowColor</item> </style> <!-- Theme for the popup container --> diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 1f7eba812..ea1ee9e6d 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -51,6 +51,7 @@ import com.android.launcher3.graphics.HolographicOutlineHelper; import com.android.launcher3.graphics.IconPalette; import com.android.launcher3.graphics.PreloadIconDrawable; import com.android.launcher3.model.PackageItemInfo; +import com.android.launcher3.util.Themes; import java.text.NumberFormat; @@ -65,8 +66,6 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private static final float AMBIENT_SHADOW_RADIUS = 2.5f; private static final float KEY_SHADOW_RADIUS = 1f; private static final float KEY_SHADOW_OFFSET = 0.5f; - private static final int AMBIENT_SHADOW_COLOR = 0x33000000; - private static final int KEY_SHADOW_COLOR = 0x66000000; private static final int DISPLAY_WORKSPACE = 0; private static final int DISPLAY_ALL_APPS = 1; @@ -82,6 +81,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { private final CheckLongPressHelper mLongPressHelper; private final HolographicOutlineHelper mOutlineHelper; private final StylusEventHelper mStylusEventHelper; + private final int mAmbientShadowColor; + private final int mKeyShadowColor; private boolean mBackgroundSizeChanged; @@ -147,6 +148,8 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { mLayoutHorizontal = a.getBoolean(R.styleable.BubbleTextView_layoutHorizontal, false); mDeferShadowGenerationOnTouch = a.getBoolean(R.styleable.BubbleTextView_deferShadowGeneration, false); + mAmbientShadowColor = a.getColor(R.styleable.BubbleTextView_ambientShadowColor, 0x33000000); + mKeyShadowColor = a.getColor(R.styleable.BubbleTextView_keyShadowColor, 0x66000000); int display = a.getInteger(R.styleable.BubbleTextView_iconDisplay, DISPLAY_WORKSPACE); int defaultIconSize = grid.iconSizePx; @@ -174,7 +177,7 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { // Set shadow layer as the larger shadow to that the textView does not clip the shadow. float density = getResources().getDisplayMetrics().density; - setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, AMBIENT_SHADOW_COLOR); + setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, mAmbientShadowColor); } else { mBackground = null; } @@ -435,14 +438,14 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { // We enhance the shadow by drawing the shadow twice float density = getResources().getDisplayMetrics().density; - getPaint().setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, AMBIENT_SHADOW_COLOR); + getPaint().setShadowLayer(density * AMBIENT_SHADOW_RADIUS, 0, 0, mAmbientShadowColor); super.draw(canvas); canvas.save(Canvas.CLIP_SAVE_FLAG); canvas.clipRect(getScrollX(), getScrollY() + getExtendedPaddingTop(), getScrollX() + getWidth(), getScrollY() + getHeight(), Region.Op.INTERSECT); getPaint().setShadowLayer( - density * KEY_SHADOW_RADIUS, 0.0f, density * KEY_SHADOW_OFFSET, KEY_SHADOW_COLOR); + density * KEY_SHADOW_RADIUS, 0.0f, density * KEY_SHADOW_OFFSET, mKeyShadowColor); super.draw(canvas); canvas.restore(); diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index d23badc58..62cf2b3c4 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -127,6 +127,7 @@ import com.android.launcher3.util.PackageManagerHelper; import com.android.launcher3.util.PackageUserKey; import com.android.launcher3.util.PendingRequestArgs; import com.android.launcher3.util.TestingUtils; +import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.ViewOnDrawExecutor; import com.android.launcher3.widget.PendingAddShortcutInfo; @@ -368,7 +369,7 @@ public class Launcher extends BaseActivity WallpaperColorInfo wallpaperColorInfo = WallpaperColorInfo.getInstance(this); wallpaperColorInfo.setOnThemeChangeListener(this); - overrideTheme(wallpaperColorInfo.isDark()); + overrideTheme(wallpaperColorInfo.isDark(), wallpaperColorInfo.supportsDarkText()); super.onCreate(savedInstanceState); @@ -466,6 +467,10 @@ public class Launcher extends BaseActivity if (mLauncherCallbacks != null) { mLauncherCallbacks.onCreate(savedInstanceState); } + + if (Themes.getAttrBoolean(this, R.attr.isWorkspaceDarkText)) { + activateLightSystemBars(true, true, true); + } } @Override @@ -473,9 +478,11 @@ public class Launcher extends BaseActivity recreate(); } - protected void overrideTheme(boolean isDark) { + protected void overrideTheme(boolean isDark, boolean supportsDarkText) { if (isDark) { setTheme(R.style.LauncherThemeDark); + } else if (supportsDarkText) { + setTheme(R.style.LauncherThemeDarkText); } } diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java index ba20135be..d79b0d19d 100644 --- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java +++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java @@ -71,6 +71,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private final VerticalPullDetector mDetector; private final ArgbEvaluator mEvaluator; private final boolean mIsDarkTheme; + private final boolean mIsWorkspaceDarkText; // Animation in this class is controlled by a single variable {@link mProgress}. // Visually, it represents top y coordinate of the all apps container if multiplied with @@ -112,7 +113,8 @@ public class AllAppsTransitionController implements TouchController, VerticalPul mEvaluator = new ArgbEvaluator(); mAllAppsBackgroundColor = Themes.getAttrColor(l, android.R.attr.colorPrimary); - mIsDarkTheme = Themes.getAttrBoolean(mLauncher, R.attr.isPrimaryColorDark); + mIsDarkTheme = Themes.getAttrBoolean(mLauncher, R.attr.isMainColorDark); + mIsWorkspaceDarkText = Themes.getAttrBoolean(mLauncher, R.attr.isWorkspaceDarkText); } @Override @@ -281,7 +283,7 @@ public class AllAppsTransitionController implements TouchController, VerticalPul private void updateLightStatusBar(float shift) { // Do not modify status bar in dark theme or on landscape as all apps is not full bleed. - if (mIsDarkTheme || (!FeatureFlags.LAUNCHER3_GRADIENT_ALL_APPS + if (mIsDarkTheme || mIsWorkspaceDarkText || (!FeatureFlags.LAUNCHER3_GRADIENT_ALL_APPS && mLauncher.getDeviceProfile().isVerticalBarLayout())) { return; } diff --git a/src/com/android/launcher3/dragndrop/DragLayer.java b/src/com/android/launcher3/dragndrop/DragLayer.java index 7178c5e8d..ed81f9075 100644 --- a/src/com/android/launcher3/dragndrop/DragLayer.java +++ b/src/com/android/launcher3/dragndrop/DragLayer.java @@ -58,6 +58,7 @@ import com.android.launcher3.folder.Folder; import com.android.launcher3.folder.FolderIcon; import com.android.launcher3.keyboard.ViewGroupFocusHelper; import com.android.launcher3.logging.LoggerUtils; +import com.android.launcher3.util.Themes; import com.android.launcher3.util.Thunk; import com.android.launcher3.util.TouchController; import com.android.launcher3.widget.WidgetsBottomSheet; @@ -451,7 +452,8 @@ public class DragLayer extends InsettableFrameLayout { @Override public void setInsets(Rect insets) { super.setInsets(insets); - setBackgroundResource(insets.top == 0 ? 0 : R.drawable.workspace_bg); + setBackground(insets.top == 0 ? null + : Themes.getAttrDrawable(getContext(), R.attr.workspaceStatusBarScrim)); } @Override diff --git a/src/com/android/launcher3/dynamicui/WallpaperColorInfo.java b/src/com/android/launcher3/dynamicui/WallpaperColorInfo.java index ca85b6af1..7470118e6 100644 --- a/src/com/android/launcher3/dynamicui/WallpaperColorInfo.java +++ b/src/com/android/launcher3/dynamicui/WallpaperColorInfo.java @@ -33,6 +33,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange private int mMainColor; private int mSecondaryColor; private boolean mIsDark; + private boolean mSupportsDarkText; private OnThemeChangeListener mOnThemeChangeListener; private WallpaperColorInfo(Context context) { @@ -54,6 +55,10 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange return mIsDark; } + public boolean supportsDarkText() { + return mSupportsDarkText; + } + @Override public void onColorsChanged(WallpaperColorsCompat colors, int which) { if (which == FLAG_SYSTEM) { @@ -72,6 +77,7 @@ public class WallpaperColorInfo implements WallpaperManagerCompat.OnColorsChange mMainColor = FALLBACK_COLOR; mSecondaryColor = FALLBACK_COLOR; } + mSupportsDarkText = wallpaperColors != null ? wallpaperColors.supportsDarkText() : false; float[] hsl = new float[3]; ColorUtils.colorToHSL(mMainColor, hsl); mIsDark = hsl[2] < 0.2f; diff --git a/src/com/android/launcher3/pageindicators/CaretDrawable.java b/src/com/android/launcher3/pageindicators/CaretDrawable.java index 416b2f0b5..c5abfe35e 100644 --- a/src/com/android/launcher3/pageindicators/CaretDrawable.java +++ b/src/com/android/launcher3/pageindicators/CaretDrawable.java @@ -45,7 +45,7 @@ public class CaretDrawable extends Drawable { final int strokeWidth = res.getDimensionPixelSize(R.dimen.all_apps_caret_stroke_width); final int shadowSpread = res.getDimensionPixelSize(R.dimen.all_apps_caret_shadow_spread); - mCaretPaint.setColor(Themes.getAttrColor(context, android.R.attr.textColorPrimary)); + mCaretPaint.setColor(Themes.getAttrColor(context, R.attr.workspaceTextColor)); mCaretPaint.setAntiAlias(true); mCaretPaint.setStrokeWidth(strokeWidth); mCaretPaint.setStyle(Paint.Style.STROKE); diff --git a/src/com/android/launcher3/util/Themes.java b/src/com/android/launcher3/util/Themes.java index 9cf45b0c7..89597b9ed 100644 --- a/src/com/android/launcher3/util/Themes.java +++ b/src/com/android/launcher3/util/Themes.java @@ -20,6 +20,7 @@ import android.content.Context; import android.content.res.TypedArray; import android.graphics.Color; import android.graphics.ColorMatrix; +import android.graphics.drawable.Drawable; /** * Various utility methods associated with theming. @@ -44,6 +45,13 @@ public class Themes { return value; } + public static Drawable getAttrDrawable(Context context, int attr) { + TypedArray ta = context.obtainStyledAttributes(new int[]{attr}); + Drawable value = ta.getDrawable(0); + ta.recycle(); + return value; + } + /** * Returns the alpha corresponding to the theme attribute {@param attr}, in the range [0, 255]. */ |