Add full preview for Grid (part 2)
Update the grid review card ratio, and add common dimens for full preview pages.
Before: https://screenshot.googleplex.com/thKsXZgStcX.png
After: https://screenshot.googleplex.com/rYyPe4ARwm3.png
Test: Manually
Bug: 151287994
Change-Id: I3f05f8a8d1f9738a764ad71ec77dce8cc315a68e
diff --git a/res/layout/fragment_grid_full_preview.xml b/res/layout/fragment_grid_full_preview.xml
index 1c01743..0484fa7 100644
--- a/res/layout/fragment_grid_full_preview.xml
+++ b/res/layout/fragment_grid_full_preview.xml
@@ -26,13 +26,14 @@
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
+ android:paddingTop="@dimen/full_preview_page_default_padding_top"
+ android:paddingBottom="@dimen/full_preview_page_default_padding_bottom"
+ android:clipToPadding="false"
android:background="@color/fullscreen_preview_background">
<androidx.cardview.widget.CardView
style="@style/FullContentPreviewCard"
android:id="@+id/grid_full_preview_card"
- android:layout_marginTop="24dp"
- android:layout_marginBottom="32dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center">
diff --git a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
index 29d74de..46de83b 100644
--- a/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
+++ b/src/com/android/customization/picker/grid/GridFullPreviewFragment.java
@@ -30,7 +30,6 @@
import android.os.Message;
import android.os.RemoteException;
import android.service.wallpaper.WallpaperService;
-import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.Surface;
import android.view.SurfaceControlViewHost;
@@ -57,6 +56,7 @@
import com.android.wallpaper.model.WallpaperInfo;
import com.android.wallpaper.module.InjectorProvider;
import com.android.wallpaper.picker.AppbarFragment;
+import com.android.wallpaper.util.ScreenSizeCalculator;
import com.android.wallpaper.util.SizeCalculator;
import com.android.wallpaper.util.SurfaceViewUtils;
import com.android.wallpaper.util.WallpaperConnection;
@@ -134,19 +134,19 @@
mWallpaperSurface = view.findViewById(R.id.grid_full_preview_wallpaper_surface);
mGridOptionSurface.setVisibility(View.GONE);
- final DisplayMetrics dm = getResources().getDisplayMetrics();
- float screenAspectRatio = (float) dm.heightPixels / dm.widthPixels;
+ final float screenAspectRatio =
+ ScreenSizeCalculator.getInstance().getScreenAspectRatio(getContext());
view.addOnLayoutChangeListener(new View.OnLayoutChangeListener() {
@Override
public void onLayoutChange(View v, int left, int top, int right, int bottom,
int oldLeft, int oldTop, int oldRight, int oldBottom) {
- int cardWidth = (int) (mCardView.getMeasuredHeight() / screenAspectRatio);
+ final int cardWidth = (int) (mCardView.getMeasuredHeight() / screenAspectRatio);
ViewGroup.LayoutParams layoutParams = mCardView.getLayoutParams();
layoutParams.width = cardWidth;
mCardView.setLayoutParams(layoutParams);
mCardView.setRadius(SizeCalculator.getPreviewCornerRadius(
- getActivity(), mCardView.getMeasuredWidth()));
+ getActivity(), cardWidth));
view.removeOnLayoutChangeListener(this);
}
});