From 4a79d7cb97ece4047aa89e4d554cbad227193fd7 Mon Sep 17 00:00:00 2001 From: Mady Mellor Date: Fri, 28 Jan 2022 15:20:53 -0800 Subject: [PATCH] Use the orientation from the config object not resources Test: manual - reboot the device, rotate, drag stuff into split => verify that the orientation of split while dragging is correct Bug: 216643100 Change-Id: I300ad7263bf2ac18575d92f057fdd9c13ef736a7 --- .../android/wm/shell/draganddrop/DragLayout.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java index fd3be2b11c15a..f988492605119 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java @@ -103,7 +103,7 @@ public class DragLayout extends LinearLayout { MATCH_PARENT)); ((LayoutParams) mDropZoneView1.getLayoutParams()).weight = 1; ((LayoutParams) mDropZoneView2.getLayoutParams()).weight = 1; - updateContainerMargins(); + updateContainerMargins(getResources().getConfiguration().orientation); } @Override @@ -128,20 +128,18 @@ public class DragLayout extends LinearLayout { } public void onConfigChanged(Configuration newConfig) { - final int orientation = getResources().getConfiguration().orientation; - if (orientation == Configuration.ORIENTATION_LANDSCAPE + if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE && getOrientation() != HORIZONTAL) { setOrientation(LinearLayout.HORIZONTAL); - updateContainerMargins(); - } else if (orientation == Configuration.ORIENTATION_PORTRAIT + updateContainerMargins(newConfig.orientation); + } else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT && getOrientation() != VERTICAL) { setOrientation(LinearLayout.VERTICAL); - updateContainerMargins(); + updateContainerMargins(newConfig.orientation); } } - private void updateContainerMargins() { - final int orientation = getResources().getConfiguration().orientation; + private void updateContainerMargins(int orientation) { final float halfMargin = mDisplayMargin / 2f; if (orientation == Configuration.ORIENTATION_LANDSCAPE) { mDropZoneView1.setContainerMargin(