Loading libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +1 −5 Original line number Diff line number Diff line Loading @@ -319,17 +319,13 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { return features; } // We will transform the feature bounds to the Activity window, so using the rotation // from the same source (WindowConfiguration) to make sure they are synchronized. final int rotation = windowConfiguration.getDisplayRotation(); for (CommonFoldingFeature baseFeature : storedFeatures) { Integer state = convertToExtensionState(baseFeature.getState()); if (state == null) { continue; } Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, rotation, featureRect); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(windowConfiguration, featureRect); if (isZero(featureRect)) { Loading libs/WindowManager/Jetpack/src/androidx/window/sidecar/SampleSidecarImpl.java +1 −3 Original line number Diff line number Diff line Loading @@ -120,12 +120,10 @@ class SampleSidecarImpl extends StubSidecar { } List<SidecarDisplayFeature> features = new ArrayList<>(); final int rotation = activity.getResources().getConfiguration().windowConfiguration .getDisplayRotation(); for (CommonFoldingFeature baseFeature : mStoredFeatures) { SidecarDisplayFeature feature = new SidecarDisplayFeature(); Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, rotation, featureRect); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(activity, featureRect); feature.setRect(featureRect); feature.setType(baseFeature.getType()); Loading libs/WindowManager/Jetpack/src/androidx/window/util/ExtensionHelper.java +34 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package androidx.window.util; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; Loading @@ -23,8 +25,8 @@ import android.app.WindowConfiguration; import android.content.Context; import android.graphics.Rect; import android.hardware.display.DisplayManagerGlobal; import android.util.RotationUtils; import android.view.DisplayInfo; import android.view.Surface; import android.view.WindowManager; import androidx.annotation.NonNull; Loading @@ -43,9 +45,10 @@ public final class ExtensionHelper { * Rotates the input rectangle specified in default display orientation to the current display * rotation. */ public static void rotateRectToDisplayRotation(int displayId, int rotation, Rect inOutRect) { public static void rotateRectToDisplayRotation(int displayId, Rect inOutRect) { DisplayManagerGlobal dmGlobal = DisplayManagerGlobal.getInstance(); DisplayInfo displayInfo = dmGlobal.getDisplayInfo(displayId); int rotation = displayInfo.rotation; boolean isSideRotation = rotation == ROTATION_90 || rotation == ROTATION_270; int displayWidth = isSideRotation ? displayInfo.logicalHeight : displayInfo.logicalWidth; Loading @@ -53,7 +56,35 @@ public final class ExtensionHelper { inOutRect.intersect(0, 0, displayWidth, displayHeight); RotationUtils.rotateBounds(inOutRect, displayWidth, displayHeight, rotation); rotateBounds(inOutRect, displayWidth, displayHeight, rotation); } /** * Rotates the input rectangle within parent bounds for a given delta. */ private static void rotateBounds(Rect inOutRect, int parentWidth, int parentHeight, @Surface.Rotation int delta) { int origLeft = inOutRect.left; switch (delta) { case ROTATION_0: return; case ROTATION_90: inOutRect.left = inOutRect.top; inOutRect.top = parentWidth - inOutRect.right; inOutRect.right = inOutRect.bottom; inOutRect.bottom = parentWidth - origLeft; return; case ROTATION_180: inOutRect.left = parentWidth - inOutRect.right; inOutRect.right = parentWidth - origLeft; return; case ROTATION_270: inOutRect.left = parentHeight - inOutRect.bottom; inOutRect.bottom = inOutRect.right; inOutRect.right = parentHeight - inOutRect.top; inOutRect.top = origLeft; return; } } /** Transforms rectangle from absolute coordinate space to the window coordinate space. */ Loading Loading
libs/WindowManager/Jetpack/src/androidx/window/extensions/layout/WindowLayoutComponentImpl.java +1 −5 Original line number Diff line number Diff line Loading @@ -319,17 +319,13 @@ public class WindowLayoutComponentImpl implements WindowLayoutComponent { return features; } // We will transform the feature bounds to the Activity window, so using the rotation // from the same source (WindowConfiguration) to make sure they are synchronized. final int rotation = windowConfiguration.getDisplayRotation(); for (CommonFoldingFeature baseFeature : storedFeatures) { Integer state = convertToExtensionState(baseFeature.getState()); if (state == null) { continue; } Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, rotation, featureRect); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(windowConfiguration, featureRect); if (isZero(featureRect)) { Loading
libs/WindowManager/Jetpack/src/androidx/window/sidecar/SampleSidecarImpl.java +1 −3 Original line number Diff line number Diff line Loading @@ -120,12 +120,10 @@ class SampleSidecarImpl extends StubSidecar { } List<SidecarDisplayFeature> features = new ArrayList<>(); final int rotation = activity.getResources().getConfiguration().windowConfiguration .getDisplayRotation(); for (CommonFoldingFeature baseFeature : mStoredFeatures) { SidecarDisplayFeature feature = new SidecarDisplayFeature(); Rect featureRect = baseFeature.getRect(); rotateRectToDisplayRotation(displayId, rotation, featureRect); rotateRectToDisplayRotation(displayId, featureRect); transformToWindowSpaceRect(activity, featureRect); feature.setRect(featureRect); feature.setType(baseFeature.getType()); Loading
libs/WindowManager/Jetpack/src/androidx/window/util/ExtensionHelper.java +34 −3 Original line number Diff line number Diff line Loading @@ -16,6 +16,8 @@ package androidx.window.util; import static android.view.Surface.ROTATION_0; import static android.view.Surface.ROTATION_180; import static android.view.Surface.ROTATION_270; import static android.view.Surface.ROTATION_90; Loading @@ -23,8 +25,8 @@ import android.app.WindowConfiguration; import android.content.Context; import android.graphics.Rect; import android.hardware.display.DisplayManagerGlobal; import android.util.RotationUtils; import android.view.DisplayInfo; import android.view.Surface; import android.view.WindowManager; import androidx.annotation.NonNull; Loading @@ -43,9 +45,10 @@ public final class ExtensionHelper { * Rotates the input rectangle specified in default display orientation to the current display * rotation. */ public static void rotateRectToDisplayRotation(int displayId, int rotation, Rect inOutRect) { public static void rotateRectToDisplayRotation(int displayId, Rect inOutRect) { DisplayManagerGlobal dmGlobal = DisplayManagerGlobal.getInstance(); DisplayInfo displayInfo = dmGlobal.getDisplayInfo(displayId); int rotation = displayInfo.rotation; boolean isSideRotation = rotation == ROTATION_90 || rotation == ROTATION_270; int displayWidth = isSideRotation ? displayInfo.logicalHeight : displayInfo.logicalWidth; Loading @@ -53,7 +56,35 @@ public final class ExtensionHelper { inOutRect.intersect(0, 0, displayWidth, displayHeight); RotationUtils.rotateBounds(inOutRect, displayWidth, displayHeight, rotation); rotateBounds(inOutRect, displayWidth, displayHeight, rotation); } /** * Rotates the input rectangle within parent bounds for a given delta. */ private static void rotateBounds(Rect inOutRect, int parentWidth, int parentHeight, @Surface.Rotation int delta) { int origLeft = inOutRect.left; switch (delta) { case ROTATION_0: return; case ROTATION_90: inOutRect.left = inOutRect.top; inOutRect.top = parentWidth - inOutRect.right; inOutRect.right = inOutRect.bottom; inOutRect.bottom = parentWidth - origLeft; return; case ROTATION_180: inOutRect.left = parentWidth - inOutRect.right; inOutRect.right = parentWidth - origLeft; return; case ROTATION_270: inOutRect.left = parentHeight - inOutRect.bottom; inOutRect.bottom = inOutRect.right; inOutRect.right = parentHeight - inOutRect.top; inOutRect.top = origLeft; return; } } /** Transforms rectangle from absolute coordinate space to the window coordinate space. */ Loading