Merge "Dark color on super light wallpaper support" into ub-launcher3-dorval-polish

This commit is contained in:
Mario Bertschler
2017-06-08 17:45:55 +00:00
committed by Android (Google) Code Review
14 changed files with 83 additions and 23 deletions
+1 -1
View File
@@ -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">
+1 -1
View File
@@ -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">
+1 -1
View File
@@ -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">
+6 -3
View File
@@ -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>
+5 -1
View File
@@ -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 -->
+9 -1
View File
@@ -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
+21 -4
View File
@@ -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 -->
@@ -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();
+9 -2
View File
@@ -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);
}
}
@@ -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;
}
@@ -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
@@ -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;
@@ -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);
@@ -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].
*/