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

Commit 65a48032 authored by Aurélien Pomini's avatar Aurélien Pomini Committed by Android (Google) Code Review
Browse files

Merge "Improve default crops on tablet" into main

parents 464c0c47 2e8d81ad
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -137,6 +137,27 @@ public class WallpaperCropper {
                // This will fall into "Case 4" of this function and center the folded screen
                return getCrop(displaySize, bitmapSize, newSuggestedCrops, rtl);
            }

            // The second exception is if we're on tablet and we're on portrait mode.
            // In that case, center the wallpaper relatively to landscape and put some parallax.
            boolean isTablet = mWallpaperDisplayHelper.isLargeScreen()
                    && !mWallpaperDisplayHelper.isFoldable();
            if (isTablet && displaySize.x < displaySize.y) {
                Point rotatedDisplaySize = new Point(displaySize.y, displaySize.x);
                // compute the crop on landscape (without parallax)
                Rect landscapeCrop = getCrop(rotatedDisplaySize, bitmapSize, suggestedCrops, rtl);
                landscapeCrop = noParallax(landscapeCrop, rotatedDisplaySize, bitmapSize, rtl);
                // compute the crop on portrait at the center of the landscape crop
                crop = getAdjustedCrop(landscapeCrop, bitmapSize, displaySize, false, rtl, ADD);

                // add some parallax (until the border of the landscape crop without parallax)
                if (rtl) {
                    crop.left = landscapeCrop.left;
                } else {
                    crop.right = landscapeCrop.right;
                }
            }

            return getAdjustedCrop(crop, bitmapSize, displaySize, true, rtl, ADD);
        }

+14 −1
Original line number Diff line number Diff line
@@ -59,6 +59,8 @@ class WallpaperDisplayHelper {
    }

    private static final String TAG = WallpaperDisplayHelper.class.getSimpleName();
    private static final float LARGE_SCREEN_MIN_DP = 600f;

    private final SparseArray<DisplayData> mDisplayDatas = new SparseArray<>();
    private final DisplayManager mDisplayManager;
    private final WindowManagerInternal mWindowManagerInternal;
@@ -67,7 +69,8 @@ class WallpaperDisplayHelper {
    // related orientations pairs for foldable (folded orientation, unfolded orientation)
    private final List<Pair<Integer, Integer>> mFoldableOrientationPairs = new ArrayList<>();

    private boolean mIsFoldable;
    private final boolean mIsFoldable;
    private boolean mIsLargeScreen = false;

    WallpaperDisplayHelper(
            DisplayManager displayManager,
@@ -94,6 +97,9 @@ class WallpaperDisplayHelper {
                    mDefaultDisplaySizes.put(orientation, point);
                }
            }

            mIsLargeScreen |= (displaySize.x / metric.getDensity() >= LARGE_SCREEN_MIN_DP);

            if (populateOrientationPairs) {
                int orientation = WallpaperManager.getOrientation(displaySize);
                float newSurface = displaySize.x * displaySize.y
@@ -214,6 +220,13 @@ class WallpaperDisplayHelper {
        return mIsFoldable;
    }

    /**
     * Return true if any of the screens of the default display is considered large (DP >= 600)
     */
    boolean isLargeScreen() {
        return mIsLargeScreen;
    }

    /**
     * If a given orientation corresponds to an unfolded orientation on foldable, return the
     * corresponding folded orientation. Otherwise, return UNKNOWN. Always return UNKNOWN if the