Snap for 6465939 from 04750a8212ef5f3a96686fcc6b963e641dd61444 to mainline-release

Change-Id: I135ebadebd53fc0e2e630c668f61627168cab845
diff --git a/res/drawable/ic_mode_edit_gm2_24px.xml b/res/drawable/ic_mode_edit_gm2_24px.xml
new file mode 100644
index 0000000..674611c
--- /dev/null
+++ b/res/drawable/ic_mode_edit_gm2_24px.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:fillColor="#FF000000"
+      android:pathData="M20.41,4.94l-1.35,-1.35c-0.78,-0.78 -2.05,-0.78 -2.83,0L13.4,6.41 3,16.82L3,21h4.18l10.46,-10.46 2.77,-2.77c0.79,-0.78 0.79,-2.05 0,-2.83zM6.41,19.06L5,19v-1.36l9.82,-9.82 1.41,1.41 -9.82,9.83z"/>
+</vector>
diff --git a/res/drawable/ic_pan_zoom_24dp.xml b/res/drawable/ic_pan_zoom_24dp.xml
deleted file mode 100644
index 5dbfb7d..0000000
--- a/res/drawable/ic_pan_zoom_24dp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24">
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M22,2v7h-2V5.4l-4.32,4.29l-1.36,-1.37L18.67,4H15V2H22zM9.66,15.69L8.3,14.32L4,18.6V15H2v7h7v-2H5.33L9.66,15.69z"/>
-</vector>
diff --git a/res/drawable/ic_rotation_gm2_24px.xml b/res/drawable/ic_rotation_gm2_24px.xml
new file mode 100644
index 0000000..e8a12be
--- /dev/null
+++ b/res/drawable/ic_rotation_gm2_24px.xml
@@ -0,0 +1,9 @@
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+    android:width="24dp"
+    android:height="24dp"
+    android:viewportWidth="24"
+    android:viewportHeight="24">
+  <path
+      android:fillColor="#FF000000"
+      android:pathData="M13,9v2h7V4h-2v2.74C16.53,5.07 14.4,4 12,4c-2.21,0 -4.21,0.9 -5.66,2.34S4,9.79 4,12c0,4.42 3.58,8 8,8 2.21,0 4.21,-0.9 5.66,-2.34l-1.42,-1.42C15.15,17.33 13.65,18 12,18c-3.31,0 -6,-2.69 -6,-6 0,-1.65 0.67,-3.15 1.76,-4.24C8.85,6.67 10.35,6 12,6c2.21,0 4.15,1.21 5.19,3H13z"/>
+</vector>
diff --git a/res/drawable/ic_slideshow_24dp.xml b/res/drawable/ic_slideshow_24dp.xml
deleted file mode 100644
index f7c0815..0000000
--- a/res/drawable/ic_slideshow_24dp.xml
+++ /dev/null
@@ -1,27 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24">
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M4,6H2V20a2,2 0,0 0,2 2H18V20H4Z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M20,2H15V4h5V9h2V4A2,2 0,0 0,20 2Z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M8,4h5V2H8A2,2 0,0 0,6 4V9H8Z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M8,18h5V16H8V11H6v5A2,2 0,0 0,8 18Z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M20,16H15v2h5a2,2 0,0 0,2 -2V11H20Z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M13.28,13.01l-1.78,-2.01l-2.5,3l10,0l-3.22,-4l-2.5,3.01z"/>
-  <path
-      android:fillColor="#FF000000"
-      android:pathData="M17,7m-1,0a1,1 0,1 1,2 0a1,1 0,1 1,-2 0"/>
-</vector>
diff --git a/res/drawable/ic_tune_black_24dp.xml b/res/drawable/ic_tune_black_24dp.xml
deleted file mode 100644
index ad3e25e..0000000
--- a/res/drawable/ic_tune_black_24dp.xml
+++ /dev/null
@@ -1,9 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
-    android:width="24dp"
-    android:height="24dp"
-    android:viewportWidth="24"
-    android:viewportHeight="24">
-  <path
-      android:pathData="M3,17v2h6v-2L3,17zM3,5v2h10L13,5L3,5zM13,21v-2h8v-2h-8v-2h-2v6h2zM7,9v2L3,11v2h4v2h2L9,9L7,9zM21,13v-2L11,11v2h10zM15,9h2L17,7h4L21,5h-4L17,3h-2v6z"
-      android:fillColor="#000000"/>
-</vector>
diff --git a/res/layout/bottom_action_bar_preview_info.xml b/res/layout/bottom_action_bar_preview_info.xml
index 62715c2..6baf5fb 100644
--- a/res/layout/bottom_action_bar_preview_info.xml
+++ b/res/layout/bottom_action_bar_preview_info.xml
@@ -21,7 +21,7 @@
     android:layout_width="match_parent"
     android:orientation="vertical"
     android:paddingHorizontal="@dimen/preview_attribution_pane_horizontal_padding"
-    android:paddingVertical="@dimen/bottom_action_bar_preview_info_padding_vertical"
+    android:paddingVertical="@dimen/bottom_action_bar_padding_vertical"
     android:theme="@style/WallpaperPicker.BottomPaneStyle">
 
   <TextView
diff --git a/res/layout/bottom_actions_layout.xml b/res/layout/bottom_actions_layout.xml
index 15718c0..14bea38 100644
--- a/res/layout/bottom_actions_layout.xml
+++ b/res/layout/bottom_actions_layout.xml
@@ -23,9 +23,7 @@
     <!--  Bottom Sheet  -->
     <androidx.coordinatorlayout.widget.CoordinatorLayout
         android:layout_width="match_parent"
-        android:layout_height="wrap_content"
-        android:clipToPadding="false"
-        android:paddingTop="2dp">
+        android:layout_height="wrap_content">
         <!-- Bottom sheet view should be a child view of CoordinatorLayout -->
         <FrameLayout
             android:id="@+id/action_bottom_sheet"
@@ -33,7 +31,6 @@
             android:layout_height="wrap_content"
             android:background="@drawable/bottom_sheet_background"
             android:theme="@style/WallpaperPicker.BottomPaneStyle"
-            android:elevation="@dimen/bottom_action_bar_elevation"
             app:behavior_peekHeight="@dimen/preview_attribution_pane_collapsed_height"
             app:layout_behavior="com.google.android.material.bottomsheet.BottomSheetBehavior">
             <include layout="@layout/bottom_action_bar_preview_info"/>
@@ -44,126 +41,55 @@
     <androidx.constraintlayout.widget.ConstraintLayout
         android:layout_width="match_parent"
         android:layout_height="@dimen/bottom_navbar_height"
-        android:paddingTop="@dimen/bottom_action_bar_padding_top"
         android:paddingHorizontal="@dimen/bottom_action_bar_padding_horizontal"
         android:clickable="true"
         android:background="?android:colorPrimary"
-        android:theme="@style/BottomActionItemStyle"
-        android:layoutDirection="locale">
+        android:theme="@style/BottomActionItemStyle">
 
         <ImageView
-            android:id="@+id/action_back"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
+            android:id="@+id/action_cancel"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
             android:src="@drawable/ic_close_gm2_24px"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/bottom_action_bar_back"
-            app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintEnd_toStartOf="@id/action_rotation"
             app:layout_constraintHorizontal_chainStyle="spread_inside"
             app:layout_constraintStart_toStartOf="parent" />
 
         <ImageView
             android:id="@+id/action_rotation"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:src="@drawable/ic_slideshow_24dp"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/bottom_action_bar_slideshow_wallpaper"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:src="@drawable/ic_rotation_gm2_24px"
             android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintEnd_toStartOf="@id/action_delete"
-            app:layout_constraintStart_toEndOf="@id/action_back" />
-
-        <ImageView
-            android:id="@+id/action_delete"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:src="@drawable/ic_delete_24px"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/delete_live_wallpaper"
-            android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintEnd_toStartOf="@id/action_information"
-            app:layout_constraintStart_toEndOf="@id/action_rotation" />
+            app:layout_constraintStart_toEndOf="@id/action_cancel" />
 
         <ImageView
             android:id="@+id/action_information"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
             android:src="@drawable/ic_info_gm2_24px"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/tab_info"
             android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintEnd_toStartOf="@id/action_edit"
-            app:layout_constraintStart_toEndOf="@id/action_delete" />
+            app:layout_constraintStart_toEndOf="@id/action_rotation" />
 
         <ImageView
             android:id="@+id/action_edit"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:src="@drawable/ic_pan_zoom_24dp"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/bottom_action_bar_edit"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
+            android:src="@drawable/ic_mode_edit_gm2_24px"
             android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintEnd_toStartOf="@id/action_customize"
+            app:layout_constraintEnd_toStartOf="@id/action_apply"
             app:layout_constraintStart_toEndOf="@id/action_information" />
 
         <ImageView
-            android:id="@+id/action_customize"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:src="@drawable/ic_tune_black_24dp"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/tab_customize"
-            android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintEnd_toStartOf="@id/action_download"
-            app:layout_constraintStart_toEndOf="@id/action_edit" />
-
-        <ImageView
-            android:id="@+id/action_download"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:src="@drawable/ic_file_download_gm2_24px"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/bottom_action_bar_download"
-            android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintEnd_toStartOf="@id/action_progress"
-            app:layout_constraintStart_toEndOf="@id/action_customize" />
-
-        <ProgressBar
-            android:id="@+id/action_progress"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
-            android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
-            app:layout_constraintEnd_toStartOf="@id/action_apply"
-            app:layout_constraintStart_toEndOf="@id/action_download" />
-
-        <ImageView
             android:id="@+id/action_apply"
-            android:layout_width="@dimen/bottom_action_button_size"
-            android:layout_height="@dimen/bottom_action_button_size"
-            android:padding="@dimen/bottom_action_button_padding"
+            android:layout_width="wrap_content"
+            android:layout_height="match_parent"
             android:src="@drawable/ic_done_gm2_24px"
-            android:background="?android:attr/selectableItemBackgroundBorderless"
-            android:contentDescription="@string/bottom_action_bar_apply"
             android:visibility="gone"
-            app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintEnd_toEndOf="parent"
-            app:layout_constraintStart_toEndOf="@id/action_progress" />
+            app:layout_constraintStart_toEndOf="@id/action_edit" />
 
     </androidx.constraintlayout.widget.ConstraintLayout>
 </LinearLayout>
diff --git a/res/layout/fragment_individual_picker.xml b/res/layout/fragment_individual_picker.xml
index 2b8c25b..05bcb18 100755
--- a/res/layout/fragment_individual_picker.xml
+++ b/res/layout/fragment_individual_picker.xml
@@ -32,6 +32,7 @@
             android:clipToPadding="false"
             android:fitsSystemWindows="true"
             android:paddingHorizontal="@dimen/grid_edge_space"
+            android:paddingTop="@dimen/grid_padding"
             android:scrollbarSize="@dimen/grid_padding"
             android:scrollbarStyle="outsideOverlay"
             android:scrollbarThumbVertical="@color/scrollbar_thumb_color_dark"
diff --git a/res/layout/wallpaper_preview_card.xml b/res/layout/wallpaper_preview_card.xml
index f548dfb..f9e36da 100644
--- a/res/layout/wallpaper_preview_card.xml
+++ b/res/layout/wallpaper_preview_card.xml
@@ -33,11 +33,4 @@
         android:id="@+id/wallpaper_surface"
         android:layout_width="match_parent"
         android:layout_height="match_parent" />
