Merge "Import translations. DO NOT MERGE" into ub-launcher3-qt-r1-dev
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/model/theme/ThemeBundle.java b/src/com/android/customization/model/theme/ThemeBundle.java
index 7c543d4..b3258de 100644
--- a/src/com/android/customization/model/theme/ThemeBundle.java
+++ b/src/com/android/customization/model/theme/ThemeBundle.java
@@ -70,6 +70,7 @@
  */
 public class ThemeBundle implements CustomizationOption<ThemeBundle> {
 
+    private final static String EMPTY_JSON = "{}";
     private final String mTitle;
     private final PreviewInfo mPreviewInfo;
     private final boolean mIsDefault;
@@ -144,7 +145,8 @@
             return false;
         }
         if (mIsDefault) {
-            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages());
+            return other.isDefault() || TextUtils.isEmpty(other.getSerializedPackages())
+                    || EMPTY_JSON.equals(other.getSerializedPackages());
         }
         // Map#equals ensures keys and values are compared.
         return mPackagesByCategory.equals(other.mPackagesByCategory);
diff --git a/src/com/android/customization/model/theme/ThemeManager.java b/src/com/android/customization/model/theme/ThemeManager.java
index 8846338..5fddc57 100644
--- a/src/com/android/customization/model/theme/ThemeManager.java
+++ b/src/com/android/customization/model/theme/ThemeManager.java
@@ -23,7 +23,6 @@
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_SYSUI;
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_ICON_THEMEPICKER;
 import static com.android.customization.model.ResourceConstants.OVERLAY_CATEGORY_SHAPE;
-
 import android.graphics.Point;
 import android.provider.Settings;
 import android.text.TextUtils;
@@ -37,10 +36,9 @@
 import com.android.customization.module.ThemesUserEventLogger;
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.Asset;
-import com.android.wallpaper.module.WallpaperPersister;
+import com.android.wallpaper.model.LiveWallpaperInfo;
 import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback;
 import com.android.wallpaper.module.WallpaperSetter;
-import com.android.wallpaper.picker.SetWallpaperDialogFragment.Listener;
 import com.android.wallpaper.util.WallpaperCropUtils;
 
 import org.json.JSONObject;
@@ -93,26 +91,12 @@
         // Set wallpaper
         if (theme.shouldUseThemeWallpaper()) {
             mWallpaperSetter.requestDestination(mActivity, mActivity.getSupportFragmentManager(),
-                    R.string.set_theme_wallpaper_dialog_message, theme.getWallpaperInfo(),
-                    new Listener() {
-                        @Override
-                        public void onSetHomeScreen() {
-                            applyWallpaper(theme, WallpaperPersister.DEST_HOME_SCREEN,
-                                    createSetWallpaperCallback(theme, callback));
-                        }
-
-                        @Override
-                        public void onSetLockScreen() {
-                            applyWallpaper(theme, WallpaperPersister.DEST_LOCK_SCREEN,
-                                    createSetWallpaperCallback(theme, callback));
-                        }
-
-                        @Override
-                        public void onSetBoth() {
-                            applyWallpaper(theme, WallpaperPersister.DEST_BOTH,
-                                    createSetWallpaperCallback(theme, callback));
-                        }
-                    });
+                    R.string.set_theme_wallpaper_dialog_message,
+                    destination -> applyWallpaper(
+                            theme,
+                            destination,
+                            createSetWallpaperCallback(theme, callback)),
+                    theme.getWallpaperInfo() instanceof LiveWallpaperInfo);
 
         } else {
             applyOverlays(theme, callback);
diff --git a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
index 73a4a22..f7b669b 100644
--- a/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
+++ b/src/com/android/customization/model/theme/custom/IconOptionsProvider.java
@@ -86,7 +86,7 @@
         }
 
         for (String overlayPackage : mSysUiIconsOverlayPackages) {
-            addOrUpdateOption(optionsByPrefix, overlayPackage,  OVERLAY_CATEGORY_ICON_SYSUI);
+            addOrUpdateOption(optionsByPrefix, overlayPackage, OVERLAY_CATEGORY_ICON_SYSUI);
         }
 
         for (String overlayPackage : mSettingsIconsOverlayPackages) {
@@ -142,6 +142,11 @@
         } catch (NameNotFoundException | NotFoundException e) {
             Log.w(TAG, "Didn't find SystemUi package icons, will skip option", e);
         }
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_ANDROID, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SYSUI, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_SETTINGS, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_LAUNCHER, null);
+        option.addOverlayPackage(OVERLAY_CATEGORY_ICON_THEMEPICKER, null);
         mOptions.add(option);
     }
 
diff --git a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
index 8966dc5..78131cc 100644
--- a/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
+++ b/src/com/android/customization/model/theme/custom/ThemeComponentOption.java
@@ -34,7 +34,6 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.LayerDrawable;
 import android.graphics.drawable.ShapeDrawable;
-import android.text.TextUtils;
 import android.view.Gravity;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -61,7 +60,6 @@
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
-import java.util.Map.Entry;
 import java.util.Objects;
 
 /**
@@ -92,11 +90,7 @@
     public abstract void bindPreview(ViewGroup container);
 
     public Builder buildStep(Builder builder) {
-        getOverlayPackages().forEach((category, packageName) -> {
-            if (!TextUtils.isEmpty(packageName)) {
-                builder.addOverlayPackage(category, packageName);
-            }
-        });
+        getOverlayPackages().forEach(builder::addOverlayPackage);
         return builder;
     }
 
diff --git a/src/com/android/customization/module/DefaultCustomizationInjector.java b/src/com/android/customization/module/DefaultCustomizationInjector.java
index 3d47b72..a0d435b 100644
--- a/src/com/android/customization/module/DefaultCustomizationInjector.java
+++ b/src/com/android/customization/module/DefaultCustomizationInjector.java
@@ -88,6 +88,7 @@
 
     @Override
     public Fragment getPreviewFragment(
+            Context context,
             WallpaperInfo wallpaperInfo,
             int mode,
             boolean testingModeEnabled) {
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.
diff --git a/src_override/com/android/wallpaper/module/WallpapersInjector.java b/src_override/com/android/wallpaper/module/WallpapersInjector.java
index 67b07fd..1ffca80 100755
--- a/src_override/com/android/wallpaper/module/WallpapersInjector.java
+++ b/src_override/com/android/wallpaper/module/WallpapersInjector.java
@@ -65,6 +65,7 @@
 
     @Override
     public Fragment getPreviewFragment(
+        Context context,
         WallpaperInfo wallpaperInfo,
         int mode,
         boolean testingModeEnabled) {