Add wallpaper support to theme bundles

Show wallpaper preview if available, show a checkbox to keep the
current wallpaper and apply the theme's wallpaper if needed.

Bug: 120559294

Change-Id: I229ab6e3372ace8218356d965e8d38f074e95061
diff --git a/res/layout/fragment_theme_picker.xml b/res/layout/fragment_theme_picker.xml
index 245a22c..e20c5f9 100644
--- a/res/layout/fragment_theme_picker.xml
+++ b/res/layout/fragment_theme_picker.xml
@@ -45,6 +45,13 @@
         <RelativeLayout
             android:layout_width="match_parent"
             android:layout_height="wrap_content">
+            <CheckBox
+                android:id="@+id/use_my_wallpaper"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentStart="true"
+                android:layout_centerVertical="true"
+                android:text="@string/keep_my_wallpaper"/>
             <Button
                 android:id="@+id/apply_button"
                 style="@style/ActionPrimaryButton"
diff --git a/res/layout/preview_card_wallpaper_content.xml b/res/layout/preview_card_wallpaper_content.xml
new file mode 100644
index 0000000..0b43c2f
--- /dev/null
+++ b/res/layout/preview_card_wallpaper_content.xml
@@ -0,0 +1,31 @@
+<?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.
+-->
+<FrameLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:id="@+id/preview_static_image"
+    android:layout_width="wrap_content"
+    android:layout_height="wrap_content"
+    android:layout_gravity="bottom"
+    tools:showIn="@layout/theme_preview_card">
+    <TextView
+        style="@style/CardTitleTextAppearance"
+        android:id="@+id/wallpaper_description"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:gravity="center_horizontal|bottom"/>
+</FrameLayout>
\ No newline at end of file
diff --git a/res/layout/theme_preview_card.xml b/res/layout/theme_preview_card.xml
index fcb9e1e..18f2b15 100644
--- a/res/layout/theme_preview_card.xml
+++ b/res/layout/theme_preview_card.xml
@@ -16,27 +16,34 @@
 -->
 <androidx.cardview.widget.CardView
     xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:app="http://schemas.android.com/apk/res-auto"
     style="@style/PreviewCard"
     android:layout_width="match_parent"
-    android:layout_height="match_parent">
+    android:layout_height="match_parent"
+    app:contentPadding="0dp">
 
-    <LinearLayout
+    <FrameLayout
+        android:id="@+id/theme_preview_card_background"
         android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:orientation="vertical">
-        <TextView
-            android:id="@+id/theme_preview_card_header"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_gravity="center_horizontal"
-            android:layout_marginBottom="8dp"
-            android:drawablePadding="10dp"
-            android:textAppearance="@style/CardTitleTextAppearance"/>
-        <FrameLayout
-            android:id="@+id/theme_preview_card_body_container"
+        android:layout_height="match_parent">
+        <LinearLayout
             android:layout_width="match_parent"
             android:layout_height="match_parent"
-            android:layout_marginHorizontal="8dp"/>
-    </LinearLayout>
-
+            android:padding="@dimen/preview_card_padding"
+            android:orientation="vertical">
+            <TextView
+                android:id="@+id/theme_preview_card_header"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_gravity="center_horizontal"
+                android:layout_marginBottom="8dp"
+                android:drawablePadding="10dp"
+                android:textAppearance="@style/CardTitleTextAppearance"/>
+            <FrameLayout
+                android:id="@+id/theme_preview_card_body_container"
+                android:layout_width="match_parent"
+                android:layout_height="match_parent"
+                android:layout_marginHorizontal="8dp"/>
+        </LinearLayout>
+    </FrameLayout>
 </androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/values/strings.xml b/res/values/strings.xml
index e491c39..e451795 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -38,6 +38,10 @@
         [CHAR LIMIT=20] -->
     <string name="apply_theme_btn">Apply</string>
 
+    <!-- Label for a checkbox to allow the user to use their currently set wallpaper instead of
+        the one bundled with selected Theme [CHAR LIMIT=35]-->
+    <string name="keep_my_wallpaper">Keep current wallpaper</string>
+
     <!-- Label for a button that allows the user to apply the currently selected customization option.
         [CHAR LIMIT=20] -->
     <string name="apply_btn">Apply</string>
@@ -81,4 +85,8 @@
 
     <!-- Message shown when a theme has been applied successfully in the system [CHAR LIMIT=NONE] -->
     <string name="applied_theme_msg">Style applied</string>
+
+    <!-- Message shown when a theme couldn't be applied in the system because of an error
+        [CHAR LIMIT=NONE] -->
+    <string name="apply_theme_error_msg">There was a problem applying the style</string>
 </resources>