-
-    <View
-        android:id="@+id/fade_cover"
-        android:layout_width="match_parent"
-        android:layout_height="match_parent"
-        android:alpha="0"
-        android:background="@color/preview_pager_background" />
 </androidx.cardview.widget.CardView>
\ No newline at end of file
diff --git a/res/values/dimens.xml b/res/values/dimens.xml
index 618c823..b43d350 100755
--- a/res/values/dimens.xml
+++ b/res/values/dimens.xml
@@ -208,17 +208,12 @@
     <item name="preview_pager_maximum_height_ratio" format="float" type="dimen">0.7</item>
 
     <!-- Dimensions for the bottom bar. -->
-    <dimen name="bottom_navbar_height">76dp</dimen>
-    <dimen name="bottom_action_bar_padding_horizontal">4dp</dimen>
-    <dimen name="bottom_action_bar_padding_top">6dp</dimen>
-    <dimen name="bottom_action_bar_preview_info_padding_vertical">20dp</dimen>
+    <dimen name="bottom_navbar_height">56dp</dimen>
+    <dimen name="bottom_action_bar_padding_horizontal">16dp</dimen>
+    <dimen name="bottom_action_bar_padding_vertical">20dp</dimen>
     <dimen name="bottom_action_bar_elevation">10dp</dimen>
-    <dimen name="bottom_action_button_size">48dp</dimen>
-    <dimen name="bottom_action_button_padding">12dp</dimen>
-    <dimen name="bottom_action_icon_size">24dp</dimen>
 
     <dimen name="option_border_width">2dp</dimen>
     <dimen name="option_selected_border_width">3dp</dimen>
     <dimen name="option_title_font_text_size">12sp</dimen>
-    <dimen name="option_title_line_height">16dp</dimen>
 </resources>
diff --git a/res/values/strings.xml b/res/values/strings.xml
index 9cde4fd..c61d80d 100755
--- a/res/values/strings.xml
+++ b/res/values/strings.xml
@@ -316,22 +316,6 @@
     <!-- Confirmation dialog. Shown after user selects to delete one wallpaper. [CHAR LIMIT=NONE] -->
     <string name="delete_wallpaper_confirmation">Delete this wallpaper from your phone?</string>
 
-    <!-- Content description of back button on the bottom action bar. [CHAR LIMIT=30] -->
-    <string name="bottom_action_bar_back">Back</string>
-
-    <!-- Content description of edit button on the bottom action bar. [CHAR LIMIT=30] -->
-    <string name="bottom_action_bar_edit">Edit</string>
-
-    <!-- TODO(b/154299462): Separate downloadable related actions from WallpaperPicker. -->
-    <!-- Content description of download button on the bottom action bar. [CHAR LIMIT=30] -->
-    <string name="bottom_action_bar_download">Download</string>
-
-    <!-- Content description of "slideshow wallpaper" button on the bottom action bar. [CHAR LIMIT=30] -->
-    <string name="bottom_action_bar_slideshow_wallpaper">Slideshow Wallpaper</string>
-
-    <!-- Content description of apply button on the bottom action bar. [CHAR LIMIT=30] -->
-    <string name="bottom_action_bar_apply">Apply</string>
-
     <!-- The class name for the ScaleBehavior -->
     <string name="scalable_container_behavior" translatable="false">com.android.wallpaper.picker.ScaleBehavior</string>
 
diff --git a/res/values/styles.xml b/res/values/styles.xml
index 51fb1a8..3cf2dbc 100755
--- a/res/values/styles.xml
+++ b/res/values/styles.xml
@@ -227,7 +227,6 @@
         <item name="android:textColor">@color/option_title_color</item>
         <item name="android:textAlignment">center</item>
         <item name="android:textSize">@dimen/option_title_font_text_size</item>
-        <item name="android:lineHeight">@dimen/option_title_line_height</item>
     </style>
 
 </resources>
diff --git a/src/com/android/wallpaper/asset/Asset.java b/src/com/android/wallpaper/asset/Asset.java
index 25313f8..80e2196 100755
--- a/src/com/android/wallpaper/asset/Asset.java
+++ b/src/com/android/wallpaper/asset/Asset.java
@@ -27,17 +27,11 @@
 import android.graphics.drawable.Drawable;
 import android.graphics.drawable.TransitionDrawable;
 import android.os.AsyncTask;
-import android.view.Display;
 import android.view.View;
 import android.widget.ImageView;
 
 import androidx.annotation.Nullable;
 
-import com.android.wallpaper.module.BitmapCropper;
-import com.android.wallpaper.module.InjectorProvider;
-import com.android.wallpaper.util.ScreenSizeCalculator;
-import com.android.wallpaper.util.WallpaperCropUtils;
-
 import com.bumptech.glide.load.resource.bitmap.BitmapTransformation;
 
 /**
@@ -253,71 +247,6 @@
     }
 
     /**
-     * Loads the image for this asset into the provided ImageView which is used for the preview.
-     * While waiting for the image to load, first loads a ColorDrawable based on the provided
-     * placeholder color.
-     *
-     * @param activity         Activity hosting the ImageView.
-     * @param imageView        ImageView which is the target view of this asset.
-     * @param placeholderColor Color of placeholder set to ImageView while waiting for image to
-     *                         load.
-     */
-    public void loadPreviewImage(Activity activity, ImageView imageView, int placeholderColor) {
-        boolean needsTransition = imageView.getDrawable() == null;
-        Drawable placeholderDrawable = new ColorDrawable(placeholderColor);
-        if (needsTransition) {
-            imageView.setImageDrawable(placeholderDrawable);
-        }
-
-        decodeRawDimensions(activity, dimensions -> {
-            if (dimensions == null) {
-                loadDrawable(activity, imageView, placeholderColor);
-                return;
-            }
-
-            Display defaultDisplay = activity.getWindowManager().getDefaultDisplay();
-            Point screenSize = ScreenSizeCalculator.getInstance().getScreenSize(defaultDisplay);
-            Rect visibleRawWallpaperRect =
-                    WallpaperCropUtils.calculateVisibleRect(dimensions, screenSize);
-            adjustCropRect(activity, dimensions, visibleRawWallpaperRect);
-
-            BitmapCropper bitmapCropper = InjectorProvider.getInjector().getBitmapCropper();
-            bitmapCropper.cropAndScaleBitmap(this, /* scale= */ 1f, visibleRawWallpaperRect,
-                    new BitmapCropper.Callback() {
-                        @Override
-                        public void onBitmapCropped(Bitmap croppedBitmap) {
-                            // Since the size of the cropped bitmap may not exactly the same with
-                            // image view(maybe has 1px or 2px difference),
-                            // so set CENTER_CROP to let the bitmap to fit the image view.
-                            imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
-                            if (!needsTransition) {
-                                imageView.setImageBitmap(croppedBitmap);
-                                return;
-                            }
-
-                            Resources resources = activity.getResources();
-
-                            Drawable[] layers = new Drawable[2];
-                            layers[0] = placeholderDrawable;
-                            layers[1] = new BitmapDrawable(resources, croppedBitmap);
-
-                            TransitionDrawable transitionDrawable = new TransitionDrawable(layers);
-                            transitionDrawable.setCrossFadeEnabled(true);
-
-                            imageView.setImageDrawable(transitionDrawable);
-                            transitionDrawable.startTransition(resources.getInteger(
-                                    android.R.integer.config_shortAnimTime));
-                        }
-
-                        @Override
-                        public void onError(@Nullable Throwable e) {
-
-                        }
-                    });
-        });
-    }
-
-    /**
      * Interface for receiving decoded Bitmaps.
      */
     public interface BitmapReceiver {
@@ -350,23 +279,6 @@
         void onDrawableLoaded();
     }
 
-    protected void adjustCropRect(Context context, Point assetDimensions, Rect cropRect) {
-        float centerX = cropRect.centerX();
-        float centerY = cropRect.centerY();
-        float width = cropRect.width();
-        float height = cropRect.height();
-        // TODO(b/154783188): Use the new system UI's API to get the maximum scale
-        //  when the API is available.
-        float systemWallpaperMaxScale = WallpaperCropUtils.getSystemWallpaperMaximumScale();
-
-        // Adjust the rect according to the system wallpaper's maximum scale.
-        int left = (int) (centerX - (width / 2) / systemWallpaperMaxScale);
-        int top = (int) (centerY - (height / 2) / systemWallpaperMaxScale);
-        int right = (int) (centerX + (width / 2) / systemWallpaperMaxScale);
-        int bottom = (int) (centerY + (height / 2) / systemWallpaperMaxScale);
-        cropRect.set(left, top, right, bottom);
-    }
-
     /**
      * Custom AsyncTask which returns a copy of the given bitmap which is center cropped and scaled
      * to fit in the given ImageView.
diff --git a/src/com/android/wallpaper/asset/CurrentWallpaperAssetVN.java b/src/com/android/wallpaper/asset/CurrentWallpaperAssetVN.java
index 89d4b9e..70c729e 100755
--- a/src/com/android/wallpaper/asset/CurrentWallpaperAssetVN.java
+++ b/src/com/android/wallpaper/asset/CurrentWallpaperAssetVN.java
@@ -17,17 +17,13 @@
 
 import android.app.WallpaperManager;
 import android.content.Context;
-import android.graphics.Point;
-import android.graphics.Rect;
 import android.os.ParcelFileDescriptor;
 import android.os.ParcelFileDescriptor.AutoCloseInputStream;
 import android.util.Log;
-import android.view.View;
 import android.widget.ImageView;
 
 import com.android.wallpaper.compat.WallpaperManagerCompat;
 import com.android.wallpaper.compat.WallpaperManagerCompat.WallpaperLocation;
-
 import com.bumptech.glide.Glide;
 import com.bumptech.glide.load.Key;
 import com.bumptech.glide.load.resource.drawable.DrawableTransitionOptions;
@@ -99,20 +95,6 @@
                 .into(imageView);
     }
 
-    @Override
-    protected void adjustCropRect(Context context, Point assetDimensions, Rect cropRect) {
-        boolean isRtl = context.getResources().getConfiguration().getLayoutDirection()
-                == View.LAYOUT_DIRECTION_RTL;
-        if (isRtl) {
-            // Get the far right visible rect of source image
-            cropRect.offsetTo(assetDimensions.x - cropRect.width(), 0);
-        } else {
-            // Get the far left visible rect of source image
-            cropRect.offsetTo(0, 0);
-        }
-        super.adjustCropRect(context, assetDimensions, cropRect);
-    }
-
     public Key getKey() {
         return new CurrentWallpaperVNKey(mWallpaperManager, mWallpaperManagerFlag);
     }
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
index 60527d0..54393af 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPersister.java
@@ -784,7 +784,6 @@
                     mWallpaper.getActionIconRes(mAppContext));
             mWallpaperPreferences.setLockWallpaperCollectionId(
                     mWallpaper.getCollectionId(mAppContext));
-            mWallpaperPreferences.setLockWallpaperRemoteId(mWallpaper.getWallpaperId());
 
             // Save the lock wallpaper image's hash code as well for the sake of backup & restore
             // because WallpaperManager-generated IDs are specific to a physical device and
diff --git a/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java b/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
index eb2fc90..b040ebb 100755
--- a/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
+++ b/src/com/android/wallpaper/module/DefaultWallpaperPreferences.java
@@ -465,19 +465,6 @@
     }
 
     @Override
-    public String getLockWallpaperRemoteId() {
-        return mNoBackupPrefs.getString(
-                NoBackupKeys.KEY_LOCK_WALLPAPER_REMOTE_ID, null);
-    }
-
-    @Override
-    public void setLockWallpaperRemoteId(String wallpaperRemoteId) {
-        mNoBackupPrefs.edit().putString(
-                NoBackupKeys.KEY_LOCK_WALLPAPER_REMOTE_ID, wallpaperRemoteId)
-                .apply();
-    }
-
-    @Override
     public long getLockWallpaperHashCode() {
         return mSharedPrefs.getLong(WallpaperPreferenceKeys.KEY_LOCK_WALLPAPER_HASH_CODE, 0);
     }
diff --git a/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java b/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
index 17e4789..e4c6588 100755
--- a/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
+++ b/src/com/android/wallpaper/module/WallpaperPreferenceKeys.java
@@ -49,7 +49,6 @@
         public static final String KEY_HOME_WALLPAPER_REMOTE_ID = "home_wallpaper_remote_id";
         public static final String KEY_HOME_WALLPAPER_BACKING_FILE = "home_wallpaper_backing_file";
         public static final String KEY_LOCK_WALLPAPER_MANAGER_ID = "lock_wallpaper_id";
-        public static final String KEY_LOCK_WALLPAPER_REMOTE_ID = "lock_wallpaper_remote_id";
         public static final String KEY_LOCK_WALLPAPER_BACKING_FILE = "lock_wallpaper_backing_file";
         public static final String KEY_DAILY_ROTATION_TIMESTAMPS = "daily_rotation_timestamps";
         public static final String KEY_DAILY_WALLPAPER_ENABLED_TIMESTAMP =
diff --git a/src/com/android/wallpaper/module/WallpaperPreferences.java b/src/com/android/wallpaper/module/WallpaperPreferences.java
index 8857ed4..f009f59 100755
--- a/src/com/android/wallpaper/module/WallpaperPreferences.java
+++ b/src/com/android/wallpaper/module/WallpaperPreferences.java
@@ -257,18 +257,6 @@
     void setLockWallpaperId(int lockWallpaperId);
 
     /**
-     * Gets the lock wallpaper's remote identifier.
-     */
-    String getLockWallpaperRemoteId();
-
-    /**
-     * Sets the lock wallpaper's remote identifier to SharedPreferences. This should be a string
-     * which uniquely identifies the currently set lock wallpaper in the context of a remote
-     * wallpaper collection.
-     */
-    void setLockWallpaperRemoteId(String wallpaperRemoteId);
-
-    /**
      * Persists the timestamp of a daily wallpaper rotation that just occurred.
      */
     void addDailyRotation(long timestamp);
