Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f07ff3c3 authored by chihhangchuang's avatar chihhangchuang
Browse files

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
parent bc5f2448
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -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">
+5 −5
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.os.Bundle;
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.LiveWallpaperInfo;
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 @@ public class GridFullPreviewFragment extends AppbarFragment {
        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);
            }
        });