diff options
| author | 2025-02-04 15:15:56 -0800 | |
|---|---|---|
| committer | 2025-02-04 23:29:10 -0800 | |
| commit | 56a382bf1774b9810db9b92d80da8ec4cc84d507 (patch) | |
| tree | d10fdebc89ae579d9b159cd87f1b9d068cd05431 | |
| parent | f4f8f15fa15ce7c1fcc07f72eef5f16bd242c6e5 (diff) | |
Fix drag zone translations for offscreen apps
Adds a translateX and translateY to the visual drop zones for splitscreen, in cases where the split layout extends offscreen to the left or top. Without this, the drag zones' LinearLayout follows display bounds, so they are not aligned with the actual app bounds.
I opted to use translation rather than mess with R.layout.global_drop_target, since these zones are only visual (the actual drop target follows app bounds correctly).
Fixes: 391428468
Flag: com.android.wm.shell.enable_flexible_two_app_split
Test: Visually correct when dragging icons over 10:90, 90:10, 50:50, and single app layouts
Change-Id: I58566f89507e9e4c71147211b60989ca75e79a57
| -rw-r--r-- | libs/WindowManager/Shell/src/com/android/wm/shell/draganddrop/DragLayout.java | 24 |
1 files changed, 24 insertions, 0 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 ea0f09af2d3b..2571e0e36cd9 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 @@ -413,6 +413,8 @@ public class DragLayout extends LinearLayout } private void updateDropZoneSizesForSingleTask() { + resetDropZoneTranslations(); + final LinearLayout.LayoutParams dropZoneView1 = (LayoutParams) mDropZoneView1.getLayoutParams(); final LinearLayout.LayoutParams dropZoneView2 = @@ -427,6 +429,19 @@ public class DragLayout extends LinearLayout mDropZoneView2.setLayoutParams(dropZoneView2); } + /** Zeroes out translationX and translationY on all drop zone views. */ + void resetDropZoneTranslations() { + setDropZoneTranslations(0, 0); + } + + /** Sets translationX and translationY on all drop zone views. */ + void setDropZoneTranslations(int x, int y) { + mDropZoneView1.setTranslationX(x); + mDropZoneView1.setTranslationY(y); + mDropZoneView2.setTranslationX(x); + mDropZoneView2.setTranslationY(y); + } + /** * Sets the size of the two drop zones based on the provided bounds. The divider sits between * the views and its size is included in the calculations. @@ -435,6 +450,15 @@ public class DragLayout extends LinearLayout * @param bounds2 bounds to apply to the second dropzone view, null if split in half. */ private void updateDropZoneSizes(Rect bounds1, Rect bounds2) { + if (bounds1 == null || bounds2 == null) { + // We're entering 50:50 split screen from a single app, no need for any translations. + resetDropZoneTranslations(); + } else { + // We're already in split, so align our drop zones to match the left/top app edge. This + // is necessary because the left/top app can be offscreen. + setDropZoneTranslations(bounds1.left, bounds1.top); + } + final int halfDivider = mDividerSize / 2; final LinearLayout.LayoutParams dropZoneView1 = (LayoutParams) mDropZoneView1.getLayoutParams(); |