Fix full static/live wallpaper preview card is with wrong ratio in RTL language

Root cause: String#format updated the ratio string in system language, so the full preview card failed to set screen aspect ratio.
Video: https://drive.google.com/file/d/13XRpElgKkYylXxelhSnpQYX0G__oiUTt/view?usp=sharing

Also cleanup for LivePreviewFragment

Test: Manually
Fixes: 160383411
Change-Id: I0a3781b1be7ceb527326bbc97cd96594ee5f621f
diff --git a/res/layout/fragment_live_preview_v2.xml b/res/layout/fragment_live_preview_v2.xml
index cb74d71..029ffc4 100644
--- a/res/layout/fragment_live_preview_v2.xml
+++ b/res/layout/fragment_live_preview_v2.xml
@@ -47,7 +47,6 @@
                     android:id="@+id/touch_forwarding_layout"
                     android:layout_width="0dp"
                     android:layout_height="wrap_content"
-                    android:layout_weight="1"
                     android:paddingBottom="@dimen/full_preview_page_editing_padding_bottom"
                     android:clipToPadding="false"
                     app:layout_constraintLeft_toLeftOf="parent"
diff --git a/src/com/android/wallpaper/picker/ImagePreviewFragment.java b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
index 037a95e..5c2a904 100755
--- a/src/com/android/wallpaper/picker/ImagePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/ImagePreviewFragment.java
@@ -68,6 +68,8 @@
 import com.davemorrissey.labs.subscaleview.ImageSource;
 import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView;
 
+import java.util.Locale;
+
 /**
  * Fragment which displays the UI for previewing an individual static wallpaper and its attribution
  * information.
@@ -131,7 +133,7 @@
         // Set aspect ratio on the preview card dynamically.
         ConstraintSet set = new ConstraintSet();
         set.clone(mContainer);
-        String ratio = String.format("%d:%d", mScreenSize.x, mScreenSize.y);
+        String ratio = String.format(Locale.US, "%d:%d", mScreenSize.x, mScreenSize.y);
         set.setDimensionRatio(mTouchForwardingLayout.getId(), ratio);
         set.applyTo(mContainer);
 
diff --git a/src/com/android/wallpaper/picker/LivePreviewFragment.java b/src/com/android/wallpaper/picker/LivePreviewFragment.java
index 1525760..308dfff 100644
--- a/src/com/android/wallpaper/picker/LivePreviewFragment.java
+++ b/src/com/android/wallpaper/picker/LivePreviewFragment.java
@@ -76,6 +76,8 @@
 import com.android.wallpaper.widget.LockScreenPreviewer;
 import com.android.wallpaper.widget.WallpaperInfoView;
 
+import java.util.Locale;
+
 /**
  * Fragment which displays the UI for previewing an individual live wallpaper, its attribution
  * information and settings slices if available.
@@ -109,7 +111,6 @@
     private LiveData<Slice> mSettingsLiveData;
     private View mLoadingScrim;
     private Point mScreenSize;
-    private ViewGroup mPreviewContainer;
     private TouchForwardingLayout mTouchForwardingLayout;
     private View mTab;
     private TextView mHomeTextView;
@@ -169,25 +170,28 @@
         mScreenSize = ScreenSizeCalculator.getInstance().getScreenSize(
                 activity.getWindowManager().getDefaultDisplay());
 
-        mPreviewContainer = view.findViewById(R.id.live_wallpaper_preview);
-        mHomePreviewCard = mPreviewContainer.findViewById(R.id.wallpaper_full_preview_card);
+        ConstraintLayout previewContainer = view.findViewById(R.id.live_wallpaper_preview);
         mTouchForwardingLayout = view.findViewById(R.id.touch_forwarding_layout);
         // Set aspect ratio on the preview card.
         ConstraintSet set = new ConstraintSet();
-        set.clone((ConstraintLayout) mPreviewContainer);
-        String ratio = String.format("%d:%d", mScreenSize.x, mScreenSize.y);
+        set.clone(previewContainer);
+        String ratio = String.format(Locale.US, "%d:%d", mScreenSize.x, mScreenSize.y);
         set.setDimensionRatio(mTouchForwardingLayout.getId(), ratio);
-        set.applyTo((ConstraintLayout) mPreviewContainer);
+        set.applyTo(previewContainer);
 
+        mHomePreviewCard = previewContainer.findViewById(R.id.wallpaper_full_preview_card);
         mHomePreview = mHomePreviewCard.findViewById(R.id.wallpaper_preview_image);
         mTouchForwardingLayout.setTargetView(mHomePreview);
         mTouchForwardingLayout.setForwardingEnabled(true);
-        mLockPreviewContainer = mPreviewContainer.findViewById(R.id.lock_screen_preview_container);
+        mLockPreviewContainer = previewContainer.findViewById(R.id.lock_screen_preview_container);
         mLockScreenPreviewer = new LockScreenPreviewer(getLifecycle(), activity,
                 mLockPreviewContainer);
         mTab = view.findViewById(R.id.tabs_container);
         mHomeTextView = mTab.findViewById(R.id.home);
         mLockTextView = mTab.findViewById(R.id.lock);
+        mHomeTextView.setOnClickListener(v -> updateScreenTab(/* isHomeSelected= */ true));
+        mLockTextView.setOnClickListener(v -> updateScreenTab(/* isHomeSelected= */ false));
+
         mWorkspaceSurface = mHomePreviewCard.findViewById(R.id.workspace_surface);
         mWorkspaceSurfaceCallback = new WorkspaceSurfaceHolderCallback(
                 mWorkspaceSurface, getContext());
