From e34f5612247ffd7bb724d7480720658f82b19300 Mon Sep 17 00:00:00 2001 From: Sebastian Franco Date: Mon, 10 Feb 2025 13:13:27 -0600 Subject: [PATCH] Rotate Wallpaper Picker if in FixedLandscape Bug: 382906719 Test: NA Flag: com.android.launcher3.one_grid_specs Change-Id: Id4f29567899e4fec5585247077456eec5f343b98 --- .../graphics/PreviewSurfaceRenderer.java | 42 +++++++++++++++---- 1 file changed, 35 insertions(+), 7 deletions(-) diff --git a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java index 7a608143f0..738758b68c 100644 --- a/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java +++ b/src/com/android/launcher3/graphics/PreviewSurfaceRenderer.java @@ -39,6 +39,7 @@ import android.util.SparseArray; import android.util.SparseIntArray; import android.view.ContextThemeWrapper; import android.view.Display; +import android.view.Surface; import android.view.SurfaceControlViewHost; import android.view.SurfaceControlViewHost.SurfacePackage; import android.view.View; @@ -286,6 +287,20 @@ public class PreviewSurfaceRenderer { } context = context.createConfigurationContext(configuration); } + if (InvariantDeviceProfile.INSTANCE.get(context).isFixedLandscape) { + Configuration configuration = new Configuration( + context.getResources().getConfiguration() + ); + int width = configuration.screenWidthDp; + int height = configuration.screenHeightDp; + if (configuration.screenHeightDp > configuration.screenWidthDp) { + configuration.screenWidthDp = height; + configuration.screenHeightDp = width; + configuration.orientation = Surface.ROTATION_90; + } + context = context.createConfigurationContext(configuration); + } + if (Flags.newCustomizationPickerUi()) { if (mPreviewColorOverride != null) { LocalColorExtractor.newInstance(context) @@ -396,15 +411,28 @@ public class PreviewSurfaceRenderer { } renderer.hideBottomRow(mHideQsb); View view = renderer.getRenderedView(dataModel, widgetProviderInfoMap); - // This aspect scales the view to fit in the surface and centers it - final float scale = Math.min(mWidth / (float) view.getMeasuredWidth(), - mHeight / (float) view.getMeasuredHeight()); - view.setScaleX(scale); - view.setScaleY(scale); + view.setPivotX(0); view.setPivotY(0); - view.setTranslationX((mWidth - scale * view.getWidth()) / 2); - view.setTranslationY((mHeight - scale * view.getHeight()) / 2); + if (idp.isFixedLandscape) { + final float scale = Math.min(mHeight / (float) view.getMeasuredWidth(), + mWidth / (float) view.getMeasuredHeight()); + view.setScaleX(scale); + view.setScaleY(scale); + view.setRotation(90); + view.setTranslationX((mHeight - scale * view.getWidth()) / 2 + mWidth); + view.setTranslationY((mWidth - scale * view.getHeight()) / 2); + } else { + // This aspect scales the view to fit in the surface and centers it + final float scale = Math.min(mWidth / (float) view.getMeasuredWidth(), + mHeight / (float) view.getMeasuredHeight()); + view.setScaleX(scale); + view.setScaleY(scale); + view.setTranslationX((mWidth - scale * view.getWidth()) / 2); + view.setTranslationY((mHeight - scale * view.getHeight()) / 2); + } + + if (!Flags.newCustomizationPickerUi()) { view.setAlpha(0); view.animate().alpha(1)