diff --git a/src/com/android/wallpaper/picker/BottomActionBarFragment.java b/src/com/android/wallpaper/picker/BottomActionBarFragment.java
deleted file mode 100644
index bf3b997..0000000
--- a/src/com/android/wallpaper/picker/BottomActionBarFragment.java
+++ /dev/null
@@ -1,74 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-package com.android.wallpaper.picker;
-
-import android.app.Activity;
-import android.os.Bundle;
-import android.view.View;
-
-import androidx.annotation.NonNull;
-import androidx.annotation.Nullable;
-import androidx.fragment.app.Fragment;
-
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
-
-/**
- * Base class for Fragments that own a {@link BottomActionBar} widget.
- *
- * A Fragment extending this class is expected to have a {@link BottomActionBar} in its activity
- * which is a {@link BottomActionBarHost}, which can handle lifecycle management of
- * {@link BottomActionBar} for extending fragment.
- */
-public class BottomActionBarFragment extends Fragment {
-
-    private BottomActionBar mBottomActionBar;
-
-    @Override
-    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
-        super.onViewCreated(view, savedInstanceState);
-        Activity activity = getActivity();
-        if (activity instanceof BottomActionBarHost) {
-            mBottomActionBar = ((BottomActionBarHost) activity).getBottomActionBar();
-            mBottomActionBar.bindBackButtonToSystemBackKey(activity);
-            onBottomActionBarReady(mBottomActionBar);
-        }
-    }
-
-    @Override
-    public void onDestroyView() {
-        if (mBottomActionBar != null) {
-            mBottomActionBar.reset();
-            mBottomActionBar = null;
-        }
-        super.onDestroyView();
-    }
-
-    /** Returns {@code true} if the fragment would handle the event. */
-    public boolean onBackPressed() {
-        if (mBottomActionBar != null && mBottomActionBar.isVisible()) {
-            mBottomActionBar.hide();
-            return true;
-        }
-        return false;
-    }
-
-    /**
-     * Gets called when {@link #onViewCreated} finished. For extending fragment, this is the only
-     * one interface to get {@link BottomActionBar}.
-     */
-    protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {}
-}
diff --git a/src/com/android/wallpaper/picker/CategoryFragment.java b/src/com/android/wallpaper/picker/CategoryFragment.java
index 43f88fc..13ebef0 100755
--- a/src/com/android/wallpaper/picker/CategoryFragment.java
+++ b/src/com/android/wallpaper/picker/CategoryFragment.java
@@ -17,9 +17,6 @@
 
 import static android.view.View.MeasureSpec.EXACTLY;
 import static android.view.View.MeasureSpec.makeMeasureSpec;
-import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
-
-import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED;
 
 import android.app.Activity;
 import android.app.ProgressDialog;
@@ -36,15 +33,12 @@
 import android.os.Build.VERSION;
 import android.os.Build.VERSION_CODES;
 import android.os.Bundle;
-import android.os.Message;
-import android.os.RemoteException;
 import android.provider.Settings;
 import android.service.wallpaper.WallpaperService;
 import android.util.DisplayMetrics;
 import android.util.Log;
 import android.view.Display;
 import android.view.LayoutInflater;
-import android.view.Surface;
 import android.view.SurfaceControlViewHost;
 import android.view.SurfaceHolder;
 import android.view.SurfaceView;
@@ -63,11 +57,11 @@
 import androidx.appcompat.app.AlertDialog;
 import androidx.cardview.widget.CardView;
 import androidx.core.content.ContextCompat;
-import androidx.fragment.app.Fragment;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.viewpager.widget.PagerAdapter;
 import androidx.viewpager.widget.ViewPager;
 
+import com.android.systemui.shared.system.SurfaceViewRequestUtils;
 import com.android.wallpaper.R;
 import com.android.wallpaper.config.Flags;
 import com.android.wallpaper.model.Category;
@@ -79,7 +73,6 @@
 import com.android.wallpaper.module.InjectorProvider;
 import com.android.wallpaper.module.LockWallpaperStatusChecker;
 import com.android.wallpaper.module.UserEventLogger;
-import com.android.wallpaper.module.WallpaperPersister;
 import com.android.wallpaper.module.WallpaperPreferences;
 import com.android.wallpaper.module.WallpaperPreferences.PresentationMode;
 import com.android.wallpaper.module.WallpaperRotationRefresher;
@@ -87,13 +80,10 @@
 import com.android.wallpaper.picker.CategorySelectorFragment.CategorySelectorFragmentHost;
 import com.android.wallpaper.picker.MyPhotosStarter.MyPhotosStarterProvider;
 import com.android.wallpaper.picker.MyPhotosStarter.PermissionChangedListener;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment;
 import com.android.wallpaper.picker.individual.IndividualPickerFragment.ThumbnailUpdater;
-import com.android.wallpaper.picker.individual.IndividualPickerFragment.WallpaperDestinationCallback;
 import com.android.wallpaper.util.DisplayMetricsRetriever;
 import com.android.wallpaper.util.PreviewUtils;
 import com.android.wallpaper.util.ScreenSizeCalculator;
-import com.android.wallpaper.util.SurfaceViewUtils;
 import com.android.wallpaper.util.TileSizeCalculator;
 import com.android.wallpaper.util.WallpaperConnection;
 import com.android.wallpaper.util.WallpaperConnection.WallpaperConnectionListener;
@@ -111,12 +101,8 @@
 /**
  * Displays the Main UI for picking a category of wallpapers to choose from.
  */
