Merge "Set KeyboardQuickSwitchView ratio correctly." into main
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
index 8ceb77d..ce96556 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchTaskView.java
@@ -36,14 +36,15 @@
 
 import com.android.launcher3.R;
 import com.android.launcher3.util.Preconditions;
+import com.android.launcher3.util.SplitConfigurationOptions.SplitBounds;
 import com.android.quickstep.util.BorderAnimator;
 import com.android.systemui.shared.recents.model.Task;
 import com.android.systemui.shared.recents.model.ThumbnailData;
 
-import java.util.function.Consumer;
-
 import kotlin.Unit;
 
+import java.util.function.Consumer;
+
 /**
  * A view that displays a recent task during a keyboard quick switch.
  */
@@ -173,6 +174,61 @@
         });
     }
 
+    protected void setThumbnailsForSplitTasks(
+            @NonNull Task task1,
+            @Nullable Task task2,
+            @Nullable ThumbnailUpdateFunction thumbnailUpdateFunction,
+            @Nullable IconUpdateFunction iconUpdateFunction,
+            @Nullable SplitBounds splitBounds) {
+        setThumbnails(task1, task2, thumbnailUpdateFunction, iconUpdateFunction);
+
+        if (splitBounds == null) {
+            return;
+        }
+
+
+        final boolean isLeftRightSplit = !splitBounds.appsStackedVertically;
+        final float leftOrTopTaskPercent = isLeftRightSplit
+                ? splitBounds.leftTaskPercent : splitBounds.topTaskPercent;
+
+        ConstraintLayout.LayoutParams leftTopParams = (ConstraintLayout.LayoutParams)
+                mThumbnailView1.getLayoutParams();
+        ConstraintLayout.LayoutParams rightBottomParams = (ConstraintLayout.LayoutParams)
+                mThumbnailView2.getLayoutParams();
+
+        if (isLeftRightSplit) {
+            // Set thumbnail view ratio in left right split mode.
+            leftTopParams.width = 0; // Set width to 0dp, so it uses the constraint dimension ratio.
+            leftTopParams.height = ConstraintLayout.LayoutParams.MATCH_PARENT;
+            leftTopParams.matchConstraintPercentWidth = leftOrTopTaskPercent;
+            leftTopParams.leftToLeft = ConstraintLayout.LayoutParams.PARENT_ID;
+            leftTopParams.rightToLeft = R.id.thumbnail_2;
+            mThumbnailView1.setLayoutParams(leftTopParams);
+
+            rightBottomParams.width = 0;
+            rightBottomParams.height = ConstraintLayout.LayoutParams.MATCH_PARENT;
+            rightBottomParams.matchConstraintPercentWidth = 1 - leftOrTopTaskPercent;
+            rightBottomParams.leftToRight = R.id.thumbnail_1;
+            rightBottomParams.rightToRight = ConstraintLayout.LayoutParams.PARENT_ID;
+            mThumbnailView2.setLayoutParams(rightBottomParams);
+        } else {
+            // Set thumbnail view ratio in top bottom split mode.
+            leftTopParams.height = 0;
+            leftTopParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
+            leftTopParams.matchConstraintPercentHeight = leftOrTopTaskPercent;
+            leftTopParams.topToTop = ConstraintLayout.LayoutParams.PARENT_ID;
+            leftTopParams.bottomToTop = R.id.thumbnail_2;
+            mThumbnailView1.setLayoutParams(leftTopParams);
+
+            rightBottomParams.height = 0;
+            rightBottomParams.width = ConstraintLayout.LayoutParams.MATCH_PARENT;
+            rightBottomParams.matchConstraintPercentHeight = 1 - leftOrTopTaskPercent;
+            rightBottomParams.topToBottom = R.id.thumbnail_1;
+            rightBottomParams.bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID;
+            mThumbnailView2.setLayoutParams(rightBottomParams);
+        }
+    }
+
     private void applyThumbnail(
             @Nullable ImageView thumbnailView,
             @Nullable Task task,
diff --git a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
index a527c82..b4102a9 100644
--- a/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
+++ b/quickstep/src/com/android/launcher3/taskbar/KeyboardQuickSwitchView.java
@@ -214,11 +214,13 @@
                     groupTask.mSplitBounds == null
                             || groupTask.mSplitBounds.leftTopTaskId == groupTask.task1.key.id
                             || groupTask.task2 == null;
-            currentTaskView.setThumbnails(
+
+            currentTaskView.setThumbnailsForSplitTasks(
                     firstTaskIsLeftTopTask ? groupTask.task1 : groupTask.task2,
                     firstTaskIsLeftTopTask ? groupTask.task2 : groupTask.task1,
                     updateTasks ? mViewCallbacks::updateThumbnailInBackground : null,
-                    updateTasks ? mViewCallbacks::updateIconInBackground : null);
+                    updateTasks ? mViewCallbacks::updateIconInBackground : null,
+                    groupTask.mSplitBounds);
 
             previousTaskView = currentTaskView;
         }