@@ -196,7 +200,8 @@
             @Override
             public void onLayoutChange(View thisView, int left, int top, int right, int bottom,
                     int oldLeft, int oldTop, int oldRight, int oldBottom) {
-                setupPreview();
+                mHomePreviewCard.setRadius(SizeCalculator.getPreviewCornerRadius(activity,
+                        mHomePreviewCard.getMeasuredWidth()));
                 view.removeOnLayoutChangeListener(this);
             }
         });
@@ -217,26 +222,6 @@
         mLockPreviewContainer.setVisibility(isHomeSelected ? View.INVISIBLE : View.VISIBLE);
     }
 
-    private void setupPreview() {
-        mHomeTextView.setOnClickListener(view ->
-                updateScreenTab(/* isHomeSelected= */ true)
-        );
-        mLockTextView.setOnClickListener(view ->
-                updateScreenTab(/* isHomeSelected= */ false)
-        );
-        if (mWallpaperInfoView != null) {
-            mWallpaperInfoView.populateWallpaperInfo(
-                    mWallpaper,
-                    mActionLabel,
-                    mExploreIntent,
-                    LivePreviewFragment.this::onExploreClicked);
-        }
-
-        ((CardView) mHomePreview.getParent())
-                .setRadius(SizeCalculator.getPreviewCornerRadius(
-                        getActivity(), mHomePreviewCard.getMeasuredWidth()));
-    }
-
     private void repositionPreview(ImageView previewView) {
         previewView.getLocationOnScreen(mLivePreviewLocation);
         mPreviewGlobalRect.set(0, 0, previewView.getMeasuredWidth(),
@@ -349,10 +334,11 @@
     protected void onBottomActionBarReady(BottomActionBar bottomActionBar) {
         super.onBottomActionBarReady(bottomActionBar);
         mBottomActionBar.showActionsOnly(INFORMATION, DELETE, CUSTOMIZE, APPLY);
-        mBottomActionBar.setActionClickListener(APPLY, unused ->
-                this.onSetWallpaperClicked(null));
+        mBottomActionBar.setActionClickListener(APPLY, unused -> onSetWallpaperClicked(null));
         mWallpaperInfoView = (WallpaperInfoView) LayoutInflater.from(getContext())
                 .inflate(R.layout.wallpaper_info_view, /* root= */ null);
+        mWallpaperInfoView.populateWallpaperInfo(mWallpaper, mActionLabel, mExploreIntent,
+                this::onExploreClicked);
         mBottomActionBar.attachViewToBottomSheetAndBindAction(mWallpaperInfoView, INFORMATION);
 
         // Update target view's accessibility param since it will be blocked by the bottom sheet