-public class CategoryFragment extends AppbarFragment
-        implements CategorySelectorFragmentHost, ThumbnailUpdater, WallpaperDestinationCallback {
-
-    private final Rect mPreviewLocalRect = new Rect();
-    private final Rect mPreviewGlobalRect = new Rect();
-    private final int[] mLivePreviewLocation = new int[2];
+public class CategoryFragment extends ToolbarFragment
+        implements CategorySelectorFragmentHost, ThumbnailUpdater {
 
     /**
      * Interface to be implemented by an Activity hosting a {@link CategoryFragment}
@@ -132,7 +118,7 @@
 
     public static CategoryFragment newInstance(CharSequence title) {
         CategoryFragment fragment = new CategoryFragment();
-        fragment.setArguments(AppbarFragment.createArguments(title));
+        fragment.setArguments(ToolbarFragment.createArguments(title));
         return fragment;
     }
 
@@ -158,16 +144,13 @@
     private List<View> mWallPaperPreviews;
     private WallpaperConnection mWallpaperConnection;
     private CategorySelectorFragment mCategorySelectorFragment;
-    private IndividualPickerFragment mIndividualPickerFragment;
     private boolean mShowSelectedWallpaper;
-    private BottomSheetBehavior<View> mBottomSheetBehavior;
+    private BottomSheetBehavior mBottomSheetBehavior;
     private PreviewUtils mPreviewUtils;
-    private int mSelectedPreviewPage;
 
     // Home workspace surface is behind the app window, and so must the home image wallpaper like
     // the live wallpaper. This view is rendered on mWallpaperSurface for home image wallpaper.
     private ImageView mHomeImageWallpaper;
-    private boolean mIsCollapsingByUserSelecting;
 
     public CategoryFragment() {
         mCategorySelectorFragment = new CategorySelectorFragment();
@@ -217,10 +200,6 @@
 
             @Override
             public void onPageSelected(int i) {
-                mSelectedPreviewPage = i;
-                if (mIndividualPickerFragment != null && mIndividualPickerFragment.isVisible()) {
-                    mIndividualPickerFragment.highlightAppliedWallpaper(i);
-                }
             }
 
             @Override
@@ -231,42 +210,15 @@
 
         View fragmentContainer = view.findViewById(R.id.category_fragment_container);
         mBottomSheetBehavior = BottomSheetBehavior.from(fragmentContainer);
-        mBottomSheetBehavior.setBottomSheetCallback(new BottomSheetBehavior.BottomSheetCallback() {
-            @Override
-            public void onStateChanged(@NonNull View bottomSheet, int newState) {
-                if (mIsCollapsingByUserSelecting) {
-                    mIsCollapsingByUserSelecting = newState != STATE_COLLAPSED;
-                    return;
-                }
-
-                if (mIndividualPickerFragment != null && mIndividualPickerFragment.isVisible()) {
-                    mIndividualPickerFragment.resizeLayout(newState == STATE_COLLAPSED
-                            ? mBottomSheetBehavior.getPeekHeight() : MATCH_PARENT);
-                }
-            }
-
-            @Override
-            public void onSlide(@NonNull View bottomSheet, float slideOffset) {
-
-            }
+        fragmentContainer.addOnLayoutChangeListener((containerView, left, top, right, bottom,
+                                                     oldLeft, oldTop, oldRight, oldBottom) -> {
+            int minimumHeight = containerView.getHeight() - mPreviewPager.getMeasuredHeight();
+            mBottomSheetBehavior.setPeekHeight(minimumHeight);
+            containerView.setMinimumHeight(minimumHeight);
+            ((CardView) mHomePreview.getParent())
+                    .setRadius(TileSizeCalculator.getPreviewCornerRadius(
+                            getActivity(), homePreviewCard.getMeasuredWidth()));
         });
-        fragmentContainer.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
-            @Override
-            public void onLayoutChange(View containerView, int left, int top, int right,
-                    int bottom, int oldLeft, int oldTop, int oldRight, int oldBottom) {
-                int minimumHeight = containerView.getHeight() - mPreviewPager.getMeasuredHeight();
-                mBottomSheetBehavior.setPeekHeight(minimumHeight);
-                containerView.setMinimumHeight(minimumHeight);
-                ((CardView) mHomePreview.getParent())
-                        .setRadius(TileSizeCalculator.getPreviewCornerRadius(
-                                getActivity(), homePreviewCard.getMeasuredWidth()));
-                if (mLockscreenPreview != null) {
-                    ((CardView) mLockscreenPreview.getParent())
-                            .setRadius(TileSizeCalculator.getPreviewCornerRadius(
-                                    getActivity(), mLockscreenPreview.getMeasuredWidth()));
-                }
-                fragmentContainer.removeOnLayoutChangeListener(this);
-            }});
 
         mPreviewUtils = new PreviewUtils(getContext(),
                 getString(R.string.grid_control_metadata_name));
@@ -323,7 +275,6 @@
     @Override
     public void onDestroyView() {
         super.onDestroyView();
-        LiveTileOverlay.INSTANCE.detach(mHomePreview.getOverlay());
         if (mWallpaperConnection != null) {
             mWallpaperConnection.disconnect();
             mWallpaperConnection = null;
@@ -356,24 +307,10 @@
 
     @Override
     public void show(String collectionId) {
-        mIndividualPickerFragment =
-                InjectorProvider.getInjector().getIndividualPickerFragment(collectionId);
-        mIndividualPickerFragment.highlightAppliedWallpaper(mSelectedPreviewPage);
-        mIndividualPickerFragment.setOnWallpaperSelectedListener(position -> {
-            // Scroll to the selected wallpaper and collapse the sheet if needed.
-            // Resize and scroll here because we want to let the RecyclerView's scrolling and
-            // BottomSheet's collapsing can be executed together instead of scrolling
-            // the RecyclerView after the BottomSheet is collapsed.
-            mIndividualPickerFragment.resizeLayout(mBottomSheetBehavior.getPeekHeight());
-            mIndividualPickerFragment.scrollToPosition(position);
-            if (mBottomSheetBehavior.getState() != STATE_COLLAPSED) {
-                mIsCollapsingByUserSelecting = true;
-                mBottomSheetBehavior.setState(STATE_COLLAPSED);
-            }
-        });
         getChildFragmentManager()
                 .beginTransaction()
-                .replace(R.id.category_fragment_container, mIndividualPickerFragment)
+                .replace(R.id.category_fragment_container,
+                        InjectorProvider.getInjector().getIndividualPickerFragment(collectionId))
                 .addToBackStack(null)
                 .commit();
         getChildFragmentManager().executePendingTransactions();
@@ -391,6 +328,7 @@
             updateThumbnail(wallpaperInfo, mHomePreview, true);
             updateThumbnail(wallpaperInfo, mLockscreenPreview, false);
             mShowSelectedWallpaper = true;
+            mBottomSheetBehavior.setState(BottomSheetBehavior.STATE_COLLAPSED);
         });
     }
 
@@ -400,25 +338,6 @@
         mShowSelectedWallpaper = false;
     }
 
-    @Override
-    public void onDestinationSet(@WallpaperPersister.Destination int destination) {
-        if (destination == WallpaperPersister.DEST_BOTH) {
-            return;
-        }
-        mPreviewPager.switchPreviewPage(destination);
-    }
-
-    @Override
-    public boolean onBackPressed() {
-        Fragment childFragment = getChildFragmentManager().findFragmentById(
-                R.id.category_fragment_container);
-        if (childFragment instanceof BottomActionBarFragment
-                && ((BottomActionBarFragment) childFragment).onBackPressed()) {
-            return true;
-        }
-        return false;
-    }
-
     /**
      * Pops the child fragment from the stack if {@link CategoryFragment} is visible to the users.
      *
@@ -606,12 +525,10 @@
                     previewView.getBottom());
         }
 
-        previewView.getLocationOnScreen(mLivePreviewLocation);
-        mPreviewGlobalRect.set(0, 0, previewView.getMeasuredWidth(),
-                previewView.getMeasuredHeight());
-        mPreviewLocalRect.set(mPreviewGlobalRect);
-        mPreviewGlobalRect.offset(mLivePreviewLocation[0], mLivePreviewLocation[1]);
-
+        Rect previewLocalRect = new Rect();
+        Rect previewGlobalRect = new Rect();
+        previewView.getLocalVisibleRect(previewLocalRect);
+        previewView.getGlobalVisibleRect(previewGlobalRect);
         mWallpaperConnection = new WallpaperConnection(
                 getWallpaperIntent(homeWallpaper.getWallpaperComponent()), activity,
                 new WallpaperConnectionListener() {
@@ -624,20 +541,21 @@
                         LiveTileOverlay.INSTANCE.setForegroundDrawable(placeholder);
                         LiveTileOverlay.INSTANCE.attach(previewView.getOverlay());
                         previewView.animate()
-                                .setStartDelay(50)
-                                .setDuration(200)
+                                .setStartDelay(400)
+                                .setDuration(400)
                                 .setInterpolator(AnimationUtils.loadInterpolator(getContext(),
                                         android.R.interpolator.fast_out_linear_in))
                                 .setUpdateListener(value -> placeholder.setAlpha(
                                         (int) (MAX_ALPHA * (1 - value.getAnimatedFraction()))))
                                 .withEndAction(() -> {
                                     LiveTileOverlay.INSTANCE.setForegroundDrawable(null);
+
                                 }).start();
 
                     }
-                }, mPreviewGlobalRect);
+                }, previewGlobalRect);
 
-        LiveTileOverlay.INSTANCE.update(new RectF(mPreviewLocalRect),
+        LiveTileOverlay.INSTANCE.update(new RectF(previewLocalRect),
                 ((CardView) previewView.getParent()).getRadius());
 
         mWallpaperConnection.setVisibility(true);
@@ -750,15 +668,12 @@
         boolean renderInImageWallpaperSurface =
                 !(wallpaperInfo instanceof LiveWallpaperInfo) && isHomeWallpaper;
         wallpaperInfo.getThumbAsset(activity.getApplicationContext())
-                .loadPreviewImage(activity,
+                .loadDrawable(activity,
                         renderInImageWallpaperSurface ? mHomeImageWallpaper : thumbnailView,
                         getResources().getColor(R.color.secondary_color));
         if (isHomeWallpaper) {
             LiveTileOverlay.INSTANCE.detach(thumbnailView.getOverlay());
             if (wallpaperInfo instanceof LiveWallpaperInfo) {
-                wallpaperInfo.getThumbAsset(activity.getApplicationContext()).loadPreviewImage(
-                        activity, mHomeImageWallpaper,
-                        getResources().getColor(R.color.secondary_color));
                 setUpLiveWallpaperPreview(wallpaperInfo, thumbnailView,
                         new ColorDrawable(getResources().getColor(
                                 R.color.secondary_color, activity.getTheme())));
@@ -786,12 +701,9 @@
 
     private final SurfaceHolder.Callback mWallpaperSurfaceCallback = new SurfaceHolder.Callback() {
 
-        private Surface mLastSurface;
-
         @Override
-        public void surfaceCreated(SurfaceHolder holder) {
-            if (mLastSurface != holder.getSurface()) {
-                mLastSurface = holder.getSurface();
+        public void surfaceCreated(@NonNull SurfaceHolder surfaceHolder) {
+            if (mHomeImageWallpaper == null) {
                 mHomeImageWallpaper = new ImageView(getContext());
                 mHomeImageWallpaper.setBackgroundColor(
                         ContextCompat.getColor(getContext(), R.color.primary_color));
@@ -808,48 +720,30 @@
         }
 
         @Override
+        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
+        }
+
+        @Override
+        public void surfaceDestroyed(@NonNull SurfaceHolder surfaceHolder) {
+        }
+    };
+
+    private final SurfaceHolder.Callback mWorkspaceSurfaceCallback = new SurfaceHolder.Callback() {
+        @Override
+        public void surfaceCreated(SurfaceHolder holder) {
+            Bundle bundle = SurfaceViewRequestUtils.createSurfaceBundle(mWorkspaceSurface);
+            if (mPreviewUtils.supportsPreview()) {
+                mPreviewUtils.renderPreview(bundle);
+            }
+        }
+
+        @Override
         public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { }
 
         @Override
         public void surfaceDestroyed(SurfaceHolder holder) { }
     };
 
-    private final SurfaceHolder.Callback mWorkspaceSurfaceCallback = new SurfaceHolder.Callback() {
-
-        private Surface mLastSurface;
-        private Message mCallback;
-
-        @Override
-        public void surfaceCreated(SurfaceHolder holder) {
-            if (mPreviewUtils.supportsPreview() && mLastSurface != holder.getSurface()) {
-                mLastSurface = holder.getSurface();
-                Bundle result = mPreviewUtils.renderPreview(
-                        SurfaceViewUtils.createSurfaceViewRequest(mWorkspaceSurface));
-                if (result != null) {
-                    mWorkspaceSurface.setChildSurfacePackage(
-                            SurfaceViewUtils.getSurfacePackage(result));
-                    mCallback = SurfaceViewUtils.getCallback(result);
-                }
-            }
-        }
-
-        @Override
-        public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { }
-
-        @Override
-        public void surfaceDestroyed(SurfaceHolder holder) {
-            if (mCallback != null) {
-                try {
-                    mCallback.replyTo.send(mCallback);
-                } catch (RemoteException e) {
-                    e.printStackTrace();
-                } finally {
-                    mCallback = null;
-                }
-            }
-        }
-    };
-
     private interface MetadataHolder {
         /**
          * Binds {@link WallpaperInfo} objects representing the currently-set wallpapers to the
diff --git a/src/com/android/wallpaper/picker/LivePreviewFragment.java b/src/com/android/wallpaper/picker/LivePreviewFragment.java
index 6e2c1ba..0a3003d 100644
--- a/src/com/android/wallpaper/picker/LivePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/LivePreviewFragment.java
@@ -71,11 +71,11 @@
 public class LivePreviewFragment extends PreviewFragment implements
         WallpaperConnection.WallpaperConnectionListener {
 
-    public static final String EXTRA_LIVE_WALLPAPER_INFO = "android.live_wallpaper.info";
-    public static final String KEY_ACTION_DELETE_LIVE_WALLPAPER = "action_delete_live_wallpaper";
-
     private static final String TAG = "LivePreviewFragment";
 
+    private static final String KEY_ACTION_DELETE_LIVE_WALLPAPER = "action_delete_live_wallpaper";
+    private static final String EXTRA_LIVE_WALLPAPER_INFO = "android.live_wallpaper.info";
+
     /**
      * Instance of {@link WallpaperConnection} used to bind to the live wallpaper service to show
      * it in this preview fragment.
diff --git a/src/com/android/wallpaper/picker/AppbarFragment.java b/src/com/android/wallpaper/picker/ToolbarFragment.java
similarity index 93%
rename from src/com/android/wallpaper/picker/AppbarFragment.java
rename to src/com/android/wallpaper/picker/ToolbarFragment.java
index 0729d16..488d49e 100644
--- a/src/com/android/wallpaper/picker/AppbarFragment.java
+++ b/src/com/android/wallpaper/picker/ToolbarFragment.java
@@ -24,13 +24,12 @@
 import androidx.annotation.MenuRes;
 import androidx.appcompat.widget.Toolbar;
 import androidx.appcompat.widget.Toolbar.OnMenuItemClickListener;
+import androidx.fragment.app.Fragment;
 
 import com.android.wallpaper.R;
-import com.android.wallpaper.widget.BottomActionBar;
 
 /**
- * Base class for Fragments that own a {@link Toolbar} widget and a {@link BottomActionBar}.
- *
+ * Base class for Fragments that own a {@link Toolbar} widget.
  * A Fragment extending this class is expected to have a {@link Toolbar} in its root view, with id
  * {@link R.id#toolbar}, which can optionally have a TextView with id custom_toolbar_title for
  * the title.
@@ -40,10 +39,8 @@
  * used as title.
  *
  * @see #setArguments(Bundle)
- * @see BottomActionBarFragment
  */
-public abstract class AppbarFragment extends BottomActionBarFragment
-        implements OnMenuItemClickListener {
+public abstract class ToolbarFragment extends Fragment implements OnMenuItemClickListener {
 
     private static final String ARG_TITLE = "ToolbarFragment.title";
 
diff --git a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
index b513dc2..1d0d8f0 100755
--- a/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
+++ b/src/com/android/wallpaper/picker/TopLevelPickerActivity.java
@@ -79,8 +79,6 @@
 import com.android.wallpaper.picker.individual.IndividualPickerFragment;
 import com.android.wallpaper.util.ScreenSizeCalculator;
 import com.android.wallpaper.util.ThrowableAnalyzer;
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
 
 import com.google.android.material.bottomsheet.BottomSheetBehavior;
 import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback;
@@ -95,7 +93,7 @@
  */
 public class TopLevelPickerActivity extends BaseActivity implements WallpapersUiContainer,
         CurrentWallpaperBottomSheetPresenter, SetWallpaperErrorDialogFragment.Listener,
-        MyPhotosStarter, CategoryFragmentHost, BottomActionBarHost {
+        MyPhotosStarter, CategoryFragmentHost {
 
     private static final String TAG_SET_WALLPAPER_ERROR_DIALOG_FRAGMENT =
             "toplevel_set_wallpaper_error_dialog";
@@ -1097,11 +1095,6 @@
         }
     }
 
-    @Override
-    public BottomActionBar getBottomActionBar() {
-        return findViewById(R.id.bottom_actionbar);
-    }
-
     private interface AssetReceiver {
         void onAssetReceived(Asset asset);
     }
diff --git a/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java b/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
index 1a790dd..5f8436d 100644
--- a/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
+++ b/src/com/android/wallpaper/picker/WallpaperPickerDelegate.java
@@ -449,7 +449,6 @@
                 // image.
                 ImageWallpaperInfo imageWallpaper = new ImageWallpaperInfo(imageUri);
 
-                mWallpaperPersister.setWallpaperInfoInPreview(imageWallpaper);
                 imageWallpaper.showPreview(mActivity, getPreviewIntentFactory(),
                         PREVIEW_WALLPAPER_REQUEST_CODE);
                 return false;
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
index 57d16de..beb8a75 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerActivity.java
@@ -50,14 +50,12 @@
 import com.android.wallpaper.picker.BaseActivity;
 import com.android.wallpaper.picker.PreviewActivity.PreviewActivityIntentFactory;
 import com.android.wallpaper.util.DiskBasedLogger;
-import com.android.wallpaper.widget.BottomActionBar;
-import com.android.wallpaper.widget.BottomActionBar.BottomActionBarHost;
 
 /**
  * Activity that can be launched from the Android wallpaper picker and allows users to pick from
  * various wallpapers and enter a preview mode for specific ones.
  */
-public class IndividualPickerActivity extends BaseActivity implements BottomActionBarHost {
+public class IndividualPickerActivity extends BaseActivity {
     private static final String TAG = "IndividualPickerAct";
     private static final String EXTRA_CATEGORY_COLLECTION_ID =
             "com.android.wallpaper.category_collection_id";
@@ -260,11 +258,6 @@
         bundle.putString(KEY_CATEGORY_COLLECTION_ID, mCategoryCollectionId);
     }
 
-    @Override
-    public BottomActionBar getBottomActionBar() {
-        return findViewById(R.id.bottom_actionbar);
-    }
-
     /**
      * Default implementation of intent factory that provides an intent to start an
      * IndividualPickerActivity.
diff --git a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
index 58cb84f..4392ca8 100755
--- a/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
+++ b/src/com/android/wallpaper/picker/individual/IndividualPickerFragment.java
@@ -16,12 +16,12 @@
 package com.android.wallpaper.picker.individual;
 
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.APPLY;
+import static com.android.wallpaper.widget.BottomActionBar.BottomAction.CANCEL;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.INFORMATION;
 import static com.android.wallpaper.widget.BottomActionBar.BottomAction.ROTATION;
 
 import android.app.Activity;
 import android.app.ProgressDialog;
-import android.app.WallpaperManager;
 import android.content.Context;
 import android.content.res.Configuration;
 import android.content.res.Resources.NotFoundException;
@@ -45,6 +45,7 @@
 import androidx.annotation.Nullable;
 import androidx.cardview.widget.CardView;
 import androidx.fragment.app.DialogFragment;
+import androidx.fragment.app.Fragment;
 import androidx.recyclerview.widget.GridLayoutManager;
 import androidx.recyclerview.widget.RecyclerView;
 import androidx.recyclerview.widget.RecyclerView.OnScrollListener;
@@ -76,7 +77,6 @@
 import com.android.wallpaper.module.WallpaperPreferences;
 import com.android.wallpaper.module.WallpaperSetter;
 import com.android.wallpaper.picker.BaseActivity;
-import com.android.wallpaper.picker.BottomActionBarFragment;
 import com.android.wallpaper.picker.CurrentWallpaperBottomSheetPresenter;
 import com.android.wallpaper.picker.MyPhotosStarter.MyPhotosStarterProvider;
 import com.android.wallpaper.picker.RotationStarter;
@@ -95,14 +95,14 @@
 
 import java.util.ArrayList;
 import java.util.Date;
+import java.util.EnumSet;
 import java.util.List;
-import java.util.Optional;
 import java.util.Random;
 
 /**
  * Displays the Main UI for picking an individual wallpaper image.
  */
-public class IndividualPickerFragment extends BottomActionBarFragment
+public class IndividualPickerFragment extends Fragment
         implements RotationStarter, StartRotationErrorDialogFragment.Listener,
         CurrentWallpaperBottomSheetPresenter.RefreshListener,
         SetWallpaperErrorDialogFragment.Listener, SetWallpaperDialogFragment.Listener {
@@ -112,10 +112,6 @@
      */
     static final int SPECIAL_FIXED_TILE_ADAPTER_POSITION = 0;
     static final String ARG_CATEGORY_COLLECTION_ID = "category_collection_id";
-    /**
-     * A temporary flag to hide the bottom action bar feature.
-     */
-    static final boolean TEMP_BOTTOM_ACTION_BAR_FEATURE = true;
 
     private static final String TAG = "IndividualPickerFrgmnt";
     private static final int UNUSED_REQUEST_CODE = 1;
@@ -128,6 +124,11 @@
     private static final String KEY_NIGHT_MODE = "IndividualPickerFragment.NIGHT_MODE";
 
     /**
+     * A temporary flag to hide the bottom action bar feature.
+     */
+    private static final boolean TEMP_BOTTOM_ACTION_BAR_FEATURE = false;
+
+    /**
      * An interface for updating the thumbnail with the specific wallpaper.
      */
     public interface ThumbnailUpdater {
@@ -142,31 +143,6 @@
         void restoreThumbnails();
     }
 
-    /**
-     * An interface for receiving the destination of the new applied wallpaper.
-     */
-    public interface WallpaperDestinationCallback {
-        /**
-         * Called when the destination of the wallpaper is set.
-         *
-         * @param destination the destination which a wallpaper may be set.
-         *                    See {@link Destination} for more details.
-         */
-        void onDestinationSet(@Destination int destination);
-    }
-
-    /**
-     * The listener which will be notified when the wallpaper is selected.
-     */
-    public interface WallpaperSelectedListener {
-        /**
-         * Called when the wallpaper is selected.
-         *
-         * @param position the position of the selected wallpaper
-         */
-        void onWallpaperSelected(int position);
-    }
-
     WallpaperPreferences mWallpaperPreferences;
     WallpaperChangedNotifier mWallpaperChangedNotifier;
     RecyclerView mImageGrid;
@@ -206,8 +182,6 @@
         }
     };
     PackageStatusNotifier.Listener mAppStatusListener;
-    BottomActionBar mBottomActionBar;
-    @Nullable WallpaperInfo mSelectedWallpaperInfo;
 
     private ProgressDialog mProgressDialog;
     private boolean mTestingMode;
@@ -251,12 +225,11 @@
         }
     };
 
+    private BottomActionBar mBottomActionBar;
     private WallpaperSetter mWallpaperSetter;
     private WallpaperPersister mWallpaperPersister;
+    @Nullable private WallpaperInfo mSelectedWallpaperInfo;
     private WallpaperInfo mAppliedWallpaperInfo;
-    private WallpaperManager mWallpaperManager;
-    private int mWallpaperDestination;
-    private WallpaperSelectedListener mWallpaperSelectedListener;
 
     public static IndividualPickerFragment newInstance(String collectionId) {
         Bundle args = new Bundle();
@@ -267,21 +240,6 @@
         return fragment;
     }
 
-    /**
-     * Highlights the applied wallpaper (if it exists) according to the destination a wallpaper
-     * would be set.
-     *
-     * @param wallpaperDestination the destination a wallpaper would be set.
-     *                             It will be either {@link Destination#DEST_HOME_SCREEN}
-     *                             or {@link Destination#DEST_LOCK_SCREEN}.
-     */
-    public void highlightAppliedWallpaper(@Destination int wallpaperDestination) {
-        mWallpaperDestination = wallpaperDestination;
-        if (mWallpapers != null) {
-            refreshAppliedWallpaper();
-        }
-    }
-
     private static int getResIdForRotationState(@RotationInitializationState int rotationState) {
         switch (rotationState) {
             case WallpaperRotationInitializer.ROTATION_NOT_INITIALIZED:
@@ -326,8 +284,6 @@
         mWallpaperChangedNotifier = WallpaperChangedNotifier.getInstance();
         mWallpaperChangedNotifier.registerListener(mWallpaperChangedListener);
 
-        mWallpaperManager = WallpaperManager.getInstance(appContext);
-
         mFormFactor = injector.getFormFactorChecker(appContext).getFormFactor();
 
         mPackageStatusNotifier = injector.getPackageStatusNotifier(appContext);
@@ -447,13 +403,44 @@
                 getResources().getDimensionPixelSize(R.dimen.grid_padding)));
 
         maybeSetUpImageGrid();
+
         setUpBottomSheet();
+
+        if (TEMP_BOTTOM_ACTION_BAR_FEATURE) {
+            mBottomActionBar = getActivity().findViewById(R.id.bottom_actionbar);
+
+            mBottomActionBar.setActionClickListener(CANCEL, unused -> {
+                if (mSelectedWallpaperInfo != null) {
+                    onWallpaperSelected(null);
+                    return;
+                }
+                getActivity().onBackPressed();
+            });
+            mBottomActionBar.setActionClickListener(ROTATION, unused -> {
+                DialogFragment startRotationDialogFragment = new StartRotationDialogFragment();
+                startRotationDialogFragment.setTargetFragment(
+                        IndividualPickerFragment.this, UNUSED_REQUEST_CODE);
+                startRotationDialogFragment.show(getFragmentManager(), TAG_START_ROTATION_DIALOG);
+            });
+            mBottomActionBar.setActionClickListener(APPLY, unused -> {
+                mBottomActionBar.disableActions();
+                mWallpaperSetter.requestDestination(getActivity(), getFragmentManager(), this,
+                        mSelectedWallpaperInfo instanceof LiveWallpaperInfo);
+            });
+
+            mBottomActionBar.show();
+            mBottomActionBar.showActionsOnly(
+                    isRotationEnabled() ? EnumSet.of(CANCEL, ROTATION) : EnumSet.of(CANCEL));
+        }
+
         return view;
     }
 
     @Override
     public void onDestroyView() {
         if (TEMP_BOTTOM_ACTION_BAR_FEATURE) {
+            mBottomActionBar.hide();
+            mBottomActionBar.clearActionClickListeners();
             updateThumbnail(null);
         }
         super.onDestroyView();
@@ -532,28 +519,6 @@
     }
 
     @Override
-    protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
-        if (TEMP_BOTTOM_ACTION_BAR_FEATURE) {
-            mBottomActionBar = bottomActionBar;
-            if (isRotationEnabled()) {
-                mBottomActionBar.showActionsOnly(ROTATION);
-            }
-            mBottomActionBar.setActionClickListener(ROTATION, unused -> {
-                DialogFragment startRotationDialogFragment = new StartRotationDialogFragment();
-                startRotationDialogFragment.setTargetFragment(
-                        IndividualPickerFragment.this, UNUSED_REQUEST_CODE);
-                startRotationDialogFragment.show(getFragmentManager(), TAG_START_ROTATION_DIALOG);
-            });
-            mBottomActionBar.setActionClickListener(APPLY, unused -> {
-                mBottomActionBar.disableActions();
-                mWallpaperSetter.requestDestination(getActivity(), getFragmentManager(), this,
-                        mSelectedWallpaperInfo instanceof LiveWallpaperInfo);
-            });
-            mBottomActionBar.show();
-        }
-    }
-
-    @Override
     public void onResume() {
         super.onResume();
 
@@ -603,6 +568,7 @@
                 }
             }
         }
