Use white text and a scrim for the cover page
Use white header and "tap to edit" button, and use scrims
to ensure visibility.
Bug: 130759508
Change-Id: I3c6bdeb797d708e87bd224fce1829a2cc495d3a8
diff --git a/res/drawable/theme_cover_scrim.xml b/res/drawable/theme_cover_scrim.xml
new file mode 100644
index 0000000..029ea85
--- /dev/null
+++ b/res/drawable/theme_cover_scrim.xml
@@ -0,0 +1,26 @@
+<?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.
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <gradient
+ android:angle="90"
+ android:startColor="@android:color/transparent"
+ android:centerColor="@android:color/transparent"
+ android:endColor="@color/translucent_black_darker"
+ 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
new file mode 100644
index 0000000..de49be3
--- /dev/null
+++ b/res/drawable/theme_cover_scrim_custom.xml
@@ -0,0 +1,32 @@
+<?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/colors.xml b/res/values/colors.xml
index 68ad908..ee4207e 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">@android:color/black</color>
+ <color name="icon_thumbnail_color">@color/white_70_alpha</color>
<color name="clockface_preview_background">@android:color/black</color>
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 7857247..800e99a 100644
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -90,6 +90,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>
</style>
<style name="FontCardTitleStyle" parent="HeaderTextAppearance">
@@ -105,6 +106,7 @@
<style name="EditLabelStyle">
<item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault</item>
+ <item name="android:textColor">@color/material_white_100</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 84915ff..04aac7d 100644
--- a/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
+++ b/src/com/android/customization/picker/theme/CustomThemeNameFragment.java
@@ -15,11 +15,12 @@
*/
package com.android.customization.picker.theme;
-import android.app.WallpaperColors;
-import android.content.res.ColorStateList;
+import android.content.Context;
import android.content.res.Resources;
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;
@@ -35,7 +36,6 @@
import androidx.cardview.widget.CardView;
import com.android.customization.model.theme.ThemeBundle.PreviewInfo;
-import com.android.customization.model.theme.custom.CustomTheme;
import com.android.customization.picker.theme.ThemePreviewPage.ThemeCoverPage;
import com.android.wallpaper.R;
import com.android.wallpaper.asset.Asset;
@@ -107,13 +107,14 @@
}
private void bindCover(CardView card) {
- PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(getContext());
- mCoverPage = new ThemeCoverPage(getContext(), getThemeName(),
+ Context context = getContext();
+ PreviewInfo previewInfo = mCustomThemeManager.buildCustomThemePreviewInfo(context);
+ mCoverPage = new ThemeCoverPage(context, getThemeName(),
previewInfo.resolveAccentColor(getResources()), previewInfo.icons,
previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
previewInfo.shapeDrawable, previewInfo.shapeAppIcons, null,
mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
- new WallpaperLayoutListener());
+ new WallpaperLayoutListener(context));
mCoverPage.setCard(card);
mCoverPage.bindPreviewContent();
mNameEditor.addTextChangedListener(new TextWatcher() {
@@ -135,6 +136,12 @@
}
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) {
@@ -152,8 +159,10 @@
private void setWallpaperBitmap(View view, Bitmap bitmap) {
Resources res = view.getContext().getResources();
- BitmapDrawable background = new BitmapDrawable(res, bitmap);
- background.setAlpha(128);
+ Drawable background = new BitmapDrawable(res, bitmap);
+ if (mScrim != null) {
+ background = new LayerDrawable(new Drawable[]{background, mScrim});
+ }
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 134d255..22fa1d4 100644
--- a/src/com/android/customization/picker/theme/ThemeFragment.java
+++ b/src/com/android/customization/picker/theme/ThemeFragment.java
@@ -24,6 +24,7 @@
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.util.Log;
import android.view.LayoutInflater;
@@ -321,12 +322,16 @@
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());
+
addPage(new ThemeCoverPage(activity, theme.getTitle(),
previewInfo.resolveAccentColor(res), previewInfo.icons,
previewInfo.headlineFontFamily, previewInfo.bottomSheeetCornerRadius,
previewInfo.shapeDrawable, previewInfo.shapeAppIcons, editClickListener,
mColorButtonIds, mColorTileIds, mColorTileIconIds, mShapeIconIds,
- new WallpaperPreviewLayoutListener(theme, previewInfo, true)));
+ new WallpaperPreviewLayoutListener(theme, previewInfo, coverScrim)));
addPage(new ThemePreviewPage(activity, R.string.preview_name_font, R.drawable.ic_font,
R.layout.preview_card_font_content,
previewInfo.resolveAccentColor(res)) {
@@ -427,7 +432,7 @@
previewInfo.resolveAccentColor(res)) {
private final WallpaperPreviewLayoutListener mListener =
- new WallpaperPreviewLayoutListener(theme, previewInfo, false);
+ new WallpaperPreviewLayoutListener(theme, previewInfo, null);
@Override
protected boolean containsWallpaper() {
@@ -459,13 +464,13 @@
private static class WallpaperPreviewLayoutListener implements OnLayoutChangeListener {
private final ThemeBundle mTheme;
private final PreviewInfo mPreviewInfo;
- private final boolean mTransparent;
+ private final Drawable mScrim;
public WallpaperPreviewLayoutListener(ThemeBundle theme, PreviewInfo previewInfo,
- boolean transparent) {
+ Drawable scrim) {
mTheme = theme;
mPreviewInfo = previewInfo;
- mTransparent = transparent;
+ mScrim = scrim;
}
@Override
@@ -487,12 +492,12 @@
private void setWallpaperBitmap(View view, Bitmap bitmap) {
Resources res = view.getContext().getResources();
- BitmapDrawable background = new BitmapDrawable(res, bitmap);
- if (mTransparent) {
- background.setAlpha(128);
+ Drawable background = new BitmapDrawable(res, bitmap);
+ if (mScrim != null) {
+ background = new LayerDrawable(new Drawable[]{background, mScrim});
}
view.findViewById(R.id.theme_preview_card_background).setBackground(background);
- if (!mTransparent) {
+ if (mScrim == null) {
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 eaa169e..3c58079 100644
--- a/src/com/android/customization/picker/theme/ThemePreviewPage.java
+++ b/src/com/android/customization/picker/theme/ThemePreviewPage.java
@@ -160,12 +160,6 @@
ImageView iconView = card.findViewById(mShapeIconIds[i]);
iconView.setBackground(mShapeAppIcons.get(i));
}
-
- Drawable background = card.findViewById(R.id.theme_preview_card_background)
- .getBackground();
- if (background != null) {
- background.setAlpha(128);
- }
}
@Override
@@ -198,9 +192,7 @@
card.setOnClickListener(mEditClickListener);
editLabel.setVisibility(mEditClickListener != null
? View.VISIBLE : View.INVISIBLE);
- ColorStateList themeAccentColor = ColorStateList.valueOf(accentColor);
- editLabel.setTextColor(themeAccentColor);
- editLabel.setCompoundDrawableTintList(themeAccentColor);
+
View qsb = card.findViewById(R.id.theme_qsb);
if (qsb != null && qsb.getVisibility() == View.VISIBLE) {
if (qsb.getBackground() instanceof GradientDrawable) {