Fix the wallpaper offset problem in full screen preview when clicking the small preview to full screen preview.

The small preview shows the wallpaper which the user applied to the system instead of the wallpaper from wallpaper gallery.
This wallpaper has been cropped when applying to the system.
The far left of this cropped wallpaper will be the area the user chooses to apply.
HOME screen and the small preview will show the far left of this cropped wallpaper.
But full screen preview still shows the center of it.
So for this kind of wallpaper, full screen preview should show the far left instead of center.

Video: https://drive.google.com/file/d/129EmLU33d4h3uEqmMDT0UhZmzd3etsN2/view?usp=sharing

Bug: 167651054
Change-Id: Iacde420859dcd81acf15d327b245c5e9924e33c3
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index b1153bb..308e907 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -52,6 +52,7 @@
 
 import com.android.wallpaper.R;
 import com.android.wallpaper.asset.Asset;
+import com.android.wallpaper.asset.CurrentWallpaperAssetVN;
 import com.android.wallpaper.model.WallpaperInfo;
 import com.android.wallpaper.module.WallpaperPersister.Destination;
 import com.android.wallpaper.module.WallpaperPersister.SetWallpaperCallback;
@@ -314,7 +315,8 @@
                         // Set page bitmap.
                         mFullResImageView.setImage(ImageSource.bitmap(pageBitmap));
 
-                        setDefaultWallpaperZoomAndScroll();
+                        setDefaultWallpaperZoomAndScroll(
+                                mWallpaperAsset instanceof CurrentWallpaperAssetVN);
                         crossFadeInMosaicView();
                     }
                     getActivity().invalidateOptionsMenu();
@@ -370,14 +372,20 @@
      *
      * <p>This method is called once in the Fragment lifecycle after the wallpaper asset has loaded
      * and rendered to the layout.
+     *
+     * @param offsetToFarLeft {@code true} if we want to offset the visible rectangle to far left of
+     *                                    the raw wallpaper; {@code false} otherwise.
      */
-    private void setDefaultWallpaperZoomAndScroll() {
+    private void setDefaultWallpaperZoomAndScroll(boolean offsetToFarLeft) {
         // Determine minimum zoom to fit maximum visible area of wallpaper on crop surface.
         int cropWidth = mWorkspaceSurface.getMeasuredWidth();
         int cropHeight = mWorkspaceSurface.getMeasuredHeight();
         Point crop = new Point(cropWidth, cropHeight);
         Rect visibleRawWallpaperRect =
                 WallpaperCropUtils.calculateVisibleRect(mRawWallpaperSize, crop);
+        if (offsetToFarLeft) {
+            visibleRawWallpaperRect.offsetTo(/* newLeft= */ 0, visibleRawWallpaperRect.top);
+        }
 
         final PointF centerPosition = WallpaperCropUtils.calculateDefaultCenter(requireContext(),
                 mRawWallpaperSize, visibleRawWallpaperRect);