Improve the scrim on the cover card
Use a translucent wallpaper and black header text, as well
as always use a bottom scrim to ensure the QSB is fully
visible as well as the "Tap to edit" button
Bug: 131296977
Change-Id: I6bca899065919812e5771f5e60e0864169f25098
diff --git a/res/drawable/theme_cover_scrim.xml b/res/drawable/theme_cover_scrim.xml
index 029ea85..c75213c 100644
--- a/res/drawable/theme_cover_scrim.xml
+++ b/res/drawable/theme_cover_scrim.xml
@@ -17,10 +17,11 @@
-->
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
- <gradient
+ <gradient
android:angle="90"
- android:startColor="@android:color/transparent"
+ android:centerY="25%"
+ android:startColor="@color/black_38_alpha"
android:centerColor="@android:color/transparent"
- android:endColor="@color/translucent_black_darker"
+ android:endColor="@android:color/transparent"
android:type="linear" />
</shape>
\ No newline at end of file
diff --git a/res/drawable/theme_cover_scrim_custom.xml b/res/drawable/theme_cover_scrim_custom.xml
deleted file mode 100644
index de49be3..0000000
--- a/res/drawable/theme_cover_scrim_custom.xml
+++ /dev/null
@@ -1,32 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
-
- Copyright (C) 2019 The Android Open Source Project
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<layer-list
- xmlns:android="http://schemas.android.com/apk/res/android" >
- <item android:drawable="@drawable/theme_cover_scrim"/>
- <item>
- <shape android:shape="rectangle">
- <gradient
- android:angle="90"
- android:centerY="25%"
- android:startColor="@color/black_67_alpha"
- android:centerColor="@android:color/transparent"
- android:endColor="@android:color/transparent"
- android:type="linear" />
- </shape>
- </item>
-</layer-list>
\ No newline at end of file
diff --git a/res/values-night/colors.xml b/res/values-night/colors.xml
index 9179bc2..4037f4d 100644
--- a/res/values-night/colors.xml
+++ b/res/values-night/colors.xml
@@ -18,7 +18,7 @@
<resources>
<color name="theme_preview_icon_color">@color/white_70_alpha</color>
- <color name="icon_thumbnail_color">@color/white_70_alpha</color>
+ <color name="icon_thumbnail_color">@color/black_87_alpha</color>
<color name="control_grey">#b3b3b3</color>
<color name="switch_track_tint">#171717</color>
diff --git a/res/values/colors.xml b/res/values/colors.xml
index bc27623..b63f8ff 100644
--- a/res/values/colors.xml
+++ b/res/values/colors.xml
@@ -26,7 +26,7 @@
<color name="system_navigation_bar_divider">#1f000000</color>
<color name="shape_thumbnail_color">#b2b2b2</color>
- <color name="icon_thumbnail_color">@color/white_70_alpha</color>
+ <color name="icon_thumbnail_color">@color/black_87_alpha</color>
<color name="clockface_preview_background">@android:color/black</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 622cd90..c4c5d4d 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -91,7 +91,7 @@
<style name="CoverTitleTextAppearance" parent="CardTitleTextAppearance">
<item name="android:textSize">@dimen/card_cover_title_text_size</item>
- <item name="android:textColor">@color/white_70_alpha</item>
+ <item name="android:textColor">@color/black_87_alpha</item>
</style>
<style name="FontCardTitleStyle" parent="HeaderTextAppearance">
@@ -107,8 +107,9 @@
<!-- Custom theme editor -->
<style name="EditLabelStyle">
- <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault</item>
+ <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Widget.Button</item>
<item name="android:textColor">@color/material_white_100</item>
+ <item name="android:textAllCaps">false</item>
</style>
<style name="CustomThemeNameEditText" parent="@android:style/Widget.DeviceDefault.EditText">
diff --git a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
index 5f7381a..e21fc80 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -20,7 +20,6 @@
import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
-import android.graphics.drawable.LayerDrawable;
import android.os.Bundle;
import android.text.Editable;
import android.text.TextWatcher;
@@ -138,7 +137,7 @@
previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
previewInfo.shapeDrawable, previewInfo.shapeAppIcons, null,
mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
- new WallpaperLayoutListener(context));
+ new WallpaperLayoutListener());
mCoverPage.setCard(card);
mCoverPage.bindPreviewContent();
mNameEditor.addTextChangedListener(new TextWatcher() {
@@ -160,12 +159,7 @@
}
private class WallpaperLayoutListener implements OnLayoutChangeListener {
- private final Drawable mScrim;
- WallpaperLayoutListener(Context context) {
- mScrim = context.getResources()
- .getDrawable(R.drawable.theme_cover_scrim, context.getTheme());
- }
@Override
public void onLayoutChange(View view, int left, int top, int right,
int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
@@ -184,9 +178,8 @@
private void setWallpaperBitmap(View view, Bitmap bitmap) {
Resources res = view.getContext().getResources();
Drawable background = new BitmapDrawable(res, bitmap);
- if (mScrim != null) {
- background = new LayerDrawable(new Drawable[]{background, mScrim});
- }
+ background.setAlpha(ThemeCoverPage.COVER_PAGE_WALLPAPER_ALPHA);
+
view.findViewById(R.id.theme_preview_card_background).setBackground(background);
}
}
diff --git a/src/com/android/customization/picker/theme/ThemeFragment.java b/src/com/android/customization/picker/theme/ThemeFragment.java
index bec3cf8..cb78ea6 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -17,7 +17,6 @@
import android.app.Activity;
import android.app.WallpaperColors;
-import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.res.ColorStateList;
@@ -48,7 +47,6 @@
import com.android.customization.model.CustomizationManager.Callback;
import com.android.customization.model.CustomizationManager.OptionsFetchedListener;
-import com.android.customization.model.grid.GridOption;
import com.android.customization.model.theme.ThemeBundle;
import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
import com.android.customization.model.theme.ThemeManager;
@@ -377,12 +375,13 @@
super(activity, R.layout.theme_preview_card);
final Resources res = activity.getResources();
final PreviewInfo previewInfo = theme.getPreviewInfo();
+
Drawable coverScrim = theme instanceof CustomTheme
- ? res.getDrawable(R.drawable.theme_cover_scrim_custom, activity.getTheme())
- : res.getDrawable(R.drawable.theme_cover_scrim, activity.getTheme());
+ ? res.getDrawable(R.drawable.theme_cover_scrim, activity.getTheme())
+ : null;
WallpaperPreviewLayoutListener wallpaperListener = new WallpaperPreviewLayoutListener(
- theme, previewInfo, coverScrim);
+ theme, previewInfo, coverScrim, true);
addPage(new ThemeCoverPage(activity, theme.getTitle(),
previewInfo.resolveAccentColor(res), previewInfo.icons,
@@ -490,7 +489,7 @@
previewInfo.resolveAccentColor(res)) {
private final WallpaperPreviewLayoutListener mListener =
- new WallpaperPreviewLayoutListener(theme, previewInfo, null);
+ new WallpaperPreviewLayoutListener(theme, previewInfo, null, false);
@Override
protected boolean containsWallpaper() {
@@ -531,12 +530,14 @@
private final ThemeBundle mTheme;
private final PreviewInfo mPreviewInfo;
private final Drawable mScrim;
+ private final boolean mIsTranslucent;
public WallpaperPreviewLayoutListener(ThemeBundle theme, PreviewInfo previewInfo,
- Drawable scrim) {
+ Drawable scrim, boolean translucent) {
mTheme = theme;
mPreviewInfo = previewInfo;
mScrim = scrim;
+ mIsTranslucent = translucent;
}
@Override
@@ -559,11 +560,14 @@
private void setWallpaperBitmap(View view, Bitmap bitmap) {
Resources res = view.getContext().getResources();
Drawable background = new BitmapDrawable(res, bitmap);
+ if (mIsTranslucent) {
+ background.setAlpha(ThemeCoverPage.COVER_PAGE_WALLPAPER_ALPHA);
+ }
if (mScrim != null) {
background = new LayerDrawable(new Drawable[]{background, mScrim});
}
view.findViewById(R.id.theme_preview_card_background).setBackground(background);
- if (mScrim == null) {
+ if (mScrim == null && !mIsTranslucent) {
int colorsHint = WallpaperColors.fromBitmap(bitmap).getColorHints();
TextView header = view.findViewById(R.id.theme_preview_card_header);
if ((colorsHint & WallpaperColors.HINT_SUPPORTS_DARK_TEXT) == 0) {
diff --git a/src/com/android/customization/picker/theme/ThemePreviewPage.java b/src/com/android/customization/picker/theme/ThemePreviewPage.java
index 47282eb..79f2e9c 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -78,6 +78,7 @@
static class ThemeCoverPage extends ThemePreviewPage implements TimeContainer {
+ public static final int COVER_PAGE_WALLPAPER_ALPHA = 0x66;
/**
* Maps which icon from ResourceConstants#ICONS_FOR_PREVIEW to use for each icon in the
* top bar (fake "status bar") of the cover page.