+
     }
 
     @Override
@@ -629,15 +595,6 @@
         startRotation(networkPreference);
     }
 
-    @Override
-    public boolean onBackPressed() {
-        if (mSelectedWallpaperInfo != null) {
-            onWallpaperSelected(null, 0);
-            return true;
-        }
-        return false;
-    }
-
     public void setCurrentWallpaperBottomSheetPresenter(
             CurrentWallpaperBottomSheetPresenter presenter) {
         mCurrentWallpaperBottomSheetPresenter = presenter;
@@ -647,29 +604,6 @@
         mWallpapersUiContainer = uiContainer;
     }
 
-    public void setOnWallpaperSelectedListener(
-            WallpaperSelectedListener wallpaperSelectedListener) {
-        mWallpaperSelectedListener = wallpaperSelectedListener;
-    }
-
-    /**
-     * Resizes the layout's height.
-     */
-    public void resizeLayout(int height) {
-        mImageGrid.getLayoutParams().height = height;
-        mImageGrid.requestLayout();
-    }
-
-    /**
-     * Scrolls to the specific item.
-     *
-     * @param position the position of the item
-     */
-    public void scrollToPosition(int position) {
-        ((GridLayoutManager) mImageGrid.getLayoutManager())
-                .scrollToPositionWithOffset(position, /* offset= */ 0);
-    }
-
     /**
      * Enable a test mode of operation -- in which certain UI features are disabled to allow for
      * UI tests to run correctly. Works around issue in ProgressDialog currently where the dialog
@@ -850,17 +784,17 @@
             mWallpaperSetter.setCurrentWallpaper(
                     getActivity(), mSelectedWallpaperInfo, destination, mSetWallpaperCallback);
         }
-        onWallpaperDestinationSet(destination);
     }
 
     private WallpaperPersister.SetWallpaperCallback mSetWallpaperCallback =
             new WallpaperPersister.SetWallpaperCallback() {
                 @Override
                 public void onSuccess(WallpaperInfo wallpaperInfo) {
-                    Toast.makeText(getActivity(), R.string.wallpaper_set_successfully_message,
-                            Toast.LENGTH_SHORT).show();
+                    // TODO(b/150913705): Show the snack bar.
                     mBottomActionBar.enableActions();
-                    refreshAppliedWallpaper();
+                    updateAppliedStatus(mAppliedWallpaperInfo, false);
+                    updateAppliedStatus(wallpaperInfo, true);
+                    mAppliedWallpaperInfo = wallpaperInfo;
 
                     mWallpaperPersister.onLiveWallpaperSet();
                 }
@@ -894,12 +828,11 @@
         }
     }
 
-    void updateBottomActions(boolean hasWallpaperSelected) {
-        if (hasWallpaperSelected) {
-            mBottomActionBar.showActionsOnly(INFORMATION, APPLY);
-        } else {
-            mBottomActionBar.showActionsOnly(ROTATION);
-        }
+    private void updateBottomActions(boolean hasWallpaperSelected) {
+        mBottomActionBar.showActions(
+                hasWallpaperSelected ? EnumSet.of(APPLY, INFORMATION) : EnumSet.of(ROTATION));
+        mBottomActionBar.hideActions(
+                hasWallpaperSelected ? EnumSet.of(ROTATION) : EnumSet.of(APPLY, INFORMATION));
     }
 
     private void updateThumbnail(WallpaperInfo selectedWallpaperInfo) {
@@ -915,18 +848,7 @@
         }
     }
 
-    private void onWallpaperDestinationSet(int destination) {
-        WallpaperDestinationCallback wallpaperDestinationCallback =
-                (WallpaperDestinationCallback) getParentFragment();
-        if (wallpaperDestinationCallback == null) {
-            return;
-        }
-
-        wallpaperDestinationCallback.onDestinationSet(destination);
-    }
-
-    void onWallpaperSelected(@Nullable WallpaperInfo newSelectedWallpaperInfo,
-                                     int position) {
+    private void onWallpaperSelected(@Nullable WallpaperInfo newSelectedWallpaperInfo) {
         if (mSelectedWallpaperInfo == newSelectedWallpaperInfo) {
             return;
         }
@@ -943,12 +865,8 @@
         // Populate wallpaper info to bottom sheet page.
         if (mSelectedWallpaperInfo != null) {
             mBottomActionBar.populateInfoPage(
-                    mSelectedWallpaperInfo.getAttributions(getContext()),
-                    shouldShowMetadataInPreview(mSelectedWallpaperInfo));
-        }
-
-        if (mWallpaperSelectedListener != null) {
-            mWallpaperSelectedListener.onWallpaperSelected(position);
+                mSelectedWallpaperInfo.getAttributions(getContext()),
+                shouldShowMetadataInPreview(mSelectedWallpaperInfo));
         }
     }
 
@@ -990,45 +908,6 @@
         return wallpaperComponent == null || wallpaperComponent.getShowMetadataInPreview();
     }
 
-    private void refreshAppliedWallpaper() {
-        // Clear the check mark and blue border(if it shows) of the old applied wallpaper.
-        showCheckMarkAndBorderForAppliedWallpaper(false);
-
-        // Update to the new applied wallpaper.
-        String appliedWallpaperId = getAppliedWallpaperId();
-        Optional<WallpaperInfo> wallpaperInfoOptional = mWallpapers
-                .stream()
-                .filter(wallpaper -> wallpaper.getWallpaperId() != null)
-                .filter(wallpaper -> wallpaper.getWallpaperId().equals(appliedWallpaperId))
-                .findFirst();
-        mAppliedWallpaperInfo = wallpaperInfoOptional.orElse(null);
-
-        // Set the check mark and blue border(if user doesn't select) of the new applied wallpaper.
-        showCheckMarkAndBorderForAppliedWallpaper(true);
-    }
-
-    private String getAppliedWallpaperId() {
-        WallpaperPreferences prefs =
-                InjectorProvider.getInjector().getPreferences(getContext());
-        android.app.WallpaperInfo wallpaperInfo = mWallpaperManager.getWallpaperInfo();
-        boolean isDestinationBoth =
-                mWallpaperManager.getWallpaperId(WallpaperManager.FLAG_LOCK) < 0;
-
-        if (isDestinationBoth || mWallpaperDestination == WallpaperPersister.DEST_HOME_SCREEN) {
-            return wallpaperInfo != null
-                    ? wallpaperInfo.getServiceName() : prefs.getHomeWallpaperRemoteId();
-        } else {
-            return prefs.getLockWallpaperRemoteId();
-        }
-    }
-
-    private void showCheckMarkAndBorderForAppliedWallpaper(boolean show) {
-        updateAppliedStatus(mAppliedWallpaperInfo, show);
-        if (mSelectedWallpaperInfo == null) {
-            updateActivatedStatus(mAppliedWallpaperInfo, show);
-        }
-    }
-
     /**
      * ViewHolder subclass for "daily refresh" tile in the RecyclerView, only shown if rotation is
      * enabled for this category.
@@ -1360,7 +1239,8 @@
                     ? position - 1 : position;
             WallpaperInfo wallpaper = mWallpapers.get(wallpaperIndex);
             ((IndividualHolder) holder).bindWallpaper(wallpaper);
-            String appliedWallpaperId = getAppliedWallpaperId();
+            WallpaperPreferences prefs = InjectorProvider.getInjector().getPreferences(getContext());
+            String appliedWallpaperId = prefs.getHomeWallpaperRemoteId();
             boolean isWallpaperApplied = wallpaper.getWallpaperId().equals(appliedWallpaperId);
             boolean isWallpaperSelected = wallpaper.equals(mSelectedWallpaperInfo);
             boolean hasUserSelectedWallpaper = mSelectedWallpaperInfo != null;
@@ -1376,7 +1256,7 @@
                 holder.itemView.findViewById(R.id.check_circle).setVisibility(
                         isWallpaperApplied ? View.VISIBLE : View.GONE);
                 holder.itemView.findViewById(R.id.tile).setOnClickListener(
-                        view -> onWallpaperSelected(wallpaper, position));
+                        view -> onWallpaperSelected(wallpaper));
             }
         }
     }
diff --git a/src/com/android/wallpaper/util/PreviewUtils.java b/src/com/android/wallpaper/util/PreviewUtils.java
index 5b1d857..14b9cde 100644
--- a/src/com/android/wallpaper/util/PreviewUtils.java
+++ b/src/com/android/wallpaper/util/PreviewUtils.java
@@ -52,9 +52,8 @@
     }
 
     /** Render preview under the current grid option. */
-    public Bundle renderPreview(Bundle bundle) {
-        return mContext.getContentResolver().call(getUri(PREVIEW), METHOD_GET_PREVIEW, null,
-                bundle);
+    public void renderPreview(Bundle bundle) {
+        mContext.getContentResolver().call(getUri(PREVIEW), METHOD_GET_PREVIEW, null, bundle);
     }
 
     /** Easy way to generate a Uri with the provider info from this class. */
diff --git a/src/com/android/wallpaper/util/SurfaceViewUtils.java b/src/com/android/wallpaper/util/SurfaceViewUtils.java
deleted file mode 100644
index 1656b1b..0000000
--- a/src/com/android/wallpaper/util/SurfaceViewUtils.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2020 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.
- */
-package com.android.wallpaper.util;
-
-import android.os.Bundle;
-import android.os.Message;
-import android.view.SurfaceControlViewHost;
-import android.view.SurfaceView;
-
-/** Util class to generate surface view requests and parse responses */
-public class SurfaceViewUtils {
-
-    private static final String KEY_HOST_TOKEN = "host_token";
-    private static final String KEY_VIEW_WIDTH = "width";
-    private static final String KEY_VIEW_HEIGHT = "height";
-    private static final String KEY_DISPLAY_ID = "display_id";
-    private static final String KEY_SURFACE_PACKAGE = "surface_package";
-    private static final String KEY_CALLBACK = "callback";
-
-    /** Create a surface view request. */
-    public static Bundle createSurfaceViewRequest(SurfaceView surfaceView) {
-        Bundle bundle = new Bundle();
-        bundle.putBinder(KEY_HOST_TOKEN, surfaceView.getHostToken());
-        bundle.putInt(KEY_DISPLAY_ID, surfaceView.getDisplay().getDisplayId());
-        bundle.putInt(KEY_VIEW_WIDTH, surfaceView.getWidth());
-        bundle.putInt(KEY_VIEW_HEIGHT, surfaceView.getHeight());
-        return bundle;
-    }
-
-    /** Return the surface package. */
-    public static SurfaceControlViewHost.SurfacePackage getSurfacePackage(Bundle bundle) {
-        return bundle.getParcelable(KEY_SURFACE_PACKAGE);
-    }
-
-    /** Return the message callback. */
-    public static Message getCallback(Bundle bundle) {
-        return bundle.getParcelable(KEY_CALLBACK);
-    }
-}
diff --git a/src/com/android/wallpaper/util/WallpaperConnection.java b/src/com/android/wallpaper/util/WallpaperConnection.java
index b8c02de..ed12095 100644
--- a/src/com/android/wallpaper/util/WallpaperConnection.java
+++ b/src/com/android/wallpaper/util/WallpaperConnection.java
@@ -34,8 +34,6 @@
 
 import androidx.annotation.Nullable;
 
-import java.lang.reflect.Method;
-
 /**
  * Implementation of {@link IWallpaperConnection} that handles communication with a
  * {@link android.service.wallpaper.WallpaperService}
@@ -53,7 +51,6 @@
     private boolean mIsVisible;
     private boolean mIsEngineVisible;
     private boolean mEngineReady;
-    private Method mScalePreviewMethod;
 
     /**
      * @param intent used to bind the wallpaper service
@@ -167,16 +164,17 @@
 
     private void updateEnginePosition() {
         if (mWallpaperPreviewRect != null) {
-            // TODO(santie): switch to regular method call once SDK is sync'ed
+            // TODO(santie): replace with proper surface resizing when the API is available
+            View decorView = mActivity.getWindow().getDecorView();
+            int availw = decorView.getWidth();
+            int availh = decorView.getHeight();
             try {
-                if (mScalePreviewMethod == null) {
-                    mScalePreviewMethod =
-                            mEngine.getClass().getMethod("scalePreview", Rect.class);
-                    mScalePreviewMethod.setAccessible(true);
-                }
-                mScalePreviewMethod.invoke(mEngine, mWallpaperPreviewRect);
-            } catch (Exception e) {
-                Log.e(TAG, "Couldn't call scalePreview method on WallpaperEngine", e);
+                mEngine.setDisplayPadding(
+                        new Rect(-mWallpaperPreviewRect.left, -mWallpaperPreviewRect.top,
+                                mWallpaperPreviewRect.right - availw,
+                                mWallpaperPreviewRect.bottom - availh));
+            } catch (RemoteException e) {
+                Log.e(TAG, "Couldn't set preview padding", e);
             }
         }
     }
diff --git a/src/com/android/wallpaper/util/WallpaperCropUtils.java b/src/com/android/wallpaper/util/WallpaperCropUtils.java
index 7d9c2b8..3e751b8 100755
--- a/src/com/android/wallpaper/util/WallpaperCropUtils.java
+++ b/src/com/android/wallpaper/util/WallpaperCropUtils.java
@@ -243,18 +243,6 @@
         }
     }
 
-    // TODO(b/154783188): Remove this method when new system UI's API is available.
-    /**
-     * Get the system wallpaper's maximum scale value.
-     */
-    public static float getSystemWallpaperMaximumScale() {
-        Resources system = Resources.getSystem();
-        return system.getFloat(system.getIdentifier(
-                /* name= */ "config_wallpaperMaxScale",
-                /* defType= */ "dimen",
-                /* defPackage= */ "android"));
-    }
-
     /**
      * Returns whether layout direction is RTL (or false for LTR). Since native RTL layout support
      * was added in API 17, returns false for versions lower than 17.
diff --git a/src/com/android/wallpaper/widget/BottomActionBar.java b/src/com/android/wallpaper/widget/BottomActionBar.java
index b5bbdd5..ee68b81 100644
--- a/src/com/android/wallpaper/widget/BottomActionBar.java
+++ b/src/com/android/wallpaper/widget/BottomActionBar.java
@@ -18,7 +18,6 @@
 import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_COLLAPSED;
 import static com.google.android.material.bottomsheet.BottomSheetBehavior.STATE_EXPANDED;
 
-import android.app.Activity;
 import android.content.Context;
 import android.graphics.drawable.GradientDrawable;
 import android.util.AttributeSet;
@@ -37,31 +36,20 @@
 import com.google.android.material.bottomsheet.BottomSheetBehavior;
 import com.google.android.material.bottomsheet.BottomSheetBehavior.BottomSheetCallback;
 
-import java.util.Arrays;
 import java.util.EnumMap;
-import java.util.HashSet;
+import java.util.EnumSet;
 import java.util.List;
 import java.util.Map;
-import java.util.Set;
 
 /** A {@code ViewGroup} which provides the specific actions for the user to interact with. */
 public class BottomActionBar extends FrameLayout {
 
-    /**
-     * Interface to be implemented by an Activity hosting a {@link BottomActionBar}
-     */
-    public interface BottomActionBarHost {
-        /** Gets {@link BottomActionBar}. */
-        BottomActionBar getBottomActionBar();
-    }
-
-    // TODO(b/154299462): Separate downloadable related actions from WallpaperPicker.
     /** The action items in the bottom action bar. */
     public enum BottomAction {
-        ROTATION, DELETE, INFORMATION, EDIT, CUSTOMIZE, DOWNLOAD, PROGRESS, APPLY,
+        CANCEL, ROTATION, INFORMATION, EDIT, APPLY,
     }
 
-    private final Map<BottomAction, View> mActionMap = new EnumMap<>(BottomAction.class);
+    private final Map<BottomAction, View> mActionList = new EnumMap<>(BottomAction.class);
     private final BottomSheetBehavior<ViewGroup> mBottomSheetBehavior;
     private final TextView mAttributionTitle;
     private final TextView mAttributionSubtitle1;
@@ -75,14 +63,11 @@
         mAttributionSubtitle1 = findViewById(R.id.preview_attribution_pane_subtitle1);
         mAttributionSubtitle2 = findViewById(R.id.preview_attribution_pane_subtitle2);
 
-        mActionMap.put(BottomAction.ROTATION, findViewById(R.id.action_rotation));
-        mActionMap.put(BottomAction.DELETE, findViewById(R.id.action_delete));
-        mActionMap.put(BottomAction.INFORMATION, findViewById(R.id.action_information));
-        mActionMap.put(BottomAction.EDIT, findViewById(R.id.action_edit));
-        mActionMap.put(BottomAction.CUSTOMIZE, findViewById(R.id.action_customize));
-        mActionMap.put(BottomAction.DOWNLOAD, findViewById(R.id.action_download));
-        mActionMap.put(BottomAction.PROGRESS, findViewById(R.id.action_progress));
-        mActionMap.put(BottomAction.APPLY, findViewById(R.id.action_apply));
+        mActionList.put(BottomAction.CANCEL, findViewById(R.id.action_cancel));
+        mActionList.put(BottomAction.ROTATION, findViewById(R.id.action_rotation));
+        mActionList.put(BottomAction.INFORMATION, findViewById(R.id.action_information));
+        mActionList.put(BottomAction.EDIT, findViewById(R.id.action_edit));
+        mActionList.put(BottomAction.APPLY, findViewById(R.id.action_apply));
 
         ViewGroup bottomSheet = findViewById(R.id.action_bottom_sheet);
         mBottomSheetBehavior = BottomSheetBehavior.from(bottomSheet);
@@ -131,18 +116,12 @@
      */
     public void setActionClickListener(
             BottomAction bottomAction, OnClickListener actionClickListener) {
-        mActionMap.get(bottomAction).setOnClickListener(actionClickListener);
-    }
-
-    /** Binds the cancel button to back key. */
-    public void bindBackButtonToSystemBackKey(Activity activity) {
-        findViewById(R.id.action_back).setOnClickListener(v -> activity.onBackPressed());
+        mActionList.get(bottomAction).setOnClickListener(actionClickListener);
     }
 
     /** Clears all the actions' click listeners */
     public void clearActionClickListeners() {
-        mActionMap.forEach((bottomAction, view) -> view.setOnClickListener(null));
-        findViewById(R.id.action_back).setOnClickListener(null);
+        mActionList.forEach((bottomAction, view) -> view.setOnClickListener(null));
     }
 
     /**
@@ -180,10 +159,6 @@
         }
     }
 
-    /** Returns {@code true} if visible. */
-    public boolean isVisible() {
-        return getVisibility() == VISIBLE;
-    }
 
     /** Shows {@link BottomActionBar}. */
     public void show() {
@@ -200,10 +175,8 @@
      *
      * @param actions the specific actions
      */
-    public void showActions(BottomAction... actions) {
-        for (BottomAction action : actions) {
-            mActionMap.get(action).setVisibility(VISIBLE);
-        }
+    public void showActions(EnumSet<BottomAction> actions) {
+        showActions(actions, true);
     }
 
     /**
@@ -211,13 +184,10 @@
      *
      * @param actions the specific actions
      */
-    public void hideActions(BottomAction... actions) {
-        for (BottomAction action : actions) {
-            mActionMap.get(action).setVisibility(GONE);
-
-            if (BottomAction.INFORMATION.equals(action)) {
-                mBottomSheetBehavior.setState(STATE_COLLAPSED);
-            }
+    public void hideActions(EnumSet<BottomAction> actions) {
+        showActions(actions, false);
+        if (actions.contains(BottomAction.INFORMATION)) {
+            mBottomSheetBehavior.setState(STATE_COLLAPSED);
         }
     }
 
@@ -226,64 +196,28 @@
      *
      * @param actions the specific actions which will be shown. Others will be hidden.
      */
-    public void showActionsOnly(BottomAction... actions) {
-        final Set<BottomAction> actionsSet = new HashSet<>(Arrays.asList(actions));
-
-        mActionMap.forEach((action, view) -> {
-            if (actionsSet.contains(action)) {
-                showActions(action);
-            } else {
-                hideActions(action);
-            }
-        });
-    }
-
-    /**
-     * All actions will be hidden.
-     */
-    public void hideAllActions() {
-        showActionsOnly(/* No actions to show */);
+    public void showActionsOnly(EnumSet<BottomAction> actions) {
+        showActions(actions);
+        hideActions(EnumSet.complementOf(actions));
     }
 
     /** Enables all the actions' {@link View}. */
     public void enableActions() {
-        mActionMap.forEach((bottomAction, view) -> view.setEnabled(true));
+        enableActions(true);
     }
 
     /** Disables all the actions' {@link View}. */
     public void disableActions() {
-        mActionMap.forEach((bottomAction, view) -> view.setEnabled(false));
+        enableActions(false);
     }
 
-    /**
-     * Enables specified actions' {@link View}.
-     *
-     * @param actions the specified actions to enable their views
-     */
-    public void enableActions(BottomAction... actions) {
-        for (BottomAction action : actions) {
-            mActionMap.get(action).setEnabled(true);
-        }
+    private void enableActions(boolean enable) {
+        mActionList.forEach((bottomAction, view) -> view.setEnabled(enable));
     }
 
-    /**
-     * Disables specified actions' {@link View}.
-     *
-     * @param actions the specified actions to disable their views
-     */
-    public void disableActions(BottomAction... actions) {
-        for (BottomAction action : actions) {
-            mActionMap.get(action).setEnabled(false);
-        }
-    }
-
-    /** Resets {@link BottomActionBar}. */
-    public void reset() {
-        hide();
-        hideAllActions();
-        clearActionClickListeners();
-        enableActions();
-        resetInfoPage();
+    private void showActions(EnumSet<BottomAction> actions, boolean show) {
+        actions.forEach(bottomAction ->
+                mActionList.get(bottomAction).setVisibility(show ? VISIBLE : GONE));
     }
 
     private void resetInfoPage() {
diff --git a/src/com/android/wallpaper/widget/PreviewPager.java b/src/com/android/wallpaper/widget/PreviewPager.java
index a70fdda..1e11abc 100644
--- a/src/com/android/wallpaper/widget/PreviewPager.java
+++ b/src/com/android/wallpaper/widget/PreviewPager.java
@@ -19,12 +19,11 @@
 import android.content.res.Resources;
 import android.content.res.TypedArray;
 import android.database.DataSetObserver;
-import android.graphics.Point;
 import android.util.AttributeSet;
+import android.util.DisplayMetrics;
 import android.util.TypedValue;
 import android.view.LayoutInflater;
 import android.view.View;
-import android.view.WindowManager;
 import android.widget.LinearLayout;
 
 import androidx.annotation.Nullable;
@@ -35,7 +34,6 @@
 import androidx.viewpager.widget.ViewPager.OnPageChangeListener;
 
 import com.android.wallpaper.R;
-import com.android.wallpaper.util.ScreenSizeCalculator;
 
 import java.util.Locale;
 
@@ -87,32 +85,6 @@
         mMaxHeightRatio = ratioValue.getFloat();
 
         mViewPager = findViewById(R.id.preview_viewpager);
-        mViewPager.setPageTransformer(false, (view, position) -> {
-            int origin = mViewPager.getPaddingStart();
-            int leftBoundary = -view.getWidth();
-            int rightBoundary = mViewPager.getWidth();
-            int pageWidth = view.getWidth();
-            int offset = (int) (pageWidth * position);
-
-            //               left      origin     right
-            //             boundary              boundary
-            // ---------------|----------|----------|----------
-            // Cover alpha:  1.0         0         1.0
-            float alpha;
-            if (offset <= leftBoundary || offset >= rightBoundary) {
-                alpha = 1.0f;
-            } else if (offset <= origin) {
-                // offset in (leftBoundary, origin]
-                alpha = (float) Math.abs(offset - origin) / Math.abs(leftBoundary - origin);
-            } else {
-                // offset in (origin, rightBoundary)
-                alpha = (float) Math.abs(offset - origin) / Math.abs(rightBoundary - origin);
-            }
-            View cover = view.findViewById(R.id.fade_cover);
-            if (cover != null) {
-                view.findViewById(R.id.fade_cover).setAlpha(alpha);
-            }
-        }, LAYER_TYPE_NONE);
         mViewPager.setPageMargin(res.getDimensionPixelOffset(R.dimen.preview_page_gap));
         mViewPager.setClipToPadding(false);
         if (mPageStyle == STYLE_PEEKING) {
@@ -125,27 +97,15 @@
                     hMargin,
                     res.getDimensionPixelOffset(R.dimen.preview_page_bottom_margin));
         } else if (mPageStyle == STYLE_ASPECT_RATIO) {
-            WindowManager windowManager = context.getSystemService(WindowManager.class);
-            Point screenSize = ScreenSizeCalculator.getInstance()
-                    .getScreenSize(windowManager.getDefaultDisplay());
-            mScreenAspectRatio = (float) screenSize.y / screenSize.x;
+            DisplayMetrics dm = res.getDisplayMetrics();
+            mScreenAspectRatio = dm.heightPixels > dm.widthPixels
+                    ? (float) dm.heightPixels / dm.widthPixels
+                    : (float) dm.widthPixels / dm.heightPixels;
             mViewPager.setPadding(
                     0,
                     res.getDimensionPixelOffset(R.dimen.preview_page_top_margin),
                     0,
                     res.getDimensionPixelOffset(R.dimen.preview_page_bottom_margin));
-            // Set the default margin to make sure not peeking the second page before calculating
-            // the real margin.
-            mViewPager.setPageMargin(screenSize.x / 2);
-            mViewPager.addOnLayoutChangeListener(new OnLayoutChangeListener() {
-                @Override
-                public void onLayoutChange(View view, int left, int top, int right, int bottom,
-                                           int oldLeft, int oldTop, int oldRight, int oldBottom) {
-                    // Set the minimum margin which can't peek the second page.
-                    mViewPager.setPageMargin(view.getPaddingEnd());
-                    mViewPager.removeOnLayoutChangeListener(this);
-                }
-            });
         }
         mPageIndicator = findViewById(R.id.page_indicator);
         mPreviousArrow = findViewById(R.id.arrow_previous);
@@ -164,18 +124,12 @@
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        View parentView = (View) getParent();
-        float parentHeight = parentView != null ? parentView.getMeasuredHeight() : 0;
-        if (parentHeight > 0) {
-            int maxHeight = Math.min(MeasureSpec.getSize(heightMeasureSpec),
-                    (int) (parentHeight * mMaxHeightRatio));
-            heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
-        }
-
         if (mPageStyle == STYLE_ASPECT_RATIO) {
             int availableWidth = MeasureSpec.getSize(widthMeasureSpec);
             int availableHeight = MeasureSpec.getSize(heightMeasureSpec);
-            int indicatorHeight = ((View) mPageIndicator.getParent()).getLayoutParams().height;
+            int indicatorHeight = mPageIndicator.getVisibility() == VISIBLE
+                    ? ((View) mPageIndicator.getParent()).getLayoutParams().height
+                    : 0;
             int pagerHeight = availableHeight - indicatorHeight;
             if (availableWidth > 0) {
                 int absoluteCardWidth = (int) ((pagerHeight - mViewPager.getPaddingBottom()
@@ -189,6 +143,14 @@
             }
         }
 
+        View parentView = (View) getParent();
+        float parentHeight = parentView != null ? parentView.getMeasuredHeight() : 0;
+        if (parentHeight > 0) {
+            int maxHeight = Math.min(MeasureSpec.getSize(heightMeasureSpec),
+                    (int) (parentHeight * mMaxHeightRatio));
+            heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.AT_MOST);
+        }
+
         super.onMeasure(widthMeasureSpec, heightMeasureSpec);
     }
 
@@ -244,15 +206,6 @@
         mExternalPageListener = listener;
     }
 
-    /**
-     * Switches to the specific preview page.
-     *
-     * @param index preview page index to select
-     */
-    public void switchPreviewPage(int index) {
-        mViewPager.setCurrentItem(index);
-    }
-
     private void initIndicator() {
         mPageIndicator.setNumPages(mAdapter.getCount());
         mPageIndicator.setLocation(mViewPager.getCurrentItem());
diff --git a/tests/src/com/android/wallpaper/testing/TestWallpaperPersister.java b/tests/src/com/android/wallpaper/testing/TestWallpaperPersister.java
index 5c1ddbd..26bd25f 100644
--- a/tests/src/com/android/wallpaper/testing/TestWallpaperPersister.java
+++ b/tests/src/com/android/wallpaper/testing/TestWallpaperPersister.java
@@ -85,7 +85,6 @@
             if (destination == DEST_LOCK_SCREEN || destination == DEST_BOTH) {
                 mPendingLockWallpaper = bitmap;
                 mPrefs.setLockWallpaperAttributions(wallpaperInfo.getAttributions(mAppContext));
-                mPrefs.setLockWallpaperRemoteId(wallpaperInfo.getWallpaperId());
             }
             mDestination = destination;
             mCallback = callback;
@@ -110,7 +109,6 @@
                 mPrefs.setWallpaperPresentationMode(WallpaperPreferences.PRESENTATION_MODE_STATIC);
                 mPendingLockWallpaper = bitmap;
                 mPrefs.setLockWallpaperAttributions(wallpaper.getAttributions(mAppContext));
-                mPrefs.setLockWallpaperRemoteId(wallpaper.getWallpaperId());
 
                 mDestination = WallpaperPersister.DEST_BOTH;
                 mCallback = callback;
diff --git a/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java b/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
index 840e40a..715e81b 100644
--- a/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
+++ b/tests/src/com/android/wallpaper/testing/TestWallpaperPreferences.java
@@ -45,7 +45,6 @@
     private int mLockWallpaperManagerId;
     private String mLockActionUrl;
     private String mLockCollectionId;
-    private String mLockWallpaperRemoteId;
 
     private List<Long> mDailyRotations;
     private long mDailyWallpaperEnabledTimestamp;
@@ -301,16 +300,6 @@
     }
 
     @Override
-    public String getLockWallpaperRemoteId() {
-        return mLockWallpaperRemoteId;
-    }
-
-    @Override
-    public void setLockWallpaperRemoteId(String wallpaperRemoteId) {
-        mLockWallpaperRemoteId = wallpaperRemoteId;
-    }
-
-    @Override
     public void addDailyRotation(long timestamp) {
         mDailyRotations.add(timestamp);
     }